From 77d422f8ad5c6dcb298d454ac986db7f8979832a Mon Sep 17 00:00:00 2001 From: wumengyu <2683447714@qq.com> Date: Fri, 25 Jan 2019 10:42:26 +0800 Subject: [PATCH] 添加已取消icon,优化个人信息验证,登录接口添加性别参数 --- app.js | 3 ++- images/quxiao@2x.png | Bin 0 -> 10203 bytes pages/get-user-info/get-user-info.js | 3 ++- pages/my/edit-info/edit-info.js | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------- pages/my/edit-info/edit-info.wxml | 9 +++++---- pages/my/edit-info/edit-info.wxss | 2 +- pages/my/my-wallet/my-wallet.wxml | 2 +- pages/my/my.js | 3 ++- 8 files changed, 87 insertions(+), 23 deletions(-) create mode 100644 images/quxiao@2x.png diff --git a/app.js b/app.js index f12bd3a..2008695 100644 --- a/app.js +++ b/app.js @@ -52,7 +52,8 @@ App({ self.post(url, { code: res.code, user_nickname: user.userInfo.nickName, - avatar: user.userInfo.avatarUrl + avatar: user.userInfo.avatarUrl, + sex: user.userInfo.gender, }, {}).then((ret) => { console.log('获取token', ret); wx.setStorageSync('token', ret.data.token); diff --git a/images/quxiao@2x.png b/images/quxiao@2x.png new file mode 100644 index 0000000..b879479 Binary files /dev/null and b/images/quxiao@2x.png differ diff --git a/pages/get-user-info/get-user-info.js b/pages/get-user-info/get-user-info.js index 986ba04..366e82e 100644 --- a/pages/get-user-info/get-user-info.js +++ b/pages/get-user-info/get-user-info.js @@ -16,7 +16,8 @@ Page({ app.post(url, { code: res.code, user_nickname: e.detail.userInfo.nickName, - avatar: e.detail.userInfo.avatarUrl + avatar: e.detail.userInfo.avatarUrl, + sex: e.detail.userInfo.gender, }, {}).then((ret) => { console.log('获取token', ret); wx.setStorageSync('token', ret.token); diff --git a/pages/my/edit-info/edit-info.js b/pages/my/edit-info/edit-info.js index 4450f69..33f045d 100644 --- a/pages/my/edit-info/edit-info.js +++ b/pages/my/edit-info/edit-info.js @@ -17,6 +17,7 @@ Page({ phone_number_params:'', introduce:'', is_change:false, + is_choose_phone:false }, //选择性别 sexPickerChange(e) { @@ -30,6 +31,7 @@ Page({ inputPhone(e) { this.setData({ phone_number: e.detail.value, + is_choose_phone:true }); if(this.data.phone_number.length>=11) { if(!(/^1[0-9]{10}$/.test(this.data.phone_number))){ @@ -44,6 +46,18 @@ Page({ console.log('params', this.data.phone_number_params); } } + if(e.detail.value === '') { + console.log('手机号为空',this.data.is_wrong_phone,this.data.phone_number,this.data.is_choose_phone); + this.setData({is_change:false});//按钮置灰 + } + if((this.data.is_choose_phone&&this.data.phone_number !== '') && + this.data.user.country !== null && + this.data.user.city !== null && + this.data.user.introduce !== null + ){ + console.log(2); + this.setData({is_change:true}); + } }, //失去焦点 blur() { @@ -69,7 +83,7 @@ Page({ app.post(url, params, {}).then((res) => { console.log('自动获取手机号', res); if (+res.code === 1) { - this.setData({phone_number:res.data,is_wrong_phone:false}) + this.setData({phone_number:res.data,is_wrong_phone:false,is_choose_phone:true}) } }); }, @@ -78,14 +92,36 @@ Page({ this.setData({ country: e.detail.value, is_choose_country:true - }) + }); + if(e.detail.value === '') { + this.setData({is_change:false}); + } + if((this.data.is_choose_country&&this.data.country !== '') && + this.data.user.city !== null && + this.data.user.tel !== null && + this.data.user.introduce !== null + ){ + console.log(2); + this.setData({is_change:true}); + } }, //输入城市 inputCity(e) { this.setData({ city: e.detail.value, is_choose_city:true - }) + }); + if(e.detail.value === '') { + this.setData({is_change:false}); + } + if((this.data.is_choose_city&&this.data.city !== '') && + this.data.user.country !== null && + this.data.user.tel !== null && + this.data.user.introduce !== null + ){ + console.log(2); + this.setData({is_change:true}); + } }, //简介 inputContent(e) { @@ -105,17 +141,37 @@ Page({ introduce: textcontent, is_choose_introduce:true }); + if(e.detail.value === '') { + this.setData({is_change:false}); + } console.log('textcontent', textcontent); - if(this.data.current_sex !== undefined && - this.data.country !== '' && - this.data.city !== '' && - this.data.phone_number !== '' && - !this.data.is_wrong_phone && - this.data.introduce !== '') { + if((this.data.is_choose_introduce&&this.data.introduce !== '') && + this.data.user.city !== null && + this.data.user.tel !== null && + this.data.user.country !== null + ){ + console.log(2); this.setData({is_change:true}); - }else { - this.setData({is_change:false}); } + // if((this.data.is_choose_country&&this.data.country !== '')&& + // (this.data.is_choose_city&&this.data.city !== '') && + // (this.data.is_choose_phone&&this.data.phone_number !== '') && + // (this.data.is_choose_introduce&&this.data.introduce !== '') + // ) { + // console.log(1); + // this.setData({is_change:true}); + // }else if((this.data.is_choose_country&&this.data.country !== '')){ + // console.log(2); + // this.setData({is_change:true}); + // } + // if(((this.data.is_choose_country&&this.data.country !== '') || this.data.user.country !== null) && + // ((this.data.is_choose_city&&this.data.city !== '')|| this.data.user.city !== null) && + // ((this.data.is_choose_phone&&this.data.phone_number !== '')|| this.data.user.tel !== null) && + // !this.data.is_wrong_phone && + // ((this.data.is_choose_introduce&&this.data.introduce !== '') || this.data.user.introduce !== null)) { + // console.log('111'); + // this.setData({is_change:true}); + // } } }, //保存 @@ -125,8 +181,8 @@ Page({ wx.showToast({title:'请填写国家',icon:'none'}) }else if(this.data.city === '' && this.data.user.city === null) { wx.showToast({title:'请填写城市',icon:'none'}) - }else if (this.data.phone_number === '' && this.data.user.tel === null) { - wx.showToast({title:'请填写手机号',icon:'none'}) + }else if (this.data.user.tel === null) { + wx.showToast({title:'请获取手机号',icon:'none'}) }else if(this.data.is_wrong_phone){ wx.showToast({title:'手机号格式错误',icon:'none'}) }else if(this.data.introduce === '' && this.data.user.introduce === null) { @@ -139,7 +195,8 @@ Page({ sex: sex || this.data.user.sex, country:this.data.is_choose_country?this.data.country:this.data.user.country, city:this.data.is_choose_city?this.data.city:this.data.user.city, - tel:this.data.phone_number !== ''?this.data.phone_number:this.data.user.tel, + // tel:(this.data.is_choose_phone&&this.data.phone_number !== '')?this.data.phone_number:this.data.user.tel, + tel:this.data.user.tel, introduce:this.data.is_choose_introduce?this.data.introduce:this.data.user.introduce }; app.post(url, params, {}).then((res) => { @@ -182,6 +239,9 @@ Page({ */ onLoad: function (options) { this.setData({userInfo:app.globalData.userInfo}); + if(this.data.userInfo.tel !== null) { + this.setData({is_wrong_phone:false}) + } // console.log('userInfo', this.data.userInfo); this.getDetail(); diff --git a/pages/my/edit-info/edit-info.wxml b/pages/my/edit-info/edit-info.wxml index 536b7c4..d9cf18e 100644 --- a/pages/my/edit-info/edit-info.wxml +++ b/pages/my/edit-info/edit-info.wxml @@ -16,26 +16,27 @@ <view class="flex-box"> <view class="title">国家:</view> <view class="text"> - <input type="text" bindinput="inputCountry" value="{{country || user.country}}"/> + <input type="text" bindinput="inputCountry" value="{{is_choose_country?country:user.country}}"/> </view> </view> <view class="flex-box"> <view class="title">城市:</view> <view class="text"> - <input type="text" bindinput="inputCity" value="{{city || user.city}}"/> + <input type="text" bindinput="inputCity" value="{{is_choose_city?city:user.city}}"/> </view> </view> <view class="flex-box"> <view class="title">手机号:</view> <view class="phone-box"> - <input type="number" bindinput="inputPhone" bindblur="blur" value="{{phone_number || user.tel}}"/> + <text>{{user.tel}}</text> + <!--<input type="number" bindinput="inputPhone" bindblur="blur" value="{{is_choose_phone&&!is_wrong_phone?phone_number:user.tel}}"/>--> <button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="phone-btn">自动填写</button> </view> </view> <view class="content-box"> <view class="title">个人简介:</view> <view class="text"> - <textarea type="text" bindinput="inputContent" maxlength="50" value="{{introduce || user.introduce}}"></textarea> + <textarea type="text" bindinput="inputContent" maxlength="50" value="{{is_choose_introduce?introduce:user.introduce}}"></textarea> <view class='word_num'>{{currentnum}}/{{maxlength}}</view> </view> </view> diff --git a/pages/my/edit-info/edit-info.wxss b/pages/my/edit-info/edit-info.wxss index 2bcb120..4b32f0b 100644 --- a/pages/my/edit-info/edit-info.wxss +++ b/pages/my/edit-info/edit-info.wxss @@ -28,7 +28,7 @@ font-size: 26rpx; color: #666666; } -.text input, .phone-box input { +.text input, .phone-box text { font-size: 26rpx; color: #666666; } diff --git a/pages/my/my-wallet/my-wallet.wxml b/pages/my/my-wallet/my-wallet.wxml index dd0dae6..155244b 100644 --- a/pages/my/my-wallet/my-wallet.wxml +++ b/pages/my/my-wallet/my-wallet.wxml @@ -6,7 +6,7 @@ <view class="list-item {{item.type === 1?'change-bg':''}} {{item.status === 6?'change-bg-end':''}} {{item.status === 10?'change-bg-cancel':''}}" wx:for="{{list}}" wx:key="index" data-id="{{item.id}}" bindtap="goDetail"> <image src="../../../images/end-flag@2x.png" wx:if="{{item.status === 6}}" class="flag-img"></image> - <image src="../../../images/end-flag@2x.png" wx:if="{{item.status === 10}}" class="flag-img"></image> + <image src="../../../images/quxiao@2x.png" wx:if="{{item.status === 10}}" class="flag-img"></image> <view class="detail {{item.status === 6?'change-color':''}}"> <view class="area"> <text class="addr">{{item.addr}}</text> diff --git a/pages/my/my.js b/pages/my/my.js index 43fa4ae..f3ec6e7 100644 --- a/pages/my/my.js +++ b/pages/my/my.js @@ -187,7 +187,8 @@ Page({ app.post(url, { code: res.code, user_nickname: e.detail.userInfo.nickName, - avatar: e.detail.userInfo.avatarUrl + avatar: e.detail.userInfo.avatarUrl, + sex: e.detail.userInfo.gender, }, {}).then((ret) => { console.log('获取token', ret); wx.setStorageSync('token', ret.data.token); -- libgit2 0.24.0