作者 mxd

教师端:修改个人资料

... ... @@ -6,16 +6,23 @@
<view class="oneSettingV2-c-1-l">头像</view>
<view class="oneSettingV2-c-1-r">
<avatar selWidth="100rpx" selHeight="100rpx" @upload="myUpload"
:avatarSrc="userdata.img?$service.getimg(userdata.img):imgUrl"
:avatarSrc="userdata.img?$service.getimg(userdata.img):'/static/images/tx.png'"
avatarStyle="width: 100rpx;height: 100rpx;border-radius: 50%;" inner=true></avatar>
</view>
</view>
<view class="oneSettingV2-c-1">
<view class="oneSettingV2-c-1-l">姓名</view>
<view class="oneSettingV2-c-1-r">{{userdata.title}}</view>
<view class="oneSettingV2-c-1-r">
<input v-model="userdata.title" placeholder="请输入" />
</view>
</view>
</view>
<view class="btn" @click="submit">
提交
</view>
</view>
</view>
</template>
... ... @@ -23,48 +30,32 @@
<script>
import Vue from 'vue'
import {
mapState,
mapMutations
mapState
} from 'vuex'
var that
export default {
data() {
return {
imgUrl: '/static/images/tx.png',
userName: "学员01",
gender: "男",
studentNum: "ZZ202012058",
identity:0,
userdata:{
img:''
}
userdata: {}
}
},
onLoad(option) {
that=this
console.log(option);
this.identity=uni.getStorageSync('identity')
this.userdata=this.userDatas
},
computed: {
...mapState(['userDatas']),
...mapState(['userDatas']),
},
methods: {
// 更新头像
myUpload(rsp) {
var avatar = rsp.path
// console.log(avatar)
// Vue.set(that.userdata,'head_portrait',avatar)
// return
this.$service.wx_upload(avatar).then(res => {
that.btn_kg = 0
this.btn_kg = 0
console.log(res)
if (res.code == 1) {
var datas = res.data
console.log(that.userdata)
Vue.set(that.userdata,'img',datas)
that.setmsg()
console.log('datas', datas)
Vue.set(this.userdata,'img',datas)
} else {
if (res.msg) {
uni.showToast({
... ... @@ -79,7 +70,7 @@
}
}
}).catch(e => {
that.btn_kg = 0
this.btn_kg = 0
console.log(e)
uni.showToast({
icon: 'none',
... ... @@ -87,27 +78,28 @@
})
})
},
setmsg(){
var datas = {
img:that.userdata.img
}
var jkurl = '/my/save'
that.$service.P_post(jkurl, datas).then(res => {
that.btnkg = 0
console.log(res)
submit() {
uni.showLoading({
title: '提交中',
mask: true
})
const { img, title } = this.userdata;
this.$service.P_post('/lecturer/update_info', {
img_url: img,
title,
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
that.htmlReset = 0
var datas = res.data
console.log(typeof datas)
if (typeof datas == 'string') {
datas = JSON.parse(datas)
}
console.log(res)
} else {
uni.showToast({
icon:'none',
title:'保存成功'
})
setTimeout(function(){
uni.navigateBack()
},1000)
}else {
if (res.msg) {
uni.showToast({
icon: 'none',
... ... @@ -120,25 +112,15 @@
})
}
}
}).catch(e => {
that.htmlReset = 1
that.btnkg = 0
// that.$refs.htmlLoading.htmlReset_fuc(1)
console.log(e)
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
},
getimg(img){
return this.$service.getimg(img)
},
logout_fuc(){
uni.removeStorageSync('token')
uni.reLaunch({
url:'/pages/login/login'
})
}
}
}
... ... @@ -168,6 +150,8 @@
.oneSettingV2-c-1-r{
font-size: 28rpx;
color: #646464;
flex: 1;
text-align: right;
}
}
}
... ... @@ -259,4 +243,17 @@
color: #2D81FF;
}
}
.btn {
height: 88rpx;
line-height: 88rpx;
background: #2D81FF;
border-radius: 44rpx;
text-align: center;
font-size: 34rpx;
font-family: PingFang SC;
font-weight: 500;
color: #FFFFFF;
}
</style>
... ...