App.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <script>
  2. const util = require("@/utils/util.js")
  3. export default {
  4. globalData: {
  5. userInfo: {
  6. nickName: 'Hi,游客',
  7. userName: '点击去登录',
  8. avatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
  9. },
  10. token: ''
  11. },
  12. onLaunch: function() {
  13. //获取小程序更新机制兼容
  14. if (uni.canIUse('getUpdateManager')) {
  15. const updateManager = uni.getUpdateManager()
  16. updateManager.onCheckForUpdate(function(res) {
  17. // 请求完新版本信息的回调
  18. if (res.hasUpdate) {
  19. updateManager.onUpdateReady(function() {
  20. uni.showModal({
  21. title: '更新提示',
  22. content: '新版本已经准备好,是否重启应用?',
  23. success: function(res) {
  24. if (res.confirm) {
  25. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  26. updateManager.applyUpdate()
  27. }
  28. }
  29. })
  30. })
  31. updateManager.onUpdateFailed(function() {
  32. // 新的版本下载失败
  33. uni.showModal({
  34. title: '已经有新版本了哟~',
  35. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
  36. })
  37. })
  38. }
  39. })
  40. } else {
  41. // 如果希望用户在最新版本的客户端上体验您的小程序,可以这样子提示
  42. uni.showModal({
  43. title: '提示',
  44. content: '当前微信版本过低,无法更好体验程序,请升级到最新微信版本后重试。'
  45. })
  46. }
  47. },
  48. onShow: function() {
  49. },
  50. onHide: function() {},
  51. onError: function(err) {
  52. //全局错误监听
  53. // #ifdef APP-PLUS
  54. plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
  55. const res = uni.getSystemInfoSync();
  56. let errMsg = `手机品牌:${res.brand};手机型号:${res.model};操作系统版本:${res.system};客户端平台:${res.platform};错误描述:${err}`;
  57. console.log('发生错误:' + errMsg);
  58. });
  59. // #endif
  60. }
  61. };
  62. </script>
  63. <style>
  64. /*每个页面公共css uParse为优化版本*/
  65. @import './common/app.css';
  66. /* #ifndef APP-NVUE */
  67. @import './components/uParse/src/wxParse.css';
  68. /* #endif */
  69. </style>