zjh
2025-04-26 18db0dbf100ff81ead99b1d6a3daa6c4c26e5d91
pages/BasePages/main.vue
@@ -9,21 +9,20 @@
<!--          </swiper-item>-->
<!--        </swiper>-->
        <!-- 通报批评、消息预警、公告、报告 -->
        <uni-notice-bar :show-icon="true" :scrollable="true" :speed="30" :single="true"
                        :text="msg"/>
            <uni-notice-bar :show-icon="true" :scrollable="true" :speed="30" :single="true" :text="msg" />
        <!-- 用户系统菜单模块 -->
        <view class="example-body">
          <uni-grid :column="col" :showBorder="false">
            <uni-grid-item v-for="(item, index) in userMenu" :index="index" :key="index" class="grid-item">
              <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/WARBAAHtml.png"></image>
           <!--       <uni-notice-bar v-if="item.pagE_VIEW.length>6" :speed="30"
                                style="padding:0;margin-bottom:0;font-weight: 900;" textSize="13px"
                                background-color="#ffffff" color="#000000" :scrollable="item.pagE_VIEW.length>6"
                                :single="true" :text="item.pagE_VIEW"/>-->
                <text class="text" style="text-align: center;padding:5px 0px 5px 0px">{{ item.pagE_VIEW }}</text>
                        <text class="text"
                           style="text-align: center;padding:5px 0px 5px 0px">{{ item.pagE_VIEW }}</text>
              </navigator>
            </uni-grid-item>
          </uni-grid>
@@ -54,7 +53,9 @@
        "../../static/img/SN-GG1.png"
      ],
      col: 4, //菜单列数
      msg: "宁波广深科技有限公司"
            msg: "宁波广深科技有限公司",
            updateChecked: false
    };
  },
  methods: {
@@ -69,6 +70,7 @@
        success: (res) => {
          this.userMenu = res;
          uni.stopPullDownRefresh();
        },
        fail: (err) => {
@@ -77,6 +79,8 @@
          if (isShowMask) uni.hideLoading();
        }
      });
    },
    getIsMsg() {
      this.$post({
@@ -100,9 +104,72 @@
          });
        }
      })
         },
         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) {
      uni.showModal({
        title: '未登录',
@@ -129,7 +196,9 @@
        }
      });
    } else {
      this.getMenu(true);
            this.checkForUpdate();
    }
@@ -159,14 +228,17 @@
  font-size: 14px;
  /* background-color: #ffffff; */
}
.grid-item {
   display: flex;
     flex-wrap: wrap;
   height: 100% !important;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* 保证垂直拉伸以适应内容 */
      align-items: stretch;
      /* 保证垂直拉伸以适应内容 */
   }
.grid-item-box {
  flex: 1;
  /* position: relative;*/