小程序更新完成小程序黑屏,微信无响应?
发布于 6 年前 作者 jing26 534 次浏览 来自 问答

//app.js

App({

  onLaunch: function () {

    var that = this;

    const updateManager = wx.getUpdateManager()

    updateManager.onCheckForUpdate(function (res) {

      // 请求完新版本信息的回调

      console.log(res.hasUpdate)

    })

    updateManager.onUpdateReady(function () {

      wx.showModal({

        title: ‘更新提示’,

        content: ‘新版本已经准备好,是否重启应用?’,

        success: function (res) {

          if (res.confirm) {

            // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启

            updateManager.applyUpdate()

          }

        }

      })

    })

    updateManager.onUpdateFailed(function () {

      // 新的版本下载失败

      wx.showModal({

        title: ‘更新提示’,

        content: ‘新版本下载失败’,

        showCancel: false

      })

    })

 

    try {

      var res = wx.getSystemInfoSync()

      that.globalData.windowWidth = res.windowWidth;

      that.globalData.windowHeight = res.windowHeight; 

      var windowWidth = res.windowWidth;

      var windowHeight = res.windowHeight;

      var imgheight = windowWidth * 360.0 / 750;

      wx.setStorageSync(“imgheight”, imgheight);

      var imgheight2 = (windowHeight - imgheight) / 2 - 5;

      wx.setStorageSync(“imgheight2”, imgheight2);

      var top = (imgheight2 - 80) / 3;

      wx.setStorageSync(“top”, top);

    } catch (e) {

    }

  },

  //appid线上  wxda75989e3497bf5e

  //测试 wx4e627044f8b2ee3c

  globalData: {

  },

})

1 回复

这种情况可以调试小程序看看,正式版可按如下方式调试:先在开发版或体验版打开调试,再切到正式版就能看到vConsole

回到顶部