Browse Source

update 个人中心 修改个人资料

master
fanp 6 years ago
parent
commit
841635097e
  1. 10
      models/user.js
  2. 56
      pages/user/myInfo/index.js
  3. 21
      pages/user/myInfo/index.wxml
  4. 12
      pages/user/myInfo/index.wxss

10
models/user.js

@ -26,20 +26,24 @@ class UserModel extends HTTP {
} }
updateUserInfo(avatarUrl, nickName, success){ updateUserInfo(data, success){
let params = { let params = {
url: UserConst.user_updateUserInfo_url, url: UserConst.user_updateUserInfo_url,
method: Method.POST, method: Method.POST,
data: { data: {
isRegister: 2, //1.注册 2.修改用户信息 isRegister: 2, //1.注册 2.修改用户信息
avatar: avatarUrl, avatar: data.avatarUrl,
realName: nickName, realName: data.nickName,
phone: data.phone,
company: data.company,
position: data.position
}, },
success: success success: success
} }
this.request(params) this.request(params)
} }
getMyMessageList(page, success){ getMyMessageList(page, success){
let params = { let params = {
url: UserConst.user_myMessage_url, url: UserConst.user_myMessage_url,

56
pages/user/myInfo/index.js

@ -10,7 +10,7 @@ Page({
*/ */
data: { data: {
avatarUrl:String, avatarUrl:String,
nikeName: String, nickName: String,
phone: String, phone: String,
company: String, company: String,
position: String, position: String,
@ -23,7 +23,7 @@ Page({
console.log(options) console.log(options)
this.setData({ this.setData({
avatarUrl: options.userIcon, avatarUrl: options.userIcon,
nikeName: options.userName, nickName: options.userName,
phone: options.userPhone || '', phone: options.userPhone || '',
company: options.company || '', company: options.company || '',
position: options.position || '', position: options.position || '',
@ -32,9 +32,9 @@ Page({
onTapItem(e) { onTapItem(e) {
const { type } = e.currentTarget.dataset const { type } = e.currentTarget.dataset
console.log(type) console.log(type)
// if(type === 'userIcon'){ if(type === 'userIcon'){
// this.upload() this.upload()
// } }
}, },
upload(){ upload(){
let that = this let that = this
@ -69,34 +69,16 @@ Page({
} }
}) })
}, },
getUserInfo(){ bindNickNameInput(e){
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){
this.setData({ this.setData({
nikeName:e.detail.value nickName:e.detail.value
})
},
bindPhoneInput(e) {
this.setData({
phone: e.detail.value
}) })
}, },
// bindPhoneInput(e) {
// this.setData({
// phone: e.detail.value
// })
// },
bindCompanyInput(e) { bindCompanyInput(e) {
this.setData({ this.setData({
company: e.detail.value company: e.detail.value
@ -108,15 +90,13 @@ Page({
}) })
}, },
submit(){ submit(){
let avatarUrl = this.data.avatarUrl userModel.updateUserInfo(this.data, res => {
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()
if(res.code === 200){ if(res.code === 200){
store.saveUserInfo({
nickName: this.data.nickName,
avatarUrl: this.data.avatarUrl,
phone: this.data.phone || ''
})
wx.showToast({ wx.showToast({
title: '修改成功', title: '修改成功',
icon: 'none', icon: 'none',

21
pages/user/myInfo/index.wxml

@ -4,6 +4,7 @@
<mp-cell <mp-cell
bindtap="onTapItem" data-type="userIcon" bindtap="onTapItem" data-type="userIcon"
title="头像" title="头像"
link="true"
ext-class="cell-item"> ext-class="cell-item">
<image slot="footer" class="user_logo" src="{{avatarUrl}}" /> <image slot="footer" class="user_logo" src="{{avatarUrl}}" />
</mp-cell> </mp-cell>
@ -11,32 +12,32 @@
bindtap="onTapItem" data-type="userName" bindtap="onTapItem" data-type="userName"
title="名字" title="名字"
ext-class="cell-item"> ext-class="cell-item">
<view slot="footer" class="msg_footer" >{{nikeName}}</view> <!-- <view slot="footer" class="msg_footer" >{{nikeName}}</view> -->
<!-- <input slot="footer" class="footer_input" bindinput="bindNikeNameInput" value="{{nikeName}}"></input> --> <input slot="footer" class="footer_input" maxlength="120" bindinput="bindNickNameInput" value="{{nickName}}"></input>
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="userPhone" bindtap="onTapItem" data-type="userPhone"
title="手机号" title="手机号"
ext-class="cell-item"> ext-class="cell-item">
<view slot="footer" class="msg_footer" >{{phone}}</view> <!-- <view slot="footer" class="msg_footer" >{{phone}}</view> -->
<!-- <input slot="footer" class="footer_input" bindinput="bindPhoneInput" value="{{phone}}"></input> --> <input slot="footer" class="footer_input_phone" maxlength="45" bindinput="bindPhoneInput" value="{{phone}}" disabled></input>
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="workUnit" bindtap="onTapItem" data-type="workUnit"
title="工作单位" title="工作单位"
ext-class="cell-item"> ext-class="cell-item">
<view slot="footer" class="msg_footer" >{{company}}</view> <!-- <view slot="footer" class="msg_footer" >{{company}}</view> -->
<!-- <input slot="footer" class="footer_input" bindinput="bindCompanyInput" value="{{company}}"></input> --> <input slot="footer" class="footer_input" maxlength="45" bindinput="bindCompanyInput" value="{{company}}"></input>
</mp-cell> </mp-cell>
<mp-cell <mp-cell
bindtap="onTapItem" data-type="position" bindtap="onTapItem" data-type="position"
title="职务" title="职务"
ext-class="cell-item"> ext-class="cell-item">
<view slot="footer" class="msg_footer" >{{position}}</view> <!-- <view slot="footer" class="msg_footer" >{{position}}</view> -->
<!-- <input slot="footer" class="footer_input" bindinput="bindPositionInput" value="{{position}}"></input> --> <input slot="footer" class="footer_input" maxlength="45" bindinput="bindPositionInput" value="{{position}}"></input>
</mp-cell> </mp-cell>
<!-- <view class="btnView"> <view class="btnView">
<e-ibutton title="提交" bind:onTap="submit"/> <e-ibutton title="提交" bind:onTap="submit"/>
</view> --> </view>
</mp-cells> </mp-cells>
</view> </view>

12
pages/user/myInfo/index.wxss

@ -59,11 +59,23 @@
padding: 0 10px 0 0; padding: 0 10px 0 0;
} }
.footer_input{ .footer_input{
padding: 0 5px;
font-size: 14px; font-size: 14px;
border: 1px solid #AAAAAA; border: 1px solid #AAAAAA;
border-radius: 4px; border-radius: 4px;
height: 30px; height: 30px;
text-align: left; 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{ .msg_footer{
font-size: 14px; font-size: 14px;

Loading…
Cancel
Save