Explorar o código

4号板子优化

wzh %!s(int64=2) %!d(string=hai) anos
pai
achega
6910c05d69
Modificáronse 3 ficheiros con 80 adicións e 7 borrados
  1. 34 1
      App.vue
  2. 36 6
      pages/device/detail.vue
  3. 10 0
      pages/login.vue

+ 34 - 1
App.vue

@@ -17,13 +17,46 @@
         //#ifdef H5
         this.checkLogin()
         //#endif
+        this.updateManager();
       },
       initConfig() {
         this.globalData.config = config
       },
+      /**
+       * 小程序主动更新
+       */
+      updateManager() {
+        const updateManager = uni.getUpdateManager();
+        updateManager.onCheckForUpdate(res => {
+          // 请求完新版本信息的回调
+          // console.log(res.hasUpdate)
+        })
+        updateManager.onUpdateReady(() => {
+          uni.showModal({
+            title: '更新提示',
+            content: '新版本已经准备好,即将重启应用',
+            showCancel: false,
+            success(res) {
+              if (res.confirm) {
+                // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+                updateManager.applyUpdate()
+              }
+            }
+          })
+        })
+
+        updateManager.onUpdateFailed(() => {
+          // 新的版本下载失败
+          uni.showModal({
+            title: '更新提示',
+            content: '新版本下载失败',
+            showCancel: false
+          })
+        })
+      },
       checkLogin() {
         if (!getToken()) {
-          this.$tab.reLaunch('/pages/login') 
+          this.$tab.reLaunch('/pages/login')
         }
       }
     }

+ 36 - 6
pages/device/detail.vue

@@ -1390,12 +1390,12 @@ export default {
     isMulTab(index){
       let type = this.deviceType;
       if(index == 2){
-        if(type == 4 || type == 5){
-          return true;
-        }
+       if(this.secondMachine){
+         return true;
+       }
       }
       if(index == 3){
-        if(type == 5){
+        if(this.thirdMachine){
           return true;
         }
       }
@@ -1566,6 +1566,7 @@ export default {
       if(!tag){
         return;
       }
+      debugger;
       let type = this.deviceType;
       let self = this;
       if(index == 2 || index == 3){
@@ -1575,7 +1576,9 @@ export default {
       }
       this.resetChoose();
      if(index == 4){
-
+       if(!this.forthMachine){
+         return;
+       }
        uni.showLoading({title:"加载中"});
        getDeviceStatus(this.id,0).then(res=>{
          let data =res.data;
@@ -1590,7 +1593,7 @@ export default {
      }else{
 
        let arr = ["a","b","c"]
-       if(type == 4 || type == 5){
+       if(this.isMulTab(index)){
          this.childId =arr[index-1];
          this.getDeviceStatus(function(){
            self.tabIndex = index;
@@ -2443,6 +2446,14 @@ export default {
       getDetail(this.id).then(res=>{
         self.deviceInfo = res.data;
         self.deviceType = res.data.type;
+        let msg = res.msg;
+        if(msg){
+          try{
+            msg = JSON.parse(msg+"");
+          }catch (e){
+            msg = null;
+          }
+        }
         let productId = self.deviceInfo.productId;
         if(productId === 57){
           self.boardType = 5;
@@ -2464,6 +2475,25 @@ export default {
           }
         }
 
+        if(msg != null){
+          let b = msg.b;
+          let c = msg.c;
+          let a = msg.a;
+          let d = msg.d;
+          if(a == 1){
+            self.firstMachine = true;
+          }
+          if(b == 1){
+            self.secondMachine = true;
+          }
+          if(c == 1){
+            self.thirdMachine = true;
+          }
+          if(d == 1){
+            self.forthMachine = true;
+          }
+        }
+
         console.log("当前设备类型:"+JSON.stringify(self.deviceInfo.type))
         self.location = {
           latitude: self.deviceInfo.latitude,

+ 10 - 0
pages/login.vue

@@ -5,6 +5,9 @@
 <!--      </image>-->
       <text class="title">老药师云平台移动端登录</text>
     </view>
+    <view style="position: fixed;top:1vw;left:1vh;font-size: 12px;color: white;">
+      版本号:{{version}}
+    </view>
     <view class="login-form-content">
       <view class="input-item flex align-center">
         <view class="iconfont icon-user icon"></view>
@@ -41,6 +44,7 @@
   export default {
     data() {
       return {
+        version:"",
         codeUrl: "",
         captchaEnabled: true,
         globalConfig: getApp().globalData.config,
@@ -53,6 +57,7 @@
       }
     },
     created() {
+      this.getVersion();
       this.checkLogin();
     },
     methods: {
@@ -84,6 +89,11 @@
           }
         })
       },
+      getVersion(){
+        let appBaseInfo = uni.getAppBaseInfo();
+        let appVersionCode = appBaseInfo.appVersionCode;
+        this.version = appVersionCode;
+      },
       // 登录方法
       async handleLogin() {
         if (this.loginForm.username === "") {