소스 검색

修改设备详情问题

wangming 1 주 전
부모
커밋
382be56d66

+ 1 - 1
src/pagesA/adDevice/adDevice.vue

@@ -443,7 +443,7 @@ export default {
                 height: parseInt(this.height),
                 // wifiName: this.wifiName,
                 // wifiPassword: this.wifiPassword,
-                northAngle: this.northAngle,
+                northAngle: this.northAngle == "" ? "0" : this.northAngle,
                 mountPlain:
                     this.mountPlain == "" ? "mountPlain" : this.mountPlain,
                 installPosition: this.installPosition,

+ 3 - 3
src/pagesA/deviceDetail/deviceDetail.vue

@@ -1041,10 +1041,8 @@ export default {
         this.clientId = clientId;
         uni.setStorageSync("currentDevItem", devItem);
         this.getFrequency(devId);
-        this.getdevInfo(devId);
-        this.getdevRoomInfo(devId);
+        this.dev_id = devId;
         this.todayDate = this.$time(new Date(), 2);
-
         // 清理旧定时器
         clearTimeout(this.autoPlayinterval);
         this.autoPlayinterval = setTimeout(() => this.autoSwipe(), 3000);
@@ -1073,6 +1071,8 @@ export default {
                 })
                 .catch((err) => console.error("DATA MQTT 初始化失败", err));
         }
+        this.getdevInfo(this.dev_id);
+        this.getdevRoomInfo(this.dev_id);
     },
 
     onUnload() {

+ 53 - 42
src/pagesA/linkShare/linkShare.vue

@@ -37,6 +37,7 @@
                 <view class="funItem" @click="smChange()">
                     <label class="simple-radio"
                         ><radio
+                            :disabled="generateFlag == true"
                             :value="messageFlag"
                             color="#7c5345"
                             :checked="messageFlag == true"
@@ -48,6 +49,7 @@
                 <view class="funItem">
                     <label class="simple-radio" @click="snChange()"
                         ><radio
+                            :disabled="generateFlag == true"
                             :value="serviceNumberFlag"
                             color="#7c5345"
                             :checked="serviceNumberFlag == true"
@@ -59,6 +61,7 @@
                 <view class="funItem">
                     <label class="simple-radio" @click="vfChange()"
                         ><radio
+                            :disabled="generateFlag == true"
                             :value="voipFlag"
                             color="#7c5345"
                             :checked="voipFlag == true"
@@ -69,10 +72,10 @@
                 >
             </view>
         </view>
-        <button class="btn1" open-type="share" v-if="shareFlag">
-            确认分享
+        <button class="btn1" @click="shareUserLink()" v-if="!generateFlag">
+            生成分享链接
         </button>
-        <button class="btn1" v-else @click="unShare()">暂不可分享</button>
+        <button class="btn1" open-type="share" v-else>确认分享</button>
     </view>
 </template>
 <script>
@@ -86,83 +89,91 @@ export default {
             voipFlag: false,
             shareFlag: false,
             shareId: "",
+            generateFlag: false,
         };
     },
     methods: {
+        // 切换短信分享
         smChange() {
             this.messageFlag = !this.messageFlag;
-            this.shareUserLink();
         },
+
+        // 切换服务号分享
         snChange() {
             this.serviceNumberFlag = !this.serviceNumberFlag;
-            this.shareUserLink();
         },
 
+        // 切换语音分享
         vfChange() {
             this.voipFlag = !this.voipFlag;
-            this.shareUserLink();
         },
         onShareAppMessage() {
             return {
                 title: "好友向您分享了一台设备",
                 path:
                     "/pagesA/sharePages/sharePages?phone=" +
-                    this.phone +
+                    uni.getStorageSync("phone") +
                     "&devInfo=" +
                     JSON.stringify(this.devInfo) +
                     "&shareId=" +
                     this.shareId,
             };
         },
+
+        // 调用后端接口生成分享链接
         shareUserLink() {
-            let shareParam = {
-                devId: this.devInfo.devId,
-                sharerUserId: uni.getStorageSync("userId"),
-                sharerPhone: uni.getStorageSync("phone"),
-                sharedUserId: "",
-                sharedPhone: "",
-                messageFlag: this.messageFlag == true ? 0 : 1,
-                serviceNumberFlag: this.serviceNumberFlag == true ? 0 : 1,
-                voipFlag: this.voipFlag == true ? 0 : 1,
-            };
-            this.$http
-                .post("wap/share/shareByUrl", shareParam, {
-                    header: {
-                        "Content-Type": "application/json;charset=UTF-8",
-                    },
-                })
-                .then((res) => {
-                    if (res.data.code == 200) {
-                        // uni.showToast({
-                        //     title: itemTitle,
-                        //     icon: "none",
-                        //     duration: 1500,
-                        // });
-                        this.shareFlag = true;
-                        this.shareId = res.data.data.shareId;
-                    } else {
-                        this.shareFlag = false;
+            return new Promise((resolve, reject) => {
+                const shareParam = {
+                    devId: this.devInfo.devId,
+                    sharerUserId: uni.getStorageSync("userId"),
+                    sharerPhone: uni.getStorageSync("phone"),
+                    sharedUserId: "",
+                    sharedPhone: "",
+                    messageFlag: this.messageFlag ? 0 : 1,
+                    serviceNumberFlag: this.serviceNumberFlag ? 0 : 1,
+                    voipFlag: this.voipFlag ? 0 : 1,
+                };
+
+                this.$http
+                    .post("wap/share/shareByUrl", shareParam, {
+                        header: {
+                            "Content-Type": "application/json;charset=UTF-8",
+                        },
+                    })
+                    .then((res) => {
+                        const { code, data, message } = res.data;
+                        if (code == 200 && data.shareId) {
+                            this.shareId = data.shareId;
+                            this.generateFlag = true;
+                        } else {
+                            uni.showToast({
+                                title: message || "生成分享链接失败",
+                                icon: "none",
+                            });
+                            this.generateFlag = false;
+                        }
+                    })
+                    .catch((err) => {
                         uni.showToast({
-                            title: res.data.message,
+                            title: "网络异常,请稍后再试",
                             icon: "none",
-                            duration: 1500,
                         });
-                    }
-                });
+                        reject();
+                    });
+            });
         },
         unShare() {
             uni.showToast({
                 title: "当前用户暂不可分享",
                 icon: "none",
-                duration: 1500,
             });
         },
     },
     onLoad(options) {
         this.devInfo = JSON.parse(options.devInfo);
-        setTimeout(() => {
-            this.shareUserLink();
-        }, 500);
+        // setTimeout(() => {
+        //     this.shareUserLink();
+        // }, 500);
     },
 };
 </script>

+ 2 - 2
src/pagesA/shareCountList/shareCountList.vue

@@ -26,14 +26,14 @@
                         <text>{{ item.sharerPhone }}</text></view
                     >
                 </view>
-                <view class="menu-item">
+                <!-- <view class="menu-item">
                     <view class="meanLeft">
                         <text>被分享人手机号</text>
                     </view>
                     <view class="meanRight">
                         <text>{{ item.sharedPhone }}</text></view
                     >
-                </view>
+                </view> -->
                 <view class="menu-item">
                     <view class="meanLeft">
                         <text>分享时间</text>

+ 2 - 2
src/pagesA/shareDetail/shareDetail.vue

@@ -25,14 +25,14 @@
                     <text>{{ shareDetail.sharerPhone }}</text></view
                 >
             </view>
-            <view class="menu-item">
+            <!-- <view class="menu-item">
                 <view class="meanLeft">
                     <text>被分享人手机号</text>
                 </view>
                 <view class="meanRight">
                     <text>{{ shareDetail.sharedPhone }}</text></view
                 >
-            </view>
+            </view> -->
             <view class="menu-item">
                 <view class="meanLeft">
                     <text>分享时间</text>