Commit 6428c9c0da3bea98c0ca8d6989630d4f93e5eb87

Authored by 后端开发-许程
1 parent 76307c80

个人资料数据填充

pages/user/userinfo/userinfo.js
... ... @@ -5,7 +5,7 @@ function e(e, a, r) {
5 5 configurable: !0,
6 6 writable: !0
7 7 }) : e[a] = r, e;
8   -}
  8 +}
9 9  
10 10 var a = getApp(),
11 11 r = a.globalData.setting,
... ... @@ -50,6 +50,13 @@ Page({
50 50 isstcsp:1,//是否启动密码消费
51 51 isGender:1,//什么性别
52 52 iscalendar:1,//是否是农历
  53 + consumption:"",//消费密码
  54 + identity_card:"",//身份证值
  55 + address:"",//地址
  56 + openid:"",//openid
  57 + pulscardname:"",//puls会员的卡
  58 + gradename:"",//会员权益的卡
  59 + isBool:"",
53 60 },
54 61 //是否启动密码消费
55 62 isstcsp:function(){
... ... @@ -80,24 +87,21 @@ Page({
80 87 }
81 88 },
82 89 //性别
83   - isGender:function(){
  90 + isGender:function(e){
84 91 var th = this;
85   -
86   - var isGender = th.data.isGender;
87   - if (isGender == 2) {
  92 + var sex = e.currentTarget.dataset.sex;
  93 + console.log("点击选择性别",sex);
88 94 th.setData({
89   - isGender: 1
  95 + isGender:sex
90 96 })
91   - } else {
92   - th.setData({
93   - isGender: 2
94   - })
95   - }
  97 +
  98 +
96 99 },
97 100 //密码是否隐藏显示
98 101 ispwhid:function(){
99 102 var th = this;
100 103 var ispwhid = th.data.ispwhid;
  104 +
101 105 if (ispwhid == 0) {
102 106 th.setData({
103 107 ispwhid: 1
... ... @@ -139,7 +143,6 @@ Page({
139 143 var th = this;
140 144 var item = null;
141 145 var openindstore = th.data.open_ind_store;
142   -
143 146 if (th.data.choice_sort_store == 0) {
144 147 var index = th.data.fir_pick_index;
145 148 if (th.data.is_show_sto_cat == 1) {
... ... @@ -156,6 +159,7 @@ Page({
156 159 console.log("选择门店刷新", "def_pick_store", item);
157 160 th.setData({
158 161 def_pick_store: item,
  162 + stoname: item.pickup_name,
159 163 sto_sele_name: item.pickup_name,
160 164 sto_sele_id: item.pickup_id,
161 165 sto_sele_distr: item.distr_type,
... ... @@ -173,14 +177,12 @@ Page({
173 177 th.setData({
174 178 openSpecModal: !0,
175 179 openSpecModal_ind: openindstore,
176   -
177 180 openSpecModal_pt: 1
178 181 });
179 182 }
180 183 },
181 184 choose_for_store_fir: function(e) {
182 185 var index_c = e.currentTarget.dataset.ind;
183   -
184 186 this.setData({
185 187 fir_pick_index: index_c
186 188 })
... ... @@ -202,13 +204,11 @@ Page({
202 204 if (th.data.is_gps == 0) {
203 205 getApp().confirmBox("请开启GPS定位", null, 10000, !1);
204 206 }
205   -
206 207 } else {
207 208 th.setData({
208 209 is_gps: "3"
209 210 });
210 211 }
211   -
212 212 th.data.is_get_local_ok = 1;
213 213 }
214 214 })
... ... @@ -502,10 +502,57 @@ Page({
502 502 },
503 503 //------初始化加载----------
504 504 onLoad: function(t) {
505   - var th = this;
506   - th.setData({
507   - isGender:th.data.user.sex
508   - })//设置性别
  505 + this.puls_user();
  506 + this.equity_user();
  507 + this.initial_user();
  508 + },
  509 + //-----------会员是否初始化---------------------
  510 + initial_user: function () {
  511 +
  512 + var th = this;
  513 + getApp().request.get("/api/weshop/users/grade/vip/init/get", {
  514 + data: {
  515 + storeId: r.stoid,
  516 + },
  517 + success: function (su) {
  518 + var isBool = su.data.data.isBool;
  519 + console.log("会员是否初始化", isBool);
  520 + th.setData({isBool:isBool});
  521 + }
  522 + });
  523 + },
  524 + //-----会员等级卡获取---------------
  525 + equity_user:function(){
  526 + var th = this;
  527 + getApp().request.get("/api/weshop/users/grade/aftervipinfo/get", {
  528 + data: {
  529 + storeId: r.stoid,
  530 + userId: getApp().globalData.user_id,
  531 + },
  532 + success: function (su) {
  533 + var gradename=su.data.data.GradeName;
  534 + th.setData({gradename: gradename});
  535 +
  536 + }
  537 + });
  538 + },
  539 +
  540 + //-----Plus会员获取-----------
  541 + puls_user:function(){
  542 + var th=this;
  543 + getApp().request.get("/api/weshop/plus/vip/mem/list", {
  544 + data: {
  545 + storeId: r.stoid,
  546 + userId: getApp().globalData.user_id, },
  547 + success: function (su) {
  548 +
  549 + if (su.data.code == 0) {
  550 + var cardname=su.data.data[0].MemCardName;
  551 + console.log("卡的名字", cardname);
  552 + th.setData({pulscardname:cardname});
  553 + }
  554 + }
  555 + });
509 556 },
510 557 onShow: function() {
511 558  
... ... @@ -522,8 +569,7 @@ Page({
522 569 if (a.pickup_id!=null) {
523 570 req.get("/api/weshop/pickup/get/" + r.stoid + "/" + a.pickup_id, {
524 571 success: function(da) {
525   - console.log('getsto');
526   - console.log(da);
  572 +
527 573 //设置门店
528 574 e.setData({
529 575 stoname: da.data.data.pickup_name
... ... @@ -531,13 +577,18 @@ Page({
531 577 }
532 578 })
533 579 }
534   - var phone = "";
535   - phone+=a.mobile.substr(0, 3)+"****";
536   - phone += a.mobile.substr(7, 12);
  580 + // var phone = "";
  581 + // phone+=a.mobile.substr(0, 3)+"****";
  582 + // phone += a.mobile.substr(7, 12);
  583 +
  584 +
537 585 e.setData({
538   - phone:phone,
539   - user: a
  586 + phone: a.mobile,
  587 + user: a,
  588 + openid: a.openid,
  589 + consumption: a.paypwd,
540 590 });
  591 +
541 592 e.setData({
542 593 isGender:e.data.user.sex
543 594 })
... ... @@ -585,4 +636,118 @@ Page({
585 636 tc_hide: true,
586 637 });
587 638 },
  639 + //消费密码输入框失去焦点事件
  640 + lose_focus:function(e){
  641 + var th=this;
  642 + var val=e.detail.value;
  643 + console.log("是什么东西",val);
  644 + if (val.length > 6 || val!=""){
  645 +
  646 + this.setData({ consumption: val });
  647 + }
  648 +
  649 +
  650 + },
  651 +
  652 +//地址
  653 + address:function(e){
  654 + var val = e.detail;
  655 + console.log("地址55555555", val.value);
  656 + this.setData({ address: val.value });
  657 + },
  658 +
  659 + //身份证验证
  660 + identity_card:function(e){
  661 + var val = e.detail;
  662 +
  663 + this.setData({ identity_card: val.value });
  664 +
  665 + },
  666 + //用户名字
  667 + user_name:function(e){
  668 + var name = e.detail.value;
  669 + if (name !=""||name!=null){
  670 +
  671 + this.setData({ user_name: name });
  672 +
  673 + }
  674 +
  675 + },
  676 +
  677 + //点击确认修改信息
  678 + confirm_revision:function(){
  679 + var th=this;
  680 + var phone=th.data.phone;//手机号码
  681 + if (phone == "" || phone==null){
  682 + getApp().my_warnning("手机不能为空", 0, th);
  683 +
  684 + return false;
  685 + }
  686 + var consumption = th.data.consumption;//消费密码
  687 + var isstcsp = th.data.isstcsp;
  688 + if(isstcsp==1){
  689 + if (consumption.length < 6 && consumption==""){
  690 + getApp().my_warnning("消费密码不能为空及小于6位数", 0, th);
  691 + return false;
  692 + }
  693 + }
  694 + var sex = th.data.isGender;//性别
  695 + console.log(sex,"性别");
  696 + if (sex!="1"&&sex!="2" ) {
  697 + getApp().my_warnning("请选择性别", 0, th);
  698 + return false;
  699 + }
  700 + var user_name = th.data.user.vipname;//用户姓名
  701 + if (user_name == ""&& user_name!= null) {
  702 + getApp().my_warnning("请输入名字", 0, th);
  703 + return false;
  704 + }
  705 + var identity_card = th.data.identity_card;//身份证
  706 + console.log("身份证",identity_card);
  707 +
  708 + if (identity_card == "" && identity_card != null ) {
  709 + getApp().my_warnning("请输入身份证", 0, th);
  710 + return false;
  711 + } else if (!(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(identity_card))){
  712 + getApp().my_warnning("身份证号码错误",0, th);
  713 + return false;
  714 + }
  715 + var address = th.data.address;//地址
  716 + console.log("地址1010101", address)
  717 + if (address == "" && address != null) {
  718 + getApp().my_warnning("请输入地址", 0, th);
  719 + return false;
  720 + }
  721 + //保存所属门店的id
  722 + var sto_sele_id=th.data.sto_sele_id;
  723 + console.log("请输入所属门店的id", sto_sele_id);
  724 + if (sto_sele_id == null && sto_sele_id==""){
  725 + getApp().my_warnning("请输入所属门店", 0, th);
  726 + }
  727 + console.log("要保存的数据", sex, consumption, identity_card, address, user_name);
  728 + var datas = {
  729 + mobile: phone,//手机号码
  730 + store_id: r.stoid,
  731 + user_id: getApp().globalData.user_id,
  732 + openid: th.data.openid,
  733 + paypwd: consumption,//消费密码
  734 + sex: sex,//性别
  735 + nickname:user_name,//昵称
  736 + idcard:identity_card,//身份证
  737 + address:address,
  738 + }
  739 + getApp().request.put("/api/weshop/users/update", {
  740 + data: datas,
  741 + success: function (res) {
  742 +
  743 + if (res.data.code==0){
  744 + getApp().showWarning("修改成功");
  745 + }else{
  746 + getApp().showWarning("修改失败");
  747 + }
  748 +
  749 + }
  750 + })
  751 + }
  752 +
588 753 });
589 754 \ No newline at end of file
... ...
pages/user/userinfo/userinfo.json
1 1 {
2 2 "navigationBarTitleText": "个人资料",
3   - "enablePullDownRefresh": false
  3 + "enablePullDownRefresh": false,
  4 + "usingComponents": {
  5 + "warn": "/components/long_warn/long_warn"
  6 + }
4 7 }
5 8 \ No newline at end of file
... ...
pages/user/userinfo/userinfo.wxml
... ... @@ -3,7 +3,7 @@
3 3  
4 4 <!-- 头像,昵称,多个卡 -->
5 5 <view class="head flex-space-between">
6   - <view class="flex-center">
  6 + <view class="flex-center">
7 7  
8 8 <view class="flex-center">
9 9 <image class="Headportrait" src="{{user.head_pic}}"></image>
... ... @@ -16,18 +16,22 @@
16 16 </view>
17 17  
18 18 <view class="flex-center fs22 vip">
  19 + <block wx:if="{{isBool&&gradename}}">
19 20 <navigator url="">
20 21 <view class="flex-center AncrownMax">
21 22 <image class="Ancrown" src="{{iurl}}/miniapp/images/userqy/user_userqy_huang.png"></image>
22   - <view>黑卡会员</view>
  23 + <view>{{gradename}}</view>
23 24 </view>
24 25 </navigator>
  26 + </block>
  27 + <block wx:if="{{user.card_field!=''&& user.card_field!=null && user.card_expiredate!=null&&user.card_expiredate!=null}}">
25 28 <navigator url="/pages/user/plus/plus">
26 29 <view class="flex-center plusMax">
27 30 <image class="fuls" src="{{iurl}}/miniapp/images/userinfo/userinfo/privilege_t.png"></image>
28   - <view>PULS会员</view>
  31 + <view>{{pulscardname}}</view>
29 32 </view>
30 33 </navigator>
  34 + </block>
31 35 </view>
32 36 </view>
33 37 </view>
... ... @@ -67,46 +71,37 @@
67 71 消费密码
68 72 </view>
69 73 <view class="flex">
70   - <block wx:if="{{ispwhid}}">
71   - <input class="fs28 hion user-txt-right" maxlength="6" value="{{user.paypwd.length>0?user.paypwd:'******'}}" type="number" password="true"/>
72   - </block>
73   - <block wx:else>
74   - <input class="fs20 hion user-txt-right" maxlength="6" value="{{user.paypwd.length>0?user.paypwd:'未设置'}}" type="number"/>
75   - </block>
  74 + <block wx:if="{{ispwhid}}">
  75 + <input bindblur="lose_focus" class="fs28 hion user-txt-right"value="{{consumption}}" password="true"/>
  76 + </block>
  77 + <block wx:else>
  78 + <input bindblur="lose_focus" class="fs28 hion user-txt-right"value="{{consumption}}"/>
  79 + </block>
  80 +
76 81 <block wx:if="{{ispwhid}}">
77 82 <image class="eye" src="{{iurl}}/miniapp/images/userinfo/userinfo/Eye.png" bindtap="ispwhid"></image>
78 83 </block>
79 84 <block wx:else>
80   - <image class="eye" src="../../../images/open_eye.png" bindtap="ispwhid"></image>
  85 + <image class="eye" src="{{iurl}}/miniapp/images/userinfo/open_eye.png" bindtap="ispwhid"></image>
81 86 </block>
82   -
83   - </view>
  87 +
  88 +</view>
84 89 </view>
85 90  
86 91  
87   -
88   -
89   -
90   -
91   -
92   -
93   -
94   -
95   -
96   -
97 92 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="sex">
98 93 <view>性别</view>
99   - <view class="flex" wx:if="{{isGender!=0}}">
100   - <view class="flex-center {{isGender==1?'Gendercheck':'Gender'}}" bindtap="isGender">
  94 + <view class="flex">
  95 + <view class="flex-center {{isGender==1?'Gendercheck':'Gender'}}" data-sex="1" bindtap="isGender">
101 96 <block wx:if="{{isGender==1}}">
102 97 <image class="GenderImage" src="{{iurl}}/miniapp/images/userinfo/userinfo/malealready.png"></image>
103 98 </block>
104 99 <block wx:else>
105   - <image class="GenderImage" src="../../../images/userinfo/malenot.png"></image>
  100 + <image class="GenderImage" src="{{iurl}}/miniapp/images/userinfo/userinfo/malenot.png"></image>
106 101 </block>
107 102 <view class="fs24">男</view>
108 103 </view>
109   - <view class="flex-center {{isGender==2?'Gendercheck':'Gender'}}" bindtap="isGender">
  104 + <view class="flex-center {{isGender==2?'Gendercheck':'Gender'}}" data-sex="2"bindtap="isGender" >
110 105 <block wx:if="{{isGender==2}}">
111 106 <image class="GenderImage" src="{{iurl}}/miniapp/images/userinfo/userinfo/femalealready.png"></image>
112 107 </block>
... ... @@ -116,16 +111,14 @@
116 111 <view class="fs26">女</view>
117 112 </view>
118 113 </view>
119   - <view class="user-txt-right" wx:if="{{isGender==0}}" bindtap="isGender">保密</view>
  114 +
120 115 </view>
121 116  
122 117 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="sex">
123 118 <view>出生日期</view>
124   -
125   -
126 119 <view class="flex flex-vertical-between fs28 Birth">
127 120 <view class="flex" bindtap="iscalendar">
128   - <block wx:if="{{iscalendar}}">
  121 + <block wx:if="{{iscalendar&&user.birthday==null&&user.birthday==''}}">
129 122 <view class="flex-center">
130 123 <icon size="20" type="success" color="rgb(212,2,31)"></icon>
131 124 </view>
... ... @@ -139,10 +132,15 @@
139 132 </view>
140 133 <view class="user-txt-right">
141 134 <!-- 填充数据的时候要判断是否已经有出生日期,有值的话就不可修改 -->
  135 + <block wx:if="{{user.birthday==''||user.birthday==null}}">
142 136 <picker bindchange='bindChange' value="{{datet}}" mode="date"
143 137 start="{{year-70}}-1-1" end="{{year}}-12-31">
  138 + </picker>
  139 + </block>
  140 + <block wx:else>
144 141 <view>{{datet==""?user.birthday:datet}}</view>
145   - </picker>
  142 + </block>
  143 +
146 144 </view>
147 145 </view>
148 146 </view>
... ... @@ -150,17 +148,18 @@
150 148 <view class="Bbottom">
151 149 <view bindtap="editUserInfo1" class="user-name mt flex-vertical-between" data-type="nickname">
152 150 <view class="user-name-txt">姓名</view>
153   - <input class="user-txt-right" style="text-indent:300rpx;" placeholder="{{user.vipname.length>0?user.vipname:'*姓名'}}"/>
  151 + <input bindblur="user_name" class="user-txt-right t-r" placeholder="*姓名" value='{{user.vipname}}'/>
154 152 </view>
155 153  
156 154 <view bindtap="editUserInfo1" class="user-name flex-vertical-between" data-type="nickname">
157 155 <view class="user-name-txt">身份证</view>
158   - <block wx:if="{{user.idcard.length>0}}">
159   - <view class="user-txt-right">{{user.idcard}}</view>
160   - </block>
161   - <block wx:else>
  156 +
  157 + <input bindblur="identity_card" class="user-txt-right t-r" value="{{user.idcard}}" placeholder="*身份证"></input>
  158 +
  159 +
  160 + <!-- <block wx:else>
162 161 <input class="user-txt-right" bindblur="IdentityIDCard" value="" type="idcard" maxlength="18" placeholder="*身份证" />
163   - </block>
  162 + </block> -->
164 163 </view>
165 164 <navigator url="/pages/user/Change_phone/Change_phone?mobile={{user.mobile}}" class="user-name flex-vertical-between" data-type="mobile">
166 165 <view class="user-name-txt">更换手机</view>
... ... @@ -175,14 +174,16 @@
175 174 <view>{{user.address}}</view>
176 175 </block>
177 176 <block wx:else>
178   - <input maxlength="30" class="user-txt-right" placeholder="*地址" style=" text-indent: 370rpx;" />
  177 + <input bindblur="address" maxlength="30" class="user-txt-right" placeholder="*地址" style="text-align:right" />
179 178 </block>
180 179 </view>
181 180  
182 181 <view bindtap="onclickstore" class="user-name flex-vertical-between" data-type="email">
183 182 <view class="user-name-txt">所属门店</view>
184 183 <view class="flex-center user-txt-right">
185   - <view class="one-line">{{def_pick_store.pickup_name}}</view>
  184 + <view class="one-line">{{stoname}}
  185 + </view>
  186 +
186 187 <view class="angle">∟</view>
187 188 </view>
188 189 </view>
... ... @@ -190,7 +191,7 @@
190 191 <navigator class="user-name mt flex-vertical-between" url="/pages/user/address_list/address_list">
191 192 <view class="user-name-txt">收货地址</view>
192 193 <view class="flex-center user-txt-right">
193   - <view class="flex">{{user.address_id}}</view>
  194 + <!-- <view class="flex">{{user.address_id}}</view> -->
194 195 <view class="angle">∟</view>
195 196 </view>
196 197 </navigator>
... ... @@ -202,7 +203,7 @@
202 203 </view>
203 204 <!-- 确认修改按钮 -->
204 205 <view class="flex-center confirm">
205   - <view class="flex-center fs30 confirmtext">
  206 + <view class="flex-center fs30 confirmtext"bindtap="confirm_revision">
206 207 <view>确认修改</view>
207 208 </view>
208 209 </view>
... ... @@ -368,4 +369,5 @@
368 369 </view>
369 370 </block>
370 371 </view>
371   -</block>
372 372 \ No newline at end of file
  373 +</block>
  374 +<warn id="warn"></warn>
373 375 \ No newline at end of file
... ...
pages/user/userinfo/userinfo.wxss
... ... @@ -2,7 +2,7 @@
2 2 padding-bottom:165rpx;
3 3 }
4 4 .user-container {
5   - font-size: 30rpx;
  5 + font-size: 30rpx;
6 6 }
7 7 input{
8 8 width: 450rpx;
... ... @@ -32,11 +32,14 @@ input{
32 32  
33 33 .AncrownMax {
34 34 background-color: rgb(57, 57, 57);
35   - width: 150rpx;
  35 +
36 36 height: 36rpx;
37 37 border-radius: 20rpx;
38 38 margin-right: 20rpx;
39 39 line-height: 36rpx;
  40 + padding-right: 14rpx;
  41 +padding-left: 10rpx;
  42 +
40 43 }
41 44 .Nickname{
42 45 max-width:170rpx;
... ... @@ -49,10 +52,12 @@ input{
49 52  
50 53 .plusMax {
51 54 background-color: rgb(212, 58, 30);
52   - width: 150rpx;
53 55 height: 36rpx;
54 56 border-radius: 20rpx;
55 57 line-height: 36rpx;
  58 + padding-left: 10rpx;
  59 +padding-right: 14rpx;
  60 +
56 61 }
57 62  
58 63 .fuls {
... ... @@ -118,7 +123,8 @@ input{
118 123 }
119 124  
120 125 .hion {
121   - width:85rpx;
  126 + width: 97%;
  127 +text-align: right;
122 128 margin-top: 3rpx;
123 129 margin-right: 5rpx;
124 130 }
... ...