|
@@ -5,8 +5,56 @@
|
|
|
|
|
|
export default {
|
|
|
onLaunch: function() {
|
|
|
- this.initApp()
|
|
|
+ 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() {
|