free_delivery.js
3.89 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// packageF/pages/free_delivery/free_delivery.js
var o = getApp().globalData.setting
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
url: o.imghost,
userInfo:null,
login_title:'暂未登录,请先登录',
login_name:'授权登录',
login_off:false,
hd_id:'',
delHeight:736, //默认窗口高度,用于对比,定位图片用
delOff:false, //窗口高度对比,false 用默认定位,ture 定位调整
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let window_info = wx.getWindowInfo()
if (window_info.screenHeight > this.data.delHeight) {
this.setData({
delOff:true
})
}
if (options && options.id) {
this.setData({
hd_id:options.id
})
this.getInfo()
}else{
wx.showToast({
title: '获取活动失败',
icon: 'none',
duration: 2000,
mask:true
})
setTimeout(()=>{
wx.reLaunch({
url: '/pages/index/index/index'
})
},2000)
}
},
getInfo(){
app.promiseGet(`/api/weshop/meitu/storeMeituHdlist/get/${app.globalData.setting.stoid}/${this.data.hd_id}`, {}).then(res => {
if (res.data.code == 0 && res.data.data && res.data.data.hd_name) {
wx.setNavigationBarTitle({
title: res.data.data.hd_name
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
let userInfo = getApp().globalData.userInfo;
this.setData({
userInfo
})
if (userInfo) {
if (userInfo.mobile) {
this.setData({
login_title:userInfo.mobile,
login_name:'领取会员'
})
}else{
getApp().globalData.userInfo=null
wx.setStorageSync("userinfo", null);
}
}
},
//--跳到绑定页面--
gobindtel: function () {
let userInfo = this.data.userInfo
let login_off = this.data.login_off
if (userInfo) {
if (!login_off) {
this.setData({
login_off:true
})
wx.showLoading({
title: '领取中',
mask: true,
});
app.request.promisePost('/api/weshop/meitu/storeMeituUserlist/save', {
is_json: true,
data: {
store_id: app.globalData.setting.stoid,
user_id: app.globalData.user_id,
hd_id: this.data.hd_id,
},
}).then((res)=>{
if(res.data.code == 0) {
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000,
mask:true,
});
this.setData({
login_name:'已领取'
})
// setTimeout(()=>{
// wx.reLaunch({
// url: '/pages/index/index/index'
// })
// },2000)
// self.getData(true, '/api/weshop/goods/page?isnewwhere=1&is_mainshow=1&isonsale=1&dis_type=1', self.data.currentQuery, false);
} else {
this.setData({
login_off:false
})
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000,
mask:true,
});
}
});
}
}else{
wx.navigateTo({
url: '/packageE/pages/togoin/togoin',
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
wx.stopPullDownRefresh()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})