CustomMessageRender.vue 17 KB

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