wx电子地图
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

App.vue 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. // console.log('App Launch')
  5. this.updateManager()
  6. },
  7. onShow: function() {
  8. // console.log('App Show')
  9. },
  10. onHide: function() {
  11. // console.log('App Hide')
  12. },
  13. methods: {
  14. updateManager () {
  15. // console.log("update");
  16. const that = this;
  17. //region 如果有更新小程序的版本,就清除缓存
  18. if (wx.canIUse('getUpdateManager')) {
  19. const updateManager = wx.getUpdateManager();
  20. updateManager.onCheckForUpdate(function (res) {
  21. console.debug('onCheckForUpdate====', res);
  22. // 请求完新版本信息的回调
  23. if (res.hasUpdate) {
  24. console.debug('res.hasUpdate====');
  25. updateManager.onUpdateReady(function () {
  26. wx.showModal({
  27. title: '更新提示',
  28. content: '新版本已经准备好,是否重启应用?',
  29. success: function (res) {
  30. console.debug('success====', res);
  31. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  32. if (res.confirm) {
  33. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  34. updateManager.applyUpdate();
  35. }
  36. }
  37. })
  38. });
  39. updateManager.onUpdateFailed(function () {
  40. // 新的版本下载失败
  41. wx.showModal({
  42. title: '已经有新版本了哟~',
  43. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  44. })
  45. });
  46. }
  47. })
  48. }
  49. },
  50. },
  51. }
  52. </script>
  53. <style lang="scss">
  54. /* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
  55. @import "./colorui/main.css";
  56. @import "./colorui/icon.css";
  57. @import "./colorui/animation.css";
  58. @import "@/uni_modules/uview-ui/index.scss";
  59. @import "uni.scss";
  60. </style>