Browse Source

feat(coach): 更新教练个人信息页面

- 修改头像上传功能,优化上传逻辑
- 完善个人信息展示和编辑功能
- 添加用户信息获取和更新接口调用
- 优化页面样式和布局
master
liutong 12 months ago
parent
commit
ac4339f14f
  1. 3
      pages/coach/my/index.vue
  2. 197
      pages/coach/my/info.vue

3
pages/coach/my/index.vue

@ -15,7 +15,8 @@
<view class="name">{{memberInfo.name}}</view> <view class="name">{{memberInfo.name}}</view>
</view> </view>
<view class="right"> <view class="right">
<view class="btn">切换身份</view> <view class="btn"></view>
<!-- <view class="btn">切换身份</view>-->
<view class="btn" @click="openViewArrivalStatistics()">到课率统计</view> <view class="btn" @click="openViewArrivalStatistics()">到课率统计</view>
<view class="btn"></view> <view class="btn"></view>
</view> </view>

197
pages/coach/my/info.vue

@ -1,11 +1,16 @@
<!--用户信息(教练)-详情--> <!--销售-个人资料-详情-->
<template> <template>
<view class="main_box"> <view class="main_box">
<view class="main_section"> <view class="main_section">
<view class="section"> <view class="section">
<view class="item"> <view class="item">
<image @click="changeAvatar()" class="pic" src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image> <image
@click="changeAvatar()"
class="pic"
:src="$util.img(formData.header)"
></image>
<view class="btn" @click="changeAvatar()">修改头像</view> <view class="btn" @click="changeAvatar()">修改头像</view>
</view> </view>
</view> </view>
@ -25,7 +30,7 @@
账号 <text class="required"></text> 账号 <text class="required"></text>
</view> </view>
<view class="input"> <view class="input">
<input disabled placeholder="暂无" /> <input v-model="formData.username" disabled placeholder="暂无" />
</view> </view>
</view> </view>
@ -43,7 +48,7 @@
等级 <text class="required"></text> 等级 <text class="required"></text>
</view> </view>
<view class="input"> <view class="input">
<input disabled placeholder="暂无" /> <input v-model="formData.member_level_name" disabled placeholder="暂无" />
</view> </view>
</view> </view>
</view> </view>
@ -54,7 +59,7 @@
性别 <text class="required">*</text> 性别 <text class="required">*</text>
</view> </view>
<view class="input"> <view class="input">
<input placeholder="请选择性别" v-model="sex_name" @click="picker_show_sex=true"/> <input placeholder="请选择性别" v-model="formData.gender" @click="picker_show_sex=true"/>
<fui-picker <fui-picker
layer="1" layer="1"
:linkage="true" :linkage="true"
@ -97,7 +102,7 @@
手机 <text class="required">*</text> 手机 <text class="required">*</text>
</view> </view>
<view class="input"> <view class="input">
<input v-model="formData.tel" placeholder="请输入手机" /> <input v-model="formData.phone" placeholder="请输入手机" />
</view> </view>
</view> </view>
@ -111,14 +116,16 @@
</view> </view>
</view> </view>
<view class="submet_btn">提交</view> <view class="submet_btn" @click="submit">提交</view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
// import user from '@/api/user.js'; import marketApi from '@/api/market.js';
import {Api_url} from "@/common/config.js"; import {
Api_url
} from "@/common/config.js";
import AQTabber from "@/components/AQ/AQTabber" import AQTabber from "@/components/AQ/AQTabber"
@ -129,30 +136,43 @@ export default {
data() { data() {
return { return {
formData:{ formData:{
images_arr:[], header:'',//
name:'',// name:'',//
email:'',// username:'',//
tel:'',// address:'',//
wx:'',// gender:'',//|,
sex:'',//
birthday:'',// birthday:'',//
email:'',//
phone:'',//
wx:'',//
}, },
userInfo: {},
//APi //APi
uploadUrl: `${Api_url}/salesmanapi/common/uploadFile`, uploadUrl: `${Api_url}/file/image`,
// //
picker_show_sex: false, picker_show_sex: false,
sex_name:'请选择', sex_name:'请选择',
options_sex_arr: [ options_sex_arr: [
{ value: 1, text: '男' }, {
{ value: 2, text: '女' }, value: 1,
text: '男'
},
{
value: 2,
text: '女'
},
], ],
// //
minDate: '', minDate: '',
maxDate: '', maxDate: '',
picker_show_birthday: false, picker_show_birthday: false,
upload_type: 1,
uploadHeadimg: '',
editHeadimg: '',
} }
}, },
onLoad() { onLoad() {
@ -163,7 +183,44 @@ export default {
methods: { methods: {
async init(){ async init(){
this.getBirthday() // this.getBirthday()
this.setDateYear()
await this.getUserInfo()
},
//
setDateYear() {
let currentYear = new Date().getFullYear();
this.minDate = String(currentYear - 100);
this.maxDate = String(currentYear + 1);
},
//
async getUserInfo(){
let res = await marketApi.member({})
if (res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
//
this.formData = {
header: res.data.headimg,//
name: res.data.name,//
username: res.data.username,//
address: res.data.address,//
gender: res.data.gender,//|,
birthday: res.data.birthday,//
email: res.data.email,//
phone: res.data.phone,//
wx: res.data.wx || '',//
member_level_name: res.data.member_level_name || '',//
}
console.log(123,this.formData);
}, },
// //
@ -179,34 +236,31 @@ export default {
} }
}) })
}, },
async uploadFilePromise(url) { uploadFilePromise(url) {
console.log('AQ',this.uploadUrl,url) let token = uni.getStorageSync('token') || ''
return new Promise((resolve, reject) => {
let a = uni.uploadFile({ let a = uni.uploadFile({
url: this.uploadUrl, // url: this.uploadUrl, //
filePath: url, filePath: url,
name: "file", name: 'file',
formData: { header: {
token: this.$store.state.token, 'token': `${token}`, //token
}, },
success: (e) => { success: (e) => {
console.log('上传成功1',e)
let res = JSON.parse(e.data.replace(/\ufeff/g, "") || "{}") let res = JSON.parse(e.data.replace(/\ufeff/g, "") || "{}")
console.log('上传成功2', res) console.log('上传成功2', res)
if (res.code >= 0){ if (res.code == 1) {
this.userInfo.pic = res.data.pic_path this.upload_type = 2
this.editPic(res.data.pic_path) this.formData.header = res.data.path
// this.editHeadimg = res.data.path
// this.uploadHeadimg = res.data.url
} else { } else {
this.$util.showToast({ uni.showToast({
title: res.message title: res.msg,
}); icon: 'none'
})
} }
setTimeout(() => {
resolve(res.data.data);
}, 1000);
}, },
}); });
});
}, },
//Api //Api
async editPic(pic) { async editPic(pic) {
@ -225,8 +279,7 @@ export default {
// //
changePickerSex(e) { changePickerSex(e) {
console.log('监听选择', e) console.log('监听选择', e)
this.sex_name = e.text this.formData.gender = e.text
this.formData.sex = e.value
this.picker_show_sex = false this.picker_show_sex = false
}, },
@ -277,6 +330,76 @@ export default {
this.picker_show_birthday = false this.picker_show_birthday = false
}, },
//
async submit() {
let data = {...this.formData}
if(!data.header){
uni.showToast({
title: '请上传头像',
icon: 'none'
})
return
}
if(!data.name){
uni.showToast({
title: '请填写',
icon: 'none'
})
return
}
if(!data.gender){
uni.showToast({
title: '请选择性别',
icon: 'none'
})
return
}
if(!data.birthday){
uni.showToast({
title: '请选择生日',
icon: 'none'
})
return
}
if(!data.email){
uni.showToast({
title: '请填写邮箱',
icon: 'none'
})
return
}
if(!data.phone){
uni.showToast({
title: '请填写手机',
icon: 'none'
})
return
}
let res = await marketApi.memberEdit(data)
if(res.code != 1){
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
uni.showToast({
title: res.msg,
icon: 'success'
})
this.getUserInfo()
},
} }
} }
</script> </script>

Loading…
Cancel
Save