Browse Source

update 修改上传用户信息

master
fanp 6 years ago
parent
commit
f0c75eba39
  1. 22
      models/user.js
  2. 12
      pages/user/index.js
  3. 20
      pages/user/myInfo/index.js
  4. 4
      pages/user/myInfo/index.wxml

22
models/user.js

@ -8,7 +8,8 @@ const UserConst = {
user_myTopics_url:'/api/group/groupByUser', // 我的议题
user_myActivity_url:'/api/activity/activityList', // 我的活动
user_updateUserInfo_url:'/api/miniuser/updateMiniUser' // 更新用户信息
user_updateUserInfo_url:'/api/miniuser/updateMiniUser', // 更新用户信息
user_sendUserInfo_url:'/api/miniuser/updateUserInfo' // 上传用户信息
}
class UserModel extends HTTP {
constructor () {
@ -43,7 +44,24 @@ class UserModel extends HTTP {
this.request(params)
}
sendUserInfo(weChatInfo,success){
let params = {
url: UserConst.user_sendUserInfo_url,
method: Method.POST,
data: {
avatarUrl: weChatInfo.avatarUrl,
city: weChatInfo.city,
country: weChatInfo.country,
gender: weChatInfo.gender,
nickName: weChatInfo.nickName,
province: weChatInfo.province
},
success: success
}
this.request(params)
}
getMyMessageList(page, success){
let params = {
url: UserConst.user_myMessage_url,

12
pages/user/index.js

@ -44,19 +44,19 @@ Page({
if (e.detail.userInfo){
let avatarUrl = e.detail.userInfo.avatarUrl
let nickName = e.detail.userInfo.nickName
this.updateUserInfo(avatarUrl,nickName)
this.sendUserInfo(e.detail.userInfo)
}
},
// 将用户信息发送服务器
updateUserInfo (avatarUrl, nickName) {
userModel.updateUserInfo(avatarUrl, nickName, res => {
if(res.code === 200){
// 上传用户信息
sendUserInfo(weChatInfo){
userModel.sendUserInfo(weChatInfo, res => {
if (res.code === 200) {
this.getUserInfo()
}
})
},
// 获取用户信息
getUserInfo () {
userModel.getUserInfo(res => {

20
pages/user/myInfo/index.js

@ -79,16 +79,16 @@ Page({
// phone: e.detail.value
// })
// },
bindCompanyInput(e) {
this.setData({
company: e.detail.value
})
},
bindPositionInput(e) {
this.setData({
position: e.detail.value
})
},
// bindCompanyInput(e) {
// this.setData({
// company: e.detail.value
// })
// },
// bindPositionInput(e) {
// this.setData({
// position: e.detail.value
// })
// },
submit(){
userModel.updateUserInfo(this.data, res => {
if(res.code === 200){

4
pages/user/myInfo/index.wxml

@ -27,14 +27,14 @@
title="工作单位"
ext-class="cell-item">
<!-- <view slot="footer" class="msg_footer" >{{company}}</view> -->
<input slot="footer" class="footer_input" maxlength="45" bindinput="bindCompanyInput" value="{{company}}"></input>
<input slot="footer" class="footer_input_phone" maxlength="45" bindinput="bindCompanyInput" value="{{company}}" disabled></input>
</mp-cell>
<mp-cell
bindtap="onTapItem" data-type="position"
title="职务"
ext-class="cell-item">
<!-- <view slot="footer" class="msg_footer" >{{position}}</view> -->
<input slot="footer" class="footer_input" maxlength="45" bindinput="bindPositionInput" value="{{position}}"></input>
<input slot="footer" class="footer_input_phone" maxlength="45" bindinput="bindPositionInput" value="{{position}}" disabled></input>
</mp-cell>
<view class="btnView">
<e-ibutton title="提交" bind:onTap="submit"/>

Loading…
Cancel
Save