From e4eccdea42c9be95993feead5bb074df48ce979b Mon Sep 17 00:00:00 2001 From: taiyuan Date: Mon, 26 Apr 2021 11:45:40 +0800 Subject: [PATCH] 个人信息 --- packageA/pages/profile/profile.js | 646 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- packageA/pages/profile/profile.wxml | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------- packageA/pages/profile/profile.wxss | 2 +- 3 files changed, 480 insertions(+), 299 deletions(-) diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index 1cedc68..cf17637 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -6,6 +6,8 @@ function e(e, a, r) { writable: !0 }) : e[a] = r, e; } +const app = getApp(); +let self = null; var a = getApp(), r = a.globalData.setting, @@ -17,10 +19,10 @@ var a = getApp(), var timestamp = Date.parse(new Date()); var date = new Date(timestamp); -const { - barcode, - qrcode -} = require('../../../utils/index.js'); +// const { +// barcode, +// qrcode +// } = require('../../../utils/index.js'); Page({ data: { @@ -31,7 +33,7 @@ Page({ defaultAvatar: r.resourceUrl + "/static/images/user68.jpg", user: null, tc_hide: true, - stoname: "", + stoname: "请选择", checkDate: false, datet: "", year: date.getFullYear(), @@ -54,7 +56,7 @@ Page({ open_ind_store: 0, //哪里打开的门店列表的控制属性 ispwhid: 1, //是否隐藏密码显示 isstcsp: 0, //是否启用密码消费 - isGender: 1, //什么性别 + isGender: 0, //什么性别 iscalendar: 0, //是否是农历 consumption: "", //消费密码 identity_card: "", //身份证值 @@ -68,6 +70,7 @@ Page({ is_lable_set: "", //是否启用我的兴趣标签 check_label: [], //我选择的兴趣标签 fir_guide_id:null, //存储会员详情接口出来的美导ID + isLunar: 0, }, //通过路径跳转到其他页面 @@ -75,22 +78,8 @@ Page({ var url = e.currentTarget.dataset.url; getApp().goto(url); }, - //获取配置信息 - get_config: function() { - var th = this; - getApp().getConfig2(function(ee) { - var sms_conf = ee.switch_list; - sms_conf = JSON.parse(sms_conf); - th.setData({ - is_lable_set: sms_conf.user_label_set, //是不是会员标签设置 - guide_title:sms_conf.guide_consultant, //系统参数 导购标题 - guide_change_time:sms_conf.guide_change_time //每月能修改几次 - }) - if (sms_conf.user_label_set) { - th.query_checklabels(); - } - }) - }, + + //查找会员选择的兴趣标签 query_checklabels: function() { var th = this; @@ -119,20 +108,8 @@ Page({ } }) }, - //是否启动密码消费 - isstcsp: function() { - var th = this; - var isstcsp = th.data.isstcsp; - if (isstcsp == 0) { - th.setData({ - isstcsp: 1 - }) - } else { - th.setData({ - isstcsp: 0 - }) - } - }, + + //出生日期是否是农历 iscalendar: function() { @@ -149,29 +126,8 @@ Page({ }) } }, - //性别 - isGender: function(e) { - var th = this; - var sex = e.currentTarget.dataset.sex; - th.setData({ - isGender: sex - }) - }, - //密码是否隐藏显示 - ispwhid: function() { - var th = this; - var ispwhid = th.data.ispwhid; - - if (ispwhid == 0) { - th.setData({ - ispwhid: 1 - }) - } else { - th.setData({ - ispwhid: 0 - }) - } - }, + + checkDate: function() { var th = this; if (th.data.checkDate) { @@ -184,11 +140,9 @@ Page({ }) } }, - bindChange: function(e) { - this.setData({ - datet: e.detail.value, - }); - }, + + + //---点击二级之后的选择--- choose_for_store: function(e) { var index_c = e.currentTarget.dataset.ind; @@ -198,6 +152,8 @@ Page({ fir_pick_index: index_c }) }, + + //确定def_pick为选择的门店 sure_pick: function(e) { var th = this; @@ -273,8 +229,6 @@ Page({ }, onclickstore: function() { var th = this; - //检验门店的点击,看下次数是不是到了 - this.check_click_ok(function(){ if (th.data.store == 0) { th.setData({ store: 1 @@ -432,9 +386,12 @@ Page({ }); } } - }, 200) + }, 200) + //检验门店的点击,看下次数是不是到了 + // this.check_click_ok(function(){ + - },2) + // },2) }, @@ -444,6 +401,7 @@ Page({ sort_store: 1 }); }, + //---选择分类门店--- choice_sort_store: function(e) { var index = e.currentTarget.dataset.index; @@ -464,6 +422,8 @@ Page({ choice_sort_store: 0 }); }, + + //身份证号严格校验 IdentityIDCard: function(e) { var code = e.detail.value; @@ -518,7 +478,7 @@ Page({ //区域数组中不包含需验证的身份证前两位 else if (!city[code.substr(0, 2)]) { - errorMess = "您输入的身份证地址编码有误!"; + errorMess = "您输入的身份证号格式有误!"; isPass = false; } else { //18位身份证需要验证最后一位校验位 @@ -549,88 +509,81 @@ Page({ 'isPass': isPass } if (errorMess != "") { - wx.showModal({ - title: errorMess, - content: '', - showCancel: false, - confirmText: '确定', - confirmColor: '', - success: function(res) {}, - fail: function(res) {}, - complete: function(res) {}, - }) + // wx.showModal({ + // title: errorMess, + // content: '', + // showCancel: false, + // confirmText: '确定', + // confirmColor: '', + // success: function(res) {}, + // fail: function(res) {}, + // complete: function(res) {}, + // }) + + getApp().my_warnning(errorMess, 0, this); + this.setData({ + id: null, + }); } return returnParam; }, //------初始化加载---------- onLoad: function(t) { - var user = getApp().globalData.userInfo; - if (user.card_field != '' && user.card_field != null && user.card_field != undefined && user.card_expiredate) { - var now = ut.gettimestamp(); - var str = user.card_expiredate.replace(/-/g, '/');; - var end = new Date(str); - end = Date.parse(end) / 1000; - if (now < end) { - this.puls_user(); - } - } - this.initial_user(); - }, - //-----------会员是否初始化--------------------- - initial_user: function() { - - var th = this; - getApp().request.get("/api/weshop/users/grade/vip/init/get", { - data: { - storeId: r.stoid, - }, - success: function(su) { - var isBool = su.data.data.isBool; - th.setData({ - isBool: isBool - }); - - if (!isBool) return false; - //-----会员权益获取-------------- - getApp().request.get("/api/weshop/users/grade/aftervipinfo/get", { - data: { - storeId: r.stoid, - userId: getApp().globalData.user_id, - }, - success: function(su) { - var gradename = su.data.data.GradeName; - th.setData({ - gradename: gradename - }); - } - }); - - } - }); - this.get_config(); + // var user = getApp().globalData.userInfo; + // if (user.card_field != '' && user.card_field != null && user.card_field != undefined && user.card_expiredate) { + // var now = ut.gettimestamp(); + // var str = user.card_expiredate.replace(/-/g, '/');; + // var end = new Date(str); + // end = Date.parse(end) / 1000; + // if (now < end) { + // this.puls_user(); + // } + // }; + // this.initial_user(); + self = this; + let url1 = '/api/weshop/storeconfig/get/'; + let url2 = '/api/weshop/prom/coupon/get/'; + url1 += r.stoid; + + app.request.get(url1, { + success: function(res) { + console.log('x-->', res.data.code, res.data.data.reg_type, res.data.data.reg_info); + if(res.data.code == 0) { + let reg_type = res.data.data.reg_type; + let reg_info = res.data.data.reg_info; + if(reg_type) { //reg_type为1才显示积分信息 + if(reg_info) { + reg_info = JSON.parse(reg_info); + //获取优惠券 + url2 += reg_info.reginfo_coupon; + app.request.get(url2, { + success: function(r) { + if(r.data.code == 0) { + console.log('000res==>', r.data.data.name); + self.setData({ + couponInfo: r.data.data.name, + }); + }; + }, + }); + }; + }; + self.setData({ + reg_type, + reg_info, + user: app.globalData.userInfo, + }); + }; + + }, + }); + + }, - //-----Plus会员获取----------- - puls_user: function() { - var th = this; - getApp().request.get("/api/weshop/plus/vip/mem/list", { - data: { - storeId: r.stoid, - userId: getApp().globalData.user_id, - }, - success: function(su) { - - if (su.data.code == 0) { - var cardname = su.data.data[0].MemCardName; - th.setData({ - pulscardname: cardname - }); - } - } - }); - }, + onShow: function() { var e = this; if (this.data.is_zy) return false; @@ -644,44 +597,44 @@ Page({ } var req = t; - req.get("/api/weshop/users/getAndUpdateUser/" + r.stoid + "/" + getApp().globalData.user_id, { - success: function(src) { - var a = src.data.data; - - if(!a) a={}; - var time ="",birthday =""; - if(a && a.reg_time) time=util.formatTime(a.reg_time, "'Y/M/D"); - if(a && a.birthday) birthday=util.formatTime(a.birthday, "'Y/M/D"); + // req.get("/api/weshop/users/getAndUpdateUser/" + r.stoid + "/" + getApp().globalData.user_id, { + // success: function(src) { + // var a = src.data.data; + + // if(!a) a={}; + // var time ="",birthday =""; + // if(a && a.reg_time) time=util.formatTime(a.reg_time, "'Y/M/D"); + // if(a && a.birthday) birthday=util.formatTime(a.birthday, "'Y/M/D"); - a.reg_time = time; - a.birthday = birthday + // a.reg_time = time; + // a.birthday = birthday - if(a.address=='null' || !a.address){ - a.address=""; - } + // if(a.address=='null' || !a.address){ + // a.address=""; + // } - e.data.fir_guide_id=a.staffId; - if(choice_guide){ - a.staffName=choice_guide.StaffName; - a.staffId=choice_guide.Id; - } + // e.data.fir_guide_id=a.staffId; + // if(choice_guide){ + // a.staffName=choice_guide.StaffName; + // a.staffId=choice_guide.Id; + // } - e.setData({ - phone: a.mobile, - user: a, - openid: a.openid, - sto_sele_id: a.pickup_id, - consumption: a.paypwd, - identity_card: a.idcard, - address: a.address, - isGender: a.sex, - isstcsp: a.vipnopwd, - iscalendar:a.islunar - }); + // e.setData({ + // // phone: a.mobile, + // user: a, + // openid: a.openid, + // sto_sele_id: a.pickup_id, + // consumption: a.paypwd, + // // identity_card: a.idcard, + // address: a.address, + // // isGender: a.sex, + // // isstcsp: a.vipnopwd, + // // iscalendar:a.islunar + // }); - } - }) + // } + // }) a.getUserInfo(function(a) { var txt = util.formatTime(a.birthday, 'yyyy-M-d'), arr = txt.split(' '); @@ -695,7 +648,7 @@ Page({ if(da.data.data){ //设置门店 e.setData({ - stoname: da.data.data.pickup_name + // stoname: da.data.data.pickup_name }); } @@ -714,34 +667,7 @@ Page({ }, !0); }, - editUserInfo: function(e) { - var r = e.currentTarget.dataset.type; - if (("password" == r || "paypwd" == r) && !this.data.user.mobile) return a.showWarning("请先绑定手机号码"); - r && this.data.user && wx.navigateTo({ - url: "/pages/user/userinfo_edit/userinfo_edit?type=" + r - }); - }, - /*--------------------修改头像---------------------*/ - changeAvatar: function() { - return false; - var r = this; - wx.chooseImage({ - count: 1, - sizeType: ["compressed", "original"], - sourceType: ["camera", "album"], - success: function(u) { - t.uploadFile(r.data.url + "/api/user/upload_headpic", { - filePath: u.tempFilePaths[0], - name: "head_pic", - success: function(t) { - var u = s.getFullUrl(t.data.result); - r.setData(e({}, "user.head_pic", u)), a.globalData.userInfo.head_pic = u, a.showSuccess("设置头像成功"); - } - }); - } - }); - }, //------卡片的显示和关闭-------- @@ -762,14 +688,8 @@ Page({ tc_hide: true, }); }, - //消费密码输入框失去焦点事件 - lose_focus: function(e) { - var th = this; - var val = e.detail.value; - this.setData({ - consumption: val - }) - }, + + //地址 address: function(e) { @@ -779,27 +699,19 @@ Page({ }); }, - //身份证验证 - identity_card: function(e) { - var val = e.detail; - - this.setData({ - identity_card: val.value - }); - - }, + //用户名字 - user_name: function(e) { - var th = this; - var name = e.detail.value; - var vipname = 'user.vipname'; - if (name != "" || name != null) { - th.setData({ - [vipname]: name - }); - } + // user_name: function(e) { + // var th = this; + // var name = e.detail.value; + // var vipname = 'user.vipname'; + // if (name != "" || name != null) { + // th.setData({ + // [vipname]: name + // }); + // } - }, + // }, //点击确认修改信息 confirm_revision: function() { @@ -878,13 +790,13 @@ Page({ // this.setData({ is_zy: 1 }); }, //更换手机 - go_phone: function(e) { - var url = e.currentTarget.dataset.url; - this.setData({ - is_zy: 1 - }); - getApp().goto(url); - }, + // go_phone: function(e) { + // var url = e.currentTarget.dataset.url; + // this.setData({ + // is_zy: 1 + // }); + // getApp().goto(url); + // }, //--点击分享事件--- onShareAppMessage: function(t) { @@ -911,7 +823,267 @@ Page({ } } }); - } + }, + + //获取输入框内容 + getInput(e) { + return e.detail.value; + }, + + verifyInput(e) { + let value = e.detail.value; + if (value == "" || value == null || value == undefined) { + app.my_warnning("请输入" + name, 0, this); + } + }, + + //获取推荐人 + getReferee(e) { + let referee = this.getInput(e); + this.data.referee = referee; + console.log(referee); + }, + + //获取姓名 + getName(e) { + let name = this.getInput(e); + this.data.name = name; + }, + + //获取性别 + getGender(e) { + let sex = e.currentTarget.dataset.sex; + this.setData({ + isGender: sex, + }); + }, + + //获取身份证 + getId(e) { + let id = this.getInput(e); + this.data.id = id; + }, + + //验证身份证号码 + // verifyId(e) { + // let id = this.data.id; + // if(id) { + // if (id != null && id != undefined && id != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(id))) { + // getApp().my_warnning("身份证号码无效!", 0, this); + // } + // }; + // }, + + //获取地址 + getAddress(e) { + let address = this.getInput(e); + this.data.address = address; + }, + + //获取生日 + bindChange: function(e) { + let strBirthday = e.detail.value; + let age = this.verifyBirthday(strBirthday); + + if(age <= 10) { + app.my_warnning("会员年龄不能小于10岁(含10岁)", 0, this); + } else if(age >= 70) { + app.my_warnning("会员年龄不能超过70岁(含70岁)", 0, this); + } else { + this.setData({ + datet: e.detail.value, + }); + }; + + // console.log(this.data.datet, this.data.isCalendar); + }, + + // 生日判断 + verifyBirthday(strBirthday) { + var returnAge; + var strBirthdayArr = strBirthday.split("-"); + var birthYear = strBirthdayArr[0]; + var birthMonth = strBirthdayArr[1]; + var birthDay = strBirthdayArr[2]; + + d = new Date(); + var nowYear = d.getFullYear(); + var nowMonth = d.getMonth() + 1; + var nowDay = d.getDate(); + + if(nowYear == birthYear){ + returnAge = 0;//同年 则为0岁 + } else { + var ageDiff = nowYear - birthYear ; //年之差 + if(ageDiff > 0){ + if(nowMonth == birthMonth) { + var dayDiff = nowDay - birthDay;//日之差 + if(dayDiff < 0) + { + returnAge = ageDiff - 1; + } + else + { + returnAge = ageDiff ; + } + } + else + { + var monthDiff = nowMonth - birthMonth;//月之差 + if(monthDiff < 0) + { + returnAge = ageDiff - 1; + } + else + { + returnAge = ageDiff ; + } + } + } + else + { + returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天 + } + } + return returnAge;//返回周岁年龄 + }, + + //是否为农历 + isLunar(e) { + let isLunar = null; + if(e.detail.value[0]) { + isLunar = 1; + } else { + isLunar = 0; + }; + this.data.isLunar = isLunar; + // console.log(isLunar); + }, + + // 是否同意协议 + isAgree(e) { + let isAgree = null; + if(e.detail.value[0]) { + isAgree = true; + } else { + isAgree = false; + }; + this.data.isAgree = isAgree; + console.log(isAgree); + }, + + + //保存 + save: function() { + var th = this; + let isAgree = this.data.isAgree; + // 同意协议 + if(isAgree) { + var sto_sele_id = self.data.sto_sele_id; + var data = { + store_id: r.stoid, + user_id: app.globalData.user_id, + tjrname: self.data.referee, //推荐人 + vipname: self.data.name, //名称 + sex: self.data.isGender, //性别 + birthday: self.data.datet, + islunar: self.data.isLunar, + idcard: self.data.id, + address: self.data.address, + pickup_id: sto_sele_id ,//自提门店 所属门店 + }; + + + console.log('data==>', data); + + app.request.put("/api/weshop/users/updateInfo", { + data: data, + success: function(res) { + if (res.data.code == 0) { + getApp().my_warnning("保存成功", 1, self); + getApp().goto("/pages/user/index/index"); + } else { + getApp().my_warnning(res.data.msg, 0, self); + }; + } + }) + + } else { + app.my_warnning("保存前需要您同意指定协议和政策", 0, self); + }; + // var isstcsp = th.data.isstcsp; //是否启用消费密码 + // 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) { + + // if (consumption == null || consumption == "" || consumption == undefined) { + // getApp().my_warnning("消费密码不能为空", 0, th); + // return false; + // } + // if (consumption.length < 6) { + // getApp().my_warnning("消费密码不能小于6位", 0, th); + // return false; + // } + // } + // var sex = th.data.isGender; //性别 + + // if (sex != "1" && sex != "2") { + // getApp().my_warnning("请选择性别", 0, th); + // return false; + // } + // var vipname = th.data.user.vipname; //用户姓名 + // if (user_name == "" || user_name == null) { + // getApp().my_warnning("请输入名字", 0, th); + // return false; + // } + // var identity_card = th.data.identity_card; //身份证 + + // if (identity_card!=null && identity_card!=undefined && 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; //地址 + // var sto_sele_id = self.data.sto_sele_id; + // var data = { + // store_id: r.stoid, + // user_id: app.globalData.user_id, + // tjrname: self.data.referee, //推荐人 + // vipname: self.data.name, //名称 + // sex: self.data.isGender, //性别 + // birthday: self.data.datet, + // islunar: self.data.isLunar, + // idcard: self.data.id, + // address: self.data.address, + // pickup_id: sto_sele_id ,//自提门店 所属门店 + // }; + + // console.log('data==>', data); + //往上提交美导的ID + // if(th.data.fir_guide_id!=th.data.user.staffId){ + // datas.staffId=th.data.user.staffId; + // } + + // app.request.put("/api/weshop/users/updateInfo", { + // data: data, + // success: function(res) { + // if (res.data.code == 0) { + // getApp().my_warnning("保存成功", 1, self); + // getApp().goto("/pages/user/index/index"); + // } else { + // getApp().my_warnning("系统繁忙,请稍后再试", 0, self); + // }; + // } + // }) + }, + + + + }); \ No newline at end of file diff --git a/packageA/pages/profile/profile.wxml b/packageA/pages/profile/profile.wxml index 341ef43..9cf5482 100644 --- a/packageA/pages/profile/profile.wxml +++ b/packageA/pages/profile/profile.wxml @@ -24,22 +24,24 @@ - + 推荐人: - - 可获10积分 + + +{{reg_info.introducer}}积分 + +{{reg_info.introducer}}成长值 - + 姓名: - - 可获10积分 + + +{{reg_info.name}}积分 + +{{reg_info.name}}成长值 - + 性别: - + @@ -48,7 +50,7 @@ - + @@ -58,86 +60,93 @@ - 可获10积分 + +{{reg_info.sex}}积分 + +{{reg_info.sex}}成长值 - + 出生日期: - - - - - - - - - - - - - - 农历 - - - - - - - {{datet?datet:"请选择时间"}} + + + + + + {{datet?datet:"请选择时间"}} - - - {{datet==""? user.birthday==""?"":filters.replace_time2(user.birthday):datet}} - + - 可获10积分 + +{{reg_info.birthday}}积分 + +{{reg_info.birthday}}成长值 - - 身份证号码: - - 可获10积分 + + 身份证: + + +{{reg_info.idcard}}积分 + +{{reg_info.idcard}}成长值 - + 地址: - - 可获10积分 + + +{{reg_info.address}}积分 + +{{reg_info.address}}成长值 - - 手机: - - 可获10积分 - - - - 验证码: - - 获取验证码 - + - + 所属门店: {{stoname}} - 可获10积分 + +{{reg_info.pick}}积分 + +{{reg_info.pick}}成长值 + + + + + + + 我的兴趣 + + + + + + + {{label}} + + + + + + + 标签 + + + + + + - - 我已阅读同意 《用户使用协议》《隐私政策》 + + + + 我已阅读同意 《用户使用协议》《隐私政策》 @@ -145,8 +154,8 @@ - 保存 - 保存成功即可获得一张20.00元优惠券 + 保存 + 保存成功即可获得一张{{couponInfo}} diff --git a/packageA/pages/profile/profile.wxss b/packageA/pages/profile/profile.wxss index 1a0babf..99963b1 100644 --- a/packageA/pages/profile/profile.wxss +++ b/packageA/pages/profile/profile.wxss @@ -623,7 +623,7 @@ input { } .interest { - padding: 0rpx 20rpx; + /* padding: 0rpx 20rpx; */ padding-top: 30rpx; padding-bottom: 30rpx; } -- libgit2 0.21.4