123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <script>
- import config from './config'
- import store from '@/store'
- import { getToken } from '@/utils/auth'
- export default {
- onLaunch: function() {
- this.initApp();
- wx.onAppRoute(function(res) {
- let pages = getCurrentPages()
- let view = pages[pages.length - 1]
- if(view) {
- wx.showShareMenu({
- withShareTicket:true,
- menus:['shareAppMessage','shareTimeline']
- })
- }
- })
- console.log('App Launch')
- },
- onShow: function() {
-
- const updateManager = uni.getUpdateManager();
-
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log(res);
- });
-
- updateManager.onUpdateReady(function (res) {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- }
- });
-
- });
-
- updateManager.onUpdateFailed(function (res) {
- debugger
- // 新的版本下载失败
- console.log('download error')
- uni.showModal({
- title: '提示',
- content: '新版小程序下载失败\n请自行退出程序,手动卸载本程序,再运行',
- confirmText: "知道了"
- });
- });
- },
- onHide: function() {
- console.log('App Hide')
- },
- methods: {
- // 初始化应用
- initApp() {
- // 初始化应用配置
- this.initConfig()
- // 检查用户登录状态
- //#ifdef H5
- this.checkLogin()
- //#endif
- },
- initConfig() {
- this.globalData.config = config
- },
- checkLogin() {
- if (!getToken()) {
- this.$tab.reLaunch('/pages/login')
- }
- }
- }
- }
- </script>
- <style lang="scss">
- @import '@/static/scss/index.scss';
- @import './static/font/iconfont.css';
- .uni-list-cell-db{
- max-width: 75% !important;
- }
- </style>
|