| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- require("./utils/string.js")
- const ald = require('./libs/ald-stat.js')
- import {
- updataStorageData
- } from './utils/storage.js'
- var startTime = Date.now();//启动时间
- App({
- onLaunch: function (options) {
- this.aldstat.sendEvent('小程序的启动时长', {
- time: Date.now() - startTime
- })
- // 小程序版本更新
- if (wx.getUpdateManager) {
- const updateManager = wx.getUpdateManager()
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate)
- })
- updateManager.onUpdateReady(function () {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function () {
- // 新版本下载失败
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '当前微信版本过低,部分功能可能无法使用,请升级到最新微信版本后重试。'
- })
- }
- },
- onShow(options) {
- console.log("rr", options)
- //群聊信息
- if (options.shareTicket) {
- this.getShareInfo(options.shareTicket)
- }
- },
- globalData: {
- openId: '',
- userInfo: null,
- userId: '',
- userToken: '',
- sessionKey: '',
- city: updataStorageData('city') || '无锡'
- },
- //页面分享
- onShareAppMessage: function () {
- wx.showShareMenu({
- withShareTicket: true,
- success: (res) => { // 成功后要做的事情
- console.log(res)
- },
- fail: function (res) {
- console.log(res)
- }
- })
- },
- //获取群聊分享信息
- getShareInfo(shareTicket) {
- wx.getShareInfo({
- shareTicket: shareTicket,
- success: (res) => {
- //需后台解析数据 encryptedData iv
- console.log(res)
- },
- fail: function (res) {
- console.log(res)
- },
- complete: function (res) { }
- })
- },
- // 跳转登录页面
- goLogin() {
- wx.navigateTo({
- url: '/pages/login/login',
- })
- },
- })
|