diff --git a/pages/giftpack/buygiftpack/giftpackbuy.js b/pages/giftpack/buygiftpack/giftpackbuy.js index e223d8f..7949a2a 100644 --- a/pages/giftpack/buygiftpack/giftpackbuy.js +++ b/pages/giftpack/buygiftpack/giftpackbuy.js @@ -25,40 +25,56 @@ Page({ curpage: 1, //当前分页数 pageSize: 10, //页大小 total: 0, //总数量 - ad_data:null, + ad_data: null, first_leader: e.globalData.first_leader || 0, // 推荐人ID }, - onLoad: function(options) { - + onLoad: function (options) { var th = this; var my_confirm = th.selectComponent("#my_confirm"); //组件的id my_confirm.open_cancel(0); th.setData({ getStorageID: a.stoid, getUserID: d.user_id + }); + + //-- 获取分享人的ID -- + var first_leader = options.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; + } + }) + } + + getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, { + data: { + enabled: 1 + } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { + var a = res.data.data.pageData; + var tt = { + 'ad_code': os.imghost + a[0].ad_code, + 'media_link': '', + 'ad_weapplink': a[0].ad_weapplink, + 'bgcolor': a[0].bgcolor, + }; + th.setData({ + ad_data: tt + }); + } }) - - - getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, { - data: { - enabled: 1 - } - }).then(res => { - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ - var a = res.data.data.pageData; - var tt = { - 'ad_code': os.imghost + a[0].ad_code, - 'media_link': '', - 'ad_weapplink':a[0].ad_weapplink, - 'bgcolor':a[0].bgcolor, - }; - th.setData({ad_data:tt}); - } - }) - + }, - onShow: function() { + onShow: function () { //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { @@ -69,7 +85,8 @@ Page({ }, - GetBuyPrice: function(e) { + //购买礼包 + GetBuyPrice: function (e) { var that = this.data; var th = this; var id = e.currentTarget.dataset.id; //活动id @@ -80,10 +97,10 @@ Page({ "是否确定购买该礼包", "取消", "确定", - function() { + function () { my_confirm.open_cancel(0); }, - function() { + function () { my_confirm.open_cancel(0); var json = { "actId": '', //活动Id @@ -93,25 +110,22 @@ Page({ "storeId": that.getStorageID, //商家Id "userId": that.getUserID, //用户ID "buyFrom": 2, - "first_leader": that.first_leader + "first_leader": that.first_leader, }; - - //-- 分享导购要记录 -- - if(getApp().globalData.guide_id){ - json.guide_id=getApp().globalData.guide_id; - } - - + + //-- 分享导购要记录 -- + 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) { + function (res) { if (res.data.code == 0 && res.data.data) { - - var order_sn = res.data.data.orderSn; - res = res.data.data.result; - if(!res) return false; - + var order_sn = res.data.data.orderSn; + res = res.data.data.result; + if (!res) return false; var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; wx.requestPayment({ timeStamp: String(res.timeStamp), @@ -119,10 +133,10 @@ Page({ package: res.packageValue, signType: res.signType, paySign: res.paySign, - success: function(res) { + success: function (res) { getApp().goto(url); }, - fail: function(res) { + fail: function (res) { getApp().my_warnning("取消支付", 0, th); } }); @@ -130,7 +144,7 @@ Page({ getApp().my_warnning(res.data.msg, 0, th); } }, - function(res) { + function (res) { } @@ -144,20 +158,20 @@ Page({ }, // 积分兑换 - GetBuyIntegral: function(e) { + 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() { + function () { my_confirm.open_cancel(0); }, - function() { + function () { my_confirm.open_cancel(0); var json = { "actId": '', //活动Id @@ -169,71 +183,71 @@ Page({ "buyFrom": 2, "first_leader": that.first_leader }; - - - //-- 分享导购要记录 -- - if(getApp().globalData.guide_id){ - json.guide_id=getApp().globalData.guide_id; - } + //-- 分享导购要记录 -- + if (getApp().globalData.guide_id) { + json.guide_id = getApp().globalData.guide_id; + } + console.log(json,'json'); 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) { + function (res) { if (res.data.code == 0) { getApp().my_warnning("兑换成功!", 1, th); } else { getApp().my_warnning(res.data.msg, 0, th); } }, - function(res) {}) + function (res) {}) }) }, //免费领取 - GetFree:function (e){ + GetFree: 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": '3', //1=积分兑换 2=余额购买 3=免费领取 - "giftBagId": id, //礼包Id - "storeId": that.getStorageID, //商家Id - "userId": that.getUserID, //用户ID - "buyFrom": 2 - }; - //-- 分享导购要记录 -- - 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) {}) - }) + "是否确定领取该礼包", + "取消", + "确定", + function () { + my_confirm.open_cancel(0); + }, + function () { + my_confirm.open_cancel(0); + var json = { + "actId": '', //活动Id + "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 + "buyType": '3', //1=积分兑换 2=余额购买 3=免费领取 + "giftBagId": id, //礼包Id + "storeId": that.getStorageID, //商家Id + "userId": that.getUserID, //用户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) {}) + }) }, - getList: function(e) { + getList: function (e) { var th = this; getApp().request.get('/api/weshop/marketing/giftbag/page', { isShowLoading: true, @@ -243,7 +257,7 @@ Page({ page: th.data.curpage, pageSize: th.data.pageSize }, - success: function(res) { + success: function (res) { if (res.data.code == 0) { th.data.curpage++; var arr1 = th.data.wareCard; @@ -260,7 +274,7 @@ Page({ } else { th.setData({ is_read: 1, - ismore:1 + ismore: 1 }) } } @@ -268,7 +282,7 @@ Page({ }, //销毁界面跳转 - redirectTo: function(e) { + redirectTo: function (e) { var th = this; var url = e.currentTarget.dataset.url; //销毁跳转 @@ -277,14 +291,14 @@ Page({ }); }, //不销毁界面跳转 - navigateTo: function(e) { + navigateTo: function (e) { var th = this; var url = e.currentTarget.dataset.url; getApp().goto(url); }, //下拉事件 - onReachBottom: function() { + onReachBottom: function () { var th = this; if (th.data.total <= th.data.pageSize) return; if (th.data.ismore) return; @@ -292,42 +306,44 @@ Page({ th.getList(); }, //图片失败,默认图片 - bind_bnerr2: function(e) { + bind_bnerr2: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; }, - goto: function(e) { + goto: function (e) { var th = this; var url = e.currentTarget.dataset.url; getApp().goto(url); }, - - onShareAppMessage: function (e) { - var curPage=this; - var pagePath = curPage.route; //当前页面url - if (pagePath.indexOf('/') != 0) { - pagePath = '/' + pagePath; - } - return { - title: "专享礼包", - path:pagePath, - } - }, + + onShareAppMessage: function (e) { + var curPage = this; + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + pagePath += "?first_leader="+this.data.getUserID; + return { + title: "专享礼包", + path: pagePath, + } + }, // 分享朋友圈 - onShareTimeline() { - var curPage=this; - var pagePath = curPage.route; //当前页面url - if (pagePath.indexOf('/') != 0) { - pagePath = '/' + pagePath; - } - return { - title: '专享礼包', - imageUrl: this.data.ad_data.ad_code, - path: pagePath, - } - }, - + onShareTimeline() { + var curPage = this; + var pagePath = curPage.route; //当前页面url + if (pagePath.indexOf('/') != 0) { + pagePath = '/' + pagePath; + } + pagePath += "?first_leader="+this.data.getUserID; + return { + title: '专享礼包', + imageUrl: this.data.ad_data.ad_code, + path: pagePath, + } + }, + }) \ No newline at end of file diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index b300c4b..997afb2 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -28,33 +28,37 @@ Page({ code: "", //核销码 c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 is_lb: 0, //是否有礼包 - default_color:null, + default_color: null, + first_leader: e.globalData.first_leader || 0, // 推荐人ID }, - onLoad: function(options) { + onLoad: function (options) { var th = this; th.setData({ isBuy: options.isBuy, getGiftID: options.lbId, - orderSn: options.orderSn + orderSn: options.orderSn, + getUserID: d.user_id, }) - - //-- 获取分享人的ID -- - var first_leader=options.first_leader; - if(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; - } - }) - } + //-- 获取分享人的ID -- + var first_leader = options.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() { + + onShow: function () { //--先判断会员状态-- var user_info = getApp().globalData.userInfo; if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { @@ -68,14 +72,14 @@ Page({ } }, - GetBuyPrice: function(e) { + 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; + if (th.data.isStart != 1) { + getApp().my_warnning("活动还没有开始", 0, th); + return false; } @@ -85,10 +89,10 @@ Page({ "是否确定购买该礼包", "取消", "确定", - function() { + function () { my_confirm.open_cancel(0); }, - function() { + function () { my_confirm.open_cancel(0); var json = { @@ -98,24 +102,25 @@ Page({ "giftBagId": that.getGiftID, //礼包Id "storeId": a.stoid, //商家Id "userId": d.user_id, //用户ID - "buyFrom": 2 + "buyFrom": 2, + "first_leader": that.first_leader, }; - - //-- 分享导购要记录 -- - if(getApp().globalData.guide_id){ - json.guide_id=getApp().globalData.guide_id; - } - + + //-- 分享导购要记录 -- + 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) { + function (res) { if (res.data.code == 0) { var res = res.data.data; - if(!res) return false; - if(!res.result) return false; - + 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({ @@ -124,10 +129,10 @@ Page({ package: res.result.packageValue, signType: res.result.signType, paySign: res.result.paySign, - success: function(n) { + success: function (n) { getApp().goto(url); }, - fail: function(n) { + fail: function (n) { getApp().my_warnning("取消支付", 0, th); } }); @@ -135,7 +140,7 @@ Page({ getApp().my_warnning(res.data.msg, 0, th); } }, - function(res) { + function (res) { } @@ -147,12 +152,12 @@ Page({ ) }, - GetBuyIntegral: function(e) { + GetBuyIntegral: function (e) { var that = this.data; var th = this; //如果还没有开始的话 - if(th.data.isStart!=1){ + if (th.data.isStart != 1) { getApp().my_warnning("活动还没有开始", 0, th); return false; } @@ -162,10 +167,10 @@ Page({ "是否确定兑换该礼包", "取消", "确定", - function() { + function () { my_confirm.open_cancel(0); }, - function() { + function () { my_confirm.open_cancel(0); var json = { "actId": '', //活动Id @@ -174,26 +179,25 @@ Page({ "giftBagId": that.getGiftID, //礼包Id "storeId": a.stoid, //商家ID "userId": d.user_id, //用户ID - "buyFrom":2 + "buyFrom": 2, + "first_leader": that.first_leader, }; - - //-- 分享导购要记录 -- - if(getApp().globalData.guide_id){ - json.guide_id=getApp().globalData.guide_id; - } - - + //-- 分享导购要记录 -- + 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) { + function (res) { if (res.data.code == 0) { getApp().my_warnning("兑换成功!", 1, th); } else { getApp().my_warnning(res.data.msg, 0, th); } }, - function(res) { + function (res) { } @@ -203,7 +207,7 @@ Page({ }, - GetMyGiftList: function() { + GetMyGiftList: function () { var _this = this; var th = this; getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { @@ -213,12 +217,12 @@ Page({ "userId": d.user_id, //用户ID "orderSn": th.data.orderSn }, - success: function(res) { + 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 + default_color: res.data.data.bgcolor }) if (res.data.data.giftRemark == '') { th.setData({ @@ -272,7 +276,7 @@ Page({ }); }, - GetBuyGiftList: function() { + GetBuyGiftList: function () { var _this2 = this; var th = this.data; getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { @@ -287,7 +291,7 @@ Page({ _this2.setData({ giftImage: th.iurl + res.data.data.lbUrl, giftTitle: res.data.data.giftTitle, - default_color:res.data.data.bgcolor + default_color: res.data.data.bgcolor }) if (res.data.data.giftRemark == '') { _this2.setData({ @@ -299,13 +303,13 @@ Page({ }) } - var isStart=0; - var now=ut.gettimestamp(); + var isStart = 0; + var now = ut.gettimestamp(); - var str = res.data.data.starTime.replace(/-/g,'/'); + var str = res.data.data.starTime.replace(/-/g, '/'); var start = Date.parse(new Date(str)); start = start / 1000; - if(start {{"数量:"+item.num}} - + + 已核销 未核销 + diff --git a/pages/giftpack/mygiftpack/mygiftpack.js b/pages/giftpack/mygiftpack/mygiftpack.js index f2ff3f7..8f30334 100644 --- a/pages/giftpack/mygiftpack/mygiftpack.js +++ b/pages/giftpack/mygiftpack/mygiftpack.js @@ -25,11 +25,10 @@ Page({ curpage: 1, //当前分页数 pageSize: 10, //页大小 total: 0, //总数量 - ad_data:null, + ad_data:null, }, onLoad: function(options) { - var th = this; th.setData({ getStorageID: a.stoid, @@ -125,13 +124,13 @@ Page({ if (th.data.ismore) return; th.getList(); }, + //图片失败,默认图片 bind_bnerr2: function(e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - }, @@ -142,6 +141,7 @@ onShareAppMessage: function (e) { if (pagePath.indexOf('/') != 0) { pagePath = '/' + pagePath; } + pagePath += "?first_leader="+ this.data.getUserID; return { title: "专享礼包", path:pagePath, @@ -153,7 +153,8 @@ onShareAppMessage: function (e) { var pagePath = curPage.route; //当前页面url if (pagePath.indexOf('/') != 0) { pagePath = '/' + pagePath; - } + } + pagePath += "?first_leader="+ this.data.getUserID; return { title: '专享礼包', imageUrl: this.data.ad_data.ad_code,