作者 wumengyu

添加已取消icon,优化个人信息验证,登录接口添加性别参数

@@ -52,7 +52,8 @@ App({ @@ -52,7 +52,8 @@ App({
52 self.post(url, { 52 self.post(url, {
53 code: res.code, 53 code: res.code,
54 user_nickname: user.userInfo.nickName, 54 user_nickname: user.userInfo.nickName,
55 - avatar: user.userInfo.avatarUrl 55 + avatar: user.userInfo.avatarUrl,
  56 + sex: user.userInfo.gender,
56 }, {}).then((ret) => { 57 }, {}).then((ret) => {
57 console.log('获取token', ret); 58 console.log('获取token', ret);
58 wx.setStorageSync('token', ret.data.token); 59 wx.setStorageSync('token', ret.data.token);
@@ -16,7 +16,8 @@ Page({ @@ -16,7 +16,8 @@ Page({
16 app.post(url, { 16 app.post(url, {
17 code: res.code, 17 code: res.code,
18 user_nickname: e.detail.userInfo.nickName, 18 user_nickname: e.detail.userInfo.nickName,
19 - avatar: e.detail.userInfo.avatarUrl 19 + avatar: e.detail.userInfo.avatarUrl,
  20 + sex: e.detail.userInfo.gender,
20 }, {}).then((ret) => { 21 }, {}).then((ret) => {
21 console.log('获取token', ret); 22 console.log('获取token', ret);
22 wx.setStorageSync('token', ret.token); 23 wx.setStorageSync('token', ret.token);
@@ -17,6 +17,7 @@ Page({ @@ -17,6 +17,7 @@ Page({
17 phone_number_params:'', 17 phone_number_params:'',
18 introduce:'', 18 introduce:'',
19 is_change:false, 19 is_change:false,
  20 + is_choose_phone:false
20 }, 21 },
21 //选择性别 22 //选择性别
22 sexPickerChange(e) { 23 sexPickerChange(e) {
@@ -30,6 +31,7 @@ Page({ @@ -30,6 +31,7 @@ Page({
30 inputPhone(e) { 31 inputPhone(e) {
31 this.setData({ 32 this.setData({
32 phone_number: e.detail.value, 33 phone_number: e.detail.value,
  34 + is_choose_phone:true
33 }); 35 });
34 if(this.data.phone_number.length>=11) { 36 if(this.data.phone_number.length>=11) {
35 if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){ 37 if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){
@@ -44,6 +46,18 @@ Page({ @@ -44,6 +46,18 @@ Page({
44 console.log('params', this.data.phone_number_params); 46 console.log('params', this.data.phone_number_params);
45 } 47 }
46 } 48 }
  49 + if(e.detail.value === '') {
  50 + console.log('手机号为空',this.data.is_wrong_phone,this.data.phone_number,this.data.is_choose_phone);
  51 + this.setData({is_change:false});//按钮置灰
  52 + }
  53 + if((this.data.is_choose_phone&&this.data.phone_number !== '') &&
  54 + this.data.user.country !== null &&
  55 + this.data.user.city !== null &&
  56 + this.data.user.introduce !== null
  57 + ){
  58 + console.log(2);
  59 + this.setData({is_change:true});
  60 + }
47 }, 61 },
48 //失去焦点 62 //失去焦点
49 blur() { 63 blur() {
@@ -69,7 +83,7 @@ Page({ @@ -69,7 +83,7 @@ Page({
69 app.post(url, params, {}).then((res) => { 83 app.post(url, params, {}).then((res) => {
70 console.log('自动获取手机号', res); 84 console.log('自动获取手机号', res);
71 if (+res.code === 1) { 85 if (+res.code === 1) {
72 - this.setData({phone_number:res.data,is_wrong_phone:false}) 86 + this.setData({phone_number:res.data,is_wrong_phone:false,is_choose_phone:true})
73 } 87 }
74 }); 88 });
75 }, 89 },
@@ -78,14 +92,36 @@ Page({ @@ -78,14 +92,36 @@ Page({
78 this.setData({ 92 this.setData({
79 country: e.detail.value, 93 country: e.detail.value,
80 is_choose_country:true 94 is_choose_country:true
81 - }) 95 + });
  96 + if(e.detail.value === '') {
  97 + this.setData({is_change:false});
  98 + }
  99 + if((this.data.is_choose_country&&this.data.country !== '') &&
  100 + this.data.user.city !== null &&
  101 + this.data.user.tel !== null &&
  102 + this.data.user.introduce !== null
  103 + ){
  104 + console.log(2);
  105 + this.setData({is_change:true});
  106 + }
82 }, 107 },
83 //输入城市 108 //输入城市
84 inputCity(e) { 109 inputCity(e) {
85 this.setData({ 110 this.setData({
86 city: e.detail.value, 111 city: e.detail.value,
87 is_choose_city:true 112 is_choose_city:true
88 - }) 113 + });
  114 + if(e.detail.value === '') {
  115 + this.setData({is_change:false});
  116 + }
  117 + if((this.data.is_choose_city&&this.data.city !== '') &&
  118 + this.data.user.country !== null &&
  119 + this.data.user.tel !== null &&
  120 + this.data.user.introduce !== null
  121 + ){
  122 + console.log(2);
  123 + this.setData({is_change:true});
  124 + }
89 }, 125 },
90 //简介 126 //简介
91 inputContent(e) { 127 inputContent(e) {
@@ -105,17 +141,37 @@ Page({ @@ -105,17 +141,37 @@ Page({
105 introduce: textcontent, 141 introduce: textcontent,
106 is_choose_introduce:true 142 is_choose_introduce:true
107 }); 143 });
  144 + if(e.detail.value === '') {
  145 + this.setData({is_change:false});
  146 + }
108 console.log('textcontent', textcontent); 147 console.log('textcontent', textcontent);
109 - if(this.data.current_sex !== undefined &&  
110 - this.data.country !== '' &&  
111 - this.data.city !== '' &&  
112 - this.data.phone_number !== '' &&  
113 - !this.data.is_wrong_phone &&  
114 - this.data.introduce !== '') { 148 + if((this.data.is_choose_introduce&&this.data.introduce !== '') &&
  149 + this.data.user.city !== null &&
  150 + this.data.user.tel !== null &&
  151 + this.data.user.country !== null
  152 + ){
  153 + console.log(2);
115 this.setData({is_change:true}); 154 this.setData({is_change:true});
116 - }else {  
117 - this.setData({is_change:false});  
118 } 155 }
  156 + // if((this.data.is_choose_country&&this.data.country !== '')&&
  157 + // (this.data.is_choose_city&&this.data.city !== '') &&
  158 + // (this.data.is_choose_phone&&this.data.phone_number !== '') &&
  159 + // (this.data.is_choose_introduce&&this.data.introduce !== '')
  160 + // ) {
  161 + // console.log(1);
  162 + // this.setData({is_change:true});
  163 + // }else if((this.data.is_choose_country&&this.data.country !== '')){
  164 + // console.log(2);
  165 + // this.setData({is_change:true});
  166 + // }
  167 + // if(((this.data.is_choose_country&&this.data.country !== '') || this.data.user.country !== null) &&
  168 + // ((this.data.is_choose_city&&this.data.city !== '')|| this.data.user.city !== null) &&
  169 + // ((this.data.is_choose_phone&&this.data.phone_number !== '')|| this.data.user.tel !== null) &&
  170 + // !this.data.is_wrong_phone &&
  171 + // ((this.data.is_choose_introduce&&this.data.introduce !== '') || this.data.user.introduce !== null)) {
  172 + // console.log('111');
  173 + // this.setData({is_change:true});
  174 + // }
119 } 175 }
120 }, 176 },
121 //保存 177 //保存
@@ -125,8 +181,8 @@ Page({ @@ -125,8 +181,8 @@ Page({
125 wx.showToast({title:'请填写国家',icon:'none'}) 181 wx.showToast({title:'请填写国家',icon:'none'})
126 }else if(this.data.city === '' && this.data.user.city === null) { 182 }else if(this.data.city === '' && this.data.user.city === null) {
127 wx.showToast({title:'请填写城市',icon:'none'}) 183 wx.showToast({title:'请填写城市',icon:'none'})
128 - }else if (this.data.phone_number === '' && this.data.user.tel === null) {  
129 - wx.showToast({title:'请填写手机号',icon:'none'}) 184 + }else if (this.data.user.tel === null) {
  185 + wx.showToast({title:'请获取手机号',icon:'none'})
130 }else if(this.data.is_wrong_phone){ 186 }else if(this.data.is_wrong_phone){
131 wx.showToast({title:'手机号格式错误',icon:'none'}) 187 wx.showToast({title:'手机号格式错误',icon:'none'})
132 }else if(this.data.introduce === '' && this.data.user.introduce === null) { 188 }else if(this.data.introduce === '' && this.data.user.introduce === null) {
@@ -139,7 +195,8 @@ Page({ @@ -139,7 +195,8 @@ Page({
139 sex: sex || this.data.user.sex, 195 sex: sex || this.data.user.sex,
140 country:this.data.is_choose_country?this.data.country:this.data.user.country, 196 country:this.data.is_choose_country?this.data.country:this.data.user.country,
141 city:this.data.is_choose_city?this.data.city:this.data.user.city, 197 city:this.data.is_choose_city?this.data.city:this.data.user.city,
142 - tel:this.data.phone_number !== ''?this.data.phone_number:this.data.user.tel, 198 + // tel:(this.data.is_choose_phone&&this.data.phone_number !== '')?this.data.phone_number:this.data.user.tel,
  199 + tel:this.data.user.tel,
143 introduce:this.data.is_choose_introduce?this.data.introduce:this.data.user.introduce 200 introduce:this.data.is_choose_introduce?this.data.introduce:this.data.user.introduce
144 }; 201 };
145 app.post(url, params, {}).then((res) => { 202 app.post(url, params, {}).then((res) => {
@@ -182,6 +239,9 @@ Page({ @@ -182,6 +239,9 @@ Page({
182 */ 239 */
183 onLoad: function (options) { 240 onLoad: function (options) {
184 this.setData({userInfo:app.globalData.userInfo}); 241 this.setData({userInfo:app.globalData.userInfo});
  242 + if(this.data.userInfo.tel !== null) {
  243 + this.setData({is_wrong_phone:false})
  244 + }
185 // console.log('userInfo', this.data.userInfo); 245 // console.log('userInfo', this.data.userInfo);
186 this.getDetail(); 246 this.getDetail();
187 247
@@ -16,26 +16,27 @@ @@ -16,26 +16,27 @@
16 <view class="flex-box"> 16 <view class="flex-box">
17 <view class="title">国家:</view> 17 <view class="title">国家:</view>
18 <view class="text"> 18 <view class="text">
19 - <input type="text" bindinput="inputCountry" value="{{country || user.country}}"/> 19 + <input type="text" bindinput="inputCountry" value="{{is_choose_country?country:user.country}}"/>
20 </view> 20 </view>
21 </view> 21 </view>
22 <view class="flex-box"> 22 <view class="flex-box">
23 <view class="title">城市:</view> 23 <view class="title">城市:</view>
24 <view class="text"> 24 <view class="text">
25 - <input type="text" bindinput="inputCity" value="{{city || user.city}}"/> 25 + <input type="text" bindinput="inputCity" value="{{is_choose_city?city:user.city}}"/>
26 </view> 26 </view>
27 </view> 27 </view>
28 <view class="flex-box"> 28 <view class="flex-box">
29 <view class="title">手机号:</view> 29 <view class="title">手机号:</view>
30 <view class="phone-box"> 30 <view class="phone-box">
31 - <input type="number" bindinput="inputPhone" bindblur="blur" value="{{phone_number || user.tel}}"/> 31 + <text>{{user.tel}}</text>
  32 + <!--<input type="number" bindinput="inputPhone" bindblur="blur" value="{{is_choose_phone&&!is_wrong_phone?phone_number:user.tel}}"/>-->
32 <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="phone-btn">自动填写</button> 33 <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="phone-btn">自动填写</button>
33 </view> 34 </view>
34 </view> 35 </view>
35 <view class="content-box"> 36 <view class="content-box">
36 <view class="title">个人简介:</view> 37 <view class="title">个人简介:</view>
37 <view class="text"> 38 <view class="text">
38 - <textarea type="text" bindinput="inputContent" maxlength="50" value="{{introduce || user.introduce}}"></textarea> 39 + <textarea type="text" bindinput="inputContent" maxlength="50" value="{{is_choose_introduce?introduce:user.introduce}}"></textarea>
39 <view class='word_num'>{{currentnum}}/{{maxlength}}</view> 40 <view class='word_num'>{{currentnum}}/{{maxlength}}</view>
40 </view> 41 </view>
41 </view> 42 </view>
@@ -28,7 +28,7 @@ @@ -28,7 +28,7 @@
28 font-size: 26rpx; 28 font-size: 26rpx;
29 color: #666666; 29 color: #666666;
30 } 30 }
31 -.text input, .phone-box input { 31 +.text input, .phone-box text {
32 font-size: 26rpx; 32 font-size: 26rpx;
33 color: #666666; 33 color: #666666;
34 } 34 }
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <view class="list-item {{item.type === 1?'change-bg':''}} {{item.status === 6?'change-bg-end':''}} {{item.status === 10?'change-bg-cancel':''}}" 6 <view class="list-item {{item.type === 1?'change-bg':''}} {{item.status === 6?'change-bg-end':''}} {{item.status === 10?'change-bg-cancel':''}}"
7 wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="goDetail"> 7 wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="goDetail">
8 <image src="../../../images/end-flag@2x.png" wx:if="{{item.status === 6}}" class="flag-img"></image> 8 <image src="../../../images/end-flag@2x.png" wx:if="{{item.status === 6}}" class="flag-img"></image>
9 - <image src="../../../images/end-flag@2x.png" wx:if="{{item.status === 10}}" class="flag-img"></image> 9 + <image src="../../../images/quxiao@2x.png" wx:if="{{item.status === 10}}" class="flag-img"></image>
10 <view class="detail {{item.status === 6?'change-color':''}}"> 10 <view class="detail {{item.status === 6?'change-color':''}}">
11 <view class="area"> 11 <view class="area">
12 <text class="addr">{{item.addr}}</text> 12 <text class="addr">{{item.addr}}</text>
@@ -187,7 +187,8 @@ Page({ @@ -187,7 +187,8 @@ Page({
187 app.post(url, { 187 app.post(url, {
188 code: res.code, 188 code: res.code,
189 user_nickname: e.detail.userInfo.nickName, 189 user_nickname: e.detail.userInfo.nickName,
190 - avatar: e.detail.userInfo.avatarUrl 190 + avatar: e.detail.userInfo.avatarUrl,
  191 + sex: e.detail.userInfo.gender,
191 }, {}).then((ret) => { 192 }, {}).then((ret) => {
192 console.log('获取token', ret); 193 console.log('获取token', ret);
193 wx.setStorageSync('token', ret.data.token); 194 wx.setStorageSync('token', ret.data.token);