From 991ec2af595822646fe9ad6a5afdf912c7cc9b3f Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 20 May 2021 14:22:34 +0800 Subject: [PATCH] 礼包列表 --- packageA/pages/myGift/myGift.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ packageA/pages/myGift/myGift.json | 3 ++- packageA/pages/myGift/myGift.wxml | 8 ++++++-- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/packageA/pages/myGift/myGift.js b/packageA/pages/myGift/myGift.js index fb8c06e..bf7daf4 100644 --- a/packageA/pages/myGift/myGift.js +++ b/packageA/pages/myGift/myGift.js @@ -1,6 +1,7 @@ // packageA//pages/myGift/myGift.js const app = getApp(); let self = null; +var os = app.globalData.setting; Page({ @@ -202,4 +203,97 @@ Page({ } app.goto(url); }, + + + //-- 礼包购买 -- + GetBuyPrice: function(e) { + var th = this,that=th; + var index=e.currentTarget.dataset.index; + var item=that.data.list.pageData[index]; + + var id = item.id; //活动id + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + var user=getApp().globalData.userInfo; + + my_confirm.open( + "是否确定购买该礼包", + "取消", + "确定", + function() { + my_confirm.open_cancel(0); + }, + function() { + my_confirm.open_cancel(0); + var json = { + "lbid": id, //活动Id + "paytype": 2, //1=积分兑换 2=购买 + "store_id": os.stoid, //商家Id + "user_id": user.user_id, //用户ID + }; + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; + getApp().request.post(url, + { + data:json, + success:function(res) { + if (res.data.code == 0 && res.data.data) { + res = res.data.data; + wx.requestPayment({ + timeStamp: String(res.timeStamp), + nonceStr: res.nonceStr, + package: res.packageValue, + signType: res.signType, + paySign: res.paySign, + success: function(res) { + getApp().my_warnning("支付成功", 1, th); + }, + fail: function(res) { + getApp().my_warnning("取消支付", 0, th); + } + }); + } else { + getApp().my_warnning(res.data.msg, 0, th); + } + } + }) + }) + }, + + //-- 积分兑换 -- + GetBuyIntegral: function(e) { + var th = this,that=th; + var index=e.currentTarget.dataset.index; + var item=that.data.list.pageData[index]; + + var id = item.id; //活动id + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + var user=getApp().globalData.userInfo; + my_confirm.open( + "是否确定兑换该礼包", + "取消", + "确定", + function() { + my_confirm.open_cancel(0); + }, + function() { + my_confirm.open_cancel(0); + var json = { + "lbid": id, //活动Id + "paytype": 1, //1=积分兑换 2=购买 + "store_id": os.stoid, //商家Id + "user_id": user.user_id, //用户ID + }; + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; + getApp().request.post(url,{ + data:json, + success:function(res) { + if (res.data.code == 0) { + getApp().my_warnning("兑换成功!", 1, th); + } else { + getApp().my_warnning(res.data.msg, 0, th); + } + }, + }) + + }) + }, }) \ No newline at end of file diff --git a/packageA/pages/myGift/myGift.json b/packageA/pages/myGift/myGift.json index c7693b0..eb599c0 100644 --- a/packageA/pages/myGift/myGift.json +++ b/packageA/pages/myGift/myGift.json @@ -3,6 +3,7 @@ "enablePullDownRefresh": false, "usingComponents": { "warn": "/components/long_warn/long_warn", - "nav_b": "/components/nav_b/nav_b" + "nav_b": "/components/nav_b/nav_b", + "my_confirm": "/components/my_confirm/my_confirm" } } \ No newline at end of file diff --git a/packageA/pages/myGift/myGift.wxml b/packageA/pages/myGift/myGift.wxml index f0e37c7..f8f00ab 100644 --- a/packageA/pages/myGift/myGift.wxml +++ b/packageA/pages/myGift/myGift.wxml @@ -26,8 +26,8 @@ - 立即兑换 - 立即购买 + 立即兑换 + 立即购买 @@ -51,3 +51,7 @@ + + + + -- libgit2 0.21.4