作者 wumengyu

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

... ... @@ -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);
... ...
... ... @@ -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);
... ...
... ... @@ -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();
... ...
... ... @@ -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>
... ...
... ... @@ -28,7 +28,7 @@
font-size: 26rpx;
color: #666666;
}
.text input, .phone-box input {
.text input, .phone-box text {
font-size: 26rpx;
color: #666666;
}
... ...
... ... @@ -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>
... ...
... ... @@ -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);
... ...