1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<template>
<div class="flex flex-col nim-index" style="height: 100vh">
<div class="py-2 px-3 text-black text-center shrink-0 doc-nav-bar" v-if='showNav()'>
<span>专家在线咨询</span>
</div>
<img src="@/assets/image/residentWX/banner.png" alt="" class="shrink-0 w-full">
<div style="color: #8C8C8C;" class="py-2 px-3">以下为您提供慢病筛查的专家,可向其进行慢病咨询</div>
<div class="grow flex">
<div class="h-full list-l">
<div v-for="item in orgList" :key="item"
:class="['p-3', { 'active': item === activeOrg }]"
@click="onOrgChange(item)">
<span>{{ item || '-' }}</span>
</div>
</div>
<div class="h-full p-3 list-r">
<div class="mb-3 p-4 card" v-for="item in innerDoctorList" :key="item.serviceDoctorId">
<div class="mb-3">
<span class="text-16 mr-2 font-semibold">{{item.serviceDoctorName}}</span>
<span>{{item.serviceOfficeName || '-'}}</span>
</div>
<div class="mb-3">{{item.serviceUnitName || '-'}}</div>
<div>
<van-button plain round type="primary"
@click="toSession(item)">咨询医生</van-button>
</div>
</div>
<div class='text-center shrink-0 empty' v-if='!innerDoctorList.length'>
<img src='@/assets/image/doctor/empty.png' alt='' style='width: 1.2rem;'>
<p>暂无数据</p>
</div>
</div>
</div>
</div>
</template>
<script>
import { useStore } from '@/residentWX/store'
import { getServiceDoc } from '@/api/residentWX/nim.js'
import { showFailToast } from 'vant'
import { getSessionInfo } from '@/api/residentWX/nim.js'
export default {
inject:['showNav', 'isResidentInfo'],
data() {
return {
store: useStore(),
orgList: [],
doctorList: [],
// 沟通过的医生列表
recordList: [],
activeOrg: {}
}
},
computed: {
userInfo() {
return this.store.userInfo
},
innerDoctorList() {
if (this.activeOrg === '咨询过的专家') {
return this.recordList
}
return this.doctorList.filter(e => e.serviceUnitName === this.activeOrg)
}
},
created() {
document.title = '专家在线咨询'
if (this.isResidentInfo()) {
this.init()
}
},
methods: {
init() {
console.log(this.userInfo)
this.load()
},
load() {
getServiceDoc({ residentInfoId: this.userInfo.residentInfoId }).then(res => {
const result = res.data || {}
const orgList = []
let doctorList = []
Reflect.ownKeys(result).forEach(key => {
orgList.push(key)
doctorList = doctorList.concat(result[key])
})
this.doctorList = doctorList
this.orgList = ['咨询过的专家'].concat(orgList)
this.activeOrg = this.orgList[0]
// 获取咨询过的医生列表
this.loadRecord()
})
},
loadRecord() {
getSessionInfo(this.userInfo.idCard).then(res =>{
console.log('getSessionInfo', res)
const result = res.data || []
const array = []
result.forEach(e => {
const item = this.doctorList.find(i => e.idCard === i.identityCard)
item && array.push(item)
})
this.recordList = array
})
},
onOrgChange(item) {
this.activeOrg = item || ''
},
// 聊天页面
toSession(item = {}) {
if (!item.identityCard) {
showFailToast('缺失医生信息')
return
}
const path = `/residentWX/nim/${item.identityCard}`
this.$router.push({
path,
query: {
name: item.serviceDoctorName,
gender: this.userInfo.gender || 0
}
})
}
},
}
</script>
<style lang="less" scoped>
@import url('../utils/common.less');
.nim-index {
background: #f8fafc;
}
.list-l {
width: 35%;
background: transparent;
>div {
line-height: 1.5;
}
.active {
background-color: #fff;
}
}
.list-r {
width: 65%;
background: #fff;
.card {
background-color: #E4E8EE;
background: linear-gradient(to bottom, #E5F3FF 0%, #E9FAFC 100%);
border-radius: 8px;
border: 1px solid #E4E8EE;
.van-button {
height: 26px;
line-height: 26px;
font-size: 14px;
}
}
}
</style>