Commit 21bb9ff51453aa60bcfa22bd6e0888df612a4452

Authored by abson
1 parent cf078b76

专享礼包分享

pages/giftpack/buygiftpack/giftpackbuy.js
@@ -25,40 +25,56 @@ Page({ @@ -25,40 +25,56 @@ Page({
25 curpage: 1, //当前分页数 25 curpage: 1, //当前分页数
26 pageSize: 10, //页大小 26 pageSize: 10, //页大小
27 total: 0, //总数量 27 total: 0, //总数量
28 - ad_data:null, 28 + ad_data: null,
29 first_leader: e.globalData.first_leader || 0, // 推荐人ID 29 first_leader: e.globalData.first_leader || 0, // 推荐人ID
30 }, 30 },
31 - onLoad: function(options) {  
32 - 31 + onLoad: function (options) {
33 var th = this; 32 var th = this;
34 var my_confirm = th.selectComponent("#my_confirm"); //组件的id 33 var my_confirm = th.selectComponent("#my_confirm"); //组件的id
35 my_confirm.open_cancel(0); 34 my_confirm.open_cancel(0);
36 th.setData({ 35 th.setData({
37 getStorageID: a.stoid, 36 getStorageID: a.stoid,
38 getUserID: d.user_id 37 getUserID: d.user_id
  38 + });
  39 +
  40 + //-- 获取分享人的ID --
  41 + var first_leader = options.first_leader;
  42 + if (first_leader) {
  43 + this.setData({
  44 + first_leader,
  45 + })
  46 + //-- user_id代过来免登录 --
  47 + getApp().globalData.first_leader = first_leader;
  48 + //调用接口判断是不是会员
  49 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  50 + if (res.data.code == 0) {
  51 + getApp().globalData.guide_id = res.data.data.id;
  52 + }
  53 + })
  54 + }
  55 +
  56 + getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, {
  57 + data: {
  58 + enabled: 1
  59 + }
  60 + }).then(res => {
  61 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  62 + var a = res.data.data.pageData;
  63 + var tt = {
  64 + 'ad_code': os.imghost + a[0].ad_code,
  65 + 'media_link': '',
  66 + 'ad_weapplink': a[0].ad_weapplink,
  67 + 'bgcolor': a[0].bgcolor,
  68 + };
  69 + th.setData({
  70 + ad_data: tt
  71 + });
  72 + }
39 }) 73 })
40 -  
41 -  
42 - getApp().request.promiseGet("/api/weshop/ad/page?pid=901&store_id=" + os.stoid, {  
43 - data: {  
44 - enabled: 1  
45 - }  
46 - }).then(res => {  
47 - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){  
48 - var a = res.data.data.pageData;  
49 - var tt = {  
50 - 'ad_code': os.imghost + a[0].ad_code,  
51 - 'media_link': '',  
52 - 'ad_weapplink':a[0].ad_weapplink,  
53 - 'bgcolor':a[0].bgcolor,  
54 - };  
55 - th.setData({ad_data:tt});  
56 - }  
57 - })  
58 - 74 +
59 75
60 }, 76 },
61 - onShow: function() { 77 + onShow: function () {
62 //--先判断会员状态-- 78 //--先判断会员状态--
63 var user_info = getApp().globalData.userInfo; 79 var user_info = getApp().globalData.userInfo;
64 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { 80 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
@@ -69,7 +85,8 @@ Page({ @@ -69,7 +85,8 @@ Page({
69 85
70 }, 86 },
71 87
72 - GetBuyPrice: function(e) { 88 + //购买礼包
  89 + GetBuyPrice: function (e) {
73 var that = this.data; 90 var that = this.data;
74 var th = this; 91 var th = this;
75 var id = e.currentTarget.dataset.id; //活动id 92 var id = e.currentTarget.dataset.id; //活动id
@@ -80,10 +97,10 @@ Page({ @@ -80,10 +97,10 @@ Page({
80 "是否确定购买该礼包", 97 "是否确定购买该礼包",
81 "取消", 98 "取消",
82 "确定", 99 "确定",
83 - function() { 100 + function () {
84 my_confirm.open_cancel(0); 101 my_confirm.open_cancel(0);
85 }, 102 },
86 - function() { 103 + function () {
87 my_confirm.open_cancel(0); 104 my_confirm.open_cancel(0);
88 var json = { 105 var json = {
89 "actId": '', //活动Id 106 "actId": '', //活动Id
@@ -93,25 +110,22 @@ Page({ @@ -93,25 +110,22 @@ Page({
93 "storeId": that.getStorageID, //商家Id 110 "storeId": that.getStorageID, //商家Id
94 "userId": that.getUserID, //用户ID 111 "userId": that.getUserID, //用户ID
95 "buyFrom": 2, 112 "buyFrom": 2,
96 - "first_leader": that.first_leader 113 + "first_leader": that.first_leader,
97 }; 114 };
98 -  
99 - //-- 分享导购要记录 --  
100 - if(getApp().globalData.guide_id){  
101 - json.guide_id=getApp().globalData.guide_id;  
102 - }  
103 -  
104 - 115 +
  116 + //-- 分享导购要记录 --
  117 + if (getApp().globalData.guide_id) {
  118 + json.guide_id = getApp().globalData.guide_id;
  119 + }
  120 +
105 var data = JSON.stringify(json); 121 var data = JSON.stringify(json);
106 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; 122 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
107 getApp().request.json_post(url, json, 123 getApp().request.json_post(url, json,
108 - function(res) { 124 + function (res) {
109 if (res.data.code == 0 && res.data.data) { 125 if (res.data.code == 0 && res.data.data) {
110 -  
111 - var order_sn = res.data.data.orderSn;  
112 - res = res.data.data.result;  
113 - if(!res) return false;  
114 - 126 + var order_sn = res.data.data.orderSn;
  127 + res = res.data.data.result;
  128 + if (!res) return false;
115 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; 129 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn;
116 wx.requestPayment({ 130 wx.requestPayment({
117 timeStamp: String(res.timeStamp), 131 timeStamp: String(res.timeStamp),
@@ -119,10 +133,10 @@ Page({ @@ -119,10 +133,10 @@ Page({
119 package: res.packageValue, 133 package: res.packageValue,
120 signType: res.signType, 134 signType: res.signType,
121 paySign: res.paySign, 135 paySign: res.paySign,
122 - success: function(res) { 136 + success: function (res) {
123 getApp().goto(url); 137 getApp().goto(url);
124 }, 138 },
125 - fail: function(res) { 139 + fail: function (res) {
126 getApp().my_warnning("取消支付", 0, th); 140 getApp().my_warnning("取消支付", 0, th);
127 } 141 }
128 }); 142 });
@@ -130,7 +144,7 @@ Page({ @@ -130,7 +144,7 @@ Page({
130 getApp().my_warnning(res.data.msg, 0, th); 144 getApp().my_warnning(res.data.msg, 0, th);
131 } 145 }
132 }, 146 },
133 - function(res) { 147 + function (res) {
134 148
135 } 149 }
136 150
@@ -144,20 +158,20 @@ Page({ @@ -144,20 +158,20 @@ Page({
144 158
145 }, 159 },
146 // 积分兑换 160 // 积分兑换
147 - GetBuyIntegral: function(e) { 161 + GetBuyIntegral: function (e) {
148 var that = this.data; 162 var that = this.data;
149 var th = this; 163 var th = this;
150 var id = e.currentTarget.dataset.id; //活动id 164 var id = e.currentTarget.dataset.id; //活动id
151 var my_confirm = th.selectComponent("#my_confirm"); //组件的id 165 var my_confirm = th.selectComponent("#my_confirm"); //组件的id
152 - 166 +
153 my_confirm.open( 167 my_confirm.open(
154 "是否确定兑换该礼包", 168 "是否确定兑换该礼包",
155 "取消", 169 "取消",
156 "确定", 170 "确定",
157 - function() { 171 + function () {
158 my_confirm.open_cancel(0); 172 my_confirm.open_cancel(0);
159 }, 173 },
160 - function() { 174 + function () {
161 my_confirm.open_cancel(0); 175 my_confirm.open_cancel(0);
162 var json = { 176 var json = {
163 "actId": '', //活动Id 177 "actId": '', //活动Id
@@ -169,71 +183,71 @@ Page({ @@ -169,71 +183,71 @@ Page({
169 "buyFrom": 2, 183 "buyFrom": 2,
170 "first_leader": that.first_leader 184 "first_leader": that.first_leader
171 }; 185 };
172 -  
173 -  
174 - //-- 分享导购要记录 --  
175 - if(getApp().globalData.guide_id){  
176 - json.guide_id=getApp().globalData.guide_id;  
177 - }  
178 186
  187 + //-- 分享导购要记录 --
  188 + if (getApp().globalData.guide_id) {
  189 + json.guide_id = getApp().globalData.guide_id;
  190 + }
  191 + console.log(json,'json');
179 var data = JSON.stringify(json); 192 var data = JSON.stringify(json);
180 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; 193 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
181 getApp().request.json_post(url, json, 194 getApp().request.json_post(url, json,
182 - function(res) { 195 + function (res) {
183 if (res.data.code == 0) { 196 if (res.data.code == 0) {
184 getApp().my_warnning("兑换成功!", 1, th); 197 getApp().my_warnning("兑换成功!", 1, th);
185 } else { 198 } else {
186 getApp().my_warnning(res.data.msg, 0, th); 199 getApp().my_warnning(res.data.msg, 0, th);
187 } 200 }
188 }, 201 },
189 - function(res) {}) 202 + function (res) {})
190 203
191 }) 204 })
192 205
193 }, 206 },
194 //免费领取 207 //免费领取
195 - GetFree:function (e){ 208 + GetFree: function (e) {
196 var that = this.data; 209 var that = this.data;
197 var th = this; 210 var th = this;
198 var id = e.currentTarget.dataset.id; //活动id 211 var id = e.currentTarget.dataset.id; //活动id
199 var my_confirm = th.selectComponent("#my_confirm"); //组件的id 212 var my_confirm = th.selectComponent("#my_confirm"); //组件的id
200 my_confirm.open( 213 my_confirm.open(
201 - "是否确定领取该礼包",  
202 - "取消",  
203 - "确定",  
204 - function() {  
205 - my_confirm.open_cancel(0);  
206 - },  
207 - function() {  
208 - my_confirm.open_cancel(0);  
209 - var json = {  
210 - "actId": '', //活动Id  
211 - "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销  
212 - "buyType": '3', //1=积分兑换 2=余额购买 3=免费领取  
213 - "giftBagId": id, //礼包Id  
214 - "storeId": that.getStorageID, //商家Id  
215 - "userId": that.getUserID, //用户ID  
216 - "buyFrom": 2  
217 - };  
218 - //-- 分享导购要记录 --  
219 - if(getApp().globalData.guide_id){  
220 - json.guide_id=getApp().globalData.guide_id;  
221 - }  
222 - var data = JSON.stringify(json);  
223 - var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";  
224 - getApp().request.json_post(url, json,  
225 - function(res) {  
226 - if (res.data.code == 0) {  
227 - getApp().my_warnning("领取成功!", 1, th);  
228 - } else {  
229 - getApp().my_warnning(res.data.msg, 0, th);  
230 - }  
231 - },  
232 - function(res) {})  
233 - }) 214 + "是否确定领取该礼包",
  215 + "取消",
  216 + "确定",
  217 + function () {
  218 + my_confirm.open_cancel(0);
  219 + },
  220 + function () {
  221 + my_confirm.open_cancel(0);
  222 + var json = {
  223 + "actId": '', //活动Id
  224 + "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
  225 + "buyType": '3', //1=积分兑换 2=余额购买 3=免费领取
  226 + "giftBagId": id, //礼包Id
  227 + "storeId": that.getStorageID, //商家Id
  228 + "userId": that.getUserID, //用户ID
  229 + "buyFrom": 2,
  230 + "first_leader": that.first_leader
  231 + };
  232 + //-- 分享导购要记录 --
  233 + if (getApp().globalData.guide_id) {
  234 + json.guide_id = getApp().globalData.guide_id;
  235 + }
  236 + var data = JSON.stringify(json);
  237 + var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
  238 + getApp().request.json_post(url, json,
  239 + function (res) {
  240 + if (res.data.code == 0) {
  241 + getApp().my_warnning("领取成功!", 1, th);
  242 + } else {
  243 + getApp().my_warnning(res.data.msg, 0, th);
  244 + }
  245 + },
  246 + function (res) {})
  247 + })
234 }, 248 },
235 249
236 - getList: function(e) { 250 + getList: function (e) {
237 var th = this; 251 var th = this;
238 getApp().request.get('/api/weshop/marketing/giftbag/page', { 252 getApp().request.get('/api/weshop/marketing/giftbag/page', {
239 isShowLoading: true, 253 isShowLoading: true,
@@ -243,7 +257,7 @@ Page({ @@ -243,7 +257,7 @@ Page({
243 page: th.data.curpage, 257 page: th.data.curpage,
244 pageSize: th.data.pageSize 258 pageSize: th.data.pageSize
245 }, 259 },
246 - success: function(res) { 260 + success: function (res) {
247 if (res.data.code == 0) { 261 if (res.data.code == 0) {
248 th.data.curpage++; 262 th.data.curpage++;
249 var arr1 = th.data.wareCard; 263 var arr1 = th.data.wareCard;
@@ -260,7 +274,7 @@ Page({ @@ -260,7 +274,7 @@ Page({
260 } else { 274 } else {
261 th.setData({ 275 th.setData({
262 is_read: 1, 276 is_read: 1,
263 - ismore:1 277 + ismore: 1
264 }) 278 })
265 } 279 }
266 } 280 }
@@ -268,7 +282,7 @@ Page({ @@ -268,7 +282,7 @@ Page({
268 282
269 }, 283 },
270 //销毁界面跳转 284 //销毁界面跳转
271 - redirectTo: function(e) { 285 + redirectTo: function (e) {
272 var th = this; 286 var th = this;
273 var url = e.currentTarget.dataset.url; 287 var url = e.currentTarget.dataset.url;
274 //销毁跳转 288 //销毁跳转
@@ -277,14 +291,14 @@ Page({ @@ -277,14 +291,14 @@ Page({
277 }); 291 });
278 }, 292 },
279 //不销毁界面跳转 293 //不销毁界面跳转
280 - navigateTo: function(e) { 294 + navigateTo: function (e) {
281 var th = this; 295 var th = this;
282 var url = e.currentTarget.dataset.url; 296 var url = e.currentTarget.dataset.url;
283 getApp().goto(url); 297 getApp().goto(url);
284 298
285 }, 299 },
286 //下拉事件 300 //下拉事件
287 - onReachBottom: function() { 301 + onReachBottom: function () {
288 var th = this; 302 var th = this;
289 if (th.data.total <= th.data.pageSize) return; 303 if (th.data.total <= th.data.pageSize) return;
290 if (th.data.ismore) return; 304 if (th.data.ismore) return;
@@ -292,42 +306,44 @@ Page({ @@ -292,42 +306,44 @@ Page({
292 th.getList(); 306 th.getList();
293 }, 307 },
294 //图片失败,默认图片 308 //图片失败,默认图片
295 - bind_bnerr2: function(e) { 309 + bind_bnerr2: function (e) {
296 var _errImg = e.target.dataset.errorimg; 310 var _errImg = e.target.dataset.errorimg;
297 var _errObj = {}; 311 var _errObj = {};
298 _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; 312 _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
299 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; 313 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
300 }, 314 },
301 - goto: function(e) { 315 + goto: function (e) {
302 var th = this; 316 var th = this;
303 var url = e.currentTarget.dataset.url; 317 var url = e.currentTarget.dataset.url;
304 getApp().goto(url); 318 getApp().goto(url);
305 }, 319 },
306 -  
307 - onShareAppMessage: function (e) {  
308 - var curPage=this;  
309 - var pagePath = curPage.route; //当前页面url  
310 - if (pagePath.indexOf('/') != 0) {  
311 - pagePath = '/' + pagePath;  
312 - }  
313 - return {  
314 - title: "专享礼包",  
315 - path:pagePath,  
316 - }  
317 - }, 320 +
  321 + onShareAppMessage: function (e) {
  322 + var curPage = this;
  323 + var pagePath = curPage.route; //当前页面url
  324 + if (pagePath.indexOf('/') != 0) {
  325 + pagePath = '/' + pagePath;
  326 + }
  327 + pagePath += "?first_leader="+this.data.getUserID;
  328 + return {
  329 + title: "专享礼包",
  330 + path: pagePath,
  331 + }
  332 + },
318 333
319 // 分享朋友圈 334 // 分享朋友圈
320 - onShareTimeline() {  
321 - var curPage=this;  
322 - var pagePath = curPage.route; //当前页面url  
323 - if (pagePath.indexOf('/') != 0) {  
324 - pagePath = '/' + pagePath;  
325 - }  
326 - return {  
327 - title: '专享礼包',  
328 - imageUrl: this.data.ad_data.ad_code,  
329 - path: pagePath,  
330 - }  
331 - },  
332 - 335 + onShareTimeline() {
  336 + var curPage = this;
  337 + var pagePath = curPage.route; //当前页面url
  338 + if (pagePath.indexOf('/') != 0) {
  339 + pagePath = '/' + pagePath;
  340 + }
  341 + pagePath += "?first_leader="+this.data.getUserID;
  342 + return {
  343 + title: '专享礼包',
  344 + imageUrl: this.data.ad_data.ad_code,
  345 + path: pagePath,
  346 + }
  347 + },
  348 +
333 }) 349 })
334 \ No newline at end of file 350 \ No newline at end of file
pages/giftpack/giftpacklist/giftpacklist.js
@@ -28,33 +28,37 @@ Page({ @@ -28,33 +28,37 @@ Page({
28 code: "", //核销码 28 code: "", //核销码
29 c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期 29 c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期
30 is_lb: 0, //是否有礼包 30 is_lb: 0, //是否有礼包
31 - default_color:null, 31 + default_color: null,
  32 + first_leader: e.globalData.first_leader || 0, // 推荐人ID
32 }, 33 },
33 - onLoad: function(options) { 34 + onLoad: function (options) {
34 var th = this; 35 var th = this;
35 th.setData({ 36 th.setData({
36 isBuy: options.isBuy, 37 isBuy: options.isBuy,
37 getGiftID: options.lbId, 38 getGiftID: options.lbId,
38 - orderSn: options.orderSn 39 + orderSn: options.orderSn,
  40 + getUserID: d.user_id,
39 }) 41 })
40 -  
41 - //-- 获取分享人的ID --  
42 - var first_leader=options.first_leader;  
43 - if(first_leader){  
44 - //-- user_id代过来免登录 --  
45 - getApp().globalData.first_leader=first_leader;  
46 - //调用接口判断是不是会员  
47 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{  
48 - if(res.data.code==0){  
49 - getApp().globalData.guide_id=res.data.data.id;  
50 - }  
51 - })  
52 - }  
53 42
  43 + //-- 获取分享人的ID --
  44 + var first_leader = options.first_leader;
  45 + if (first_leader) {
  46 + this.setData({
  47 + first_leader,
  48 + })
  49 + //-- user_id代过来免登录 --
  50 + getApp().globalData.first_leader = first_leader;
  51 + //调用接口判断是不是会员
  52 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
  53 + if (res.data.code == 0) {
  54 + getApp().globalData.guide_id = res.data.data.id;
  55 + }
  56 + })
  57 + }
54 th.close(); 58 th.close();
55 }, 59 },
56 -  
57 - onShow: function() { 60 +
  61 + onShow: function () {
58 //--先判断会员状态-- 62 //--先判断会员状态--
59 var user_info = getApp().globalData.userInfo; 63 var user_info = getApp().globalData.userInfo;
60 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { 64 if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
@@ -68,14 +72,14 @@ Page({ @@ -68,14 +72,14 @@ Page({
68 } 72 }
69 73
70 }, 74 },
71 - GetBuyPrice: function(e) { 75 + GetBuyPrice: function (e) {
72 var that = this.data; 76 var that = this.data;
73 var th = this; 77 var th = this;
74 // var id = e.currentTarget.dataset.id;//活动id 78 // var id = e.currentTarget.dataset.id;//活动id
75 //如果还没有开始的话 79 //如果还没有开始的话
76 - if(th.data.isStart!=1){  
77 - getApp().my_warnning("活动还没有开始", 0, th);  
78 - return false; 80 + if (th.data.isStart != 1) {
  81 + getApp().my_warnning("活动还没有开始", 0, th);
  82 + return false;
79 } 83 }
80 84
81 85
@@ -85,10 +89,10 @@ Page({ @@ -85,10 +89,10 @@ Page({
85 "是否确定购买该礼包", 89 "是否确定购买该礼包",
86 "取消", 90 "取消",
87 "确定", 91 "确定",
88 - function() { 92 + function () {
89 my_confirm.open_cancel(0); 93 my_confirm.open_cancel(0);
90 }, 94 },
91 - function() { 95 + function () {
92 my_confirm.open_cancel(0); 96 my_confirm.open_cancel(0);
93 97
94 var json = { 98 var json = {
@@ -98,24 +102,25 @@ Page({ @@ -98,24 +102,25 @@ Page({
98 "giftBagId": that.getGiftID, //礼包Id 102 "giftBagId": that.getGiftID, //礼包Id
99 "storeId": a.stoid, //商家Id 103 "storeId": a.stoid, //商家Id
100 "userId": d.user_id, //用户ID 104 "userId": d.user_id, //用户ID
101 - "buyFrom": 2 105 + "buyFrom": 2,
  106 + "first_leader": that.first_leader,
102 }; 107 };
103 -  
104 - //-- 分享导购要记录 --  
105 - if(getApp().globalData.guide_id){  
106 - json.guide_id=getApp().globalData.guide_id;  
107 - }  
108 - 108 +
  109 + //-- 分享导购要记录 --
  110 + if (getApp().globalData.guide_id) {
  111 + json.guide_id = getApp().globalData.guide_id;
  112 + }
  113 +
109 var data = JSON.stringify(json); 114 var data = JSON.stringify(json);
110 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; 115 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
111 116
112 getApp().request.json_post(url, json, 117 getApp().request.json_post(url, json,
113 - function(res) { 118 + function (res) {
114 if (res.data.code == 0) { 119 if (res.data.code == 0) {
115 var res = res.data.data; 120 var res = res.data.data;
116 - if(!res) return false;  
117 - if(!res.result) return false;  
118 - 121 + if (!res) return false;
  122 + if (!res.result) return false;
  123 +
119 var order_sn = res.orderSn; 124 var order_sn = res.orderSn;
120 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn; 125 var url = "/pages/giftpack/payment/payment?money=" + money + "&order_sn=" + order_sn;
121 wx.requestPayment({ 126 wx.requestPayment({
@@ -124,10 +129,10 @@ Page({ @@ -124,10 +129,10 @@ Page({
124 package: res.result.packageValue, 129 package: res.result.packageValue,
125 signType: res.result.signType, 130 signType: res.result.signType,
126 paySign: res.result.paySign, 131 paySign: res.result.paySign,
127 - success: function(n) { 132 + success: function (n) {
128 getApp().goto(url); 133 getApp().goto(url);
129 }, 134 },
130 - fail: function(n) { 135 + fail: function (n) {
131 getApp().my_warnning("取消支付", 0, th); 136 getApp().my_warnning("取消支付", 0, th);
132 } 137 }
133 }); 138 });
@@ -135,7 +140,7 @@ Page({ @@ -135,7 +140,7 @@ Page({
135 getApp().my_warnning(res.data.msg, 0, th); 140 getApp().my_warnning(res.data.msg, 0, th);
136 } 141 }
137 }, 142 },
138 - function(res) { 143 + function (res) {
139 144
140 } 145 }
141 146
@@ -147,12 +152,12 @@ Page({ @@ -147,12 +152,12 @@ Page({
147 ) 152 )
148 153
149 }, 154 },
150 - GetBuyIntegral: function(e) { 155 + GetBuyIntegral: function (e) {
151 var that = this.data; 156 var that = this.data;
152 var th = this; 157 var th = this;
153 158
154 //如果还没有开始的话 159 //如果还没有开始的话
155 - if(th.data.isStart!=1){ 160 + if (th.data.isStart != 1) {
156 getApp().my_warnning("活动还没有开始", 0, th); 161 getApp().my_warnning("活动还没有开始", 0, th);
157 return false; 162 return false;
158 } 163 }
@@ -162,10 +167,10 @@ Page({ @@ -162,10 +167,10 @@ Page({
162 "是否确定兑换该礼包", 167 "是否确定兑换该礼包",
163 "取消", 168 "取消",
164 "确定", 169 "确定",
165 - function() { 170 + function () {
166 my_confirm.open_cancel(0); 171 my_confirm.open_cancel(0);
167 }, 172 },
168 - function() { 173 + function () {
169 my_confirm.open_cancel(0); 174 my_confirm.open_cancel(0);
170 var json = { 175 var json = {
171 "actId": '', //活动Id 176 "actId": '', //活动Id
@@ -174,26 +179,25 @@ Page({ @@ -174,26 +179,25 @@ Page({
174 "giftBagId": that.getGiftID, //礼包Id 179 "giftBagId": that.getGiftID, //礼包Id
175 "storeId": a.stoid, //商家ID 180 "storeId": a.stoid, //商家ID
176 "userId": d.user_id, //用户ID 181 "userId": d.user_id, //用户ID
177 - "buyFrom":2 182 + "buyFrom": 2,
  183 + "first_leader": that.first_leader,
178 }; 184 };
179 -  
180 - //-- 分享导购要记录 --  
181 - if(getApp().globalData.guide_id){  
182 - json.guide_id=getApp().globalData.guide_id;  
183 - }  
184 -  
185 - 185 + //-- 分享导购要记录 --
  186 + if (getApp().globalData.guide_id) {
  187 + json.guide_id = getApp().globalData.guide_id;
  188 + }
  189 +
186 var data = JSON.stringify(json); 190 var data = JSON.stringify(json);
187 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; 191 var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
188 getApp().request.json_post(url, json, 192 getApp().request.json_post(url, json,
189 - function(res) { 193 + function (res) {
190 if (res.data.code == 0) { 194 if (res.data.code == 0) {
191 getApp().my_warnning("兑换成功!", 1, th); 195 getApp().my_warnning("兑换成功!", 1, th);
192 } else { 196 } else {
193 getApp().my_warnning(res.data.msg, 0, th); 197 getApp().my_warnning(res.data.msg, 0, th);
194 } 198 }
195 }, 199 },
196 - function(res) { 200 + function (res) {
197 201
198 } 202 }
199 203
@@ -203,7 +207,7 @@ Page({ @@ -203,7 +207,7 @@ Page({
203 207
204 }, 208 },
205 209
206 - GetMyGiftList: function() { 210 + GetMyGiftList: function () {
207 var _this = this; 211 var _this = this;
208 var th = this; 212 var th = this;
209 getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { 213 getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', {
@@ -213,12 +217,12 @@ Page({ @@ -213,12 +217,12 @@ Page({
213 "userId": d.user_id, //用户ID 217 "userId": d.user_id, //用户ID
214 "orderSn": th.data.orderSn 218 "orderSn": th.data.orderSn
215 }, 219 },
216 - success: function(res) { 220 + success: function (res) {
217 if (res.data.code == 0) { 221 if (res.data.code == 0) {
218 th.setData({ 222 th.setData({
219 giftImage: th.data.iurl + res.data.data.lbUrl, 223 giftImage: th.data.iurl + res.data.data.lbUrl,
220 giftTitle: res.data.data.giftTitle, 224 giftTitle: res.data.data.giftTitle,
221 - default_color:res.data.data.bgcolor 225 + default_color: res.data.data.bgcolor
222 }) 226 })
223 if (res.data.data.giftRemark == '') { 227 if (res.data.data.giftRemark == '') {
224 th.setData({ 228 th.setData({
@@ -272,7 +276,7 @@ Page({ @@ -272,7 +276,7 @@ Page({
272 }); 276 });
273 277
274 }, 278 },
275 - GetBuyGiftList: function() { 279 + GetBuyGiftList: function () {
276 var _this2 = this; 280 var _this2 = this;
277 var th = this.data; 281 var th = this.data;
278 getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { 282 getApp().request.get('/api/weshop/marketing/giftbag/detail/get', {
@@ -287,7 +291,7 @@ Page({ @@ -287,7 +291,7 @@ Page({
287 _this2.setData({ 291 _this2.setData({
288 giftImage: th.iurl + res.data.data.lbUrl, 292 giftImage: th.iurl + res.data.data.lbUrl,
289 giftTitle: res.data.data.giftTitle, 293 giftTitle: res.data.data.giftTitle,
290 - default_color:res.data.data.bgcolor 294 + default_color: res.data.data.bgcolor
291 }) 295 })
292 if (res.data.data.giftRemark == '') { 296 if (res.data.data.giftRemark == '') {
293 _this2.setData({ 297 _this2.setData({
@@ -299,13 +303,13 @@ Page({ @@ -299,13 +303,13 @@ Page({
299 }) 303 })
300 } 304 }
301 305
302 - var isStart=0;  
303 - var now=ut.gettimestamp(); 306 + var isStart = 0;
  307 + var now = ut.gettimestamp();
304 308
305 - var str = res.data.data.starTime.replace(/-/g,'/'); 309 + var str = res.data.data.starTime.replace(/-/g, '/');
306 var start = Date.parse(new Date(str)); 310 var start = Date.parse(new Date(str));
307 start = start / 1000; 311 start = start / 1000;
308 - if(start<now) isStart=1; 312 + if (start < now) isStart = 1;
309 313
310 _this2.setData({ 314 _this2.setData({
311 giftDate: res.data.data.endTime, 315 giftDate: res.data.data.endTime,
@@ -317,7 +321,7 @@ Page({ @@ -317,7 +321,7 @@ Page({
317 giftType: res.data.data.actType, 321 giftType: res.data.data.actType,
318 actTitle: res.data.data.actTitle, 322 actTitle: res.data.data.actTitle,
319 wareCard: res.data.data.wareCard, 323 wareCard: res.data.data.wareCard,
320 - isStart:isStart, 324 + isStart: isStart,
321 }) 325 })
322 } else { 326 } else {
323 getApp().my_warnning(res.data.msg, 0, _this2); 327 getApp().my_warnning(res.data.msg, 0, _this2);
@@ -328,7 +332,7 @@ Page({ @@ -328,7 +332,7 @@ Page({
328 332
329 }, 333 },
330 //显示核销码 334 //显示核销码
331 - code_show: function(e) { 335 + code_show: function (e) {
332 var th = this; 336 var th = this;
333 //--获取成功的时候-- 337 //--获取成功的时候--
334 var no = th.data.code; 338 var no = th.data.code;
@@ -340,21 +344,21 @@ Page({ @@ -340,21 +344,21 @@ Page({
340 qc_com.open(obj) 344 qc_com.open(obj)
341 }, 345 },
342 //获取核销码 346 //获取核销码
343 - getcode: function(e) { 347 + getcode: function (e) {
344 var th = this; 348 var th = this;
345 var orderSn = th.data.orderSn; //订单号 349 var orderSn = th.data.orderSn; //订单号
346 - let codeId=e.currentTarget.dataset.codeid; 350 + let codeId = e.currentTarget.dataset.codeid;
347 var json = { 351 var json = {
348 "storeId": a.stoid, 352 "storeId": a.stoid,
349 "orderSn": orderSn, 353 "orderSn": orderSn,
350 } 354 }
351 - if(codeId && codeId !=="" ){  
352 - json.id=codeId 355 + if (codeId && codeId !== "") {
  356 + json.id = codeId
353 } 357 }
354 var data = JSON.stringify(json); 358 var data = JSON.stringify(json);
355 var url = th.data.url + "/api/weshop/marketing/gift/goods/verify/code/get"; //预约接口地址 359 var url = th.data.url + "/api/weshop/marketing/gift/goods/verify/code/get"; //预约接口地址
356 getApp().request.json_post(url, json, 360 getApp().request.json_post(url, json,
357 - function(res) { 361 + function (res) {
358 if (res.data.code == 0) { 362 if (res.data.code == 0) {
359 th.setData({ 363 th.setData({
360 code: res.data.data 364 code: res.data.data
@@ -364,7 +368,7 @@ Page({ @@ -364,7 +368,7 @@ Page({
364 getApp().my_warnning(res.data.msg, 0, th); 368 getApp().my_warnning(res.data.msg, 0, th);
365 } 369 }
366 }, 370 },
367 - function(res) { 371 + function (res) {
368 372
369 }, 373 },
370 "put" 374 "put"
@@ -372,13 +376,13 @@ Page({ @@ -372,13 +376,13 @@ Page({
372 376
373 }, 377 },
374 //界面跳转 378 //界面跳转
375 - goto: function(e) { 379 + goto: function (e) {
376 var th = this; 380 var th = this;
377 var url = e.currentTarget.dataset.url; 381 var url = e.currentTarget.dataset.url;
378 getApp().goto(url); 382 getApp().goto(url);
379 }, 383 },
380 //图片失败,默认图片 384 //图片失败,默认图片
381 - bind_bnerr2: function(e) { 385 + bind_bnerr2: function (e) {
382 var _errImg = e.target.dataset.errorimg; 386 var _errImg = e.target.dataset.errorimg;
383 var _errObj = {}; 387 var _errObj = {};
384 _errObj[_errImg] = "/miniapp/images/giftbag/gift01.png"; 388 _errObj[_errImg] = "/miniapp/images/giftbag/gift01.png";
@@ -396,7 +400,7 @@ Page({ @@ -396,7 +400,7 @@ Page({
396 }, 400 },
397 401
398 //关闭导航 402 //关闭导航
399 - close: function() { 403 + close: function () {
400 var th = this; 404 var th = this;
401 var nav_b = th.selectComponent("#nav_b"); //组件的id 405 var nav_b = th.selectComponent("#nav_b"); //组件的id
402 nav_b.close_box(); 406 nav_b.close_box();
@@ -405,76 +409,95 @@ Page({ @@ -405,76 +409,95 @@ Page({
405 409
406 //--- 分享设置 -- 410 //--- 分享设置 --
407 onShareAppMessage: function (e) { 411 onShareAppMessage: function (e) {
408 - var curPage=this; 412 + var curPage = this;
409 var pagePath = curPage.route; //当前页面url 413 var pagePath = curPage.route; //当前页面url
410 if (pagePath.indexOf('/') != 0) { 414 if (pagePath.indexOf('/') != 0) {
411 pagePath = '/' + pagePath; 415 pagePath = '/' + pagePath;
412 } 416 }
413 -  
414 - pagePath+="?isBuy="+this.data.isBuy;  
415 - if(this.data.isBuy==0){  
416 - pagePath+="&orderSn="+this.data.orderSn;  
417 - }else{  
418 - pagePath+="&lbId="+this.data.getGiftID; 417 + pagePath += "?isBuy=1" + "&lbId=" + this.data.lbId + "&first_leader="+ this.data.getUserID;
  418 + // if (this.data.isBuy == 0) {
  419 + // pagePath += "&orderSn=" + this.data.orderSn;
  420 + // } else {
  421 + // pagePath += "&lbId=" + this.data.getGiftID;
  422 + // }
  423 + return {
  424 + title: "礼包详情",
  425 + path: pagePath,
419 } 426 }
  427 + },
420 428
  429 + /**
  430 + * 用户分享朋友圈
  431 + */
  432 + onShareTimeline() {
  433 + var curPage = this;
  434 + var pagePath = curPage.route; //当前页面url
  435 + if (pagePath.indexOf('/') != 0) {
  436 + pagePath = '/' + pagePath;
  437 + }
  438 + pagePath += "?isBuy=1" + "&lbId=" + this.data.lbId + "&first_leader="+ this.data.getUserID;
  439 + // if (this.data.isBuy == 0) {
  440 + // pagePath += "&orderSn=" + this.data.orderSn;
  441 + // } else {
  442 + // pagePath += "&lbId=" + this.data.getGiftID;
  443 + // }
421 return { 444 return {
422 title: "礼包详情", 445 title: "礼包详情",
423 - path:pagePath, 446 + path: pagePath,
424 } 447 }
425 }, 448 },
426 449
427 //免费领取 450 //免费领取
428 - GetFree: function(e) { 451 + GetFree: function (e) {
429 var that = this.data; 452 var that = this.data;
430 var th = this; 453 var th = this;
431 454
432 //如果还没有开始的话 455 //如果还没有开始的话
433 - if(th.data.isStart!=1){ 456 + if (th.data.isStart != 1) {
434 getApp().my_warnning("活动还没有开始", 0, th); 457 getApp().my_warnning("活动还没有开始", 0, th);
435 return false; 458 return false;
436 } 459 }
437 // var id = e.currentTarget.dataset.id;//活动id 460 // var id = e.currentTarget.dataset.id;//活动id
438 var my_confirm = th.selectComponent("#my_confirm"); //组件的id 461 var my_confirm = th.selectComponent("#my_confirm"); //组件的id
439 my_confirm.open( 462 my_confirm.open(
440 - "是否确定领取该礼包",  
441 - "取消",  
442 - "确定",  
443 - function() {  
444 - my_confirm.open_cancel(0);  
445 - },  
446 - function() {  
447 - my_confirm.open_cancel(0);  
448 - var json = {  
449 - "actId": '', //活动Id  
450 - "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销  
451 - "buyType": '3', //1=积分兑换 2=余额购买  
452 - "giftBagId": that.getGiftID, //礼包Id  
453 - "storeId": a.stoid, //商家ID  
454 - "userId": d.user_id, //用户ID  
455 - "buyFrom":2  
456 - };  
457 -  
458 - //-- 分享导购要记录 --  
459 - if(getApp().globalData.guide_id){  
460 - json.guide_id=getApp().globalData.guide_id;  
461 - } 463 + "是否确定领取该礼包",
  464 + "取消",
  465 + "确定",
  466 + function () {
  467 + my_confirm.open_cancel(0);
  468 + },
  469 + function () {
  470 + my_confirm.open_cancel(0);
  471 + var json = {
  472 + "actId": '', //活动Id
  473 + "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销
  474 + "buyType": '3', //1=积分兑换 2=余额购买
  475 + "giftBagId": that.getGiftID, //礼包Id
  476 + "storeId": a.stoid, //商家ID
  477 + "userId": d.user_id, //用户ID
  478 + "buyFrom": 2,
  479 + "first_leader": that.first_leader,
  480 + };
462 481
  482 + //-- 分享导购要记录 --
  483 + if (getApp().globalData.guide_id) {
  484 + json.guide_id = getApp().globalData.guide_id;
  485 + }
463 486
464 - var data = JSON.stringify(json);  
465 - var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";  
466 - getApp().request.json_post(url, json,  
467 - function(res) {  
468 - if (res.data.code == 0) {  
469 - getApp().my_warnning("领取成功!", 1, th);  
470 - } else {  
471 - getApp().my_warnning(res.data.msg, 0, th);  
472 - }  
473 - },  
474 - function(res) {} 487 + var data = JSON.stringify(json);
  488 + var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert";
  489 + getApp().request.json_post(url, json,
  490 + function (res) {
  491 + if (res.data.code == 0) {
  492 + getApp().my_warnning("领取成功!", 1, th);
  493 + } else {
  494 + getApp().my_warnning(res.data.msg, 0, th);
  495 + }
  496 + },
  497 + function (res) {}
475 498
476 - )  
477 - }) 499 + )
  500 + })
478 501
479 502
480 }, 503 },
pages/giftpack/giftpacklist/giftpacklist.wxml
@@ -77,12 +77,14 @@ @@ -77,12 +77,14 @@
77 <text class="data-v-3a5b7e36 ellipsis-1"> 77 <text class="data-v-3a5b7e36 ellipsis-1">
78 {{"数量:"+item.num}} 78 {{"数量:"+item.num}}
79 </text> 79 </text>
80 - <text style="margin-left:10rpx" wx:if="{{item.useState}}"> 80 + <block wx:if="{{isBuy==0}}">
  81 + <text style="margin-left:10rpx" wx:if="{{item.useState}}">
81 已核销 82 已核销
82 </text> 83 </text>
83 <text style="margin-left:10rpx" wx:else> 84 <text style="margin-left:10rpx" wx:else>
84 未核销 85 未核销
85 </text> 86 </text>
  87 + </block>
86 </view> 88 </view>
87 <view class="box_ware_code data-v-3a5b7e36"> 89 <view class="box_ware_code data-v-3a5b7e36">
88 <!-- <block wx:if="{{c_state==0}}"> --> 90 <!-- <block wx:if="{{c_state==0}}"> -->
pages/giftpack/mygiftpack/mygiftpack.js
@@ -25,11 +25,10 @@ Page({ @@ -25,11 +25,10 @@ Page({
25 curpage: 1, //当前分页数 25 curpage: 1, //当前分页数
26 pageSize: 10, //页大小 26 pageSize: 10, //页大小
27 total: 0, //总数量 27 total: 0, //总数量
28 - ad_data:null, 28 + ad_data:null,
29 }, 29 },
30 30
31 onLoad: function(options) { 31 onLoad: function(options) {
32 -  
33 var th = this; 32 var th = this;
34 th.setData({ 33 th.setData({
35 getStorageID: a.stoid, 34 getStorageID: a.stoid,
@@ -125,13 +124,13 @@ Page({ @@ -125,13 +124,13 @@ Page({
125 if (th.data.ismore) return; 124 if (th.data.ismore) return;
126 th.getList(); 125 th.getList();
127 }, 126 },
  127 +
128 //图片失败,默认图片 128 //图片失败,默认图片
129 bind_bnerr2: function(e) { 129 bind_bnerr2: function(e) {
130 var _errImg = e.target.dataset.errorimg; 130 var _errImg = e.target.dataset.errorimg;
131 var _errObj = {}; 131 var _errObj = {};
132 _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; 132 _errObj[_errImg] = "/miniapp/images/default_g_img.gif";
133 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; 133 this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
134 -  
135 }, 134 },
136 135
137 136
@@ -142,6 +141,7 @@ onShareAppMessage: function (e) { @@ -142,6 +141,7 @@ onShareAppMessage: function (e) {
142 if (pagePath.indexOf('/') != 0) { 141 if (pagePath.indexOf('/') != 0) {
143 pagePath = '/' + pagePath; 142 pagePath = '/' + pagePath;
144 } 143 }
  144 + pagePath += "?first_leader="+ this.data.getUserID;
145 return { 145 return {
146 title: "专享礼包", 146 title: "专享礼包",
147 path:pagePath, 147 path:pagePath,
@@ -153,7 +153,8 @@ onShareAppMessage: function (e) { @@ -153,7 +153,8 @@ onShareAppMessage: function (e) {
153 var pagePath = curPage.route; //当前页面url 153 var pagePath = curPage.route; //当前页面url
154 if (pagePath.indexOf('/') != 0) { 154 if (pagePath.indexOf('/') != 0) {
155 pagePath = '/' + pagePath; 155 pagePath = '/' + pagePath;
156 - } 156 + }
  157 + pagePath += "?first_leader="+ this.data.getUserID;
157 return { 158 return {
158 title: '专享礼包', 159 title: '专享礼包',
159 imageUrl: this.data.ad_data.ad_code, 160 imageUrl: this.data.ad_data.ad_code,