NotifyMessageRender.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view :id="`auchor${source.clientMsgID}`" class="message_item" @tap="clickItem">
  3. <view class="card_header">
  4. <view class="header_left">
  5. <my-avatar size="32" :desc="source.senderNickname" shape="circle" src="/static/logo.png" />
  6. <text class="header_title">{{ notifyTitle || source.senderNickname }}</text>
  7. </view>
  8. <text class="header_time">{{ formattedMessageTime }}</text>
  9. </view>
  10. <view class="card_content">
  11. <view v-if="getMediaSource" class="media_container" @click.stop="preview">
  12. <u--image radius="4" :showLoading="true" :src="getMediaSource" width="100%" height="300rpx"
  13. mode="aspectFill"></u--image>
  14. <image v-if="isVideo" class="play_icon" src="../../../static/images/chating_message_video_play.png" />
  15. <text v-if="isVideo" class="video_duration">{{ getDuration }}</text>
  16. </view>
  17. <view class="notify_text_wrap">
  18. <text class="notify_text">{{ notifyContent.text }}</text>
  19. </view>
  20. </view>
  21. <view v-if="showFooter" class="card_footer">
  22. <view class="line"></view>
  23. <view class="footer_row">
  24. <text class="footer_text">查看详情</text>
  25. <text class="footer_arrow">></text>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { myPreview } from '../../../util/preview';
  32. import MyAvatar from '../../../components/MyAvatar/index.vue';
  33. import { formatMessageTime, secFormat } from '../../../util/imCommon';
  34. const NotificationMixTypes = {
  35. Text: 0,
  36. TextAndImage: 1,
  37. TextAndVideo: 2,
  38. TextAndFile: 3
  39. };
  40. export default {
  41. name: 'NotifyMessageRender',
  42. components: {
  43. MyAvatar
  44. },
  45. props: {
  46. source: Object
  47. },
  48. data() {
  49. return {};
  50. },
  51. computed: {
  52. notifyContent() {
  53. let notificationContent = {};
  54. try {
  55. notificationContent = JSON.parse(this.source.notificationElem.detail);
  56. } catch (e) {
  57. //TODO handle the exception
  58. }
  59. return notificationContent;
  60. },
  61. notifyTitle(){
  62. let title ="";
  63. try {
  64. let detail = JSON.parse(this.source.notificationElem.detail);
  65. const ex=JSON.parse(detail.ex);
  66. if(ex.type==1){
  67. title="订单通知";
  68. }
  69. else if(ex.type==2){
  70. title="药品订单通知";
  71. }
  72. else if(ex.type==3){
  73. title="套餐包订单通知" ;
  74. }
  75. else if(ex.type==4){
  76. title="问诊通知";
  77. }
  78. else if(ex.type==5){
  79. title="积分订单通知";
  80. }
  81. else if(ex.type==6){
  82. title="健康管理通知";
  83. }
  84. else if(ex.type==7){
  85. title="营销通知";
  86. }
  87. else{
  88. title="课程通知";
  89. }
  90. } catch (e) {
  91. title=this.source.senderNickname;
  92. }
  93. return title;
  94. },
  95. isVideo() {
  96. return this.notifyContent.mixType === NotificationMixTypes.TextAndVideo;
  97. },
  98. hasExternalUrl() {
  99. return this.notifyContent.externalUrl;
  100. },
  101. getDuration() {
  102. if (!this.isVideo) {
  103. return 0;
  104. }
  105. return secFormat(this.notifyContent.videoElem.duration);
  106. },
  107. formattedMessageTime() {
  108. return formatMessageTime(this.source.sendTime);
  109. },
  110. getMediaSource() {
  111. if (this.notifyContent.mixType === NotificationMixTypes.TextAndImage) {
  112. const picEl = this.notifyContent.pictureElem;
  113. return picEl.snapshotPicture?.url ?? picEl.sourcePicture?.url;
  114. }
  115. if (this.notifyContent.mixType === NotificationMixTypes.TextAndVideo) {
  116. const videoEl = this.notifyContent.videoElem;
  117. return videoEl.snapshotUrl;
  118. }
  119. return '';
  120. },
  121. canClick() {
  122. try {
  123. let detail = JSON.parse(this.source.notificationElem.detail);
  124. const ex = JSON.parse(detail.ex);
  125. return ex != null;
  126. } catch (e) {
  127. return false;
  128. }
  129. },
  130. showFooter() {
  131. return this.canClick || this.hasExternalUrl;
  132. }
  133. },
  134. methods: {
  135. toWebView() {
  136. uni.navigateTo({
  137. url: `/pages/common/webviewWrapper/index?url=${this.notifyContent.externalUrl}`
  138. });
  139. },
  140. preview() {
  141. if (this.notifyContent.mixType === NotificationMixTypes.TextAndVideo) {
  142. uni.navigateTo({
  143. url: `/pages/conversation/previewVideo/index?previewVideoUrl=${this.notifyContent.videoElem.videoUrl}&snapshotUrl=${this.notifyContent.videoElem.snapshotUrl}`
  144. });
  145. return;
  146. }
  147. if (this.notifyContent.mixType === NotificationMixTypes.TextAndImage) {
  148. const picEl = this.notifyContent.pictureElem;
  149. const url = picEl.SourcePicture?.Url ?? picEl.sourcePicture?.url;
  150. if (url) {
  151. myPreview(0, [url]);
  152. }
  153. }
  154. },
  155. clickItem() {
  156. if (this.hasExternalUrl) {
  157. this.toWebView();
  158. return;
  159. }
  160. let detail = JSON.parse(this.source.notificationElem.detail);
  161. const ex = JSON.parse(detail.ex);
  162. console.log("qxj clickItem detail", detail);
  163. if (ex != null) {
  164. if (ex.type == 4) { //问诊订单
  165. uni.navigateTo({
  166. url: "/pages/store/inquiryOrderDetails?orderId=" + ex.orderId
  167. });
  168. } else {
  169. uni.navigateTo({
  170. url: ex.path
  171. });
  172. }
  173. }
  174. },
  175. }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .message_item {
  180. display: flex;
  181. flex-direction: column;
  182. margin: 20rpx 30rpx;
  183. background-color: #fff;
  184. border-radius: 16rpx;
  185. overflow: hidden;
  186. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  187. .card_header {
  188. display: flex;
  189. flex-direction: row;
  190. justify-content: space-between;
  191. align-items: center;
  192. padding: 24rpx 24rpx 0;
  193. .header_left {
  194. display: flex;
  195. flex-direction: row;
  196. align-items: center;
  197. }
  198. .header_title {
  199. font-size: 30rpx;
  200. font-weight: 600;
  201. color: #333;
  202. margin-left: 16rpx;
  203. }
  204. .header_time {
  205. font-size: 24rpx;
  206. color: #999;
  207. }
  208. }
  209. .card_content {
  210. padding: 24rpx;
  211. .media_container {
  212. position: relative;
  213. margin-bottom: 20rpx;
  214. border-radius: 8rpx;
  215. overflow: hidden;
  216. .play_icon {
  217. position: absolute;
  218. top: 50%;
  219. left: 50%;
  220. width: 80rpx;
  221. height: 80rpx;
  222. transform: translate(-50%, -50%);
  223. }
  224. .video_duration {
  225. position: absolute;
  226. bottom: 10rpx;
  227. right: 10rpx;
  228. color: #fff;
  229. font-size: 24rpx;
  230. background-color: rgba(0, 0, 0, 0.5);
  231. padding: 4rpx 8rpx;
  232. border-radius: 4rpx;
  233. }
  234. }
  235. .notify_text_wrap {
  236. .notify_text {
  237. font-size: 28rpx;
  238. color: #666;
  239. line-height: 1.6;
  240. }
  241. }
  242. }
  243. .card_footer {
  244. padding: 0 24rpx 24rpx;
  245. .line {
  246. height: 1rpx;
  247. background-color: #f0f0f0;
  248. margin-bottom: 20rpx;
  249. }
  250. .footer_row {
  251. display: flex;
  252. flex-direction: row;
  253. justify-content: space-between;
  254. align-items: center;
  255. .footer_text {
  256. font-size: 28rpx;
  257. color: #333;
  258. }
  259. .footer_arrow {
  260. font-size: 28rpx;
  261. color: #999;
  262. font-family: monospace;
  263. }
  264. }
  265. }
  266. }
  267. </style>