sen
2026-03-10 933046f7fd7fa9104bc33862951d570d88d7e2df
ui/car_wx_app/App.vue
@@ -1,7 +1,11 @@
<script>
  export default {
      onLaunch: function() {
          // #ifdef MP-WEIXIN
             this.updateApp()
             // #endif
         console.log('App Launch')
      },
      onShow: function() {
@@ -10,6 +14,44 @@
      },
      onHide: function() {
         console.log('App Hide')
      },
      methods:{
          updateApp() {
           const updateManager = uni.getUpdateManager();
         console.log('updateManager',updateManager)
           updateManager.onCheckForUpdate(function (res) {
             // 请求完新版本信息的回调
             console.log(res);
           });
           updateManager.onUpdateReady(function (res) {
             uni.showModal({
               title: '更新提示',
               content: '新版本已经准备好,是否重启应用?',
            showCancel: false,
               success(res) {
                 if (res.confirm) {
                   // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                   updateManager.applyUpdate();
                 } else if (res.cancel) {
                   console.log('用户点击取消,不更新');
                 }
               }
             });
           });
           updateManager.onUpdateFailed(function (res) {
             // 新的版本下载失败
             uni.showModal({
               title: '已经有新版本了哟~',
               content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
             })
           });
         }
      }
   }
</script>