| @@ -710,7 +710,7 @@ | |||
| <el-button | |||
| type="primary" | |||
| :disabled="sendLoading" | |||
| @click="sendRequirement" | |||
| @click="sendRequirement()" | |||
| color="#000" | |||
| > | |||
| <my-Loading-Icon2 v-if="sendLoading"></my-Loading-Icon2> | |||
| @@ -1738,7 +1738,7 @@ function createWS() { | |||
| mySocket = new WebSocket("wss://gptsocket.malls.iformall.com:8010"); | |||
| mySocket.onopen = () => { | |||
| console.log("WebSocket 连接成功1"); | |||
| sendRequirement(); | |||
| sendRequirement(1); | |||
| }; | |||
| mySocket.onmessage = (event) => { | |||
| // console.log("接收到 WebSocket 消息2:", event.data); | |||
| @@ -1748,34 +1748,6 @@ function createWS() { | |||
| if (event.data == "___talk_end___") { | |||
| sendLoading.value = false; | |||
| mySocket.close(); | |||
| // 金币扣除 | |||
| ElMessageBox.confirm( | |||
| lanChange.value == "zh-cn" ? '需要扣一个金币,是否继续?' : 'Need to deduct a gold coin, do you want to continue?', | |||
| lanChange.value == "zh-cn" ? '提示' : 'Tip', | |||
| { | |||
| confirmButtonText: 'OK', | |||
| cancelButtonText: 'Cancel', | |||
| type: 'warning', | |||
| } | |||
| ).then(() => { | |||
| let userPoinsVal = localStorage.getItem('userPoinsVal') // 当前币值 | |||
| if (Number(userPoinsVal) <= 0){ | |||
| ElMessage({ | |||
| type: 'error', | |||
| message: lanChange.value == "zh-cn" ? '金币不足!' : 'Insufficient gold coins!', | |||
| }) | |||
| return | |||
| } | |||
| reduceUserPoinsApi().then(res => { | |||
| if (res.code === 200){ | |||
| ElMessage({ | |||
| type: 'success', | |||
| message: '操作成功!', | |||
| }) | |||
| } | |||
| }) | |||
| }).catch(() => {}) | |||
| return; | |||
| } | |||
| answerContent.value = answerContent.value + event.data; | |||
| }; | |||
| @@ -1803,7 +1775,7 @@ function createWS() { | |||
| const problemContent = ref(""); //问题输入框内容 | |||
| const answerContent = ref(""); //回答输入框内容 | |||
| // 点击发送需求 | |||
| async function sendRequirement() { | |||
| async function sendRequirement(tag) { | |||
| // loading | |||
| sendLoading.value = true; | |||
| @@ -1820,7 +1792,40 @@ async function sendRequirement() { | |||
| }, | |||
| ]; | |||
| // 如果处于链接状态 | |||
| if (!tag) { | |||
| // 金币扣除 | |||
| ElMessageBox.confirm( | |||
| lanChange.value == "zh-cn" ? '需要扣一个金币,是否继续?' : 'Need to deduct a gold coin, do you want to continue?', | |||
| lanChange.value == "zh-cn" ? '提示' : 'Tip', | |||
| { | |||
| confirmButtonText: 'OK', | |||
| cancelButtonText: 'Cancel', | |||
| type: 'warning', | |||
| } | |||
| ).then(() => { | |||
| let userPoinsVal = localStorage.getItem('userPoinsVal') // 当前币值 | |||
| if (Number(userPoinsVal) <= 0){ | |||
| ElMessage({ | |||
| type: 'error', | |||
| message: lanChange.value == "zh-cn" ? '金币不足!' : 'Insufficient gold coins!', | |||
| }) | |||
| return | |||
| } | |||
| reduceUserPoinsApi().then(res => { | |||
| if (res.code === 200){ | |||
| if (mySocket.readyState != WebSocket.OPEN) { | |||
| createWS(); | |||
| } else { | |||
| answerContent.value = ""; | |||
| mySocket.send(JSON.stringify(sendMessage)); | |||
| } | |||
| } | |||
| }) | |||
| }).catch(() => { | |||
| sendLoading.value = false; | |||
| }) | |||
| return | |||
| } | |||
| if (mySocket.readyState != WebSocket.OPEN) { | |||
| createWS(); | |||
| } else { | |||