Commit 21bb9ff51453aa60bcfa22bd6e0888df612a4452

Authored by abson
1 parent cf078b76

专享礼包分享

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