Browse Source

个人信息修改页面 街道 手机号码

master
chenteng 5 years ago
parent
commit
c35ce21a21
  1. 1
      app.json
  2. 2
      models/auth.js
  3. 21
      models/user.js
  4. 3
      pages/user/index.js
  5. 70
      pages/user/myInfo/index.js
  6. 25
      pages/user/myInfo/index.wxml

1
app.json

@ -17,6 +17,7 @@
"pages/user/myMessage/index", "pages/user/myMessage/index",
"pages/user/myTopics/index", "pages/user/myTopics/index",
"pages/user/myInfo/index", "pages/user/myInfo/index",
"pages/user/myInfo/register/index",
"pages/topics/interactive/submitTopic/index", "pages/topics/interactive/submitTopic/index",
"pages/topics/interactive/topicArticle/index", "pages/topics/interactive/topicArticle/index",
"pages/billboards/park/park-category/index", "pages/billboards/park/park-category/index",

2
models/auth.js

@ -2,7 +2,7 @@ import { HTTP, Method, HTTPConst } from '../utils/http.js'
const AuthConst = { const AuthConst = {
check_register_url: '/api/miniuser/isRegister', check_register_url: '/api/miniuser/isRegister',
mobile_code_url: '/api/miniuser/getSmsCode', // 获取验证码 mobile_code_url: '/api/miniuser/getSmsCode1', // 获取验证码
verify_update_phone_url: '/api/miniuser/updateMiniUser' // mobile 验证 verify_update_phone_url: '/api/miniuser/updateMiniUser' // mobile 验证
} }
class AuthModel extends HTTP { class AuthModel extends HTTP {

21
models/user.js

@ -14,7 +14,9 @@ const UserConst = {
user_myWhistle_url:'/api/whistle/getMyWhistleList',// 我的吹哨 user_myWhistle_url:'/api/whistle/getMyWhistleList',// 我的吹哨
user_whistleDetail_url:'/api/whistle/getWhistleById', // 吹哨详情 user_whistleDetail_url:'/api/whistle/getWhistleById', // 吹哨详情
user_saveWhistleComment_url:'/api/whistle/saveComment' // 吹哨评价 user_saveWhistleComment_url:'/api/whistle/saveComment' ,// 吹哨评价
user_updatePhone_url:'/api/miniuser/updatephone',//更新电话号码
} }
class UserModel extends HTTP { class UserModel extends HTTP {
constructor () { constructor () {
@ -40,8 +42,8 @@ class UserModel extends HTTP {
isRegister: 2, //1.注册 2.修改用户信息 isRegister: 2, //1.注册 2.修改用户信息
avatar: data.avatarUrl, avatar: data.avatarUrl,
realName: data.nickName, realName: data.nickName,
phone: data.phone, // phone: data.phone,//注释此行,submit无法更新phone
departId:data.street, departId:data.streetsIndex,
age:data.age, age:data.age,
gender:data.genderIndex, gender:data.genderIndex,
company: data.company, company: data.company,
@ -211,6 +213,19 @@ class UserModel extends HTTP {
} }
this.request(params) this.request(params)
} }
//更新电话号码
updatephone(phone,code,success){
let params = {
url:UserConst.user_updatePhone_url,
method: Method.POST,
data: {
phone:phone,
code:code,
},
success: success
}
this.request(params)
}
} }
export { UserModel } export { UserModel }

3
pages/user/index.js

@ -108,6 +108,9 @@ Page({
if(this.data.isAuth){ if(this.data.isAuth){
if (type === 'myInfo') { if (type === 'myInfo') {
console.log('进入个人信息页面');
console.log(this.data.userInfo);
wx.navigateTo({ wx.navigateTo({
url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}&street=${this.data.userInfo.departId || ''}&age=${this.data.userInfo.age || ''}&genderIndex=${this.data.userInfo.gender || ''}&education=${this.data.userInfo.education || ''}&professionalTitle=${this.data.userInfo.title || ''}&talentTitle=${this.data.userInfo.designation || ''}&prize=${this.data.userInfo.honor || ''}`, url: `/pages/user/${type}/index?userIcon=${this.data.userInfo.avatarUrl}&userName=${this.data.userInfo.nickName}&userPhone=${this.data.userInfo.phone || ''}&company=${this.data.userInfo.company || ''}&position=${this.data.userInfo.position || ''}&street=${this.data.userInfo.departId || ''}&age=${this.data.userInfo.age || ''}&genderIndex=${this.data.userInfo.gender || ''}&education=${this.data.userInfo.education || ''}&professionalTitle=${this.data.userInfo.title || ''}&talentTitle=${this.data.userInfo.designation || ''}&prize=${this.data.userInfo.honor || ''}`,
}) })

70
pages/user/myInfo/index.js

@ -2,6 +2,9 @@
import { store } from '../../../utils/store.js' import { store } from '../../../utils/store.js'
import { config } from '../../../config.js' import { config } from '../../../config.js'
import { UserModel } from '../../../models/user.js' import { UserModel } from '../../../models/user.js'
import { TopicModel } from '../../../models/topic.js'
let topicModel = new TopicModel()
let userModel = new UserModel() let userModel = new UserModel()
Page({ Page({
@ -14,7 +17,8 @@ Page({
phone: String, phone: String,
company: String, company: String,
position: String, position: String,
street:String, streets:[],
streetsIndex:Number,
age:String, age:String,
gender:['','男','女'], gender:['','男','女'],
genderIndex:Number, genderIndex:Number,
@ -31,37 +35,26 @@ Page({
}, },
getUserInfo(event) { getUserInfo(event) {
console.log(event.detail);
}, },
onClose() { onClose() {
this.setData({ close: false }); this.setData({ close: false });
}, },
vantConfirm(){ vantConfirm(){
console.log("vant confirm");
this.setData({ this.setData({
realData:this.data.tempData realData:this.data.tempData
}) })
console.log(this.data.realData);
if(this.data.type === 'userName'){ if(this.data.type === 'userName'){
this.setData({ this.setData({
nickName:this.data.realData nickName:this.data.realData
}) })
} }
if(this.data.type === 'userPhone'){
this.setData({
phone:this.data.realData
})
}
if(this.data.type === 'userStreet'){
this.setData({
street:this.data.realData
})
}
if(this.data.type === 'userAge'){ if(this.data.type === 'userAge'){
this.setData({ this.setData({
age:this.data.realData age:this.data.realData
}) })
} }
if(this.data.type === 'workUnit'){ if(this.data.type === 'workUnit'){
this.setData({ this.setData({
@ -105,15 +98,13 @@ Page({
}, },
onLoad: function (options) { onLoad: function (options) {
console.log("index.js");
console.log(options)
this.setData({ this.setData({
avatarUrl: options.userIcon, avatarUrl: options.userIcon,
nickName: options.userName, nickName: options.userName,
phone: options.userPhone || '', phone: options.userPhone || '',
company: options.company || '', company: options.company || '',
position: options.position || '', position: options.position || '',
street:options.street || '', streetsIndex:options.street || '',
age:options.age || '', age:options.age || '',
genderIndex:options.genderIndex || '', genderIndex:options.genderIndex || '',
educationIndex:options.education || '', educationIndex:options.education || '',
@ -121,15 +112,28 @@ Page({
talentTitle:options.talentTitle || '', talentTitle:options.talentTitle || '',
prize:options.prize || '', prize:options.prize || '',
}) })
topicModel.getStreetList(res=>{
var resultss = res.result
var streett = []
resultss.forEach((value,index)=>{
streett[index] = value.departName
})
streett.unshift('')
// console.log(streett)
this.setData({
streets: streett
})
// console.log("查看data里streets的值");
// console.log(this.data.streetsIndex);
})
}, },
//性别和学历有专门的bind方法。此方法修改年龄,工作单位,职务,职称等
onTapItem(e) { onTapItem(e) {
const { type } = e.currentTarget.dataset const { type } = e.currentTarget.dataset
this.setData({ this.setData({
type:type type:type
}) })
console.log(type)
//如果等于userIcon调用upload方法更新头像
if(type === 'userIcon'){ if(type === 'userIcon'){
this.upload() this.upload()
}else{ }else{
@ -145,7 +149,7 @@ Page({
success(res) { success(res) {
wx.showLoading() wx.showLoading()
const tempFilePaths = res.tempFilePaths const tempFilePaths = res.tempFilePaths
console.log(res) // console.log(res)
const token = store.readToken() const token = store.readToken()
wx.uploadFile({ wx.uploadFile({
url: config.api_url + "/api/common/upload", url: config.api_url + "/api/common/upload",
@ -156,7 +160,7 @@ Page({
}, },
name: 'files', name: 'files',
success(res) { success(res) {
console.log(res); // console.log(res);
const data = JSON.parse(res.data) const data = JSON.parse(res.data)
const image = { const image = {
url: config.api_url + '/' + data.result.imgUrl, url: config.api_url + '/' + data.result.imgUrl,
@ -192,18 +196,24 @@ Page({
// }) // })
// }, // },
bindGenderChange: function(e) { bindGenderChange: function(e) {
console.log("bindGenderChange");
console.log(e);
this.setData({ this.setData({
genderIndex:e.detail.value genderIndex:e.detail.value
}) })
console.log(this.data.genderIndex);
}, },
bindEducationChange:function(e){ bindEducationChange:function(e){
this.setData({ this.setData({
educationIndex:e.detail.value educationIndex:e.detail.value
}) })
console.log(this.data.educationIndex); },
bindstreetChange:function(e){
this.setData({
streetsIndex:e.detail.value
})
},
onTapPhone:function(){
wx.navigateTo({
url:'../myInfo/register/index'
})
}, },
submit(){ submit(){
console.log("submit"); console.log("submit");
@ -214,12 +224,12 @@ Page({
nickName: this.data.nickName, nickName: this.data.nickName,
avatarUrl: this.data.avatarUrl, avatarUrl: this.data.avatarUrl,
phone: this.data.phone || '', phone: this.data.phone || '',
departId:this.data.street, departId:this.data.streetsIndex,
age:this.data.age, age:this.data.age,
gender:this.data.genderIndex,// gender:this.data.genderIndex,
company:this.data.company, company:this.data.company,
position:this.data.position, position:this.data.position,
education:this.data.educationIndex,// education:this.data.educationIndex,
title:this.data.professionalTitle, title:this.data.professionalTitle,
designation:this.data.talentTitle, designation:this.data.talentTitle,
honor:this.data.prize honor:this.data.prize

25
pages/user/myInfo/index.wxml

@ -16,20 +16,39 @@
<!-- <view slot="footer" class="msg_footer" >{{nikeName}}</view> --> <!-- <view slot="footer" class="msg_footer" >{{nikeName}}</view> -->
<input slot="footer" style="text-align:right;" class="footer_input_phone" maxlength="120" bindinput="bindNickNameInput" value="{{nickName}}" disabled placeholder="请输入"></input> <input slot="footer" style="text-align:right;" class="footer_input_phone" maxlength="120" bindinput="bindNickNameInput" value="{{nickName}}" disabled placeholder="请输入"></input>
</mp-cell> </mp-cell>
<mp-cell link="true" <mp-cell link="true"
data-type="userPhone" data-type="userPhone"
title="手机号" bindtap="onTapItem" title="手机号" bindtap="onTapPhone"
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" style="text-align:right;" class="footer_input_phone" maxlength="45" bindinput="bindPhoneInput" value="{{phone}}" disabled placeholder="请输入"></input> <input slot="footer" style="text-align:right;" class="footer_input_phone" maxlength="45" bindinput="bindPhoneInput" value="{{phone}}" disabled placeholder="请输入"></input>
</mp-cell> </mp-cell>
<!-- 新加的 所在街道 年龄 性别 --> <!-- 新加的 所在街道 年龄 性别 -->
<mp-cell link="true" <mp-cell link="true"
data-type="userStreet" data-type="userStreet"
title="所在街道" bindtap="onTapItem" 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" style="text-align:right;" class="footer_input_phone" maxlength="45" bindinput="bindStreetInput" value="{{street}}" disabled placeholder=""></input> <picker slot="footer" class="footer_input_phone picker-view" range="{{streets}}" bindchange="bindstreetChange">
<view class="picker-block">
<block wx:if="{{streetsIndex == 0}}" >
<view class="picker-if">
请选择
</view>
</block>
<block wx:else>
{{streets[streetsIndex]}}
</block>
</view>
</picker>
</mp-cell> </mp-cell>
<!-- 上面的数据不能修改 --> <!-- 上面的数据不能修改 -->
<mp-cell link="true" <mp-cell link="true"

Loading…
Cancel
Save