<template>
<div class="studio-z">
<div class="studio-card">
<div class="s-card-img">
<img :src="doctorinfo.work_img" alt="" @click='show=true'>
<div class="card-v" :style="doctorinfo.approval_status=='approved'?'display:block':'display:none'">v</div>
</div>
<div class="s-card-name">{{doctorinfo.name}}</div>
<div class="s-card-about">{{doctorinfo.hospital?doctorinfo.hospital.name:""}} {{doctorinfo.department?doctorinfo.department.name:""}} {{doctorinfo.job_title?doctorinfo.job_title.name:""}}</div>
</div>
<div class="studio-list-z">
<router-link :to="{path:'writeinfo'}">
<div class="studio-list">
<div class="studio-list-name">我的基本资料</div>
<img src="../../assets/img/jiantou.jpg" alt="">
</div>
</router-link>
<router-link :to="{path:'Register'}">
<div class="studio-list">
<div class="studio-list-name">我的坐诊</div>
<img src="../../assets/img/jiantou.jpg" alt="">
</div>
</router-link>
<router-link :to="{path:'MyArticle'}">
<div class="studio-list">
<div class="studio-list-name">我的文章</div>
<img src="../../assets/img/jiantou.jpg" alt="">
</div>
</router-link>
<div class="studio-list">
<div class="studio-list-name">网络资讯</div>
<van-switch class="wlzx-btn" v-model="checked" size="20px"/>
</div>
<!-- <div class="studio-list">
<div class="studio-list-name">停诊通知</div>
<img src="../../assets/img/jiantou.jpg" alt="">
</div> -->
</div>
<van-action-sheet
v-model="show"
cancel-text="取消"
>
<!-- <div style="width:100%;display:flex;justify-content: center;"> -->
<van-uploader :after-read="afterRead" style="width:100%">
<van-button icon="photo" type="primary" style="width:100%;text-align:center; height: 50px;">修改头像</van-button>
</van-uploader>
<!-- </div> -->
</van-action-sheet>
<!-- <van-button icon="photo" type="primary">上传文件</van-button> -->
</div>
</template>
<script>
// components
import {Getdoctorinfo,ChageConsultation} from '../../api/studio.js'
import {Switch, ActionSheet,Uploader,Button } from 'vant'
import {Uppadimg} from '../../api/identity.js'
import {putData} from '../../api/user.js'
export default {
name: 'studio',
components: { 'van-action-sheet':ActionSheet,"van-uploader":Uploader,"van-button":Button },
data () {
return {
doctorinfo:{user:{avatar:{}},hospital:{},department:{},job_title:{}},
checked:false,
consult_enable:'',//网络咨询1:已开启 0:未开启
action:null,
show:false,
}
},
computed: {},
created () {
this.getme();
this.cleaninfo();
},
mounted () {
},
watch: {
checked:'chageconsultation'
},
methods: {
afterRead(file){
console.log('',file)
let content = file.file;
let data = new FormData();
data.append('file',content);
data.append('group','user');
Uppadimg(data).then(res=>{
console.log(res)
this.doctorinfo.work_img = res.url
this.show=false
putData({avatarId:res.id}).then(res=>{
console.log(res)
})
})
},
// 获取医生资料
getme(){
Getdoctorinfo().then(res=>{
if(res){
console.log(res)
this.$route.meta.title=res.name+'工作室'
this.doctorinfo=res
this.consult_enable=res.consult_enable
console.log(this.consult_enable)
// 获取网络咨询
if(this.consult_enable==1){
this.checked=true
}else{
this.checked=false
}
}
})
},
// 更改网络咨询状态
chageconsultation(){
if(this.checked==true){
this.action='open'
}else{
this.action='close'
}
console.log(this.action)
ChageConsultation({action:this.action}).then(res=>{
if(res){
console.log(res)
}
})
},
// 清除不想修改后的东西
cleaninfo(){
localStorage.removeItem('doctorname')
}
},
components: {
[Switch.name]: Switch,
}
}
</script>
<style >
.van-uploader__input-wrapper{
width: 100%;
}
</style>
<style scoped lang="scss">
a{
color: #000;
}
@import url("../../assets/css/Studio.css");
</style>