Commit c539327b280d764a75990480143894d20defdd3b
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
2 changed files
with
82 additions
and
129 deletions
pages/user/assistance/giftpacklist.js
@@ -28,137 +28,38 @@ Page({ | @@ -28,137 +28,38 @@ 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 | + receiveState: 0, //0未领取 1已领取 | ||
32 | + completeid: "", | ||
33 | + is_sub: 0, //判断是否重复提交 | ||
31 | }, | 34 | }, |
32 | - onLoad: function (options) { | 35 | + onLoad: function(options) { |
33 | var th = this; | 36 | var th = this; |
34 | th.setData({ | 37 | th.setData({ |
35 | - getGiftID: options.lbId, | 38 | + getGiftID: 100, // options.libao_id, |
39 | + completeid: options.completeid, | ||
40 | + orderSn: options.orderSn | ||
36 | }) | 41 | }) |
37 | - if (options.isBuy == 0) { | 42 | + if (options.is_libao == 0) { |
38 | th.GetMyGiftList(); | 43 | th.GetMyGiftList(); |
39 | } else { | 44 | } else { |
40 | th.GetBuyGiftList(); | 45 | th.GetBuyGiftList(); |
41 | } | 46 | } |
42 | - th.setData({ | ||
43 | - giftRemark: th.data.giftRemark.replace(/<p><img/gi, "<p class='img'><img") | ||
44 | - }) | 47 | + // th.setData({ |
48 | + // giftRemark: th.data.giftRemark.replace(/<p><img/gi, "<p class='img'><img") | ||
49 | + // }) | ||
45 | th.close(); | 50 | th.close(); |
46 | }, | 51 | }, |
47 | - onShow: function () { | ||
48 | - | ||
49 | - }, | ||
50 | - GetBuyPrice: function (e) { | ||
51 | - var that = this.data; | ||
52 | - var th = this; | ||
53 | - // var id = e.currentTarget.dataset.id;//活动id | ||
54 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
55 | - my_confirm.open( | ||
56 | - "是否确定购买该礼包", | ||
57 | - "取消", | ||
58 | - "确定", | ||
59 | - function () { | ||
60 | - my_confirm.open_cancel(0); | ||
61 | - }, | ||
62 | - function () { | ||
63 | - my_confirm.open_cancel(0); | ||
64 | - var json = { | ||
65 | - "actId": '', //活动Id | ||
66 | - "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 | ||
67 | - "buyType": '2', //1=积分兑换 2=余额购买 | ||
68 | - "lbId": that.getGiftID, //礼包Id | ||
69 | - "storeId": that.getStorageID, //商家Id | ||
70 | - "userId": that.getUserID, //用户ID | ||
71 | - "buyFrom": 2 | ||
72 | - }; | ||
73 | - var data = JSON.stringify(json); | ||
74 | - var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; | ||
75 | - wx.request({ | ||
76 | - url: url, | ||
77 | - data: data, | ||
78 | - method: 'post', | ||
79 | - header: { | ||
80 | - 'content-type': 'application/json' | ||
81 | - }, // 设置请求的 header | ||
82 | - success: function (res) { | ||
83 | - if (res.data.code == 0) { | ||
84 | - res = res.data.data; | ||
85 | - wx.requestPayment({ | ||
86 | - timeStamp: String(res.timeStamp), | ||
87 | - nonceStr: res.nonceStr, | ||
88 | - package: res.packageValue, | ||
89 | - signType: res.signType, | ||
90 | - paySign: res.paySign, | ||
91 | - success: function (n) { | ||
92 | - | ||
93 | - }, | ||
94 | - fail: function (n) { | ||
95 | - | ||
96 | - } | ||
97 | - }); | ||
98 | - } else { | ||
99 | - getApp().my_warnning(res.data.msg, 0, th); | ||
100 | - } | ||
101 | - } | ||
102 | - }) | ||
103 | - | ||
104 | - } | ||
105 | - | ||
106 | - | ||
107 | - ) | ||
108 | - | 52 | + onShow: function() { |
109 | 53 | ||
110 | }, | 54 | }, |
111 | - GetBuyIntegral: function (e) { | ||
112 | - var that = this.data; | ||
113 | - var th = this; | ||
114 | - // var id = e.currentTarget.dataset.id;//活动id | ||
115 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | ||
116 | - my_confirm.open( | ||
117 | - "是否确定兑换该礼包", | ||
118 | - "取消", | ||
119 | - "确定", | ||
120 | - function () { | ||
121 | - my_confirm.open_cancel(0); | ||
122 | - }, | ||
123 | - function () { | ||
124 | - my_confirm.open_cancel(0); | ||
125 | - var json = { | ||
126 | - "actId": '', //活动Id | ||
127 | - "actType": '', //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 | ||
128 | - "buyType": '1', //1=积分兑换 2=余额购买 | ||
129 | - "lbId": that.getGiftID, //礼包Id | ||
130 | - "storeId": that.getStorageID, //商家Id | ||
131 | - "userId": that.getUserID //用户ID | ||
132 | - }; | ||
133 | - var data = JSON.stringify(json); | ||
134 | - var url = that.url + "/api/weshop/marketing/buy/receive/gift/record/insert"; | ||
135 | - wx.request({ | ||
136 | - url: url, | ||
137 | - data: data, | ||
138 | - method: 'post', | ||
139 | - header: { | ||
140 | - 'content-type': 'application/json' | ||
141 | - }, // 设置请求的 header | ||
142 | - success: function (res) { | ||
143 | - if (res.data.code == 0) { | ||
144 | - getApp().my_warnning("兑换成功!", 1, th); | ||
145 | - } else { | ||
146 | - getApp().my_warnning(res.data.msg, 0, th); | ||
147 | - } | ||
148 | - } | ||
149 | - }) | ||
150 | - | ||
151 | - }) | ||
152 | - | ||
153 | 55 | ||
154 | - }, | ||
155 | - GetMyGiftList: function () { | 56 | + GetMyGiftList: function() { |
156 | var _this = this; | 57 | var _this = this; |
157 | var th = this; | 58 | var th = this; |
158 | getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { | 59 | getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', { |
159 | data: { | 60 | data: { |
160 | - "storeId": th.data.getStorageID, //商家ID | ||
161 | - "userId": th.data.getUserID, //用户ID | 61 | + "storeId": a.stoid, //商家ID |
62 | + "userId": d.user_id, //用户ID | ||
162 | "orderSn": th.data.orderSn | 63 | "orderSn": th.data.orderSn |
163 | }, | 64 | }, |
164 | success: function success(res) { | 65 | success: function success(res) { |
@@ -212,23 +113,68 @@ Page({ | @@ -212,23 +113,68 @@ Page({ | ||
212 | } | 113 | } |
213 | } | 114 | } |
214 | } else { | 115 | } else { |
215 | - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | 116 | + getApp().my_warnning(res.data.msg, 0, th); |
216 | return false; | 117 | return false; |
217 | } | 118 | } |
218 | } | 119 | } |
219 | }); | 120 | }); |
220 | 121 | ||
221 | }, | 122 | }, |
222 | - GetBuyGiftList: function () { | 123 | + GetReceive: function() { |
124 | + var th = this; | ||
125 | + if (th.data.receiveState) { | ||
126 | + return false; | ||
127 | + } | ||
128 | + var is_sub = th.data.is_sub; //判断是否重复提交 | ||
129 | + if (is_sub == 0) { | ||
130 | + th.setData({ | ||
131 | + is_sub: 1 | ||
132 | + }) | ||
133 | + var json = { | ||
134 | + "actId": th.data.completeid, //活动Id | ||
135 | + "actType": 1, //活动类型 1:新人礼、2:评价有礼、3:节日营销、4:生日营销 | ||
136 | + "giftBagId": th.data.giftID, //礼包Id | ||
137 | + "storeId": a.stoid, //商家Id | ||
138 | + "userId": d.user_id //用户ID | ||
139 | + }; | ||
140 | + var data = JSON.stringify(json); | ||
141 | + var url = th.data.url + "/api/weshop/marketing/free/receive/gift/record/insert"; | ||
142 | + getApp().request.json_post(url, json, | ||
143 | + function(res) { | ||
144 | + th.setData({ | ||
145 | + is_sub: 0 | ||
146 | + }) | ||
147 | + if (res.data.code == 0) { | ||
148 | + th.setData({ | ||
149 | + receiveState: 1 | ||
150 | + }) | ||
151 | + getApp().my_warnning("领取成功", 1, th); | ||
152 | + } else { | ||
153 | + getApp().my_warnning(res.data.msg, 0, th); | ||
154 | + } | ||
155 | + }, | ||
156 | + function(res) { | ||
157 | + | ||
158 | + }, "post" | ||
159 | + | ||
160 | + ) | ||
161 | + | ||
162 | + } | ||
163 | + }, | ||
164 | + GetBuyGiftList: function() { | ||
223 | var _this2 = this; | 165 | var _this2 = this; |
224 | var th = this.data; | 166 | var th = this.data; |
167 | + wx.showLoading({ | ||
168 | + title: '加载中' | ||
169 | + }) | ||
225 | getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { | 170 | getApp().request.get('/api/weshop/marketing/giftbag/detail/get', { |
226 | data: { | 171 | data: { |
227 | - "storeId": th.getStorageID, //商家ID | ||
228 | - "userId": th.getUserID, //用户ID | 172 | + "storeId": a.stoid, //商家ID |
173 | + "userId": d.user_id, //用户ID | ||
229 | "giftBagId": th.getGiftID | 174 | "giftBagId": th.getGiftID |
230 | }, | 175 | }, |
231 | - success: function success(res) { | 176 | + success: function(res) { |
177 | + wx.hideLoading(); | ||
232 | if (res.data.code == 0) { | 178 | if (res.data.code == 0) { |
233 | _this2.setData({ | 179 | _this2.setData({ |
234 | giftImage: th.iurl + res.data.data.lbUrl, | 180 | giftImage: th.iurl + res.data.data.lbUrl, |
@@ -256,7 +202,7 @@ Page({ | @@ -256,7 +202,7 @@ Page({ | ||
256 | wareCard: res.data.data.wareCard | 202 | wareCard: res.data.data.wareCard |
257 | }) | 203 | }) |
258 | } else { | 204 | } else { |
259 | - getApp().my_warnning("系统繁忙,请稍后再试", 0, _this2); | 205 | + getApp().my_warnning(res.data.msg, 0, _this2); |
260 | return false; | 206 | return false; |
261 | } | 207 | } |
262 | } | 208 | } |
@@ -264,7 +210,7 @@ Page({ | @@ -264,7 +210,7 @@ Page({ | ||
264 | 210 | ||
265 | }, | 211 | }, |
266 | //显示核销码 | 212 | //显示核销码 |
267 | - code_show: function (e) { | 213 | + code_show: function(e) { |
268 | var th = this; | 214 | var th = this; |
269 | //--获取成功的时候-- | 215 | //--获取成功的时候-- |
270 | var no = th.data.code; | 216 | var no = th.data.code; |
@@ -276,7 +222,7 @@ Page({ | @@ -276,7 +222,7 @@ Page({ | ||
276 | qc_com.open(obj) | 222 | qc_com.open(obj) |
277 | }, | 223 | }, |
278 | //获取核销码 | 224 | //获取核销码 |
279 | - getcode: function () { | 225 | + getcode: function() { |
280 | var th = this; | 226 | var th = this; |
281 | var orderSn = th.data.orderSn; //订单号 | 227 | var orderSn = th.data.orderSn; //订单号 |
282 | var json = { | 228 | var json = { |
@@ -292,7 +238,7 @@ Page({ | @@ -292,7 +238,7 @@ Page({ | ||
292 | header: { | 238 | header: { |
293 | 'content-type': 'application/json' | 239 | 'content-type': 'application/json' |
294 | }, // 设置请求的 header | 240 | }, // 设置请求的 header |
295 | - success: function (res) { | 241 | + success: function(res) { |
296 | if (res.data.code == 0) { | 242 | if (res.data.code == 0) { |
297 | th.setData({ | 243 | th.setData({ |
298 | code: res.data.data | 244 | code: res.data.data |
@@ -305,13 +251,13 @@ Page({ | @@ -305,13 +251,13 @@ Page({ | ||
305 | }) | 251 | }) |
306 | }, | 252 | }, |
307 | //界面跳转 | 253 | //界面跳转 |
308 | - goto: function (e) { | 254 | + goto: function(e) { |
309 | var th = this; | 255 | var th = this; |
310 | var url = e.currentTarget.dataset.url; | 256 | var url = e.currentTarget.dataset.url; |
311 | getApp().goto(url); | 257 | getApp().goto(url); |
312 | }, | 258 | }, |
313 | //图片失败,默认图片 | 259 | //图片失败,默认图片 |
314 | - bind_bnerr2: function (e) { | 260 | + bind_bnerr2: function(e) { |
315 | var _errImg = e.target.dataset.errorimg; | 261 | var _errImg = e.target.dataset.errorimg; |
316 | var _errObj = {}; | 262 | var _errObj = {}; |
317 | _errObj[_errImg] = "/public/images/empty.jpg"; | 263 | _errObj[_errImg] = "/public/images/empty.jpg"; |
@@ -319,7 +265,7 @@ Page({ | @@ -319,7 +265,7 @@ Page({ | ||
319 | 265 | ||
320 | }, | 266 | }, |
321 | //关闭导航 | 267 | //关闭导航 |
322 | - close: function () { | 268 | + close: function() { |
323 | var th = this; | 269 | var th = this; |
324 | var nav_b = th.selectComponent("#nav_b"); //组件的id | 270 | var nav_b = th.selectComponent("#nav_b"); //组件的id |
325 | nav_b.close_box(); | 271 | nav_b.close_box(); |
pages/user/assistance/giftpacklist.wxml
@@ -102,9 +102,16 @@ | @@ -102,9 +102,16 @@ | ||
102 | <block wx:if="{{isBuy==0}}"> | 102 | <block wx:if="{{isBuy==0}}"> |
103 | <view class="foot_button data-v-3a5b7e36"> | 103 | <view class="foot_button data-v-3a5b7e36"> |
104 | <block wx:if="{{true}}"> | 104 | <block wx:if="{{true}}"> |
105 | - <view wx:if="{{c_state==0}}" class="foot_button_buy data-v-3a5b7e36" bindtap="getcode"> | ||
106 | - <text class="data-v-3a5b7e36">一键领取</text> | ||
107 | - </view> | 105 | + <block wx:if="{{receiveState}}"> |
106 | + <view class="foot_button_buy data-v-3a5b7e36 overdue"> | ||
107 | + <text class="data-v-3a5b7e36">已领取</text> | ||
108 | + </view> | ||
109 | + </block> | ||
110 | + <block wx:else> | ||
111 | + <view class="foot_button_buy data-v-3a5b7e36" bindtap="GetReceive"> | ||
112 | + <text class="data-v-3a5b7e36">一键全部领取</text> | ||
113 | + </view> | ||
114 | + </block> | ||
108 | </block> | 115 | </block> |
109 | <block wx:else> | 116 | <block wx:else> |
110 | <block wx:if="{{is_lb!=1}}"> | 117 | <block wx:if="{{is_lb!=1}}"> |