From d711edc33e51550f2216668afb78103fc1d8be54 Mon Sep 17 00:00:00 2001 From: chenteng <17864191895@163.com> Date: Fri, 31 Jul 2020 16:42:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=BF=A1=E6=81=AF=20?= =?UTF-8?q?=E8=A1=97=E9=81=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user.js | 2 +- pages/user/myInfo/index.js | 46 +++++++++++++++++++++--------------- pages/user/myInfo/index.wxml | 25 +++++++------------- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/models/user.js b/models/user.js index 62c9845..b57a634 100644 --- a/models/user.js +++ b/models/user.js @@ -43,7 +43,7 @@ class UserModel extends HTTP { avatar: data.avatarUrl, realName: data.nickName, // phone: data.phone,//注释此行,submit无法更新phone - departId:data.streetsIndex, + departId:data.streetsID, age:data.age, gender:data.genderIndex, company: data.company, diff --git a/pages/user/myInfo/index.js b/pages/user/myInfo/index.js index 89005bd..cd5a2a9 100644 --- a/pages/user/myInfo/index.js +++ b/pages/user/myInfo/index.js @@ -17,8 +17,9 @@ Page({ phone: String, company: String, position: String, - streets:[], + streets:[], streetsIndex:Number, + streetsID:String, age:String, gender:['','男','女'], genderIndex:Number, @@ -41,7 +42,6 @@ Page({ this.setData({ close: false }); }, vantConfirm(){ - this.setData({ realData:this.data.tempData }) @@ -104,7 +104,7 @@ Page({ phone: options.userPhone || '', company: options.company || '', position: options.position || '', - streetsIndex:options.street || '', + streetsID:options.street || '',//得到streetsID的值 age:options.age || '', genderIndex:options.genderIndex || '', educationIndex:options.education || '', @@ -119,12 +119,14 @@ Page({ streett[index] = value.departName }) streett.unshift('') - // console.log(streett) this.setData({ - streets: streett + streets: streett//得到street列表 + }) + resultss.forEach((value,index)=>{ + if(value.id == this.data.streetsID){ + return this.setData({streetsIndex: index+1}) + } }) - // console.log("查看data里streets的值"); - // console.log(this.data.streetsIndex); }) }, @@ -175,11 +177,11 @@ Page({ } }) }, - bindNickNameInput(e){ - this.setData({ - nickName:e.detail.value - }) - }, + // bindNickNameInput(e){ + // this.setData({ + // nickName:e.detail.value + // }) + // }, // bindPhoneInput(e) { // this.setData({ // phone: e.detail.value @@ -204,11 +206,17 @@ Page({ this.setData({ educationIndex:e.detail.value }) - }, + }, bindstreetChange:function(e){ - this.setData({ - streetsIndex:e.detail.value - }) + // console.log("bindstreetChange"); + // console.log(e.detail.value); + var i = e.detail.value-1 + topicModel.getStreetList(res=>{ + this.setData({ + streetsIndex:e.detail.value, + streetsID:res.result[i].id + }) + }) }, onTapPhone:function(){ wx.navigateTo({ @@ -216,15 +224,15 @@ Page({ }) }, submit(){ - console.log("submit"); - console.log(this.data); + // console.log("submit"); + // console.log(this.data); userModel.updateUserInfo(this.data, res => { if(res.code === 200){ store.saveUserInfo({ nickName: this.data.nickName, avatarUrl: this.data.avatarUrl, phone: this.data.phone || '', - departId:this.data.streetsIndex, + departId:this.data.streetsID, age:this.data.age, gender:this.data.genderIndex, company:this.data.company, diff --git a/pages/user/myInfo/index.wxml b/pages/user/myInfo/index.wxml index e0379e0..973d57d 100644 --- a/pages/user/myInfo/index.wxml +++ b/pages/user/myInfo/index.wxml @@ -14,23 +14,15 @@ title="姓名" bindtap="onTapItem" ext-class="cell-item"> - + - - - - - + - - - - - - + - + - + @@ -117,21 +108,21 @@ title="职称" ext-class="cell-item"> - + - + - +