ZaiZai 1 рік тому
батько
коміт
f95ee66fcf
3 змінених файлів з 29 додано та 10 видалено
  1. 7 0
      App.vue
  2. 0 1
      httpApi/request/socket.js
  3. 22 9
      pages/my/project.vue

+ 7 - 0
App.vue

@@ -27,6 +27,13 @@
             this.getRefreshToken()
         },
         methods:{
+            //长链接发送消息
+            socketSendMsg(val) {
+                if (val) {
+                    console.log('发送消息', val)
+                    HcSocket.sendSocketMsg(val)
+                }
+            },
             //刷新token
             getRefreshToken() {
                 let _this = this;

+ 0 - 1
httpApi/request/socket.js

@@ -60,7 +60,6 @@ export default class HcSocket {
                 store.setMsgCountData(countData)
             }
         });
-        return this.socketTask
     }
 
     //发送消息

+ 22 - 9
pages/my/project.vue

@@ -57,8 +57,7 @@ import {onLoad} from '@dcloudio/uni-app'
 import {useAppStore} from "@/store";
 import mainApi from "~api/user/project";
 import {errorToast, successToast} from "@/utils/tools";
-import {deepClone, getArrValue, getObjValue} from "js-fast-way";
-import {getProjectContract} from "@/store/user";
+import {deepClone, getArrValue} from "js-fast-way";
 
 //初始变量
 const store = useAppStore()
@@ -66,6 +65,7 @@ const userInfo = ref(store.userInfo);
 const projectInfo = ref({pid: '', cid: ''});
 const projectId = ref('');
 const contractId = ref('');
+const app = getApp()
 
 //渲染完成
 onLoad(() => {
@@ -123,7 +123,7 @@ const setProjectClick = async () => {
         contractId: contractId.value,
     })
     if (!error && code === 200) {
-        await getProjectContract()
+        await setProjectContractData()
         uni.hideLoading();
         successToast('设置成功')
         setTimeout(() => {
@@ -136,21 +136,34 @@ const setProjectClick = async () => {
 }
 
 //仅本次生效
-const onlyEffectivelick = () => {
+const onlyEffectivelick = async () => {
     const pid = projectId.value, cid = contractId.value
     if (!pid || !cid) {
         cancelPopup()
         errorToast('请先选择项目和合同段')
         return
     }
-    store.setProjectId(pid)
-    store.setContractId(cid)
-    store.setProjectInfo(projectData.value)
-    store.setContractInfo(contractData.value)
+    uni.showLoading({title: '设置中...', mask: true});
+    await setProjectContractData()
+    uni.hideLoading();
     successToast('设置成功')
     setTimeout(() => {
         uni.navigateBack()
-    }, 1500)
+    }, 1200)
+}
+
+//设置项目合同信息
+const setProjectContractData = async () => {
+    const pid = store.projectId, cid = store.contractId
+    const pids = projectId.value, cids = contractId.value
+    if (pid !== pids || cid !== cids) {
+        store.setProjectId(pids)
+        store.setContractId(cids)
+        store.setProjectInfo(projectData.value)
+        store.setContractInfo(contractData.value)
+        app.socketSendMsg(`${pids},${cids}`)
+    }
+    return true
 }
 
 //取消并关闭