CustomMessageRender.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view class="custom" @click="handleCustomerItem">
  3. <template v-if="isCustom === 'order'">
  4. <view class="order-item">
  5. <view class="title">问诊订单</view>
  6. <view class="text">患者:{{ extension.patientName }} {{ extension.sex }} {{ extension.mobile }}</view>
  7. <view class="text">患病时间:{{ extension.duration }}</view>
  8. <view class="text">就诊情况:{{ extension.isVisit }}</view>
  9. <view class="text">病情描述:{{ extension.title }}</view>
  10. </view>
  11. </template>
  12. <template v-else-if="isCustom === 'prescribe'">
  13. <view class="prescribe-item">
  14. <view class="title">电子处方单</view>
  15. <view class="text">诊断:{{ extension.diagnose }}</view>
  16. <view class="btns">
  17. <view class="btn">查看处方</view>
  18. </view>
  19. </view>
  20. </template>
  21. <template v-else-if="isCustom === 'report'">
  22. <view class="report-item">
  23. <view class="title">问诊报告单</view>
  24. <view class="btns">
  25. <view class="btn">查看报告单</view>
  26. </view>
  27. </view>
  28. </template>
  29. <template v-else-if="isCustom === 'follow'">
  30. <view class="prescribe-item">
  31. <view class="title">随访单</view>
  32. <view class="btns">
  33. <view class="btn">查看随访</view>
  34. </view>
  35. </view>
  36. </template>
  37. <template v-else-if="isCustom === 'drugReport'">
  38. <view class="report-item">
  39. <view class="title">用药报告单</view>
  40. <view class="btns">
  41. <view class="btn">查看报告单</view>
  42. </view>
  43. </view>
  44. </template>
  45. <template v-else-if="isCustom === 'package'">
  46. <view class="package-item">
  47. <view class="title">{{extension.title}}</view>
  48. <view class="cover" v-if="!!extension.image">
  49. <image :src="extension.image" mode="aspectFill"></image>
  50. </view>
  51. <view v-else class="btns">
  52. <view class="btn">查看疗法</view>
  53. </view>
  54. </view>
  55. </template>
  56. <template v-else-if="isCustom === 'startInquiry'">
  57. <span class="content content-in">{{ extension.title }}</span>
  58. </template>
  59. <template v-else-if="isCustom === 'finishInquiry'">
  60. <span class="content content-out">{{ extension.title }}</span>
  61. </template>
  62. <template v-else-if="isCustom === 'course'">
  63. <view class="box">
  64. <view class="list-item">
  65. <view class="list-con border-line">
  66. <view class="list-itemtxt">
  67. <!-- <text class="list-title textOne">{{extension.courseName}}</text> -->
  68. <text class="list-desc textTwo">{{extension.title}}</text>
  69. </view>
  70. <view class="list-cover">
  71. <image :src="extension.courseUrl" mode="aspectFill"></image>
  72. </view>
  73. </view>
  74. <!-- <view class="list-footer">
  75. <view style="flex: 1;overflow: hidden;">
  76. <image :src="extension.imageUrl" mode="aspectFill"></image>
  77. <text class="list-time textOne">{{extension.qwUserName}}</text>
  78. </view>
  79. <text class="list-time">过期时间:{{extension.updateTime}}</text>
  80. </view> -->
  81. </view>
  82. </view>
  83. </template>
  84. <template v-else>
  85. <span class="content"></span>
  86. </template>
  87. </view>
  88. </template>
  89. <script>
  90. import MyAvatar from '../../../../../components/MyAvatar/index.vue';
  91. export default {
  92. name: 'CustomMessageRender',
  93. components: { MyAvatar },
  94. props: {
  95. message: {
  96. type: Object,
  97. default: () => ({
  98. customElem: {
  99. data: '{}' // 默认空JSON
  100. },
  101. cardElem: {
  102. userID: ''
  103. }
  104. })
  105. }
  106. },
  107. data() {
  108. return {
  109. isCustom: {}, // 明确初始化null
  110. payload: {}, // 与服务端数据结构对齐
  111. extension: {} // 保持响应式基础结构
  112. };
  113. },
  114. mounted() {
  115. this.safeParseData();
  116. },
  117. methods: {
  118. safeParseData() {
  119. try {
  120. const rawData = this.message?.customElem?.data || '{}';
  121. const parsed = JSON.parse(rawData);
  122. //结构化赋值
  123. this.payload = parsed.payload || {};
  124. this.extension = this.payload.extension || {};
  125. this.isCustom = this.payload.data ?? null;
  126. } catch (e) {
  127. console.error('[消息解析失败]', e);
  128. this.$emit('parse-error', {
  129. raw: this.message,
  130. error: e
  131. });
  132. }
  133. },
  134. handleCustomerItem() {
  135. console.log(this.message.customElem.data);
  136. const rawData = this.message?.customElem.data;
  137. let item = JSON.parse(rawData);
  138. console.log("handleCustomerItem:::");
  139. console.log(item);
  140. if (item.payload.data == 'order') {
  141. uni.navigateTo({
  142. url: '/pages_order/inquiryOrderDetails?orderId=' + item.payload.description
  143. });
  144. } else if (item.payload.data == 'prescribe') {
  145. var prescribe = item.payload.extension;
  146. uni.navigateTo({
  147. url: '/pages_order/prescribeDetails?prescribeId=' + prescribe.prescribeId
  148. });
  149. }else if (item.payload.data == 'package') {
  150. var packageItem = item.payload.extension;
  151. let companyId=packageItem.companyId;
  152. let companyUserId=packageItem.companyUserId;
  153. let nUrl="/pages_index/packageDetails?packageId="+packageItem.packageId+"&companyId="+companyId+"&companyUserId="+companyUserId;
  154. uni.navigateTo({url: nUrl});
  155. }
  156. else if (item.payload.data == 'follow') {
  157. var follow = item.payload.extension;
  158. if (follow.writeStatus == 0) {
  159. uni.navigateTo({
  160. url: '/pages_user/doFollow?followId=' + follow.followId
  161. });
  162. } else if (follow.writeStatus == 1) {
  163. uni.navigateTo({
  164. url: '/pages_user/followDetails?followId=' + follow.followId
  165. });
  166. }
  167. } else if (item.payload.data == 'report') {
  168. uni.navigateTo({
  169. url: '/pages_order/inquiryOrderReport?orderId=' + item.payload.description
  170. });
  171. } else if (item.payload.data == 'drugReport') {
  172. // var report=JSON.parse(item.payload.extension);
  173. uni.navigateTo({
  174. url: '/pages_user/drugReportDetails?reportId=' + item.payload.description
  175. });
  176. }
  177. else if (item.payload.data == 'course') {
  178. uni.showToast({
  179. icon:'none',
  180. title: "请前往App看课",
  181. });
  182. return;
  183. console.log("qxj extension:");
  184. console.log(item.payload.extension);
  185. var couseItem=item.payload.extension;
  186. if(couseItem.appRealLink) {
  187. uni.navigateTo({
  188. url: couseItem.appRealLink
  189. });
  190. }else {
  191. uni.showToast({
  192. icon:'none',
  193. title: "暂无看课链接",
  194. });
  195. }
  196. }
  197. }
  198. }
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. @mixin u-flex($flexD, $alignI, $justifyC) {
  203. display: flex;
  204. flex-direction: $flexD;
  205. align-items: $alignI;
  206. justify-content: $justifyC;
  207. }
  208. .card_message_container {
  209. @include colBox(false);
  210. background-color: #fff;
  211. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  212. border-radius: 12rpx;
  213. width: 444rpx;
  214. border: 1px solid #ececec;
  215. .card_info {
  216. @include vCenterBox();
  217. padding: 24rpx 32rpx;
  218. border-bottom: 1px solid #e9e9e9;
  219. .card_name {
  220. @include ellipsisWithLine(1);
  221. margin-left: 24rpx;
  222. }
  223. }
  224. .card_desc {
  225. padding: 8rpx 0 8rpx 42rpx;
  226. color: #999;
  227. }
  228. }
  229. .custom {
  230. padding: 12px 0;
  231. border-radius: 10px 0px 10px 10px;
  232. .order-item {
  233. width: 400rpx;
  234. padding: 15rpx;
  235. padding: 15rpx;
  236. border: 1rpx solid #ececec;
  237. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  238. background-color: #fff;
  239. border-radius: 15rpx;
  240. display: flex;
  241. flex-direction: column;
  242. align-items: flex-start;
  243. justify-content: flex-start;
  244. .title {
  245. font-size: 32upx;
  246. font-family: PingFang SC;
  247. font-weight: bold;
  248. color: #111111;
  249. }
  250. .text {
  251. font-size: 24upx;
  252. font-family: PingFang SC;
  253. color: #9a9a9c;
  254. padding:6rpx 0;
  255. }
  256. }
  257. .prescribe-item {
  258. width: 400rpx;
  259. padding: 15rpx;
  260. border: 1rpx solid #ececec;
  261. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  262. background-color: #fff;
  263. border-radius: 15rpx;
  264. display: flex;
  265. flex-direction: column;
  266. align-items: flex-start;
  267. justify-content: flex-start;
  268. .title {
  269. font-size: 32upx;
  270. font-family: PingFang SC;
  271. font-weight: bold;
  272. color: #111111;
  273. }
  274. .text {
  275. margin-top: 10rpx;
  276. font-size: 24upx;
  277. font-family: PingFang SC;
  278. color: #9a9a9c;
  279. }
  280. .btns {
  281. padding: 15rpx;
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. width: 100%;
  286. .btn {
  287. border-radius: 30rpx;
  288. padding: 15rpx 30rpx;
  289. border: 1rpx solid #ececec;
  290. font-family: PingFang SC;
  291. color: #333333;
  292. }
  293. }
  294. }
  295. .report-item {
  296. width: 400rpx;
  297. padding: 15rpx;
  298. border: 1rpx solid #ececec;
  299. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  300. background-color: #fff;
  301. border-radius: 15rpx;
  302. display: flex;
  303. flex-direction: column;
  304. align-items: flex-start;
  305. justify-content: flex-start;
  306. .title {
  307. font-size: 32upx;
  308. font-family: PingFang SC;
  309. font-weight: bold;
  310. color: #111111;
  311. }
  312. .text {
  313. margin-top: 10rpx;
  314. font-size: 24upx;
  315. font-family: PingFang SC;
  316. color: #9a9a9c;
  317. }
  318. .btns {
  319. padding: 15rpx;
  320. display: flex;
  321. align-items: center;
  322. justify-content: center;
  323. width: 100%;
  324. .btn {
  325. border-radius: 30rpx;
  326. padding: 15rpx 30rpx;
  327. border: 1rpx solid #ececec;
  328. font-family: PingFang SC;
  329. color: #333333;
  330. }
  331. }
  332. }
  333. .package-item{
  334. width: 450rpx;
  335. padding: 15rpx;
  336. border: 1rpx solid #ececec;
  337. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  338. background-color: #fff;
  339. border-radius: 15rpx;
  340. display: flex;
  341. flex-direction: column;
  342. align-items: flex-start;
  343. justify-content: flex-start;
  344. .title {
  345. font-size: 32upx;
  346. font-family: PingFang SC;
  347. font-weight: bold;
  348. color: #333;
  349. margin-bottom: 20rpx;
  350. }
  351. .cover{
  352. width:calc(100%);
  353. height: 400rpx;
  354. border-radius: 16rpx;
  355. box-sizing: border-box;
  356. image{
  357. width: 100%;
  358. height: 100%;
  359. }
  360. }
  361. }
  362. }
  363. .content {
  364. padding: 10px;
  365. &-in {
  366. background: #f0f0f0;
  367. border-radius: 0px 10px 10px 10px;
  368. }
  369. &-out {
  370. background: #f0f0f0;
  371. border-radius: 10px 0px 10px 10px;
  372. }
  373. }
  374. .list{
  375. &-item {
  376. width: 450rpx;
  377. padding: 0rpx;
  378. border: 1rpx solid #ececec;
  379. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  380. background-color: #fff;
  381. border-radius: 16rpx;
  382. margin-bottom: 20rpx;
  383. box-sizing: border-box;
  384. font-family: PingFang SC, PingFang SC;
  385. font-weight: 400;
  386. font-size: 30rpx;
  387. color: #333333;
  388. line-height: 36rpx;
  389. image {
  390. flex-shrink: 0;
  391. width: 150rpx;
  392. height: 120rpx;
  393. margin-left: 16rpx;
  394. background: #F5F6F6;
  395. border-radius: 10rpx 10rpx 10rpx 10rpx;
  396. overflow: hidden;
  397. }
  398. }
  399. &-con {
  400. width: 100%;
  401. padding: 24rpx;
  402. box-sizing: border-box;
  403. @include u-flex(column, flex-start, space-between);
  404. }
  405. &-cover {
  406. width: 100%;
  407. margin-top: 20rpx;
  408. @include u-flex(row, flex-start, flex-end);
  409. }
  410. &-itemtxt {
  411. flex: 1;
  412. overflow: hidden;
  413. word-break: break-all;
  414. display: block;
  415. }
  416. &-title {
  417. word-break: break-all;
  418. display: block;
  419. }
  420. &-desc {
  421. margin-top: 8rpx;
  422. font-size: 34rpx;
  423. color: #333;
  424. line-height: 44rpx;
  425. }
  426. &-time {
  427. font-size: 22rpx;
  428. color: #999999;
  429. }
  430. &-footer {
  431. padding: 20rpx 24rpx;
  432. box-sizing: border-box;
  433. @include u-flex(row, center, space-between);
  434. position: relative;
  435. view {
  436. @include u-flex(row, center, flex-start);
  437. }
  438. image {
  439. height: 50rpx;
  440. width: 50rpx;
  441. border-radius: 50%;
  442. margin: 0 10rpx 0 0;
  443. }
  444. }
  445. }
  446. </style>