var e = getApp(), a = e.globalData.setting, os = a, t = e.request, d = e.globalData; var ut = require("../../../utils/util.js"); 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: "", code: "", //核销码 c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 is_lb: 0, //是否有礼包 default_color: null, first_leader: e.globalData.first_leader || 0, // 推荐人ID }, onLoad: function (options) { var th = this; th.setData({ isBuy: options.isBuy, getGiftID: options.lbId, orderSn: options.orderSn, getUserID: d.user_id, }) if (options.lbId) th.data.lbId = options.lbId; //-- 获取分享人的ID -- var first_leader = options.first_leader || getApp().globalData.first_leader; if (first_leader) { this.setData({ first_leader, }) //-- user_id代过来免登录 -- getApp().globalData.first_leader = first_leader; //调用接口判断是不是会员 getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { if (res.data.code == 0) { getApp().globalData.guide_id = res.data.data.id; } }) } th.close(); }, onShow: function () { //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { if(getApp().is_Single_page()){ getApp().goto('/pages/togoin/togoin'); return false; } } if (this.data.isBuy == 0) { this.GetMyGiftList(); } else { this.GetBuyGiftList(); } }, GetBuyPrice: function (e) { var that = this.data; var th = this; // var id = e.currentTarget.dataset.id;//活动id //如果还没有开始的话 if (th.data.isStart != 1) { getApp().my_warnning("活动还没有开始", 0, th); return false; } var money = e.currentTarget.dataset.money; 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=余额购买 "giftBagId": that.getGiftID, //礼包Id "storeId": a.stoid, //商家Id "userId": d.user_id, //用户ID "buyFrom": 2, "first_leader": that.first_leader, }; //-- 分享导购要记录 -- if (getApp().globalData.guide_id) { json.guide_id = getApp().globalData.guide_id; } var data = JSON.stringify(json); var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; getApp().request.json_post(url, json, function (res) { if (res.data.code == 0) { var res = res.data.data; if (!res) return false; if (!res.result) return false; var order_sn = res.orderSn; var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; wx.requestPayment({ timeStamp: String(res.result.timeStamp), nonceStr: res.result.nonceStr, package: res.result.packageValue, signType: res.result.signType, paySign: res.result.paySign, success: function (n) { getApp().goto(url); }, fail: function (n) { getApp().my_warnning("取消支付", 0, th); } }); } else { getApp().my_warnning(res.data.msg, 0, th); } }, function (res) { } ) } ) }, GetBuyIntegral: function (e) { var that = this.data; var th = this; //如果还没有开始的话 if (th.data.isStart != 1) { getApp().my_warnning("活动还没有开始", 0, th); return false; } // 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=余额购买 "giftBagId": that.getGiftID, //礼包Id "storeId": a.stoid, //商家ID "userId": d.user_id, //用户ID "buyFrom": 2, "first_leader": that.first_leader, }; //-- 分享导购要记录 -- if (getApp().globalData.guide_id) { json.guide_id = getApp().globalData.guide_id; } var data = JSON.stringify(json); var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; getApp().request.json_post(url, json, function (res) { if (res.data.code == 0) { getApp().my_warnning("兑换成功!", 1, th); } else { getApp().my_warnning(res.data.msg, 0, th); } }, function (res) { } ) }) }, GetMyGiftList: function () { var _this = this; var th = this; getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { isShowLoading: true, data: { "storeId": a.stoid, //商家ID "userId": d.user_id, //用户ID "orderSn": th.data.orderSn }, success: function (res) { if (res.data.code == 0) { th.setData({ giftImage: th.data.iurl + res.data.data.lbUrl, giftTitle: res.data.data.giftTitle, default_color: res.data.data.bgcolor }) if (res.data.data.giftRemark == '') { th.setData({ giftRemark: '暂无详情......' }) } else { th.setData({ giftRemark: res.data.data.giftRemark.replace(/\