From 841635097e9b2f08afd63ebb446588e87b6bcc58 Mon Sep 17 00:00:00 2001 From: fanp Date: Mon, 4 Nov 2019 10:19:21 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=B8=AA=E4=BA=BA=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA=E8=B5=84=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/user.js | 10 +++++-- pages/user/myInfo/index.js | 56 ++++++++++++------------------------ pages/user/myInfo/index.wxml | 21 +++++++------- pages/user/myInfo/index.wxss | 12 ++++++++ 4 files changed, 48 insertions(+), 51 deletions(-) diff --git a/models/user.js b/models/user.js index 49b4680..0d9aa52 100644 --- a/models/user.js +++ b/models/user.js @@ -26,20 +26,24 @@ class UserModel extends HTTP { } - updateUserInfo(avatarUrl, nickName, success){ + updateUserInfo(data, success){ let params = { url: UserConst.user_updateUserInfo_url, method: Method.POST, data: { isRegister: 2, //1.注册 2.修改用户信息 - avatar: avatarUrl, - realName: nickName, + avatar: data.avatarUrl, + realName: data.nickName, + phone: data.phone, + company: data.company, + position: data.position }, success: success } this.request(params) } + getMyMessageList(page, success){ let params = { url: UserConst.user_myMessage_url, diff --git a/pages/user/myInfo/index.js b/pages/user/myInfo/index.js index becffa6..6026688 100644 --- a/pages/user/myInfo/index.js +++ b/pages/user/myInfo/index.js @@ -10,7 +10,7 @@ Page({ */ data: { avatarUrl:String, - nikeName: String, + nickName: String, phone: String, company: String, position: String, @@ -23,7 +23,7 @@ Page({ console.log(options) this.setData({ avatarUrl: options.userIcon, - nikeName: options.userName, + nickName: options.userName, phone: options.userPhone || '', company: options.company || '', position: options.position || '', @@ -32,9 +32,9 @@ Page({ onTapItem(e) { const { type } = e.currentTarget.dataset console.log(type) - // if(type === 'userIcon'){ - // this.upload() - // } + if(type === 'userIcon'){ + this.upload() + } }, upload(){ let that = this @@ -69,34 +69,16 @@ Page({ } }) }, - getUserInfo(){ - userModel.getUserInfo(res => { - let nickName = res.result.nickName - let avatarUrl = res.result.avatarUrl - this.setData({ - avatarUrl: res.result.avatarUrl, - nikeName: res.result.nickName, - phone: res.result.phone || '', - company: res.result.company || '', - position: res.result.position || '', - }) - store.saveUserInfo({ - nickName: res.result.nickName, - avatarUrl: res.result.avatarUrl, - phone: res.result.phone || '' - }) - }) - }, - bindNikeNameInput(e){ + bindNickNameInput(e){ this.setData({ - nikeName:e.detail.value - }) - }, - bindPhoneInput(e) { - this.setData({ - phone: e.detail.value + nickName:e.detail.value }) }, + // bindPhoneInput(e) { + // this.setData({ + // phone: e.detail.value + // }) + // }, bindCompanyInput(e) { this.setData({ company: e.detail.value @@ -108,15 +90,13 @@ Page({ }) }, submit(){ - let avatarUrl = this.data.avatarUrl - let nikeName = this.data.nikeName - let phone = this.data.phone - let company = this.data.company - let position = this.data.position - - userModel.updateUserInfo(avatarUrl, nikeName, phone, company, position, res => { - // that.getUserInfo() + userModel.updateUserInfo(this.data, res => { if(res.code === 200){ + store.saveUserInfo({ + nickName: this.data.nickName, + avatarUrl: this.data.avatarUrl, + phone: this.data.phone || '' + }) wx.showToast({ title: '修改成功', icon: 'none', diff --git a/pages/user/myInfo/index.wxml b/pages/user/myInfo/index.wxml index 571a821..5bb46cb 100644 --- a/pages/user/myInfo/index.wxml +++ b/pages/user/myInfo/index.wxml @@ -4,6 +4,7 @@ @@ -11,32 +12,32 @@ bindtap="onTapItem" data-type="userName" title="名字" ext-class="cell-item"> - {{nikeName}} - + + - {{phone}} - + + - {{company}} - + + - {{position}} - + + - + diff --git a/pages/user/myInfo/index.wxss b/pages/user/myInfo/index.wxss index c1af3ba..84b4e1f 100644 --- a/pages/user/myInfo/index.wxss +++ b/pages/user/myInfo/index.wxss @@ -59,11 +59,23 @@ padding: 0 10px 0 0; } .footer_input{ + padding: 0 5px; font-size: 14px; border: 1px solid #AAAAAA; border-radius: 4px; height: 30px; text-align: left; + color: #3B3B3B; +} +.footer_input_phone{ + padding: 0 5px; + font-size: 14px; + border: 1px solid #AAAAAA; + border-radius: 4px; + height: 30px; + text-align: left; + color: #3B3B3B; + background-color: #f7f7f7; } .msg_footer{ font-size: 14px;