123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- //app.js
- var businessT = require('tool/business-tool.js')
- var sysT = require('tool/sys-tool.js')
- App({
- onLaunch: function (options) {
- sysT.adaptor()
- businessT.debugLog(sysT.isLongScreen())
- businessT.debugLog(sysT.suffixOfClass())
- // this.judgeVersion()
- // this.getUpdateReady()
- this.getNetworkStatus()
- // this.handleData()
- },
- onShow: function (e) {
- //console.log(e)
- this.globalData.scene = e.scene
- if (e.scene == 1037) {
- this.globalData.flow_id = e.referrerInfo.appId
- this.getflowAPP(e.referrerInfo.appId)
- } else {
- this.globalData.flow_id = 1000
- this.globalData.flow_name = "其他渠道来源"
- }
- },
- // handleData: function () {
- // //购买城市
- // var d
- // try {
- // d = swan.getStorageSync(key.StorageKey.purchaseCity)
- // } catch (e) {
- // }
- // if (!d) {
- // d = {
- // p: [{ name: '广东', id: 1000 }, { name: '北京市', id: 1100 }, { name: '上海市', id: 1200 }],
- // 1000: [{ name: '广州', id: 1001 }, { name: '深圳', id: 1014 }],
- // 1100: [{ name: '北京', id: 1101 }],
- // 1200: [{ name: '上海', id: 1201 }]
- // }
- // }
- // publicData.purchaseCity = d
- // swan.setStorageSync(key.StorageKey.purchaseCity, d)
- // businessT.debugLog(d)
- // },
- getUpdateReady: function () {
- updateManager.onUpdateReady(function () {
- swan.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- },
- getNetworkStatus: function () {
- var that = this
- swan.getNetworkType({
- success: function (res) {
- // 返回网络类型, 有效值:
- // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
- that.networkStatus.type = res.networkType
- if (that.networkStatus.type == 'none') {
- that.networkStatus.connected = false
- } else {
- that.networkStatus.connected = true
- }
- businessT.debugLog(that.networkStatus)
- }
- })
- swan.onNetworkStatusChange(function (res) {
- that.networkStatus.type = res.networkType
- that.networkStatus.connected = res.isConnected
- businessT.debugLog(that.networkStatus)
- })
- },
- // judgeVersion: function () {
- // var version = swan.getStorageSync(key.StorageKey.localVersion)
- // if (!version) {
- // swan.removeStorageSync(key.StorageKey.userCode)
- // swan.removeStorageSync(key.StorageKey.user)
- // swan.removeStorageSync(key.StorageKey.userPhone)
- // } else if (version < this.localVersion) {
- // } else {
- // }
- // swan.setStorageSync(key.StorageKey.localVersion, this.localVersion)
- // },
- initRedDotArray: function () {
- this.redDotArray = ['0', '0', '0', '0', '0']
- this.tabRedDot = '0'
- },
- tabRedDot: '0',
- redDotArray: ['0', '0', '0', '0', '0'],
- bankCardTips: {},
- loginStatus: {
- key: '',
- isLogin: false
- },
- networkStatus: {
- type: 'none',
- connected: false
- },
- idCard: {
- front: '',
- back: '',
- loaclPath: ''
- },
- purchase: {
- // normalPurchaseDataArray: [],
- // supplementaryPurchaseDataArray: [],
- purchaseDataArray: [],
- purchaseData: null,
- order: null
- },
- globalData: {
- scene: null,//进入小程序场景
- flow_id: 1000,//从其他平台跳转过来的appID
- flow_name: '其他渠道来源',//从其他平台跳转过来的平台名称
- customerList: [],
- userInfo: {
- uid: '',
- phone: ''
- }
- },
- localVersion: 1,
- })
|