Commit 5130660b4fa09ecc07ec8bab3b1cbe51ff5215d9

Authored by yvan.ni
1 parent b1238bef

完善信息的bug优化

pages/user/userinfo/userinfo.js
@@ -68,6 +68,7 @@ Page({ @@ -68,6 +68,7 @@ Page({
68 is_lable_set: "", //是否启用我的兴趣标签 68 is_lable_set: "", //是否启用我的兴趣标签
69 check_label: [], //我选择的兴趣标签 69 check_label: [], //我选择的兴趣标签
70 fir_guide_id:null, //存储会员详情接口出来的美导ID 70 fir_guide_id:null, //存储会员详情接口出来的美导ID
  71 + reg_info:null
71 72
72 }, 73 },
73 //通过路径跳转到其他页面 74 //通过路径跳转到其他页面
@@ -86,6 +87,18 @@ Page({ @@ -86,6 +87,18 @@ Page({
86 guide_title:sms_conf.guide_consultant, //系统参数 导购标题 87 guide_title:sms_conf.guide_consultant, //系统参数 导购标题
87 guide_change_time:sms_conf.guide_change_time //每月能修改几次 88 guide_change_time:sms_conf.guide_change_time //每月能修改几次
88 }) 89 })
  90 +
  91 + let reg_type = ee.reg_type;
  92 + let reg_info = ee.reg_info;
  93 + if(reg_type) { //reg_type为1才显示积分信息
  94 + if(reg_info) {
  95 + reg_info = JSON.parse(reg_info);
  96 + th.setData({reg_info:reg_info});
  97 + }
  98 + }
  99 +
  100 +
  101 +
89 if (sms_conf.user_label_set) { 102 if (sms_conf.user_label_set) {
90 th.query_checklabels(); 103 th.query_checklabels();
91 } 104 }
@@ -185,9 +198,20 @@ Page({ @@ -185,9 +198,20 @@ Page({
185 } 198 }
186 }, 199 },
187 bindChange: function(e) { 200 bindChange: function(e) {
188 - this.setData({  
189 - datet: e.detail.value,  
190 - }); 201 +
  202 + let strBirthday = e.detail.value;
  203 + let age = this.verifyBirthday(strBirthday);
  204 +
  205 + if(age <= 10) {
  206 + getApp().my_warnning("会员年龄不能小于10岁(含10岁)", 0, this);
  207 + } else if(age >= 70) {
  208 + getApp().my_warnning("会员年龄不能超过70岁(含70岁)", 0, this);
  209 + } else {
  210 + this.setData({
  211 + datet: e.detail.value,
  212 + });
  213 + };
  214 +
191 }, 215 },
192 //---点击二级之后的选择--- 216 //---点击二级之后的选择---
193 choose_for_store: function(e) { 217 choose_for_store: function(e) {
@@ -564,6 +588,7 @@ Page({ @@ -564,6 +588,7 @@ Page({
564 }, 588 },
565 //------初始化加载---------- 589 //------初始化加载----------
566 onLoad: function(t) { 590 onLoad: function(t) {
  591 + var th=this;
567 var user = getApp().globalData.userInfo; 592 var user = getApp().globalData.userInfo;
568 if (user.card_field != '' && user.card_field != null && user.card_field != undefined && user.card_expiredate) { 593 if (user.card_field != '' && user.card_field != null && user.card_field != undefined && user.card_expiredate) {
569 var now = ut.gettimestamp(); 594 var now = ut.gettimestamp();
@@ -575,6 +600,9 @@ Page({ @@ -575,6 +600,9 @@ Page({
575 } 600 }
576 } 601 }
577 this.initial_user(); 602 this.initial_user();
  603 +
  604 +
  605 +
578 }, 606 },
579 //-----------会员是否初始化--------------------- 607 //-----------会员是否初始化---------------------
580 initial_user: function() { 608 initial_user: function() {
@@ -665,8 +693,7 @@ Page({ @@ -665,8 +693,7 @@ Page({
665 a.staffName=choice_guide.StaffName; 693 a.staffName=choice_guide.StaffName;
666 a.staffId=choice_guide.Id; 694 a.staffId=choice_guide.Id;
667 } 695 }
668 -  
669 - 696 +
670 e.setData({ 697 e.setData({
671 phone: a.mobile, 698 phone: a.mobile,
672 user: a, 699 user: a,
@@ -677,7 +704,9 @@ Page({ @@ -677,7 +704,9 @@ Page({
677 address: a.address, 704 address: a.address,
678 isGender: a.sex, 705 isGender: a.sex,
679 isstcsp: a.vipnopwd, 706 isstcsp: a.vipnopwd,
680 - iscalendar:a.islunar 707 + iscalendar:a.islunar,
  708 + user2:a,
  709 + datet:a.birthday
681 }); 710 });
682 711
683 } 712 }
@@ -802,7 +831,9 @@ Page({ @@ -802,7 +831,9 @@ Page({
802 }, 831 },
803 832
804 //点击确认修改信息 833 //点击确认修改信息
805 - confirm_revision: function() { 834 + confirm_revision: function() {
  835 +
  836 +
806 var th = this; 837 var th = this;
807 var isstcsp = th.data.isstcsp; //是否启用消费密码 838 var isstcsp = th.data.isstcsp; //是否启用消费密码
808 var phone = th.data.phone; //手机号码 839 var phone = th.data.phone; //手机号码
@@ -810,6 +841,9 @@ Page({ @@ -810,6 +841,9 @@ Page({
810 getApp().my_warnning("手机不能为空", 0, th); 841 getApp().my_warnning("手机不能为空", 0, th);
811 return false; 842 return false;
812 } 843 }
  844 + var address = th.data.address; //地址
  845 + var sto_sele_id = th.data.sto_sele_id;
  846 +
813 var consumption = th.data.consumption; //消费密码 847 var consumption = th.data.consumption; //消费密码
814 var isstcsp = th.data.isstcsp; 848 var isstcsp = th.data.isstcsp;
815 if (isstcsp == 1) { 849 if (isstcsp == 1) {
@@ -824,7 +858,6 @@ Page({ @@ -824,7 +858,6 @@ Page({
824 } 858 }
825 } 859 }
826 var sex = th.data.isGender; //性别 860 var sex = th.data.isGender; //性别
827 -  
828 if (sex != "1" && sex != "2") { 861 if (sex != "1" && sex != "2") {
829 getApp().my_warnning("请选择性别", 0, th); 862 getApp().my_warnning("请选择性别", 0, th);
830 return false; 863 return false;
@@ -834,14 +867,34 @@ Page({ @@ -834,14 +867,34 @@ Page({
834 getApp().my_warnning("请输入名字", 0, th); 867 getApp().my_warnning("请输入名字", 0, th);
835 return false; 868 return false;
836 } 869 }
  870 +
837 var identity_card = th.data.identity_card; //身份证 871 var identity_card = th.data.identity_card; //身份证
838 -  
839 if (identity_card!=null && identity_card!=undefined && identity_card != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(identity_card))) { 872 if (identity_card!=null && identity_card!=undefined && identity_card != "" && !(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(identity_card))) {
840 getApp().my_warnning("身份证号码错误", 0, th); 873 getApp().my_warnning("身份证号码错误", 0, th);
841 return false; 874 return false;
842 - }  
843 - var address = th.data.address; //地址  
844 - var sto_sele_id = th.data.sto_sele_id; 875 + }
  876 + if(th.data.user2.idcard && (!identity_card || identity_card=='') ){
  877 + getApp().my_warnning("身份证不能为空", 0, th);
  878 + return false;
  879 + }
  880 + if(th.data.user2.address && (!address || address=='') ){
  881 + getApp().my_warnning("地址不能为空", 0, th);
  882 + return false;
  883 + }
  884 + if(th.data.user2.pickup_id && (!sto_sele_id || sto_sele_id=='') ){
  885 + getApp().my_warnning("门店不能为空", 0, th);
  886 + return false;
  887 + }
  888 + if(th.data.user2.birthday && (!th.data.datet || th.data.datet =='') ){
  889 + getApp().my_warnning("生日不能为空", 0, th);
  890 + return false;
  891 + }
  892 +
  893 + if(this.data.confirmed) return false;
  894 + this.data.confirmed=1;
  895 +
  896 +
  897 +
845 var datas = { 898 var datas = {
846 mobile: phone, //手机号码 899 mobile: phone, //手机号码
847 store_id: r.stoid, 900 store_id: r.stoid,
@@ -864,6 +917,9 @@ Page({ @@ -864,6 +917,9 @@ Page({
864 getApp().request.put("/api/weshop/users/updateUserInfo", { 917 getApp().request.put("/api/weshop/users/updateUserInfo", {
865 data: datas, 918 data: datas,
866 success: function(res) { 919 success: function(res) {
  920 +
  921 + th.data.confirmed=0;
  922 +
867 if (res.data.code == 0) { 923 if (res.data.code == 0) {
868 getApp().my_warnning("修改成功", 1, th); 924 getApp().my_warnning("修改成功", 1, th);
869 getApp().goto("/pages/user/index/index"); 925 getApp().goto("/pages/user/index/index");
@@ -911,7 +967,58 @@ Page({ @@ -911,7 +967,58 @@ Page({
911 } 967 }
912 } 968 }
913 }); 969 });
914 - } 970 + },
  971 +
  972 + // 生日判断
  973 + verifyBirthday(strBirthday) {
  974 + var returnAge;
  975 + var strBirthdayArr = strBirthday.split("-");
  976 + var birthYear = strBirthdayArr[0];
  977 + var birthMonth = strBirthdayArr[1];
  978 + var birthDay = strBirthdayArr[2];
  979 +
  980 + d = new Date();
  981 + var nowYear = d.getFullYear();
  982 + var nowMonth = d.getMonth() + 1;
  983 + var nowDay = d.getDate();
  984 +
  985 + if(nowYear == birthYear){
  986 + returnAge = 0;//同年 则为0岁
  987 + } else {
  988 + var ageDiff = nowYear - birthYear ; //年之差
  989 + if(ageDiff > 0){
  990 + if(nowMonth == birthMonth) {
  991 + var dayDiff = nowDay - birthDay;//日之差
  992 + if(dayDiff < 0)
  993 + {
  994 + returnAge = ageDiff - 1;
  995 + }
  996 + else
  997 + {
  998 + returnAge = ageDiff ;
  999 + }
  1000 + }
  1001 + else
  1002 + {
  1003 + var monthDiff = nowMonth - birthMonth;//月之差
  1004 + if(monthDiff < 0)
  1005 + {
  1006 + returnAge = ageDiff - 1;
  1007 + }
  1008 + else
  1009 + {
  1010 + returnAge = ageDiff ;
  1011 + }
  1012 + }
  1013 + }
  1014 + else
  1015 + {
  1016 + returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
  1017 + }
  1018 + }
  1019 + return returnAge;//返回周岁年龄
  1020 + },
  1021 +
915 1022
916 1023
917 }); 1024 });
918 \ No newline at end of file 1025 \ No newline at end of file
pages/user/userinfo/userinfo.wxml
@@ -108,8 +108,15 @@ @@ -108,8 +108,15 @@
108 </block> 108 </block>
109 <view class="fs26">女</view> 109 <view class="fs26">女</view>
110 </view> 110 </view>
  111 +
  112 + <block wx:if="{{reg_info && reg_info.sex_state && reg_info.sex}}">
  113 + <view wx:if="{{!user.sex}}" class="fs28 co-red show_jf_val">+{{reg_info.sex}}
  114 + <text wx:if="{{reg_info.sex_state_type == 0}}">积分</text>
  115 + <text wx:if="{{reg_info.sex_state_type == 1}}">成长值</text>
  116 + </view>
  117 + </block>
111 </view> 118 </view>
112 - 119 +
113 </view> 120 </view>
114 121
115 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="sex"> 122 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="sex">
@@ -144,27 +151,47 @@ @@ -144,27 +151,47 @@
144 </block> 151 </block>
145 <block wx:else> 152 <block wx:else>
146 <view>{{datet==""? user.birthday==""?"":filters.replace_time2(user.birthday):datet}}</view> 153 <view>{{datet==""? user.birthday==""?"":filters.replace_time2(user.birthday):datet}}</view>
147 - </block>  
148 - 154 + </block>
149 </view> 155 </view>
  156 +
  157 +
  158 + <block wx:if="{{reg_info && reg_info.birthday_state && reg_info.birthday}}">
  159 + <view wx:if="{{!user.birthday}}" class="fs28 co-red show_jf_val">+{{reg_info.birthday}}
  160 + <text wx:if="{{reg_info.birthday_type == 0}}">积分</text>
  161 + <text wx:if="{{reg_info.birthday_type == 1}}">成长值</text>
  162 + </view>
  163 + </block>
  164 +
150 </view> 165 </view>
151 - </view> 166 +
  167 + </view>
152 </view> 168 </view>
153 <view class="Bbottom"> 169 <view class="Bbottom">
154 <view bindtap="editUserInfo1" class="user-name mt flex-vertical-between" data-type="nickname"> 170 <view bindtap="editUserInfo1" class="user-name mt flex-vertical-between" data-type="nickname">
155 <view class="user-name-txt">姓名</view> 171 <view class="user-name-txt">姓名</view>
156 - <input bindblur="user_name" class="user-txt-right t-r" placeholder="*姓名" value='{{user.vipname}}' /> 172 + <view class="flex ai-center">
  173 + <input bindblur="user_name" class="user-txt-right t-r" placeholder="*姓名" value='{{user.vipname}}' />
  174 +
  175 + <block wx:if="{{reg_info && reg_info.name_state && reg_info.name}}">
  176 + <view wx:if="{{!user2.vipname}}" class="fs28 co-red show_jf_val">+{{reg_info.name}}
  177 + <text wx:if="{{reg_info.name_val_type == 0}}">积分</text>
  178 + <text wx:if="{{reg_info.name_val_type == 1}}">成长值</text>
  179 + </view>
  180 + </block>
  181 + </view>
157 </view> 182 </view>
158 183
159 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="nickname"> 184 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="nickname">
160 <view class="user-name-txt">身份证</view> 185 <view class="user-name-txt">身份证</view>
161 -  
162 - <input bindblur="identity_card" class="user-txt-right t-r" value="{{user.idcard}}" placeholder="*身份证"></input>  
163 -  
164 -  
165 - <!-- <block wx:else>  
166 - <input class="user-txt-right" bindblur="IdentityIDCard" value="" type="idcard" maxlength="18" placeholder="*身份证" />  
167 - </block> --> 186 + <view class="flex ai-center">
  187 + <input bindblur="identity_card" class="user-txt-right t-r" value="{{user.idcard}}" placeholder="*身份证"></input>
  188 + <block wx:if="{{reg_info && reg_info.idcard_state && reg_info.idcard}}">
  189 + <view wx:if="{{!user2.idcard}}" class="fs28 co-red show_jf_val" >+{{reg_info.idcard}}
  190 + <text wx:if="{{reg_info.idcard_type == 0}}">积分</text>
  191 + <text wx:if="{{reg_info.idcard_type == 1}}">成长值</text>
  192 + </view>
  193 + </block>
  194 + </view>
168 </view> 195 </view>
169 <view data-url="/pages/user/Change_phone/Change_phone" bindtap="go_phone" class="user-name flex-vertical-between" data-type="mobile"> 196 <view data-url="/pages/user/Change_phone/Change_phone" bindtap="go_phone" class="user-name flex-vertical-between" data-type="mobile">
170 <view class="user-name-txt">更换手机</view> 197 <view class="user-name-txt">更换手机</view>
@@ -180,8 +207,16 @@ @@ -180,8 +207,16 @@
180 <view>{{user.address}}</view> 207 <view>{{user.address}}</view>
181 </block> 208 </block>
182 <block wx:else> --> 209 <block wx:else> -->
183 - <input bindblur="address" maxlength="30" value="{{user.address}}" class="user-txt-right" placeholder="*地址" style="text-align:right" />  
184 - <!-- </block> --> 210 + <view class="flex ai-center">
  211 + <input bindblur="address" maxlength="30" value="{{user.address}}" class="user-txt-right" placeholder="*地址" style="text-align:right" />
  212 + <!-- </block> -->
  213 + <block wx:if="{{reg_info && reg_info.address_state && reg_info.address}}">
  214 + <view wx:if="{{!user2.address}}" class="fs28 co-red show_jf_val" >+{{reg_info.address}}
  215 + <text wx:if="{{reg_info.address_type == 0}}">积分</text>
  216 + <text wx:if="{{reg_info.address_type == 1}}">成长值</text>
  217 + </view>
  218 + </block>
  219 + </view>
185 </view> 220 </view>
186 221
187 <!-- 选择门店 --> 222 <!-- 选择门店 -->
@@ -190,7 +225,14 @@ @@ -190,7 +225,14 @@
190 <view class="flex-center user-txt-right"> 225 <view class="flex-center user-txt-right">
191 <view class="one-line">{{stoname}}</view> 226 <view class="one-line">{{stoname}}</view>
192 <view class="angle">∟</view> 227 <view class="angle">∟</view>
  228 + <block wx:if="{{reg_info && reg_info.pick_state && reg_info.pick}}">
  229 + <view wx:if="{{!user.pickup_id}}" class="fs28 co-red show_jf_val">+{{reg_info.pick}}
  230 + <text wx:if="{{reg_info.pick_type == 0}}">积分</text>
  231 + <text wx:if="{{reg_info.pick_type == 1}}">成长值</text>
  232 + </view>
  233 + </block>
193 </view> 234 </view>
  235 +
194 </view> 236 </view>
195 237
196 <!-- 美容顾问 --> 238 <!-- 美容顾问 -->
pages/user/userinfo/userinfo.wxss
@@ -662,3 +662,5 @@ input { @@ -662,3 +662,5 @@ input {
662 height: 46rpx; 662 height: 46rpx;
663 line-height: 46rpx; 663 line-height: 46rpx;
664 } 664 }
  665 +
  666 +.show_jf_val{ margin-left: 5rpx;}