Commit 5808c26689379a635e6ae780b6bc709fe8a04454
解决mygift.js冲突
Showing
3 changed files
with
103 additions
and
4 deletions
packageA/pages/myGift/myGift.js
1 | 1 | // packageA//pages/myGift/myGift.js |
2 | 2 | const app = getApp(); |
3 | 3 | let self = null; |
4 | +var os = app.globalData.setting; | |
4 | 5 | |
5 | 6 | Page({ |
6 | 7 | |
... | ... | @@ -202,5 +203,98 @@ Page({ |
202 | 203 | } |
203 | 204 | app.goto(url); |
204 | 205 | }, |
205 | - | |
206 | + | |
207 | + | |
208 | + //-- 礼包购买 -- | |
209 | + GetBuyPrice: function(e) { | |
210 | + var th = this,that=th; | |
211 | + var index=e.currentTarget.dataset.index; | |
212 | + var item=that.data.list.pageData[index]; | |
213 | + | |
214 | + var id = item.id; //活动id | |
215 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
216 | + var user=getApp().globalData.userInfo; | |
217 | + | |
218 | + my_confirm.open( | |
219 | + "是否确定购买该礼包", | |
220 | + "取消", | |
221 | + "确定", | |
222 | + function() { | |
223 | + my_confirm.open_cancel(0); | |
224 | + }, | |
225 | + function() { | |
226 | + my_confirm.open_cancel(0); | |
227 | + var json = { | |
228 | + "lbid": id, //活动Id | |
229 | + "paytype": 2, //1=积分兑换 2=购买 | |
230 | + "store_id": os.stoid, //商家Id | |
231 | + "user_id": user.user_id, //用户ID | |
232 | + }; | |
233 | + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
234 | + getApp().request.post(url, | |
235 | + { | |
236 | + data:json, | |
237 | + success:function(res) { | |
238 | + if (res.data.code == 0 && res.data.data) { | |
239 | + res = res.data.data; | |
240 | + wx.requestPayment({ | |
241 | + timeStamp: String(res.timeStamp), | |
242 | + nonceStr: res.nonceStr, | |
243 | + package: res.packageValue, | |
244 | + signType: res.signType, | |
245 | + paySign: res.paySign, | |
246 | + success: function(res) { | |
247 | + getApp().my_warnning("支付成功", 1, th); | |
248 | + }, | |
249 | + fail: function(res) { | |
250 | + getApp().my_warnning("取消支付", 0, th); | |
251 | + } | |
252 | + }); | |
253 | + } else { | |
254 | + getApp().my_warnning(res.data.msg, 0, th); | |
255 | + } | |
256 | + } | |
257 | + }) | |
258 | + }) | |
259 | + }, | |
260 | + | |
261 | + //-- 积分兑换 -- | |
262 | + GetBuyIntegral: function(e) { | |
263 | + var th = this,that=th; | |
264 | + var index=e.currentTarget.dataset.index; | |
265 | + var item=that.data.list.pageData[index]; | |
266 | + | |
267 | + var id = item.id; //活动id | |
268 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
269 | + var user=getApp().globalData.userInfo; | |
270 | + my_confirm.open( | |
271 | + "是否确定兑换该礼包", | |
272 | + "取消", | |
273 | + "确定", | |
274 | + function() { | |
275 | + my_confirm.open_cancel(0); | |
276 | + }, | |
277 | + function() { | |
278 | + my_confirm.open_cancel(0); | |
279 | + var json = { | |
280 | + "lbid": id, //活动Id | |
281 | + "paytype": 1, //1=积分兑换 2=购买 | |
282 | + "store_id": os.stoid, //商家Id | |
283 | + "user_id": user.user_id, //用户ID | |
284 | + }; | |
285 | + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; | |
286 | + getApp().request.post(url,{ | |
287 | + data:json, | |
288 | + success:function(res) { | |
289 | + if (res.data.code == 0) { | |
290 | + getApp().my_warnning("兑换成功!", 1, th); | |
291 | + } else { | |
292 | + getApp().my_warnning(res.data.msg, 0, th); | |
293 | + } | |
294 | + }, | |
295 | + }) | |
296 | + | |
297 | + }) | |
298 | + }, | |
299 | + | |
206 | 300 | }) |
207 | 301 | \ No newline at end of file | ... | ... |
packageA/pages/myGift/myGift.json
... | ... | @@ -3,6 +3,7 @@ |
3 | 3 | "enablePullDownRefresh": false, |
4 | 4 | "usingComponents": { |
5 | 5 | "warn": "/components/long_warn/long_warn", |
6 | - "nav_b": "/components/nav_b/nav_b" | |
6 | + "nav_b": "/components/nav_b/nav_b", | |
7 | + "my_confirm": "/components/my_confirm/my_confirm" | |
7 | 8 | } |
8 | 9 | } |
9 | 10 | \ No newline at end of file | ... | ... |
packageA/pages/myGift/myGift.wxml
... | ... | @@ -26,8 +26,8 @@ |
26 | 26 | </view> |
27 | 27 | </view> |
28 | 28 | <view class="btn-container pd20"> |
29 | - <view class="btn red">立即兑换</view> | |
30 | - <view class="btn pink">立即购买</view> | |
29 | + <view bindtap="GetBuyIntegral" data-index="{{index}}" class="btn red">立即兑换</view> | |
30 | + <view bindtap="GetBuyPrice" data-index="{{index}}" class="btn pink">立即购买</view> | |
31 | 31 | </view> |
32 | 32 | </view> |
33 | 33 | </block> |
... | ... | @@ -51,3 +51,7 @@ |
51 | 51 | <view class="noMore" hidden="{{!noMore}}" wx:if="{{list.pageData.length !== 0}}">—— 已经到底了 ——</view> |
52 | 52 | </view> |
53 | 53 | </view> |
54 | + | |
55 | +<!-- 引入提示组件 --> | |
56 | +<warn id="warn"></warn> | |
57 | +<my_confirm id="my_confirm"></my_confirm> | ... | ... |