CustomMessageRender.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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 === 'couponPackage'">
  57. <view class="package-item">
  58. <view class="title">{{extension.title}}</view>
  59. <view class="stitle"><i class="psub">¥</i> <i class="psub price"> {{ extension.price.toFixed(2) }} </i> {{ "(满"+extension.minPrice.toFixed(2)+"元可用)" }} </view>
  60. <view class="stitle stitle1">{{ extension.limitTime+"到期 不可叠加使用"}}</view>
  61. <view class="cover" v-if="!!extension.image">
  62. <image :src="extension.image" mode="aspectFill"></image>
  63. </view>
  64. <view v-else class="btns">
  65. <view class="btn">查看私域疗法券</view>
  66. </view>
  67. </view>
  68. </template>
  69. <template v-else-if="isCustom === 'inquirySelect'">
  70. <view class="package-item">
  71. <view class="title">{{extension.title}}</view>
  72. <view class="stitle">医疗专家团队远程咨询</view>
  73. <view class="cover" v-if="!!extension.image">
  74. <image :src="extension.image" mode="aspectFill"></image>
  75. </view>
  76. <view v-else class="btns">
  77. <view class="btn">查看会诊</view>
  78. </view>
  79. </view>
  80. </template>
  81. <template v-else-if="isCustom === 'startInquiry'">
  82. <view class="content content-in">
  83. <span>{{ extension.title }}</span>
  84. </view>
  85. </template>
  86. <template v-else-if="isCustom === 'finishInquiry'">
  87. <view class="content content-ou">
  88. <span>{{ extension.title }}</span>
  89. </view>
  90. </template>
  91. <template v-else-if="isCustom === 'course'">
  92. <view class="box">
  93. <view class="list-item">
  94. <view class="list-con border-line">
  95. <view class="list-itemtxt">
  96. <!-- <text class="list-title textOne">{{extension.courseName}}</text> -->
  97. <text class="list-desc textTwo">{{extension.title}}</text>
  98. </view>
  99. <view class="list-cover">
  100. <image :src="extension.courseUrl" mode="aspectFill"></image>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </template>
  106. <template v-else-if="isCustom === 'live'">
  107. <view class="box">
  108. <view class="liveList">
  109. <view class="list-item">
  110. <image :src="extension.appRealLink" mode="aspectFill"></image>
  111. <view class="info">
  112. <text>{{extension.liveName}}</text>
  113. </view>
  114. <view class="livebox">直播</view>
  115. </view>
  116. </view>
  117. </view>
  118. </template>
  119. <template v-else-if="isCustom === 'luckyBag'">
  120. <view class="box">
  121. <view class="luckyBagBox" :class="isSender ? 'image_right' : 'image_left'">
  122. <view class="u-f es-ac">
  123. <view class="u-f-ajc es-mr-20">
  124. <image class="es-icon-56" src="/pages_im/static/images/luckyBag/new_lucky_bag_icon.png" mode=""></image>
  125. </view>
  126. <view class="es-fs-32 es-fw-500 es-c-white">
  127. 给你发送福袋
  128. </view>
  129. </view>
  130. <view class="es-mt-16 luckyBagBox-line"></view>
  131. <view class="es-mt-16 es-fs-20 es-c-white">
  132. 专属福袋
  133. </view>
  134. </view>
  135. </view>
  136. </template>
  137. <template v-else>
  138. <view class="content"></view>
  139. </template>
  140. </view>
  141. </template>
  142. <script>
  143. import MyAvatar from '../../../../../components/MyAvatar/index.vue';
  144. export default {
  145. name: 'CustomMessageRender',
  146. components: { MyAvatar },
  147. props: {
  148. message: {
  149. type: Object,
  150. default: () => ({
  151. customElem: {
  152. data: '{}' // 默认空JSON
  153. },
  154. cardElem: {
  155. userID: ''
  156. }
  157. })
  158. },
  159. isSender: {
  160. type: Boolean,
  161. default: false
  162. }
  163. },
  164. data() {
  165. return {
  166. isCustom: null, // 明确初始化null
  167. payload: {}, // 与服务端数据结构对齐
  168. extension: {} // 保持响应式基础结构
  169. };
  170. },
  171. computed: {
  172. customDataStr() {
  173. return this.message?.customElem?.data;
  174. }
  175. },
  176. watch: {
  177. customDataStr: {
  178. handler() {
  179. this.safeParseData();
  180. },
  181. immediate: true
  182. },
  183. message: {
  184. handler: function(newVal, oldVal) {
  185. this.safeParseData();
  186. },
  187. immediate: true,
  188. deep: true
  189. }
  190. },
  191. mounted() {
  192. this.safeParseData();
  193. },
  194. methods: {
  195. safeParseData() {
  196. try {
  197. const rawData = this.message?.customElem?.data || '{}';
  198. const parsed = JSON.parse(rawData);
  199. //结构化赋值
  200. this.payload = parsed.payload || {};
  201. this.extension = this.payload.extension || {};
  202. this.isCustom = this.payload.data ?? null;
  203. } catch (e) {
  204. console.error('[消息解析失败]', e);
  205. this.$emit('parse-error', {
  206. raw: this.message,
  207. error: e
  208. });
  209. }
  210. },
  211. handleCustomerItem() {
  212. const rawData = this.message?.customElem.data;
  213. let item = JSON.parse(rawData);
  214. if (item.payload.data == 'order') {
  215. uni.navigateTo({
  216. url: '/pages/store/inquiryOrderDetails?orderId=' + item.payload.description
  217. });
  218. } else if (item.payload.data == 'prescribe') {
  219. var prescribe = item.payload.extension;
  220. uni.navigateTo({
  221. url: '/pages/store/prescribeDetails?prescribeId=' + prescribe.prescribeId
  222. });
  223. } else if (item.payload.data == 'package') {
  224. var packageItem = item.payload.extension;
  225. let companyId=packageItem.companyId;
  226. let companyUserId=packageItem.companyUserId;
  227. let nUrl="/pages/store/packageDetails?packageId="+packageItem.packageId+"&companyId="+companyId+"&companyUserId="+companyUserId;
  228. uni.navigateTo({url: nUrl});
  229. }
  230. else if (item.payload.data == 'couponPackage') {
  231. //console.log("qxj item",item);
  232. var cItem = item.payload.extension;
  233. let companyId=cItem.companyId;
  234. let companyUserId=cItem.companyUserId;
  235. let nUrl='/pages/company/couponDetails?couponId='+cItem.couponId+"&isShare=1";
  236. uni.navigateTo({url: nUrl});
  237. }
  238. else if (item.payload.data == 'inquirySelect') {
  239. var cItem = item.payload.extension;
  240. let companyId=cItem.companyId;
  241. let companyUserId=cItem.companyUserId;
  242. let type=cItem.type;
  243. if(type==3){
  244. let nUrl="/pages/store/inquiryForm2_2?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+companyId+"&companyUserId="+companyUserId+"&isShare=1";
  245. uni.navigateTo({url: nUrl});
  246. } else if(type==4){
  247. } else {
  248. let nUrl="/pages/store/inquiryForm2_1?inquiryType=2&orderType=2&inquirySubType="+type+"&companyId="+companyId+"&companyUserId="+companyUserId+"&isShare=1";
  249. uni.navigateTo({url: nUrl});
  250. }
  251. }
  252. else if (item.payload.data == 'follow') {
  253. var follow = item.payload.extension;
  254. if (follow.writeStatus == 0) {
  255. uni.navigateTo({
  256. url: '/pages/user/doFollow?followId=' + follow.followId
  257. });
  258. } else if (follow.writeStatus == 1) {
  259. uni.navigateTo({
  260. url: '/pages/user/followDetails?followId=' + follow.followId
  261. });
  262. }
  263. } else if (item.payload.data == 'report') {
  264. uni.navigateTo({
  265. url: '/pages/store/inquiryOrderReport?orderId=' + item.payload.description
  266. });
  267. } else if (item.payload.data == 'drugReport') {
  268. // var report=JSON.parse(item.payload.extension);
  269. uni.navigateTo({
  270. url: '/pages/user/drugReportDetails?reportId=' + item.payload.description
  271. });
  272. }
  273. else if (item.payload.data == 'course') {
  274. console.log("qxj extension:",item);
  275. var couseItem=item.payload.extension;
  276. if(couseItem.appRealLink) {
  277. uni.navigateTo({
  278. url: couseItem.appRealLink
  279. });
  280. }else {
  281. uni.showToast({
  282. icon:'none',
  283. title: "暂无看课链接",
  284. });
  285. }
  286. }
  287. else if (item.payload.data == "luckyBag") {
  288. console.log("qxj extension:",item);
  289. let luckyBagItem=item.payload.extension;
  290. if(luckyBagItem.appRealLink) {
  291. let str = luckyBagItem.appRealLink.split('?link=')[1]
  292. uni.navigateTo({
  293. url: '/pages/courseAnswer/luckyBag?link='+str
  294. });
  295. }else {
  296. uni.showToast({
  297. icon:'none',
  298. title: "福袋信息为空",
  299. });
  300. }
  301. }
  302. else if (item.payload.data == 'live') {
  303. var liveItem=item.payload.extension;
  304. console.log("qxj liveItem:",JSON.stringify(liveItem));
  305. let url='/pages_live/index?liveId=' + liveItem.liveId;
  306. if(liveItem.companyId){
  307. url += "&companyId="+liveItem.companyId;
  308. }
  309. if(liveItem.companyUserId){
  310. url += "&companyUserId="+liveItem.companyUserId;
  311. }
  312. console.log("qxj url:"+url);
  313. uni.navigateTo({
  314. url: url
  315. });
  316. return;
  317. if(couseItem.appRealLink) {
  318. uni.navigateTo({
  319. url: couseItem.appRealLink
  320. });
  321. }else {
  322. uni.showToast({
  323. icon:'none',
  324. title: "暂无看课链接",
  325. });
  326. }
  327. }
  328. }
  329. }
  330. };
  331. </script>
  332. <style lang="scss" scoped>
  333. @mixin u-flex($flexD, $alignI, $justifyC) {
  334. display: flex;
  335. flex-direction: $flexD;
  336. align-items: $alignI;
  337. justify-content: $justifyC;
  338. }
  339. .card_message_container {
  340. @include colBox(false);
  341. background-color: #fff;
  342. box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
  343. border-radius: 12rpx;
  344. width: 444rpx;
  345. border: 1px solid #ececec;
  346. .card_info {
  347. @include vCenterBox();
  348. padding: 24rpx 32rpx;
  349. border-bottom: 1px solid #e9e9e9;
  350. .card_name {
  351. @include ellipsisWithLine(1);
  352. margin-left: 24rpx;
  353. }
  354. }
  355. .card_desc {
  356. padding: 8rpx 0 8rpx 42rpx;
  357. color: #999;
  358. }
  359. }
  360. .custom {
  361. .order-item {
  362. width: 450rpx;
  363. padding: 15rpx;
  364. padding: 15rpx;
  365. border: 1rpx solid #ececec;
  366. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  367. background-color: #fff;
  368. border-radius: 15rpx;
  369. display: flex;
  370. flex-direction: column;
  371. align-items: flex-start;
  372. justify-content: flex-start;
  373. .title {
  374. font-size: 16px;
  375. font-family: PingFang SC;
  376. font-weight: normal;
  377. color: #111111;
  378. }
  379. .text {
  380. font-size: 12px;
  381. font-family: PingFang SC;
  382. color: #9a9a9c;
  383. padding:6rpx 0;
  384. }
  385. }
  386. .prescribe-item {
  387. width: 450rpx;
  388. padding: 15rpx;
  389. border: 1rpx solid #ececec;
  390. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  391. background-color: #fff;
  392. border-radius: 15rpx;
  393. display: flex;
  394. flex-direction: column;
  395. align-items: flex-start;
  396. justify-content: flex-start;
  397. .title {
  398. font-size: 16px;
  399. font-family: PingFang SC;
  400. font-weight: normal;
  401. color: #111111;
  402. }
  403. .text {
  404. margin-top: 10rpx;
  405. font-size: 12px;
  406. font-family: PingFang SC;
  407. color: #9a9a9c;
  408. }
  409. .btns {
  410. padding: 15rpx;
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. width: 100%;
  415. .btn {
  416. border-radius: 30rpx;
  417. padding: 15rpx 30rpx;
  418. border: 1rpx solid #ececec;
  419. font-family: PingFang SC;
  420. color: #333333;
  421. }
  422. }
  423. }
  424. .report-item {
  425. width: 450rpx;
  426. padding: 15rpx;
  427. border: 1rpx solid #ececec;
  428. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  429. background-color: #fff;
  430. border-radius: 15rpx;
  431. display: flex;
  432. flex-direction: column;
  433. align-items: flex-start;
  434. justify-content: flex-start;
  435. .title {
  436. font-size: 16px;
  437. font-family: PingFang SC;
  438. font-weight: normal;
  439. color: #111111;
  440. }
  441. .text {
  442. margin-top: 10rpx;
  443. font-size: 12px;
  444. font-family: PingFang SC;
  445. color: #9a9a9c;
  446. }
  447. .btns {
  448. padding: 15rpx;
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. width: 100%;
  453. .btn {
  454. border-radius: 30rpx;
  455. padding: 15rpx 30rpx;
  456. border: 1rpx solid #ececec;
  457. font-family: PingFang SC;
  458. color: #333333;
  459. font-size: 16px;
  460. }
  461. }
  462. }
  463. .package-item{
  464. width: 450rpx;
  465. padding: 15rpx;
  466. border: 1rpx solid #ececec;
  467. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  468. background-color: #fff;
  469. border-radius: 15rpx;
  470. display: flex;
  471. flex-direction: column;
  472. align-items: flex-start;
  473. justify-content: flex-start;
  474. .title {
  475. font-size: 16px;
  476. font-family: PingFang SC;
  477. color: #333;
  478. margin-bottom: 10rpx;
  479. }
  480. .stitle {
  481. font-size: 15px;
  482. font-family: PingFang SC;
  483. font-weight: 500;
  484. color: #666;
  485. margin-bottom: 10rpx;
  486. }
  487. .psub{
  488. color: #e41f19;
  489. font-size: 15px;
  490. font-style: normal;
  491. }
  492. .price{
  493. font-size: 18px;
  494. font-style: normal;
  495. font-weight: bold;
  496. }
  497. .stitle1{
  498. font-size: 14px;
  499. }
  500. .cover{
  501. width:calc(100%);
  502. height: 400rpx;
  503. border-radius: 16rpx;
  504. box-sizing: border-box;
  505. image{
  506. width: 100%;
  507. height: 100%;
  508. }
  509. }
  510. }
  511. }
  512. .content {
  513. padding: 10px;
  514. background: #f0f0f0;
  515. &-in {
  516. border-radius: 0px 10px 10px 10px;
  517. }
  518. &-out {
  519. border-radius: 10px 0px 10px 10px;
  520. }
  521. }
  522. .list{
  523. &-item {
  524. width: 450rpx;
  525. padding: 0rpx;
  526. border: 1rpx solid #ececec;
  527. box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.05);
  528. background-color: #fff;
  529. border-radius: 16rpx;
  530. margin-bottom: 0rpx;
  531. box-sizing: border-box;
  532. font-family: PingFang SC, PingFang SC;
  533. font-weight: 400;
  534. font-size: 15px;
  535. color: #333333;
  536. line-height: 36rpx;
  537. image {
  538. flex-shrink: 0;
  539. width: 150rpx;
  540. height: 120rpx;
  541. margin-left: 16rpx;
  542. background: #F5F6F6;
  543. border-radius: 10rpx 10rpx 10rpx 10rpx;
  544. overflow: hidden;
  545. }
  546. }
  547. &-con {
  548. width: 100%;
  549. padding: 24rpx;
  550. box-sizing: border-box;
  551. @include u-flex(column, flex-start, space-between);
  552. }
  553. &-cover {
  554. width: 100%;
  555. margin-top: 20rpx;
  556. @include u-flex(row, flex-start, flex-end);
  557. }
  558. &-itemtxt {
  559. flex: 1;
  560. overflow: hidden;
  561. word-break: break-all;
  562. display: block;
  563. }
  564. &-title {
  565. word-break: break-all;
  566. display: block;
  567. }
  568. &-desc {
  569. margin-top: 0rpx;
  570. font-size: 16px;
  571. color: #333;
  572. line-height: 22px;
  573. }
  574. &-time {
  575. font-size: 11px;
  576. color: #999999;
  577. }
  578. &-footer {
  579. padding: 20rpx 24rpx;
  580. box-sizing: border-box;
  581. @include u-flex(row, center, space-between);
  582. position: relative;
  583. view {
  584. @include u-flex(row, center, flex-start);
  585. }
  586. image {
  587. height: 50rpx;
  588. width: 50rpx;
  589. border-radius: 50%;
  590. margin: 0 10rpx 0 0;
  591. }
  592. }
  593. }
  594. .liveList {
  595. .list-item {
  596. border-radius: 4rpx;
  597. width: 300rpx;
  598. height: 500rpx;
  599. background-color: #ececec;
  600. margin-bottom: 24rpx;
  601. overflow: hidden;
  602. position: relative;
  603. .livebox{
  604. background: #ff5500;
  605. border-radius: 8rpx;
  606. font-size: 26rpx;
  607. color: #fff;
  608. text-align: center;
  609. position: absolute;
  610. left: 18rpx;
  611. top: 18rpx;
  612. padding:8rpx 14rpx;
  613. }
  614. image {
  615. width: 100%;
  616. height: 100%;
  617. margin-left: 0;
  618. }
  619. video {
  620. width: 100%;
  621. height: 100%;
  622. object-fit: cover;
  623. }
  624. .info {
  625. position: absolute;
  626. left: 20rpx;
  627. bottom: 14rpx;
  628. right: 20rpx;
  629. color: #ffffff;
  630. display: flex;
  631. align-items: center;
  632. .live-badge {
  633. background-color: #e74c3c;
  634. padding: 4rpx 12rpx;
  635. border-radius: 8rpx;
  636. font-size: 20rpx;
  637. margin-right: 12rpx;
  638. }
  639. .record-badge {
  640. background-color: #3498db;
  641. padding: 4rpx 12rpx;
  642. border-radius: 8rpx;
  643. font-size: 20rpx;
  644. margin-right: 12rpx;
  645. }
  646. }
  647. .error-tip {
  648. position: absolute;
  649. top: 50%;
  650. left: 50%;
  651. transform: translate(-50%, -50%);
  652. color: #fff;
  653. background-color: rgba(0, 0, 0, 0.7);
  654. padding: 16rpx 24rpx;
  655. border-radius: 8rpx;
  656. font-size: 24rpx;
  657. }
  658. }
  659. // 使列表项均匀分布
  660. .list-item:nth-child(2n) {
  661. margin-right: 0;
  662. }
  663. }
  664. .luckyBagBox {
  665. width: 384rpx;
  666. height: 160rpx;
  667. border-radius: 8rpx;
  668. padding: 24rpx 24rpx 20rpx 24rpx;
  669. background-repeat: no-repeat;
  670. background-size: 100% 100%;
  671. .luckyBagBox-line {
  672. width: 100%;
  673. height: 1rpx;
  674. background: rgba(255, 255, 255,0.2);
  675. }
  676. }
  677. .image_right {
  678. background-image: url('/pages_im/static/images/luckyBag/lucky_bag_new_bg_right.png');
  679. }
  680. .image_left {
  681. background-image: url('/pages_im/static/images/luckyBag/lucky_bag_new_bg_left.png');
  682. }
  683. </style>