doctorLike.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="container">
  3. <view class="content">
  4. <view class="doc_tab p_flexCenter">
  5. <view
  6. class="doc_tab_item p_flexCenter"
  7. :class="[tabInd == 0 ? 'doc_tab_item_ac p_color' : 'p_color_6']"
  8. @click="tabClick(0)">
  9. 关注医生
  10. </view>
  11. <view
  12. class="doc_tab_item p_flexCenter"
  13. :class="[tabInd == 1 ? 'doc_tab_item_ac p_color' : 'p_color_6']"
  14. @click="tabClick(1)">
  15. 最近咨询
  16. </view>
  17. <view
  18. class="doc_tab_item p_flexCenter"
  19. :class="[tabInd == 2 ? 'doc_tab_item_ac p_color' : 'p_color_6']"
  20. @click="tabClick(2)">
  21. 关注团队
  22. </view>
  23. </view>
  24. <view class="doctor_list_con p_format" v-if="!showNoData">
  25. <!-- 医生列表 -->
  26. <template v-if="tabInd != 2">
  27. <view class="p_doctor_item p_flexCenter"
  28. v-for="(item, index) in (tabInd == 0 ? collectDoctorList : hisDoctorList)" :key="index"
  29. @click="toDocInfo(item)">
  30. <view class="p_doctor_img_con">
  31. <image class="p_doctor_img" :src="item.DoctorPhotourl"></image>
  32. </view>
  33. <view class="p_doctor_item_con">
  34. <view class="doctor_item_con p_flexBetween">
  35. <view class="p_doctor_infocon">
  36. <view class="p_doctor_tit">
  37. <view class="p_doctor_name">{{ item.DoctorName }}</view>
  38. </view>
  39. <view class="p_doctor_info p_color_6">{{ item.LczcName }} {{ item.DeptName }}</view>
  40. </view>
  41. <view class="p_doctor_btn doc_his_btn_like p_flexCenter" :class="{ doc_his_btn_liked: item.like }">
  42. <image class="doc_his_btn_img" :src="iconUrl.doctor_like_n" v-if="!item.like"></image>
  43. <view class="doc_his_btn_val" @click.stop="likeFn(item)">
  44. {{ item.like ? '已关注' : '关注' }}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="p_doctor_item_introduce p_color_9 p_lineClamp">
  49. 擅长:{{ item.DoctorSkill }}
  50. </view>
  51. <view class="p_doctor_item_introduce p_color_3" v-if="tabInd == 1">
  52. 咨询时间:{{ item.ConsultStartTime }}
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <!-- 团队列表 -->
  58. <template v-if="tabInd == 2">
  59. <view class="group_item displayFlexCol" v-for="(item, index) in groupList" :key="index"
  60. @click="jumpGroupInfo(item)">
  61. <image class="group_photo" :src="item.GroupUrl" mode="aspectFill" />
  62. <text class="group_name">{{ item.GroupName }}</text>
  63. <view class="group_introduce">
  64. <text class="skill_label">简介:</text>
  65. <text class="group_introduce_text p_color_6">{{ item.GroupIntro }}</text>
  66. </view>
  67. </view>
  68. </template>
  69. </view>
  70. <view class="noData" v-else>
  71. <noData :value="noDataValue"></noData>
  72. </view>
  73. </view>
  74. </view>
  75. </template>
  76. <script lang="ts" setup>
  77. import { ref, getCurrentInstance } from 'vue';
  78. import { useOnLoad } from '@/hook';
  79. import { queryConsultDoctorGroup, queryUserCollect, queryBDoctorList, queryHistoryConsultDoctor, userCollect, unUserCollect } from '/pagesNetHos/st1/service/doctor/index';
  80. import icon from '@/utils/icon';
  81. import { common } from '@/utils';
  82. import { doctorListHandle } from '/pagesNetHos/st1/static/js/pagesNetHosFn';
  83. import noData from '@/pages/st1/components/noData/noData.vue';
  84. const { proxy } = getCurrentInstance();
  85. const app = getApp();
  86. // 图片icon
  87. const iconUrl = ref(icon);
  88. // 0关注医生 1最近咨询
  89. const tabInd = ref(0);
  90. // 关注医生列表
  91. const collectDoctorList = ref<any[]>([]);
  92. // 历史医生列表
  93. const hisDoctorList = ref<any[]>([]);
  94. // 是否展示暂无数据
  95. const showNoData = ref(false);
  96. // 暂无数据
  97. const noDataValue = ref('暂无数据');
  98. const groupList = ref<any[]>([]);
  99. // 返回上一级页面时执行的当前页面函数
  100. const refresh = () => {
  101. };
  102. // 页面加载
  103. useOnLoad(() => {
  104. main();
  105. });
  106. // 查询关注医生
  107. const queryCollectDoctor = async () => {
  108. const collectData = { resourceType: '1' };
  109. const { resp: respCollect } = await queryUserCollect(collectData);
  110. let collectDocList: any[] = [];
  111. if (!common.isEmpty(respCollect)) {
  112. const arr: string[] = [];
  113. for (let i = 0; i < respCollect.length; i++) {
  114. arr.push(respCollect[i].ResourceId);
  115. }
  116. const queryBDoctorListData = {
  117. DoctorUid: arr.join()
  118. };
  119. const { resp: collectDocListResp } = await queryBDoctorList(queryBDoctorListData);
  120. if (!common.isEmpty(collectDocListResp)) {
  121. // 添加关注状态
  122. collectDocListResp.map((item: any) => item.like = true);
  123. collectDocList = doctorListHandle(collectDocListResp);
  124. }
  125. }
  126. collectDoctorList.value = collectDocList;
  127. };
  128. // 查询最近咨询
  129. const queryHisDoctor = async () => {
  130. const data = { ConsultType: '' };
  131. const { resp: respHis } = await queryHistoryConsultDoctor(data);
  132. let hisDocList: any[] = [];
  133. if (!common.isEmpty(respHis)) {
  134. // 获取已关注的医生ID
  135. const likedDoctorIds = collectDoctorList.value.filter(item => item.like).map(item => item.DoctorUid);
  136. for (let i of respHis) {
  137. // 判断是否已关注
  138. if (likedDoctorIds.includes(i.DoctorUid)) {
  139. i.like = true;
  140. }
  141. }
  142. hisDocList = doctorListHandle(respHis);
  143. }
  144. hisDoctorList.value = hisDocList;
  145. };
  146. // 查询咨询医生组
  147. const queryConsultDoctorGroupFn = async () => {
  148. const data = {
  149. IsMemberCollect: 1
  150. };
  151. const { resp } = await queryConsultDoctorGroup(data);
  152. if (common.isNotEmpty(resp)) {
  153. groupList.value = resp;
  154. }
  155. };
  156. // 更新暂无数据显示
  157. const updateShowNoData = () => {
  158. const currentTabInd = tabInd.value;
  159. if (currentTabInd == 0) {
  160. showNoData.value = common.isEmpty(collectDoctorList.value);
  161. } else if (currentTabInd == 1) {
  162. showNoData.value = common.isEmpty(hisDoctorList.value);
  163. } else {
  164. showNoData.value = common.isEmpty(groupList.value);
  165. }
  166. console.log(showNoData.value,'v')
  167. };
  168. const main = async () => {
  169. const currentTabInd = tabInd.value;
  170. // 根据 tabInd 请求对应接口
  171. if (currentTabInd == 0) {
  172. // 关注医生
  173. await queryCollectDoctor();
  174. } else if (currentTabInd == 1) {
  175. // 最近咨询
  176. await queryHisDoctor();
  177. } else if (currentTabInd == 2) {
  178. // 关注团队
  179. await queryConsultDoctorGroupFn();
  180. }
  181. // 更新暂无数据显示
  182. updateShowNoData();
  183. };
  184. const tabClick = (ind: number) => {
  185. if (ind == tabInd.value) {
  186. return;
  187. }
  188. tabInd.value = ind;
  189. main();
  190. };
  191. const likeFn = async (item: any) => {
  192. const data = {
  193. resourceId: item.DoctorUid,
  194. resourceType: 1
  195. };
  196. let res;
  197. if (item.like) {
  198. // 取消关注
  199. ({ resData: res } = await unUserCollect(data));
  200. } else {
  201. // 关注
  202. ({ resData: res } = await userCollect(data));
  203. }
  204. if (res.RespCode == '10000') {
  205. collectDoctorList.value.map(cell => {
  206. if (cell.DoctorUid == item.DoctorUid) {
  207. cell.like = !cell.like;
  208. }
  209. });
  210. hisDoctorList.value.map(cell => {
  211. if (cell.DoctorUid == item.DoctorUid) {
  212. cell.like = !cell.like;
  213. }
  214. });
  215. }
  216. };
  217. const toDocInfo = (item: any) => {
  218. const queryBean = common.stringify(item);
  219. const url = `/pagesNetHos/st1/business/doctor/doctorInfo/doctorInfo?queryBean=${queryBean}`;
  220. common.menuClick({ Url: url }, proxy);
  221. };
  222. /** 跳转团队主页 */
  223. const jumpGroupInfo = (item: any) => {
  224. const url = `/pagesNetHos/st1/business/doctorGroup/doctorGroupInfo/doctorGroupInfo?groupId=${item.GroupId}`;
  225. common.goToUrl(url);
  226. };
  227. // 暴露方法供父组件调用
  228. defineExpose({
  229. refresh
  230. });
  231. </script>
  232. <style lang="scss" scoped>
  233. @import "/pagesNetHos/st1/static/css/common";
  234. @import "/pagesNetHos/st1/static/css/doctorInfo";
  235. .doc_tab_item {
  236. width: 50%;
  237. position: relative;
  238. height: 100upx;
  239. font-size: 30upx;
  240. background-color: #fff;
  241. }
  242. .doc_tab_item_ac {
  243. font-size: 36upx;
  244. font-weight: 500;
  245. }
  246. .doc_tab_item_ac:after {
  247. content: "";
  248. display: block;
  249. height: 6upx;
  250. width: 48upx;
  251. background: #01BF8E;
  252. border-radius: 3upx;
  253. position: absolute;
  254. bottom: 0;
  255. left: 50%;
  256. transform: translateX(-50%);
  257. }
  258. .p_doctor_item {
  259. margin: 20upx 30upx;
  260. padding: 30upx 24upx 15upx;
  261. background-color: #fff;
  262. border-radius: 20upx;
  263. }
  264. .p_doctor_item_con {
  265. padding-bottom: 0;
  266. }
  267. .doc_his_btn_like {
  268. padding: 0 18upx;
  269. height: 54upx;
  270. background: linear-gradient(90deg, rgba(177, 236, 195, 0.2) 0%, rgba(6, 186, 132, 0.2) 100%);
  271. font-size: 26upx;
  272. font-weight: 500;
  273. color: #01BF8E;
  274. border-radius: 50px;
  275. border: 1px solid rgba(6, 186, 132, 0.2);
  276. }
  277. .doc_his_btn_liked {
  278. background: linear-gradient(90deg, rgba(232, 233, 240, 0.2) 0%, rgba(170, 173, 189, 0.2) 100%);
  279. color: #AAADBD;
  280. border-radius: 50px;
  281. border: 1px solid rgba(170, 173, 189, 0.2);
  282. }
  283. .doc_his_btn_img {
  284. width: 32upx;
  285. height: 32upx;
  286. }
  287. .doc_his_btn_val {
  288. margin-left: 8upx;
  289. }
  290. .doctor_item_con {
  291. align-items: flex-start !important;
  292. }
  293. /* 团队 */
  294. .group_item {
  295. padding: 30upx;
  296. box-sizing: border-box;
  297. background: white;
  298. border-radius: 20upx;
  299. margin-bottom: 20upx;
  300. margin: 20upx 30upx;
  301. }
  302. .group_item text {
  303. font-size: 30upx;
  304. }
  305. .group_photo {
  306. width: 100%;
  307. height: 160upx;
  308. background: #f9f9f9;
  309. border-radius: 10upx;
  310. }
  311. .group_name {
  312. width: 100%;
  313. text-align: left;
  314. margin-top: 30upx;
  315. }
  316. .group_introduce {
  317. width: 100%;
  318. overflow: hidden;
  319. text-overflow: ellipsis;
  320. flex-wrap: wrap;
  321. display: -webkit-box;
  322. /* 几行后显示省略号 */
  323. -webkit-line-clamp: 2;
  324. -webkit-box-orient: vertical;
  325. position: relative;
  326. }
  327. .group_introduce text:nth-child(1) {
  328. font-weight: bold;
  329. }
  330. .group_introduce_text {
  331. font-size: 30upx;
  332. font-family: PingFang SC;
  333. line-height: 40upx;
  334. }
  335. </style>