Commit 8c05e2f99104136f8c855655f68e1dbdbb6eef0f
1 parent
b5363827
兴趣标签的细节修改和js优化
Showing
3 changed files
with
93 additions
and
51 deletions
pages/user/labels/labels.js
| @@ -155,58 +155,98 @@ Page({ | @@ -155,58 +155,98 @@ Page({ | ||
| 155 | } | 155 | } |
| 156 | if (check_label.length < 1) { | 156 | if (check_label.length < 1) { |
| 157 | getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); | 157 | getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); |
| 158 | - return false; | ||
| 159 | - } | ||
| 160 | - var user_label_val = th.data.user_label_val; //选择标签奖励多少 | ||
| 161 | - var user_label_type = th.data.user_label_type; //增送类型 | ||
| 162 | - var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 | ||
| 163 | - var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 | ||
| 164 | - var vipLabel = ""; //选择的标签名称 | ||
| 165 | - var vipLabelId = ""; //选择的标签id | ||
| 166 | - var arr = []; | ||
| 167 | - for (var i = 0; i < check_label.length; i++) { | ||
| 168 | - if (i < check_label.length - 1) { | ||
| 169 | - vipLabelId += check_label[i].id + ","; | ||
| 170 | - vipLabel += check_label[i].LabelName + ","; | ||
| 171 | - arr.push(check_label[i].LabelName); | ||
| 172 | - } else { | ||
| 173 | - vipLabelId += check_label[i].id; | ||
| 174 | - vipLabel += check_label[i].LabelName; | ||
| 175 | - arr.push(check_label[i].LabelName); | ||
| 176 | - } | ||
| 177 | - } | ||
| 178 | - getApp().request.put(url, { | ||
| 179 | - data: { | ||
| 180 | - "storeId": a.stoid, | ||
| 181 | - "userId": d.user_id, | ||
| 182 | - "vipLabel": vipLabel, | ||
| 183 | - "vipLabelId": vipLabelId, | ||
| 184 | - "type": user_label_type, | ||
| 185 | - "remark": remark, | ||
| 186 | - "value": user_label_val, | ||
| 187 | - "fromType": "REWARD" | ||
| 188 | - }, | ||
| 189 | - success: function(res) { | ||
| 190 | - if (res.data.code == 0) { | ||
| 191 | - if (is_modify) { | ||
| 192 | - getApp().my_warnning("修改成功", 1, th); | ||
| 193 | - } else { | ||
| 194 | - getApp().my_warnning("领取成功", 1, th); | ||
| 195 | - } | ||
| 196 | - setTimeout(function() { | ||
| 197 | - var pages = getCurrentPages(); | ||
| 198 | - var prevPage = pages[pages.length - 2]; //上一个页面 | ||
| 199 | - //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | ||
| 200 | - prevPage.setData({ | ||
| 201 | - check_label: arr | ||
| 202 | - }) | ||
| 203 | - th.goto(); | ||
| 204 | - }, 2000); | 158 | + } else { |
| 159 | + var user_label_val = th.data.user_label_val; //选择标签奖励多少 | ||
| 160 | + var user_label_type = th.data.user_label_type; //增送类型 | ||
| 161 | + var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 | ||
| 162 | + var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 | ||
| 163 | + var vipLabel = ""; //选择的标签名称 | ||
| 164 | + var vipLabelId = ""; //选择的标签id | ||
| 165 | + var arr = []; | ||
| 166 | + for (var i = 0; i < check_label.length; i++) { | ||
| 167 | + if (i < check_label.length - 1) { | ||
| 168 | + vipLabelId += check_label[i].id + ","; | ||
| 169 | + vipLabel += check_label[i].LabelName + ","; | ||
| 170 | + arr.push(check_label[i].LabelName); | ||
| 205 | } else { | 171 | } else { |
| 206 | - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | 172 | + vipLabelId += check_label[i].id; |
| 173 | + vipLabel += check_label[i].LabelName; | ||
| 174 | + arr.push(check_label[i].LabelName); | ||
| 207 | } | 175 | } |
| 208 | } | 176 | } |
| 209 | - }) | 177 | + var my_confirm = th.selectComponent("#my_confirm"); //组件的id |
| 178 | + if (is_modify) { | ||
| 179 | + my_confirm.open( | ||
| 180 | + "确定修改标签?", | ||
| 181 | + "取消", | ||
| 182 | + "确定", | ||
| 183 | + function() { | ||
| 184 | + my_confirm.open_cancel(0); | ||
| 185 | + }, | ||
| 186 | + function() { | ||
| 187 | + my_confirm.open_cancel(0); | ||
| 188 | + getApp().request.put(url, { | ||
| 189 | + data: { | ||
| 190 | + "storeId": a.stoid, | ||
| 191 | + "userId": d.user_id, | ||
| 192 | + "vipLabel": vipLabel, | ||
| 193 | + "vipLabelId": vipLabelId, | ||
| 194 | + "type": user_label_type, | ||
| 195 | + "remark": remark, | ||
| 196 | + "value": user_label_val, | ||
| 197 | + "fromType": "REWARD" | ||
| 198 | + }, | ||
| 199 | + success: function(res) { | ||
| 200 | + if (res.data.code == 0) { | ||
| 201 | + getApp().my_warnning("修改成功", 1, th); | ||
| 202 | + setTimeout(function() { | ||
| 203 | + var pages = getCurrentPages(); | ||
| 204 | + var prevPage = pages[pages.length - 2]; //上一个页面 | ||
| 205 | + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | ||
| 206 | + prevPage.setData({ | ||
| 207 | + check_label: arr | ||
| 208 | + }) | ||
| 209 | + th.goto(); | ||
| 210 | + }, 2000); | ||
| 211 | + } else { | ||
| 212 | + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + }) | ||
| 216 | + } | ||
| 217 | + ) | ||
| 218 | + } else { | ||
| 219 | + | ||
| 220 | + getApp().request.put(url, { | ||
| 221 | + data: { | ||
| 222 | + "storeId": a.stoid, | ||
| 223 | + "userId": d.user_id, | ||
| 224 | + "vipLabel": vipLabel, | ||
| 225 | + "vipLabelId": vipLabelId, | ||
| 226 | + "type": user_label_type, | ||
| 227 | + "remark": remark, | ||
| 228 | + "value": user_label_val, | ||
| 229 | + "fromType": "REWARD" | ||
| 230 | + }, | ||
| 231 | + success: function(res) { | ||
| 232 | + if (res.data.code == 0) { | ||
| 233 | + getApp().my_warnning("领取成功", 1, th); | ||
| 234 | + setTimeout(function() { | ||
| 235 | + var pages = getCurrentPages(); | ||
| 236 | + var prevPage = pages[pages.length - 2]; //上一个页面 | ||
| 237 | + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 | ||
| 238 | + prevPage.setData({ | ||
| 239 | + check_label: arr | ||
| 240 | + }) | ||
| 241 | + th.goto(); | ||
| 242 | + }, 2000); | ||
| 243 | + } else { | ||
| 244 | + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); | ||
| 245 | + } | ||
| 246 | + } | ||
| 247 | + }) | ||
| 248 | + } | ||
| 249 | + } | ||
| 210 | }, | 250 | }, |
| 211 | /** | 251 | /** |
| 212 | * 生命周期函数--监听页面显示 | 252 | * 生命周期函数--监听页面显示 |
pages/user/labels/labels.json
| 1 | { | 1 | { |
| 2 | "navigationBarTitleText": "兴趣标签", | 2 | "navigationBarTitleText": "兴趣标签", |
| 3 | "usingComponents": { | 3 | "usingComponents": { |
| 4 | - "warn": "/components/long_warn/long_warn" | 4 | + "warn": "/components/long_warn/long_warn", |
| 5 | + "my_confirm": "/components/my_confirm/my_confirm" | ||
| 5 | } | 6 | } |
| 6 | } | 7 | } |
| 7 | \ No newline at end of file | 8 | \ No newline at end of file |
pages/user/labels/labels.wxml
| @@ -58,4 +58,5 @@ | @@ -58,4 +58,5 @@ | ||
| 58 | </view> | 58 | </view> |
| 59 | </view> | 59 | </view> |
| 60 | <!-- 引入提示组件 --> | 60 | <!-- 引入提示组件 --> |
| 61 | -<warn id="warn"></warn> | ||
| 62 | \ No newline at end of file | 61 | \ No newline at end of file |
| 62 | +<warn id="warn"></warn> | ||
| 63 | +<my_confirm id="my_confirm"></my_confirm> | ||
| 63 | \ No newline at end of file | 64 | \ No newline at end of file |