forked from gzzfw/frontEnd/gzDyh

xusd
2024-09-08 5424fb6cc7c907ec12025e96bb41146b28e5582c
gz-wxparty/app.js
@@ -2,48 +2,54 @@
const $$ = require('./utils/util');
App({
   onLaunch() {
      // 小程序更新
      const updateManager = wx.getUpdateManager();
      updateManager.onCheckForUpdate(function (res) {
         // 请求完新版本信息的回调
         if (res.hasUpdate == true) {
            updateManager.onUpdateReady(function () {
               $$.loginOutClearData();
               wx.showModal({
                  title: '更新提示',
                  content: '检测到新版本更新',
                  showCancel: false,
                  success(res) {
                     if (res.confirm) {
                        // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                        updateManager.applyUpdate();
                     }
                  },
               });
            });
         }
      });
      updateManager.onUpdateFailed(function () {
         // 新版本下载失败
         wx.showModal({
            title: '已经有新版本了哟~',
            content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
         });
      });
      // 获取缓存的token
      let userInfo = wx.getStorageSync('userInfo');
      if (userInfo) {
         this.globalData.token = userInfo.token;
      }
   },
   globalData: {
      token: '', // 用户token
      material: {
         uploadVisible: false,
         data: [], // 材料上传的数据
         person: [], // 申请调解页面进入附件上传页面时,需要传递的申请人,代理人,被申请人的数据,便于身份材料时选择
      },
      caseMsg: {}, // 案件详情,用于我的申请时跳转到其他页面传输案件的数据。
   },
});
  onLaunch() {
    // 字体
    wx.loadFontFace({
      family: 'DingTalk', // 字体名称
      source: 'url("../../font/DingTalk_JinBuTi_Regular.ttf")',
      global: true, // 是否全局生效
    })
    // 小程序更新
    const updateManager = wx.getUpdateManager();
    updateManager.onCheckForUpdate(function (res) {
      // 请求完新版本信息的回调
      if (res.hasUpdate == true) {
        updateManager.onUpdateReady(function () {
          $$.loginOutClearData();
          wx.showModal({
            title: '更新提示',
            content: '检测到新版本更新',
            showCancel: false,
            success(res) {
              if (res.confirm) {
                // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
                updateManager.applyUpdate();
              }
            },
          });
        });
      }
    });
    updateManager.onUpdateFailed(function () {
      // 新版本下载失败
      wx.showModal({
        title: '已经有新版本了哟~',
        content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
      });
    });
    // 获取缓存的token
    let userInfo = wx.getStorageSync('userInfo');
    if (userInfo) {
      this.globalData.token = userInfo.token;
    }
  },
  globalData: {
    token: '', // 用户token
    material: {
      uploadVisible: false,
      data: [], // 材料上传的数据
      person: [], // 申请调解页面进入附件上传页面时,需要传递的申请人,代理人,被申请人的数据,便于身份材料时选择
    },
    caseMsg: {}, // 案件详情,用于我的申请时跳转到其他页面传输案件的数据。
  },
});