From 7e79456a9059262734f0f9a9fa3455db229fb887 Mon Sep 17 00:00:00 2001 From: iceling Date: Tue, 24 Dec 2019 14:38:12 +0800 Subject: [PATCH] 会员标签重复提交问题 --- pages/user/labels/labels.js | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------- pages/user/labels/labels.wxml | 4 ++-- pages/user/labels/labels.wxss | 3 +++ 3 files changed, 121 insertions(+), 97 deletions(-) diff --git a/pages/user/labels/labels.js b/pages/user/labels/labels.js index 9ab8562..ad19d6a 100644 --- a/pages/user/labels/labels.js +++ b/pages/user/labels/labels.js @@ -10,13 +10,14 @@ Page({ */ data: { url: a.url, //接口网址 - iurl: a.imghost,//图片前缀网址 + iurl: a.imghost, //图片前缀网址 interest_lables: [], //兴趣标签 check_label: [], //用户选中的标签集合 user_label_val: "", //奖励多少 user_label_type: "", //奖励类型(1积分,1成长值) is_modify: 0, //判断是第一次填写还是修改(0填写,1修改) - isread:0,//是否读取 + isread: 0, //是否读取 + is_check: 0, //是否重复提交 }, //点击选择兴趣标签把值放到已选中 click_label: function(e) { @@ -38,14 +39,14 @@ Page({ check_label: check_label }) } else { - if (check_label.length>9){ - getApp().my_warnning("最多可选10个哦",0,th); - }else{ - var check_new = { - lable: labels[index] - }; - labels_cid = 1; - check_label.push(labels[index]); + if (check_label.length > 9) { + getApp().my_warnning("最多可选10个哦", 0, th); + } else { + var check_new = { + lable: labels[index] + }; + labels_cid = 1; + check_label.push(labels[index]); } th.setData({ [labels_check]: labels_cid, @@ -60,11 +61,10 @@ Page({ getApp().getConfig2(function(ee) { var sms_conf = ee.switch_list; sms_conf = JSON.parse(sms_conf); - var getuser_label_type=1; + var getuser_label_type = 1; var getuser_label_val = 0; - if (sms_conf.user_label_type!=undefined) - { - getuser_label_type = parseInt(sms_conf.user_label_type)+1; + if (sms_conf.user_label_type != undefined) { + getuser_label_type = parseInt(sms_conf.user_label_type) + 1; } if (sms_conf.user_label_val != undefined) { getuser_label_val = sms_conf.user_label_val; @@ -106,14 +106,14 @@ Page({ getApp().request.promiseGet(url, { data: { storeId: a.stoid, - pageSize:50, - page:1 + pageSize: 50, + page: 1 } }).then(res => { if (res.data.code == 0) { th.setData({ interest_lables: res.data.data.pageData, - isread:1 + isread: 1 }) th.query_checklabels(); } else { @@ -155,7 +155,7 @@ Page({ } } //如何有之前有选择兴趣标签的话,再进来的话就是修改 - if (data.VipLabelId !='') { + if (data.VipLabelId != '') { th.setData({ is_modify: 1 }) @@ -178,94 +178,115 @@ Page({ var user_label_val = th.data.user_label_val; //选择标签奖励多少 var remark = "领取"; var user_label_type = th.data.user_label_type; //赠送类型 + var is_check = th.data.is_check; //是否重复提交 + var i = 0; if (is_modify) { user_label_type = 0; remark = "修改"; user_label_val = 0; } - if (check_label.length < 1) { - getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); - } else { - 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); + if (is_check==1) { + getApp().my_warnning("不可重复提交", 0, th); + } + if (is_check == 0) { + + if (check_label.length < 1) { + getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); + th.setData({ + is_check: 0 + }) + } else { + th.setData({ + is_check: 1 + }) + + 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); + } } - } - var my_confirm = th.selectComponent("#my_confirm"); //组件的id - remark = "兴趣标签赠送"; - if (is_modify) { + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + remark = "兴趣标签赠送"; + if (is_modify) { - 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); - } + 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); + th.setData({ + is_check: 0 + }) } - }) - - } else { + } + }) + + } 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 + 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); + th.setData({ + is_check: 0 }) - th.goto(); - }, 2000); - } else { - getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + } } - } - }) + }) + } } } }, diff --git a/pages/user/labels/labels.wxml b/pages/user/labels/labels.wxml index 2ddb72b..6d46152 100644 --- a/pages/user/labels/labels.wxml +++ b/pages/user/labels/labels.wxml @@ -34,7 +34,7 @@ - + 确定选择 @@ -47,7 +47,7 @@ - + 提交修改 diff --git a/pages/user/labels/labels.wxss b/pages/user/labels/labels.wxss index 7af2cb9..fcfa1c4 100644 --- a/pages/user/labels/labels.wxss +++ b/pages/user/labels/labels.wxss @@ -92,4 +92,7 @@ page{ width: 290rpx; height: 220rpx; margin-bottom:40rpx; +} +.backcolor{ + background-color: rgb(204, 204, 204); } \ No newline at end of file -- libgit2 0.21.4