如洲 陈
2025-09-12 659168c1ca463b00d74f9dead9f85df7ea997aa0
pages/BasePages/main.vue
@@ -15,8 +15,7 @@
        <view class="example-body">
          <uni-grid :column="col" :showBorder="true">
            <uni-grid-item v-for="(item, index) in userMenu" :index="index" :key="index">
              <navigator navigateTo class="grid-item-box" hover-class="none"
                         :url="`../${item.path}`">
                     <navigator navigateTo class="grid-item-box" hover-class="none" :url="`../${item.path}`">
                <image v-if="item.icoimg" class="imgMenu" :src="`${item.icoimg}`" ></image>
                <image v-else class="imgMenu" src="/static/img/imgMenu/APP01.png" ></image>
                <uni-notice-bar v-if="item.pagE_VIEW.length>6" :speed="30"
@@ -76,7 +75,93 @@
          if (isShowMask) uni.hideLoading();
        }
      });
         },
         getIsMsg() {
            this.$post({
               url: "/MessageCenter/IsShow",
               data: {
                  createBy: this.$loginInfo.account,
                  isShow: 1,
               },
            }).then(res => {
               if (res.data.tbBillList > 0) {
                  this.msg = "您有新的异常待处理/您有新的异常待处理";
                  //展示图标
                  uni.showTabBarRedDot({
                     index: 1
                  });
               } else {
                  this.msg = "宁波广深科技有限公司";
                  //展示图标
                  uni.hideTabBarRedDot({
                     index: 1
                  });
    }
            })
         },
         checkForUpdate() {
            this.$post({
               url: "/Login/getAppUpgradeInfo",
               data: {}
            }).then(res => {
               let newVersion = res.data.version;
               let currentVersion = uni.getSystemInfoSync(); // 获取当前 APK 版本号
               if (newVersion > currentVersion.appVersion) {
                  uni.showModal({
                     title: "发现新版本",
                     content: "是否下载最新版本?",
                     success: (modalRes) => {
                        if (modalRes.confirm) {
                           this.downloadNewApk(res.data.apkUrl);
                        }
                     }
                  });
                  //this.downloadNewApk(res.data.apkUrl);
                  this.updateChecked = true; // 标记更新已检查过
                  //      // 如果有新版本,开始下载
                  //download(res.data.apkUrl);
               }
            })
         },
         downloadNewApk(apkUrl) {
            uni.showToast({
               title: "开始下载更新...",
               icon: "none",
               duration: 2000
            });
            uni.downloadFile({
               url: apkUrl,
               success: (res) => {
                  if (res.statusCode === 200) {
                     plus.runtime.install(res.tempFilePath, {
                        force: true
                     }, function() {
                        console.log("安装成功,重启应用");
                        //plus.runtime.restart();
                        //plus.runtime.quit();
                        // uni.navigateBack()
                     }, function(e) {
                        console.error("安装失败:", e);
                     });
                  }
               },
               fail: (err) => {
                  console.error("下载失败:", err);
                  uni.showToast({
                     title: "下载失败,请检查网络",
                     icon: "none",
                     duration: 2000
                  });
               }
            });
         }
  },
  onLoad() {
    if (!this.loginInfo.hasLogin) {
@@ -113,6 +198,7 @@
    if (this.loginInfo.hasLogin)
      this.getMenu(true);
  },
}
</script>