From cf77c4c5d8343bc764b3278ed6c452cf37a59675 Mon Sep 17 00:00:00 2001 From: DESKTOP-QHAFKU5\iceling Date: Thu, 12 Dec 2019 19:51:12 +0800 Subject: [PATCH] 个人资料的姓名,性别入参,兴趣标签的入参,兴趣标签的数据填充 --- pages/user/labels/labels.js | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------- pages/user/labels/labels.wxml | 29 ++++++++++++++++++++++++----- pages/user/userinfo/userinfo.js | 87 +++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ pages/user/userinfo/userinfo.wxml | 16 +++++++++------- pages/user/userinfo/userinfo.wxss | 4 +--- 5 files changed, 181 insertions(+), 94 deletions(-) diff --git a/pages/user/labels/labels.js b/pages/user/labels/labels.js index 04f14ca..36f0ddc 100644 --- a/pages/user/labels/labels.js +++ b/pages/user/labels/labels.js @@ -12,6 +12,9 @@ Page({ url: a.url, //接口网址 interest_lables: [], //兴趣标签 check_label: [], //用户选中的标签集合 + user_label_val: "", //奖励多少 + user_label_type: "", //奖励类型(0积分,1类型) + is_modify: 0, //判断是第一次填写还是修改(0填写,1修改) }, //点击选择兴趣标签把值放到已选中 click_label: function(e) { @@ -24,17 +27,16 @@ Page({ if (labels_cid) { labels_cid = 0; for (var i = 0; i < check_label.length; i++) { - if (index == check_label[i].id) { + if (labels[index].id == check_label[i].id) { check_label.splice(i, 1); } } } else { var check_new = { - lable: labels[index].LabelName, - id: index + lable: labels[index] }; labels_cid = 1; - check_label.push(check_new); + check_label.push(labels[index]); } th.setData({ [labels_check]: labels_cid, @@ -42,6 +44,18 @@ Page({ }) }, + //获取配置信息 + get_config: function() { + var th = this; + getApp().getConfig2(function(ee) { + var sms_conf = ee.switch_list; + sms_conf = JSON.parse(sms_conf); + th.setData({ + user_label_val: sms_conf.user_label_val, + user_label_type: sms_conf.user_label_type + }) + }) + }, //页面跳转 goto: function(e) { var th = this; @@ -61,7 +75,7 @@ Page({ is_zy: 1 }) th.query_nolabels(); - th.query_checklabels(); + th.get_config(); }, //获取标签集合 query_nolabels: function() { @@ -77,8 +91,10 @@ Page({ th.setData({ interest_lables: res.data.data.pageData }) + th.query_checklabels(); } else { - getApp().my_warnning(res.data.msg, 0, th); + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + return false; } }) }, @@ -86,7 +102,7 @@ Page({ query_checklabels: function() { var th = this; var url = "/api/weshop/marketing/holiday/vip/interest/label/get"; - var interest_lables = th.data.interest_lables; //兴趣标签集合 + var interest_lables = th.data.interest_lables; //兴趣标签 getApp().request.promiseGet(url, { data: { userId: d.user_id, @@ -94,44 +110,100 @@ Page({ } }).then(res => { if (res.data.code == 0) { + var data = res.data.data; + var arr = []; + var VipLabelId = []; //通过id标签找到已选择的标签 + var dateList = data.VipLabelId.split(","); + for (var i in dateList) { + VipLabelId = VipLabelId.concat(dateList[i]); + } + if (VipLabelId.length > 0) { + for (var i = 0; i < interest_lables.length; i++) { + for (var ii = 0; ii < VipLabelId.length; ii++) { + if (interest_lables[i].id == VipLabelId[ii]) { + interest_lables[i].check = 1; + arr.push(interest_lables[i]); + } + } + } + } + //如何有之前有选择兴趣标签的话,再进来的话就是修改 + if (data.VipLabelId != "") { + th.setData({ + is_modify: 1 + }) + } th.setData({ - check_label: res.data.data.pageData + check_label: arr, + interest_lables: interest_lables }) } else { - getApp().my_warnning(res.data.msg, 0, th); + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + return false; } }) }, //更新会员兴趣标签 update_label: function() { var th = this; - var check_label = th.data.check_label; + var is_modify = th.data.is_modify; //是否是修改 + var check_label = th.data.check_label; //用户选择 + var remark = "领取"; + if (is_modify) { + user_label_type = 0; + remark = "修改"; + } if (check_label.length < 1) { - getApp().my_warnning("完成兴趣标签才能领取哦~", 0, th); + getApp().my_warnning("完成兴趣标签才能" + remark + "哦~", 0, th); return false; } - var url = th.data.url + "/api/weshop/marketing/holiday/vip/interest/label/update"; - check_label = "美,美"; - var json = { - "storeId": a.stoid, - "userId": d.user_id, - "vipLabel": check_label, - "type":0, - "vipLabelId":"1,1" - }; - var data = JSON.stringify(json); - wx.request({ - url: url, - data: data, - method: 'put', - header: { - 'content-type': 'application/json' - }, // 设置请求的 header + 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) { - getApp().my_warnning("领取成功", 1, th); + 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 { - getApp().my_warnning("领取失败", 1, th); + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); } } }) @@ -141,12 +213,5 @@ Page({ */ onShow: function() { - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function() { - } }) \ No newline at end of file diff --git a/pages/user/labels/labels.wxml b/pages/user/labels/labels.wxml index d70ef76..27d606f 100644 --- a/pages/user/labels/labels.wxml +++ b/pages/user/labels/labels.wxml @@ -4,9 +4,12 @@ 兴趣标签 - + 跳过 + + 关闭 + @@ -25,7 +28,7 @@ - {{it.lable}} + {{it.LabelName}} @@ -33,9 +36,25 @@ - - 领取200成长值 - + + + + 确定选择 + + + 领取{{user_label_val}}积分 + + + 领取{{user_label_val}}成长值 + + + + + + 提交修改 + + + diff --git a/pages/user/userinfo/userinfo.js b/pages/user/userinfo/userinfo.js index 1d5d57c..4303681 100644 --- a/pages/user/userinfo/userinfo.js +++ b/pages/user/userinfo/userinfo.js @@ -12,7 +12,8 @@ var a = getApp(), t = a.request, s = require("../../../utils/common.js"), util = require("../../../utils/util.js"), - ut = util; + ut = util, + d = getApp().globalData; var timestamp = Date.parse(new Date()); var date = new Date(timestamp); @@ -60,7 +61,8 @@ Page({ isBool: "", sto_sele_id: "", //所属门店id is_zy: 0, //是否执行onshow - is_lable_set:"",//是否启用我的兴趣标签 + is_lable_set: "", //是否启用我的兴趣标签 + check_label: [], //我选择的兴趣标签 }, //通过路径跳转到其他页面 goto: function(e) { @@ -76,6 +78,37 @@ Page({ th.setData({ is_lable_set: sms_conf.user_label_set }) + if (sms_conf.user_label_set) { + th.query_checklabels(); + } + }) + }, + //查找会员选择的兴趣标签 + query_checklabels: function() { + var th = this; + var url = "/api/weshop/marketing/holiday/vip/interest/label/get"; + var interest_lables = th.data.interest_lables; //兴趣标签 + getApp().request.promiseGet(url, { + data: { + userId: d.user_id, + storeId: r.stoid + } + }).then(res => { + if (res.data.code == 0) { + var data = res.data.data; + var VipLabel = th.data.check_label; //通过id标签找到已选择的标签 + var dateList = data.VipLabel.split(","); + for (var i in dateList) { + if (dateList[i] != "") { + VipLabel.push(dateList[i]); + } + } + th.setData({ + check_label: VipLabel + }) + } else { + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); + } }) }, //是否启动密码消费 @@ -110,7 +143,6 @@ Page({ isGender: function(e) { var th = this; var sex = e.currentTarget.dataset.sex; - console.log("点击选择性别", sex); th.setData({ isGender: sex }) @@ -175,8 +207,6 @@ Page({ var index = th.data.sec_pick_index; item = th.data.sec_sto.s_arr[index]; } - - console.log("选择门店刷新", "def_pick_store", item); th.setData({ def_pick_store: item, stoname: item.pickup_name, @@ -393,7 +423,6 @@ Page({ } } }, 200) - console.log(th.data.all_sto + 'eeee'); }, //选择更多门店 more_store: function() { @@ -469,7 +498,6 @@ Page({ //如果身份证不满足格式正则表达式 if (!code || !idCardReg.test(code)) { - console.log("您输入的身份证号格式有误!"); errorMess = "您输入的身份证号格式有误!"; isPass = false; } @@ -533,7 +561,6 @@ Page({ } } this.initial_user(); - this.get_config(); }, //-----------会员是否初始化--------------------- initial_user: function() { @@ -545,7 +572,6 @@ Page({ }, success: function(su) { var isBool = su.data.data.isBool; - console.log("会员是否初始化", isBool); th.setData({ isBool: isBool }); @@ -567,6 +593,7 @@ Page({ } }); + this.get_config(); }, @@ -582,7 +609,6 @@ Page({ if (su.data.code == 0) { var cardname = su.data.data[0].MemCardName; - console.log("卡的名字", cardname); th.setData({ pulscardname: cardname }); @@ -592,9 +618,9 @@ Page({ }, onShow: function() { + var e = this; if (this.data.is_zy) return false; this.wait_for_store_config(); - var e = this; var req = t; req.get("/api/weshop/users/getAndUpdateUser/" + r.stoid + "/" + getApp().globalData.user_id, { success: function(src) { @@ -611,6 +637,7 @@ Page({ consumption: a.paypwd, identity_card: a.idcard, address: a.address, + isGender: a.sex }); } }) @@ -689,22 +716,17 @@ Page({ lose_focus: function(e) { var th = this; var val = e.detail.value; - console.log("是什么东西", val); if (val.length > 6 || val != "") { this.setData({ consumption: val }); - console.log("是什么东西", val); } - - }, //地址 address: function(e) { var val = e.detail; - console.log("地址55555555", val.value); this.setData({ address: val.value }); @@ -721,13 +743,13 @@ Page({ }, //用户名字 user_name: function(e) { + var th = this; var name = e.detail.value; + var vipname = 'user.vipname'; if (name != "" || name != null) { - - this.setData({ - user_name: name + th.setData({ + [vipname]: name }); - } }, @@ -739,11 +761,8 @@ Page({ var phone = th.data.phone; //手机号码 if (phone == "" || phone == null) { getApp().my_warnning("手机不能为空", 0, th); - return false; } - - var consumption = th.data.consumption; //消费密码 var isstcsp = th.data.isstcsp; if (isstcsp == 1) { @@ -764,32 +783,18 @@ Page({ return false; } var user_name = th.data.user.vipname; //用户姓名 - console.log("名字77777", user_name); if (user_name == "" || user_name == null) { getApp().my_warnning("请输入名字", 0, th); return false; } var identity_card = th.data.identity_card; //身份证 - console.log("身份证", identity_card); if (identity_card != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(identity_card))) { getApp().my_warnning("身份证号码错误", 0, th); return false; } var address = th.data.address; //地址 - // console.log("地址1010101", address) - // if (address == "" || address == null) { - // getApp().my_warnning("请输入地址", 0, th); - // return false; - // } - //保存所属门店的id var sto_sele_id = th.data.sto_sele_id; - // console.log("请输入所属门店的id", sto_sele_id); - // if (sto_sele_id == null || sto_sele_id==""){ - // getApp().my_warnning("请输入所属门店", 0, th); - // return false; - // } - console.log("要保存的数据", sex, consumption, identity_card, address, user_name); var datas = { mobile: phone, //手机号码 store_id: r.stoid, @@ -797,7 +802,7 @@ Page({ vipnopwd: isstcsp, vippass: consumption, //消费密码 sex: sex, //性别 - nickname: user_name, //昵称 + vipname: user_name, //昵称 idcard: identity_card, //身份证 address: address, //地址 pickup_id: sto_sele_id //自提门店 所属门店 @@ -805,13 +810,11 @@ Page({ getApp().request.put("/api/weshop/users/updateUserInfo", { data: datas, success: function(res) { - if (res.data.code == 0) { - getApp().showWarning("修改成功"); + getApp().my_warnning("修改成功", 0, th); } else { - getApp().showWarning("修改失败"); + getApp().my_warnning("系统繁忙,请稍后再试", 0, th); } - } }) }, diff --git a/pages/user/userinfo/userinfo.wxml b/pages/user/userinfo/userinfo.wxml index cb775da..cf21be0 100644 --- a/pages/user/userinfo/userinfo.wxml +++ b/pages/user/userinfo/userinfo.wxml @@ -187,7 +187,7 @@ - + 我的兴趣 @@ -195,13 +195,15 @@ - - 高级蓝领 - + + + {{label}} + + - - + - 标签 + + + + 标签 diff --git a/pages/user/userinfo/userinfo.wxss b/pages/user/userinfo/userinfo.wxss index 0584be6..6e4be12 100644 --- a/pages/user/userinfo/userinfo.wxss +++ b/pages/user/userinfo/userinfo.wxss @@ -645,17 +645,15 @@ input { } .add_lable { - width: 88rpx; - /* height: 46rpx; *//* line-height: 46rpx; */ color: rgb(189, 189, 189); border: 2rpx solid rgb(189, 189, 189); border-radius: 30rpx; - margin-bottom: 20rpx; padding: 0rpx 25rpx; } .plus { font-weight: bold; + margin-right: 8rpx; } .lable_wh { -- libgit2 0.21.4