Commit 7e79456a9059262734f0f9a9fa3455db229fb887
1 parent
4f3b15ca
会员标签重复提交问题
Showing
3 changed files
with
121 additions
and
97 deletions
pages/user/labels/labels.js
... | ... | @@ -10,13 +10,14 @@ Page({ |
10 | 10 | */ |
11 | 11 | data: { |
12 | 12 | url: a.url, //接口网址 |
13 | - iurl: a.imghost,//图片前缀网址 | |
13 | + iurl: a.imghost, //图片前缀网址 | |
14 | 14 | interest_lables: [], //兴趣标签 |
15 | 15 | check_label: [], //用户选中的标签集合 |
16 | 16 | user_label_val: "", //奖励多少 |
17 | 17 | user_label_type: "", //奖励类型(1积分,1成长值) |
18 | 18 | is_modify: 0, //判断是第一次填写还是修改(0填写,1修改) |
19 | - isread:0,//是否读取 | |
19 | + isread: 0, //是否读取 | |
20 | + is_check: 0, //是否重复提交 | |
20 | 21 | }, |
21 | 22 | //点击选择兴趣标签把值放到已选中 |
22 | 23 | click_label: function(e) { |
... | ... | @@ -38,14 +39,14 @@ Page({ |
38 | 39 | check_label: check_label |
39 | 40 | }) |
40 | 41 | } else { |
41 | - if (check_label.length>9){ | |
42 | - getApp().my_warnning("最多可选10个哦",0,th); | |
43 | - }else{ | |
44 | - var check_new = { | |
45 | - lable: labels[index] | |
46 | - }; | |
47 | - labels_cid = 1; | |
48 | - check_label.push(labels[index]); | |
42 | + if (check_label.length > 9) { | |
43 | + getApp().my_warnning("最多可选10个哦", 0, th); | |
44 | + } else { | |
45 | + var check_new = { | |
46 | + lable: labels[index] | |
47 | + }; | |
48 | + labels_cid = 1; | |
49 | + check_label.push(labels[index]); | |
49 | 50 | } |
50 | 51 | th.setData({ |
51 | 52 | [labels_check]: labels_cid, |
... | ... | @@ -60,11 +61,10 @@ Page({ |
60 | 61 | getApp().getConfig2(function(ee) { |
61 | 62 | var sms_conf = ee.switch_list; |
62 | 63 | sms_conf = JSON.parse(sms_conf); |
63 | - var getuser_label_type=1; | |
64 | + var getuser_label_type = 1; | |
64 | 65 | var getuser_label_val = 0; |
65 | - if (sms_conf.user_label_type!=undefined) | |
66 | - { | |
67 | - getuser_label_type = parseInt(sms_conf.user_label_type)+1; | |
66 | + if (sms_conf.user_label_type != undefined) { | |
67 | + getuser_label_type = parseInt(sms_conf.user_label_type) + 1; | |
68 | 68 | } |
69 | 69 | if (sms_conf.user_label_val != undefined) { |
70 | 70 | getuser_label_val = sms_conf.user_label_val; |
... | ... | @@ -106,14 +106,14 @@ Page({ |
106 | 106 | getApp().request.promiseGet(url, { |
107 | 107 | data: { |
108 | 108 | storeId: a.stoid, |
109 | - pageSize:50, | |
110 | - page:1 | |
109 | + pageSize: 50, | |
110 | + page: 1 | |
111 | 111 | } |
112 | 112 | }).then(res => { |
113 | 113 | if (res.data.code == 0) { |
114 | 114 | th.setData({ |
115 | 115 | interest_lables: res.data.data.pageData, |
116 | - isread:1 | |
116 | + isread: 1 | |
117 | 117 | }) |
118 | 118 | th.query_checklabels(); |
119 | 119 | } else { |
... | ... | @@ -155,7 +155,7 @@ Page({ |
155 | 155 | } |
156 | 156 | } |
157 | 157 | //如何有之前有选择兴趣标签的话,再进来的话就是修改 |
158 | - if (data.VipLabelId !='') { | |
158 | + if (data.VipLabelId != '') { | |
159 | 159 | th.setData({ |
160 | 160 | is_modify: 1 |
161 | 161 | }) |
... | ... | @@ -178,94 +178,115 @@ Page({ |
178 | 178 | var user_label_val = th.data.user_label_val; //选择标签奖励多少 |
179 | 179 | var remark = "领取"; |
180 | 180 | var user_label_type = th.data.user_label_type; //赠送类型 |
181 | + var is_check = th.data.is_check; //是否重复提交 | |
182 | + var i = 0; | |
181 | 183 | if (is_modify) { |
182 | 184 | user_label_type = 0; |
183 | 185 | remark = "修改"; |
184 | 186 | user_label_val = 0; |
185 | 187 | } |
186 | - if (check_label.length < 1) { | |
187 | - getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); | |
188 | - } else { | |
189 | - var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 | |
190 | - var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 | |
191 | - var vipLabel = ""; //选择的标签名称 | |
192 | - var vipLabelId = ""; //选择的标签id | |
193 | - var arr = []; | |
194 | - for (var i = 0; i < check_label.length; i++) { | |
195 | - if (i < check_label.length - 1) { | |
196 | - vipLabelId += check_label[i].id + ","; | |
197 | - vipLabel += check_label[i].LabelName + ","; | |
198 | - arr.push(check_label[i].LabelName); | |
199 | - } else { | |
200 | - vipLabelId += check_label[i].id; | |
201 | - vipLabel += check_label[i].LabelName; | |
202 | - arr.push(check_label[i].LabelName); | |
188 | + if (is_check==1) { | |
189 | + getApp().my_warnning("不可重复提交", 0, th); | |
190 | + } | |
191 | + if (is_check == 0) { | |
192 | + | |
193 | + if (check_label.length < 1) { | |
194 | + getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); | |
195 | + th.setData({ | |
196 | + is_check: 0 | |
197 | + }) | |
198 | + } else { | |
199 | + th.setData({ | |
200 | + is_check: 1 | |
201 | + }) | |
202 | + | |
203 | + var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 | |
204 | + var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 | |
205 | + var vipLabel = ""; //选择的标签名称 | |
206 | + var vipLabelId = ""; //选择的标签id | |
207 | + var arr = []; | |
208 | + for (var i = 0; i < check_label.length; i++) { | |
209 | + if (i < check_label.length - 1) { | |
210 | + vipLabelId += check_label[i].id + ","; | |
211 | + vipLabel += check_label[i].LabelName + ","; | |
212 | + arr.push(check_label[i].LabelName); | |
213 | + } else { | |
214 | + vipLabelId += check_label[i].id; | |
215 | + vipLabel += check_label[i].LabelName; | |
216 | + arr.push(check_label[i].LabelName); | |
217 | + } | |
203 | 218 | } |
204 | - } | |
205 | - var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
206 | - remark = "兴趣标签赠送"; | |
207 | - if (is_modify) { | |
219 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id | |
220 | + remark = "兴趣标签赠送"; | |
221 | + if (is_modify) { | |
208 | 222 | |
209 | - my_confirm.open_cancel(0); | |
210 | - getApp().request.put(url, { | |
211 | - data: { | |
212 | - "storeId": a.stoid, | |
213 | - "userId": d.user_id, | |
214 | - "vipLabel": vipLabel, | |
215 | - "vipLabelId": vipLabelId, | |
216 | - "type": user_label_type, | |
217 | - "remark": remark, | |
218 | - "value": user_label_val, | |
219 | - "fromType": "REWARD" | |
220 | - }, | |
221 | - success: function(res) { | |
222 | - if (res.data.code == 0) { | |
223 | - getApp().my_warnning("修改成功", 1, th); | |
224 | - setTimeout(function() { | |
225 | - var pages = getCurrentPages(); | |
226 | - var prevPage = pages[pages.length - 2]; //上一个页面 | |
227 | - //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | |
228 | - prevPage.setData({ | |
229 | - check_label: arr | |
230 | - }) | |
231 | - th.goto(); | |
232 | - }, 2000); | |
233 | - } else { | |
234 | - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | |
235 | - } | |
223 | + my_confirm.open_cancel(0); | |
224 | + getApp().request.put(url, { | |
225 | + data: { | |
226 | + "storeId": a.stoid, | |
227 | + "userId": d.user_id, | |
228 | + "vipLabel": vipLabel, | |
229 | + "vipLabelId": vipLabelId, | |
230 | + "type": user_label_type, | |
231 | + "remark": remark, | |
232 | + "value": user_label_val, | |
233 | + "fromType": "REWARD" | |
234 | + }, | |
235 | + success: function(res) { | |
236 | + if (res.data.code == 0) { | |
237 | + getApp().my_warnning("修改成功", 1, th); | |
238 | + setTimeout(function() { | |
239 | + var pages = getCurrentPages(); | |
240 | + var prevPage = pages[pages.length - 2]; //上一个页面 | |
241 | + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | |
242 | + prevPage.setData({ | |
243 | + check_label: arr | |
244 | + }) | |
245 | + th.goto(); | |
246 | + }, 2000); | |
247 | + } else { | |
248 | + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | |
249 | + th.setData({ | |
250 | + is_check: 0 | |
251 | + }) | |
236 | 252 | } |
237 | - }) | |
238 | - | |
239 | - } else { | |
253 | + } | |
254 | + }) | |
255 | + | |
256 | + } else { | |
240 | 257 | |
241 | - getApp().request.put(url, { | |
242 | - data: { | |
243 | - "storeId": a.stoid, | |
244 | - "userId": d.user_id, | |
245 | - "vipLabel": vipLabel, | |
246 | - "vipLabelId": vipLabelId, | |
247 | - "type": user_label_type, | |
248 | - "remark": remark, | |
249 | - "value": user_label_val, | |
250 | - "fromType": "REWARD" | |
251 | - }, | |
252 | - success: function(res) { | |
253 | - if (res.data.code == 0) { | |
254 | - getApp().my_warnning("领取成功", 1, th); | |
255 | - setTimeout(function() { | |
256 | - var pages = getCurrentPages(); | |
257 | - var prevPage = pages[pages.length - 2]; //上一个页面 | |
258 | - //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | |
259 | - prevPage.setData({ | |
260 | - check_label: arr | |
258 | + getApp().request.put(url, { | |
259 | + data: { | |
260 | + "storeId": a.stoid, | |
261 | + "userId": d.user_id, | |
262 | + "vipLabel": vipLabel, | |
263 | + "vipLabelId": vipLabelId, | |
264 | + "type": user_label_type, | |
265 | + "remark": remark, | |
266 | + "value": user_label_val, | |
267 | + "fromType": "REWARD" | |
268 | + }, | |
269 | + success: function(res) { | |
270 | + if (res.data.code == 0) { | |
271 | + getApp().my_warnning("领取成功", 1, th); | |
272 | + setTimeout(function() { | |
273 | + var pages = getCurrentPages(); | |
274 | + var prevPage = pages[pages.length - 2]; //上一个页面 | |
275 | + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | |
276 | + prevPage.setData({ | |
277 | + check_label: arr | |
278 | + }) | |
279 | + th.goto(); | |
280 | + }, 2000); | |
281 | + } else { | |
282 | + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | |
283 | + th.setData({ | |
284 | + is_check: 0 | |
261 | 285 | }) |
262 | - th.goto(); | |
263 | - }, 2000); | |
264 | - } else { | |
265 | - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | |
286 | + } | |
266 | 287 | } |
267 | - } | |
268 | - }) | |
288 | + }) | |
289 | + } | |
269 | 290 | } |
270 | 291 | } |
271 | 292 | }, | ... | ... |
pages/user/labels/labels.wxml
... | ... | @@ -34,7 +34,7 @@ |
34 | 34 | |
35 | 35 | <!-- 领取选择标签的奖励按钮 --> |
36 | 36 | <block wx:if="{{is_modify==0}}"> |
37 | - <view class="receive flex-center fs36" bindtap="update_label" data-url="/pages/user/userinfo/userinfo"> | |
37 | + <view class="receive flex-center fs36 {{is_check==1?'backcolor':''}}" bindtap="update_label" data-url="/pages/user/userinfo/userinfo"> | |
38 | 38 | <block wx:if="{{user_label_val<1 || user_label_val==''}}"> |
39 | 39 | <view>确定选择</view> |
40 | 40 | </block> |
... | ... | @@ -47,7 +47,7 @@ |
47 | 47 | </view> |
48 | 48 | </block> |
49 | 49 | <block wx:if="{{is_modify==1}}"> |
50 | - <view class="receive flex-center fs36" bindtap="update_label" data-url="/pages/user/userinfo/userinfo"> | |
50 | + <view class="receive flex-center fs36 {{is_check==1?'backcolor':''}}" bindtap="update_label" data-url="/pages/user/userinfo/userinfo"> | |
51 | 51 | <view>提交修改</view> |
52 | 52 | </view> |
53 | 53 | </block> | ... | ... |