App.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <script>
  2. import config from './config'
  3. import store from '@/store'
  4. import { getToken } from '@/utils/auth'
  5. export default {
  6. onLaunch: function() {
  7. this.initApp();
  8. wx.onAppRoute(function(res) {
  9. let pages = getCurrentPages()
  10. let view = pages[pages.length - 1]
  11. if(view) {
  12. wx.showShareMenu({
  13. withShareTicket:true,
  14. menus:['shareAppMessage','shareTimeline']
  15. })
  16. }
  17. })
  18. console.log('App Launch')
  19. },
  20. onShow: function() {
  21. const updateManager = uni.getUpdateManager();
  22. updateManager.onCheckForUpdate(function (res) {
  23. // 请求完新版本信息的回调
  24. console.log(res);
  25. });
  26. updateManager.onUpdateReady(function (res) {
  27. uni.showModal({
  28. title: '更新提示',
  29. content: '新版本已经准备好,是否重启应用?',
  30. success(res) {
  31. if (res.confirm) {
  32. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  33. updateManager.applyUpdate();
  34. }
  35. }
  36. });
  37. });
  38. updateManager.onUpdateFailed(function (res) {
  39. debugger
  40. // 新的版本下载失败
  41. console.log('download error')
  42. uni.showModal({
  43. title: '提示',
  44. content: '新版小程序下载失败\n请自行退出程序,手动卸载本程序,再运行',
  45. confirmText: "知道了"
  46. });
  47. });
  48. },
  49. onHide: function() {
  50. console.log('App Hide')
  51. },
  52. methods: {
  53. // 初始化应用
  54. initApp() {
  55. // 初始化应用配置
  56. this.initConfig()
  57. // 检查用户登录状态
  58. //#ifdef H5
  59. this.checkLogin()
  60. //#endif
  61. },
  62. initConfig() {
  63. this.globalData.config = config
  64. },
  65. checkLogin() {
  66. if (!getToken()) {
  67. this.$tab.reLaunch('/pages/login')
  68. }
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss">
  74. @import '@/static/scss/index.scss';
  75. @import './static/font/iconfont.css';
  76. .uni-list-cell-db{
  77. max-width: 75% !important;
  78. }
  79. </style>