giftpacklist.js
7.32 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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
var e = getApp(),
a = e.globalData.setting,
os = a,
t = e.request,
d = e.globalData;
Page({
data: {
url: a.url, //接口网址
iurl: a.imghost, //图片前缀网址
isBuy: 0,
getGiftID: '', //礼包id
giftImage: '',
giftTitle: '',
giftDate: '',
giftPrice: '',
giftIntegral: '',
giftPosPrice: '',
giftQty: '',
giftRemark: '',
giftType: '',
actTitle: '',
getUrl: '',
wareCard: [],
orderSn: "", //订单编号
lbId:""
},
onLoad: function(options) {
var th = this;
th.setData({
isBuy: options.isBuy,
getStorageID: a.stoid,
getUserID: d.user_id,
getGiftID: options.lbId,
orderSn: options.orderSn
})
},
onShow: function() {
var th = this;
if (th.data.isBuy == 0) {
th.GetMyGiftList();
} else {
th.GetBuyGiftList();
}
// this.giftRemark = this.giftRemark.replace(/<p><img/gi, "<p class='img'><img");
th.setData({
giftRemark: th.data.giftRemark.replace(/<p><img/gi, "<p class='img'><img")
})
},
GetBuyPrice: function (e) {
var that = this.data;
var th = this;
// var id = e.currentTarget.dataset.id;//活动id
var my_confirm = th.selectComponent("#my_confirm"); //组件的id
my_confirm.open(
"是否确定购买该礼包",
"取消",
"确定",
function () {
my_confirm.open_cancel(0);
},
function () {
my_confirm.open_cancel(0);
var json = {
"actId": '', //活动Id
"actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
"buyType": '2', //1=积分兑换 2=余额购买
"lbId": that.getGiftID, //礼包Id
"storeId": that.getStorageID, //商家Id
"userId": that.getUserID, //用户ID
"buyFrom": 2
};
var data = JSON.stringify(json);
var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
wx.request({
url: url,
data: data,
method: 'post',
header: {
'content-type': 'application/json'
}, // 设置请求的 header
success: function (res) {
if (res.data.code == 0) {
res = res.data.data;
wx.requestPayment({
timeStamp: String(res.timeStamp),
nonceStr: res.nonceStr,
package: res.packageValue,
signType: res.signType,
paySign: res.paySign,
success: function (n) {
},
fail: function (n) {
}
});
} else {
getApp().my_warnning(res.data.msg, 0, th);
}
}
})
}
)
},
GetBuyIntegral: function (e) {
var that = this.data;
var th = this;
// var id = e.currentTarget.dataset.id;//活动id
var my_confirm = th.selectComponent("#my_confirm"); //组件的id
my_confirm.open(
"是否确定兑换该礼包",
"取消",
"确定",
function () {
my_confirm.open_cancel(0);
},
function () {
my_confirm.open_cancel(0);
var json = {
"actId": '', //活动Id
"actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
"buyType": '1', //1=积分兑换 2=余额购买
"lbId": that.getGiftID, //礼包Id
"storeId": that.getStorageID, //商家Id
"userId": that.getUserID //用户ID
};
var data = JSON.stringify(json);
var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
wx.request({
url: url,
data: data,
method: 'post',
header: {
'content-type': 'application/json'
}, // 设置请求的 header
success: function (res) {
if (res.data.code == 0) {
getApp().my_warnning("兑换成功!", 1, th);
} else {
getApp().my_warnning(res.data.msg, 0, th);
}
}
})
})
},
GetMyGiftList: function() {
var _this = this;
var th = this;
getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', {
data: {
"storeId": th.data.getStorageID, //商家ID
"userId": th.data.getUserID, //用户ID
"orderSn": th.data.orderSn
},
success: function success(res) {
if (res.data.code == 0) {
th.setData({
giftImage: th.data.iurl + res.data.data.lbUrl,
giftTitle: res.data.data.giftTitle
})
if (res.data.data.giftRemark == '') {
th.setData({
giftRemark: '暂无详情......'
})
} else {
th.setData({
giftRemark: res.data.data.giftRemark
})
}
th.setData({
giftDate: res.data.data.endTime,
giftPosPrice: res.data.data.giftPosPrice,
giftQty: res.data.data.giftQty,
giftIntegral: res.data.data.payIntegral,
giftPrice: res.data.data.payMoney,
giftType: res.data.data.actType,
actTitle: res.data.data.actTitle,
wareCard: res.data.data.wareCard,
lbId: res.data.data.lbId
})
} else {
getApp().my_warnning("系统繁忙,请稍后再试", 0, th);
return false;
}
}
});
},
GetBuyGiftList: function() {
var _this2 = this;
var th = this.data;
getApp().request.get('/api/weshop/marketing/giftbag/detail/get', {
data: {
"storeId": th.getStorageID, //商家ID
"userId": th.getUserID, //用户ID
"giftBagId": th.getGiftID
},
success: function success(res) {
if (res.data.code == 0) {
_this2.setData({
giftImage: th.iurl + res.data.data.lbUrl,
giftTitle: res.data.data.giftTitle
})
if (res.data.data.giftRemark == '') {
_this2.setData({
giftRemark: '暂无详情......'
})
} else {
_this2.setData({
giftRemark: res.data.data.giftRemark
})
}
_this2.setData({
giftDate: res.data.data.endTime,
giftPosPrice: res.data.data.giftPosPrice,
giftQty: res.data.data.giftQty,
giftIntegral: res.data.data.payIntegral,
giftPrice: res.data.data.payMoney,
giftType: res.data.data.actType,
actTitle: res.data.data.actTitle,
wareCard: res.data.data.wareCard,
})
} else {
getApp().my_warnning("系统繁忙,请稍后再试", 0, _this2);
return false;
}
}
});
},
GetQrCode: function() {
//不销毁调整
uni.navigateTo({
url: '/pages/mygiftpack/QrCode?number=' + this.getGiftID
});
},
GetWebHttp: function(type) {
if (type == 0) {
this.getUrl = this.$GetInfo.HtmlHttp + '/index.php/Mobile/User/coupon/stoid/' + this.getStorageID + '/user_id/' + this.getUserID + '.html';
}
if (type == 1) {
this.getUrl = this.$GetInfo.HtmlHttp + '/index.php/Mobile/Yyservice/service_items_list/stoid/' + this.getStorageID + '/user_id/' + this.getUserID + '.html';
}
window.location.href = this.getUrl;
}
});