From 8c05e2f99104136f8c855655f68e1dbdbb6eef0f Mon Sep 17 00:00:00 2001 From: DESKTOP-QHAFKU5\iceling Date: Fri, 13 Dec 2019 17:38:01 +0800 Subject: [PATCH] 兴趣标签的细节修改和js优化 --- pages/user/labels/labels.js | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------- pages/user/labels/labels.json | 3 ++- pages/user/labels/labels.wxml | 3 ++- 3 files changed, 93 insertions(+), 51 deletions(-) diff --git a/pages/user/labels/labels.js b/pages/user/labels/labels.js index 36f0ddc..d3d7b09 100644 --- a/pages/user/labels/labels.js +++ b/pages/user/labels/labels.js @@ -155,58 +155,98 @@ Page({ } if (check_label.length < 1) { getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); - return false; - } - var user_label_val = th.data.user_label_val; //选择标签奖励多少 - var user_label_type = th.data.user_label_type; //增送类型 - var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 - var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 - var vipLabel = ""; //选择的标签名称 - var vipLabelId = ""; //选择的标签id - var arr = []; - for (var i = 0; i < check_label.length; i++) { - if (i < check_label.length - 1) { - vipLabelId += check_label[i].id + ","; - vipLabel += check_label[i].LabelName + ","; - arr.push(check_label[i].LabelName); - } else { - vipLabelId += check_label[i].id; - vipLabel += check_label[i].LabelName; - arr.push(check_label[i].LabelName); - } - } - getApp().request.put(url, { - data: { - "storeId": a.stoid, - "userId": d.user_id, - "vipLabel": vipLabel, - "vipLabelId": vipLabelId, - "type": user_label_type, - "remark": remark, - "value": user_label_val, - "fromType": "REWARD" - }, - success: function(res) { - if (res.data.code == 0) { - if (is_modify) { - getApp().my_warnning("修改成功", 1, th); - } else { - getApp().my_warnning("领取成功", 1, th); - } - setTimeout(function() { - var pages = getCurrentPages(); - var prevPage = pages[pages.length - 2]; //上一个页面 - //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 - prevPage.setData({ - check_label: arr - }) - th.goto(); - }, 2000); + } else { + var user_label_val = th.data.user_label_val; //选择标签奖励多少 + var user_label_type = th.data.user_label_type; //增送类型 + var url = "/api/weshop/marketing/holiday/vip/interest/label/update"; //更新标签接口地址 + var nav_url = "/pages/user/userinfo/userinfo"; //领取成功之后跳转页面 + var vipLabel = ""; //选择的标签名称 + var vipLabelId = ""; //选择的标签id + var arr = []; + for (var i = 0; i < check_label.length; i++) { + if (i < check_label.length - 1) { + vipLabelId += check_label[i].id + ","; + vipLabel += check_label[i].LabelName + ","; + arr.push(check_label[i].LabelName); } else { - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + vipLabelId += check_label[i].id; + vipLabel += check_label[i].LabelName; + arr.push(check_label[i].LabelName); } } - }) + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + if (is_modify) { + my_confirm.open( + "确定修改标签?", + "取消", + "确定", + function() { + my_confirm.open_cancel(0); + }, + function() { + my_confirm.open_cancel(0); + getApp().request.put(url, { + data: { + "storeId": a.stoid, + "userId": d.user_id, + "vipLabel": vipLabel, + "vipLabelId": vipLabelId, + "type": user_label_type, + "remark": remark, + "value": user_label_val, + "fromType": "REWARD" + }, + success: function(res) { + if (res.data.code == 0) { + getApp().my_warnning("修改成功", 1, th); + setTimeout(function() { + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 + prevPage.setData({ + check_label: arr + }) + th.goto(); + }, 2000); + } else { + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + } + } + }) + } + ) + } else { + + getApp().request.put(url, { + data: { + "storeId": a.stoid, + "userId": d.user_id, + "vipLabel": vipLabel, + "vipLabelId": vipLabelId, + "type": user_label_type, + "remark": remark, + "value": user_label_val, + "fromType": "REWARD" + }, + success: function(res) { + if (res.data.code == 0) { + getApp().my_warnning("领取成功", 1, th); + setTimeout(function() { + var pages = getCurrentPages(); + var prevPage = pages[pages.length - 2]; //上一个页面 + //直接调用上一个页面的setData()方法,把数据存到上一个页面中去 + prevPage.setData({ + check_label: arr + }) + th.goto(); + }, 2000); + } else { + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + } + } + }) + } + } }, /** * 生命周期函数--监听页面显示 diff --git a/pages/user/labels/labels.json b/pages/user/labels/labels.json index c816cca..12d96e4 100644 --- a/pages/user/labels/labels.json +++ b/pages/user/labels/labels.json @@ -1,6 +1,7 @@ { "navigationBarTitleText": "兴趣标签", "usingComponents": { - "warn": "/components/long_warn/long_warn" + "warn": "/components/long_warn/long_warn", + "my_confirm": "/components/my_confirm/my_confirm" } } \ No newline at end of file diff --git a/pages/user/labels/labels.wxml b/pages/user/labels/labels.wxml index 27d606f..a855aaa 100644 --- a/pages/user/labels/labels.wxml +++ b/pages/user/labels/labels.wxml @@ -58,4 +58,5 @@ - \ No newline at end of file + + \ No newline at end of file -- libgit2 0.21.4