-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
169 lines (163 loc) · 6.21 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//app.js
import { setUrlObj} from 'tool/index.js'
const imgPath = '' // cdn
//const imgPath = 'http://i1.fuimg.com/701439' // cdn
const source = '0' // 来源
import config from 'tool/config.js'
App({
data:{
scene: '',
imgBaseUrl: 'https://zksrimg.oss-cn-beijing.aliyuncs.com/kaptcha/',
version: '1.0', // 版本号
userWxInfo: null, // 用户微信信息
source:"0",
userInfo:null,// { userId: "133997" }, // 用户账户信息{ userId: "133997" }
openId: null,//'o9yv15Smf9MkXTpwgocFC2ruNZ2w',//null,// 'o9yv15Smf9MkXTpwgocFC2ruNZ2w', // 用户openId
storeId:"1", //没有用处,只是为了调用keke做测试
sysCode: "",//'6', //null,// '6', // 合伙人
colonelId: "",//'3312',//null,//'3312' , //团长
colonelInfo: {},
dcId: "",//"35",//'35', //null,//
sessionKey: '', // session_key
themeColor: '#FF5800', // 主题颜色
receivingAddr: null, //收货地址
shoppingCart:[], //购物车里面的商品
dcName:"", //配送中心名称
ww:0,
mapKey: config[source].mapKey,
postageSection:[], // 当前配送中心运费区间
startDeliveMoney: 0, // 当前配送中心起送金额
storeMode: false, // 自提点模式
storeColonelId: '', // 自提点团长ID
userIsColonel: false, // 用户是不是团长
storeInfo:{}, // 自提点数据
shareType: '' // 分享类型 goodShare 为商品分享
},
onShow(options) {
console.log('onShowonLaunch', options)
console.log(this)
this.data.scene = options.scene
// 判断是否由分享进入小程序
if ((options.scene == 1007 || options.scene == 1008) && options.query.openType == 'share') {
if (options.query.storeId && options.query.storeId != "undefined") {
console.log('asdasfasf')
this.data.storeMode = true
// wx.setStorage({ data: 1, key: 'switchTransWay' })
this.globalData.switchTransWay = 1
} else if (options.query.storeId == "undefined" && 'i' in options.query) { // 商品非自提点分享
this.data.shareType = 'goodShare'
this.data.storeMode = 'false'
this.data.storeAddr = {}
setTimeout(() => this.globalData.switchTransWay = 0, 1000)
} else {
console.log('进啊速度噶四百')
// wx.setStorage({ data: 0, key: 'switchTransWay' })
this.globalData.switchTransWay = 0
this.data.storeMode = true
console.log(this.globalData.switchTransWay)
}
// wx.setStorageSync('currentStoreMode', 1)
// wx.removeStorageSync('currentStoreAddr')
this.globalData.share = true
this.data.storeInfo.storeId = options.query.storeId
console.log(this)
} else {
console.log('mode = false')
this.globalData.share = false
this.data.storeMode = false
};
console.log('onShow', options)
console.log('app.js全局:', this)
if (options.referrerInfo.extraData) {
this.data.colonelId = options.referrerInfo.extraData.colonelId
this.data.shareItemId = options.referrerInfo.extraData.itemId
}
const shareColonelId = options.colonelId || options.query.colonelId||''
if (shareColonelId){
this.data.colonelId = shareColonelId
if (options.query.isStore) {
console.log(111)
this.data.storeMode = true
this.data.storeColonelId = shareColonelId
}
}
if (options.query.scene) {
let sceneObj = setUrlObj(decodeURIComponent(options.query.scene))
console.log(866666,sceneObj)
if (sceneObj.isStore || sceneObj.st=='1') {
this.data.storeMode = true
this.data.storeColonelId = sceneObj.colonelId
}
if (!this.data.colonelId) {
this.data.colonelId = sceneObj.colonelId || ''
}
}
if (wx.getUpdateManager && options.scene != 1154) {
const updateManager = wx.getUpdateManager()
updateManager.onUpdateReady(() => {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
showCancel: false,
success: res => {
if (res.confirm) {
updateManager.applyUpdate()
}
}
})
})
}
console.log('113版本号' ,'2.0.5')
console.log('114wx.getUpdateManager', wx.getUpdateManager())
// const updateManager = wx.getUpdateManager()
// updateManager.onUpdateReady(() => {
// wx.showModal({
// title: '更新提示',
// content: '新版本已经准备好,是否重启应用?',
// showCancel: false,
// success: res => {
// if (res.confirm) {
// updateManager.applyUpdate()
// }
// }
// })
// })
},
onLaunch: function (options) {
console.log(options)
this.globalData.q = JSON.stringify(options)
//获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
//这个最初我是在组件中获取,但是出现了一个问题,当第一次进入小程序时导航栏会把
//页面内容盖住一部分,当打开调试重新进入时就没有问题,这个问题弄得我是莫名其妙
//虽然最后解决了,但是花费了不少时间
var that = this
if (wx.getSystemInfoSync) {
const res = wx.getSystemInfoSync()
that.globalData.platform = res.platform
let totalTopHeight = 68
if (res.model.indexOf('iPhone X') !== -1) {
totalTopHeight = 88
} else if (res.model.indexOf('iPhone') !== -1) {
totalTopHeight = 64
}
that.globalData.statusBarHeight = res.statusBarHeight
console.log(res.statusBarHeight)
that.globalData.titleBarHeight = totalTopHeight - res.statusBarHeight
that.globalData.windowWidth = res.windowWidth;
that.globalData.windowHeight = res.windowHeight
// if(res.brand=="Xiaomi"&&res.model=="MI 5"){
// that.globalData.LXY="1"
// }
this.data.ww = res.windowWidth
this.data.hh = res.windowHeight
} else {
that.globalData.statusBarHeight = 30
}
},
globalData: {
share: false, // 分享默认为false
height: 0,
switchTransWay: '', // 当前的配送方式 0:送到家 1:自提 (分享模式)
q: '100'
}
})