From 5130660b4fa09ecc07ec8bab3b1cbe51ff5215d9 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 12 May 2021 09:44:50 +0800 Subject: [PATCH] 完善信息的bug优化 --- pages/user/userinfo/userinfo.js | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- pages/user/userinfo/userinfo.wxml | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- pages/user/userinfo/userinfo.wxss | 2 ++ 3 files changed, 178 insertions(+), 27 deletions(-) diff --git a/pages/user/userinfo/userinfo.js b/pages/user/userinfo/userinfo.js index d04c545..b0661fa 100644 --- a/pages/user/userinfo/userinfo.js +++ b/pages/user/userinfo/userinfo.js @@ -68,6 +68,7 @@ Page({ is_lable_set: "", //是否启用我的兴趣标签 check_label: [], //我选择的兴趣标签 fir_guide_id:null, //存储会员详情接口出来的美导ID + reg_info:null }, //通过路径跳转到其他页面 @@ -86,6 +87,18 @@ Page({ guide_title:sms_conf.guide_consultant, //系统参数 导购标题 guide_change_time:sms_conf.guide_change_time //每月能修改几次 }) + + let reg_type = ee.reg_type; + let reg_info = ee.reg_info; + if(reg_type) { //reg_type为1才显示积分信息 + if(reg_info) { + reg_info = JSON.parse(reg_info); + th.setData({reg_info:reg_info}); + } + } + + + if (sms_conf.user_label_set) { th.query_checklabels(); } @@ -185,9 +198,20 @@ Page({ } }, bindChange: function(e) { - this.setData({ - datet: e.detail.value, - }); + + let strBirthday = e.detail.value; + let age = this.verifyBirthday(strBirthday); + + if(age <= 10) { + getApp().my_warnning("会员年龄不能小于10岁(含10岁)", 0, this); + } else if(age >= 70) { + getApp().my_warnning("会员年龄不能超过70岁(含70岁)", 0, this); + } else { + this.setData({ + datet: e.detail.value, + }); + }; + }, //---点击二级之后的选择--- choose_for_store: function(e) { @@ -564,6 +588,7 @@ Page({ }, //------初始化加载---------- onLoad: function(t) { + var th=this; var user = getApp().globalData.userInfo; if (user.card_field != '' && user.card_field != null && user.card_field != undefined && user.card_expiredate) { var now = ut.gettimestamp(); @@ -575,6 +600,9 @@ Page({ } } this.initial_user(); + + + }, //-----------会员是否初始化--------------------- initial_user: function() { @@ -665,8 +693,7 @@ Page({ a.staffName=choice_guide.StaffName; a.staffId=choice_guide.Id; } - - + e.setData({ phone: a.mobile, user: a, @@ -677,7 +704,9 @@ Page({ address: a.address, isGender: a.sex, isstcsp: a.vipnopwd, - iscalendar:a.islunar + iscalendar:a.islunar, + user2:a, + datet:a.birthday }); } @@ -802,7 +831,9 @@ Page({ }, //点击确认修改信息 - confirm_revision: function() { + confirm_revision: function() { + + var th = this; var isstcsp = th.data.isstcsp; //是否启用消费密码 var phone = th.data.phone; //手机号码 @@ -810,6 +841,9 @@ Page({ getApp().my_warnning("手机不能为空", 0, th); return false; } + var address = th.data.address; //地址 + var sto_sele_id = th.data.sto_sele_id; + var consumption = th.data.consumption; //消费密码 var isstcsp = th.data.isstcsp; if (isstcsp == 1) { @@ -824,7 +858,6 @@ Page({ } } var sex = th.data.isGender; //性别 - if (sex != "1" && sex != "2") { getApp().my_warnning("请选择性别", 0, th); return false; @@ -834,14 +867,34 @@ Page({ 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 = th.data.sto_sele_id; + } + if(th.data.user2.idcard && (!identity_card || identity_card=='') ){ + getApp().my_warnning("身份证不能为空", 0, th); + return false; + } + if(th.data.user2.address && (!address || address=='') ){ + getApp().my_warnning("地址不能为空", 0, th); + return false; + } + if(th.data.user2.pickup_id && (!sto_sele_id || sto_sele_id=='') ){ + getApp().my_warnning("门店不能为空", 0, th); + return false; + } + if(th.data.user2.birthday && (!th.data.datet || th.data.datet =='') ){ + getApp().my_warnning("生日不能为空", 0, th); + return false; + } + + if(this.data.confirmed) return false; + this.data.confirmed=1; + + + var datas = { mobile: phone, //手机号码 store_id: r.stoid, @@ -864,6 +917,9 @@ Page({ getApp().request.put("/api/weshop/users/updateUserInfo", { data: datas, success: function(res) { + + th.data.confirmed=0; + if (res.data.code == 0) { getApp().my_warnning("修改成功", 1, th); getApp().goto("/pages/user/index/index"); @@ -911,7 +967,58 @@ Page({ } } }); - } + }, + + // 生日判断 + 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;//返回周岁年龄 + }, + }); \ No newline at end of file diff --git a/pages/user/userinfo/userinfo.wxml b/pages/user/userinfo/userinfo.wxml index 9b2188d..3b0f03d 100644 --- a/pages/user/userinfo/userinfo.wxml +++ b/pages/user/userinfo/userinfo.wxml @@ -108,8 +108,15 @@ + + + +{{reg_info.sex}} + 积分 + 成长值 + + - + @@ -144,27 +151,47 @@ {{datet==""? user.birthday==""?"":filters.replace_time2(user.birthday):datet}} - - + + + + + +{{reg_info.birthday}} + 积分 + 成长值 + + + - + + 姓名 - + + + + + +{{reg_info.name}} + 积分 + 成长值 + + + 身份证 - - - - - + + + + +{{reg_info.idcard}} + 积分 + 成长值 + + + 更换手机 @@ -180,8 +207,16 @@ {{user.address}} --> - - + + + + + +{{reg_info.address}} + 积分 + 成长值 + + + @@ -190,7 +225,14 @@ {{stoname}} + + +{{reg_info.pick}} + 积分 + 成长值 + + + diff --git a/pages/user/userinfo/userinfo.wxss b/pages/user/userinfo/userinfo.wxss index 6b11ea0..d35a8fd 100644 --- a/pages/user/userinfo/userinfo.wxss +++ b/pages/user/userinfo/userinfo.wxss @@ -662,3 +662,5 @@ input { height: 46rpx; line-height: 46rpx; } + +.show_jf_val{ margin-left: 5rpx;} -- libgit2 0.21.4