Explorar el Código

fix:联系方式处理

chenzhen2 hace 2 años
padre
commit
baf018089c

+ 8 - 3
src/views/envmonitor/components/Contact/index.vue

@@ -46,6 +46,10 @@ export default defineComponent({
       type: Boolean,
       default: () => false,
     },
+    contantDetail: {
+      type: Object,
+      default: () => {},
+    },
   },
   components: {
     VanLoading: Loading,
@@ -56,7 +60,7 @@ export default defineComponent({
     const proxyGlobal: any = getCurrentInstance();
     const proxyData = reactive({
       parseImgUrl: parseImgUrl,
-      contantDetail: contantDetail,
+      contantDetail: props.contantDetail,
       userInfo: userInfo,
       imgUrl: proxyGlobal.proxy.$imgUrl,
       isShowContact: props.isShowContact,
@@ -79,6 +83,7 @@ export default defineComponent({
       props,
       (newProps: any) => {
         proxyData.isShowContact = newProps.isShowContact;
+        proxyData.contantDetail = newProps.contantDetail;
       },
       {
         deep: false,
@@ -86,7 +91,7 @@ export default defineComponent({
       }
     );
     onMounted(() => {
-      proxyData.queryCustomerservice();
+      // proxyData.queryCustomerservice();
     });
     return {
       ...toRefs(proxyData),
@@ -139,7 +144,7 @@ export default defineComponent({
       flex: 1;
       border-right: 1px solid #d9d9d9;
       text-align: center;
-      color: #1F2429;
+      color: #1f2429;
       img {
         width: 134px;
         height: 134px;

+ 32 - 1
src/views/envmonitor/index.vue

@@ -40,7 +40,7 @@
             >{{ outWeather.temperature ? outWeather.temperature : "--" }}℃</span
           >
         </div>
-        <div class="weixiin" @click="showContact">
+        <div class="weixiin" v-if="contantDetail" @click="showContact">
           <img :src="parseImgUrl('ipdImages', 'weixin.svg')" />
           <span> 联系客服</span>
         </div>
@@ -302,6 +302,8 @@
     <!--联系方式-->
     <contact
       :isShowContact="isShowContact"
+      :contantDetail="contantDetail"
+      v-if="isShowContact"
       @closeDailog="closeContactDailog"
     ></contact>
   </div>
@@ -357,6 +359,7 @@ import {
   queryWorkSpace,
   getPadImg,
   getSpaceEquipList,
+  queryCustomerservice,
 } from "@/apis/envmonitor";
 import Keys from "@/constant/key";
 import {
@@ -422,6 +425,8 @@ export default defineComponent({
     const sceneDetail: any = {};
     const timeOutEvent: any = {};
     const touchInterval: any = {};
+    const contantDetail: any = {};
+    const cusServiceTimer: any = null;
     const headerInfo: {
       headImg: any;
       headScene: string;
@@ -1830,9 +1835,34 @@ export default defineComponent({
         proxyData.clearSecenTimer();
         proxyData.clearEquipTimer();
       },
+      contantDetail: contantDetail,
+      cusServiceTimer: cusServiceTimer,
+      queryCustomerserviceTimer(timer: any = 3600000) {
+        proxyData.cusServiceTimer = setTimeout(() => {
+          proxyData.queryCustomerservice();
+          clearTimeout(proxyData.cusServiceTimer);
+        }, timer);
+      },
+      // 查询联系方式
+      queryCustomerservice() {
+        let params: any = {
+          criteria: { projectId: proxyData.userInfo.projectId },
+        };
+        queryCustomerservice(params)
+          .then((res) => {
+            let resData: any = res;
+            let content: any = resData?.content ?? [];
+            proxyData.contantDetail = content[0];
+            proxyData.queryCustomerserviceTimer();
+          })
+          .catch(() => {
+            proxyData.queryCustomerserviceTimer();
+          });
+      },
     });
     onBeforeUnmount(() => {
       proxyData.clearAll();
+      clearTimeout(proxyData.cusServiceTimer);
     });
     onMounted(() => {
       let spaceId: any = route.query.spaceId;
@@ -1846,6 +1876,7 @@ export default defineComponent({
       // 获取当前平板绑定的空间
       proxyData.queryWorkSpace();
       proxyData.getWeather();
+      proxyData.queryCustomerservice();
     });
     return {
       ...toRefs(proxyData),