detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="currentTitleText" />
  4. <view id="News_Content" class="news-content">
  5. <!-- 观点分析 / 新闻资讯 / 公告 / 新闻资讯(通讯) -->
  6. <view class="content crm-border-radius" v-if="[1, 2, 3, 5].includes(type)">
  7. <view class="img" v-if="imgContentIf">
  8. <image :src="imgContent" mode="widthFix" @click="previewImage(imgContent)" />
  9. </view>
  10. <cwg-rich-text :nodes="Content" />
  11. </view>
  12. <!-- 视频评论(WebTV 视频) -->
  13. <view class="content crm-border-radius" v-if="type === 4">
  14. <text class="con-title">{{ info.title }}</text>
  15. <view class="con-time" style="display: flex; justify-content: space-between;">
  16. <text>{{ info.createTime }}</text>
  17. <image src="/static/acc_logo.png" style="height: 80rpx;" mode="heightFix" />
  18. </view>
  19. <view class="my_video" style="width: 100%">
  20. <video :id="`dplayer-${title}`" :src="info.url" controls class="video-player" />
  21. </view>
  22. <text class="con-des">{{ info.description }}</text>
  23. </view>
  24. <!-- 视频评论(另一种) -->
  25. <view class="content crm-border-radius" v-if="type === 6">
  26. <text class="con-title">{{ info.title }}</text>
  27. <text class="con-time">{{ info.subTitle }}</text>
  28. <view class="my_video" style="width: 100%">
  29. <video :id="`dplayer-${type}`" :src="imgContent" controls class="video-player" />
  30. </view>
  31. <view class="rich-text-wrapper">
  32. <cwg-rich-text :nodes="info.content" />
  33. </view>
  34. </view>
  35. <!-- 公告详情 -->
  36. <view class="content crm-border-radius" v-if="type === 7">
  37. <text class="con-title">{{ info.subject }}</text>
  38. <view class="rich-text-wrapper">
  39. <cwg-rich-text :nodes="info.content1" />
  40. </view>
  41. </view>
  42. <!-- 交易观点 / 财经日历(内嵌网页) -->
  43. <view class="content crm-border-radius" v-if="[8, 9].includes(title)">
  44. <web-view :src="imgContent" class="webview" />
  45. </view>
  46. <!-- 电子书 -->
  47. <view class="content crm-border-radius" v-if="type === 10">
  48. <view class="ebookBox">
  49. <image :src="imgUrl + info.coverImage" mode="widthFix" class="ebook-cover" />
  50. <view>
  51. <text class="news-title">{{ info.title }}</text>
  52. <view class="rich-text-wrapper">
  53. <cwg-rich-text :nodes="info.content" />
  54. </view>
  55. <view class="news-status">
  56. <cwg-link type="html" title="blockchain.item12" :url="imgUrl + info.bookUrl"
  57. target="_blank" />
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 视频评论(iframe 嵌入) -->
  63. <view class="content crm-border-radius" v-if="type === 11">
  64. <view style="display: flex; justify-content: end; margin-bottom: 30rpx;">
  65. <image src="/static/acc_logo.png" style="height: 80rpx;" mode="heightFix" />
  66. </view>
  67. <view style="width: 80%; margin: auto;">
  68. <web-view v-if="isZh" src="https://videos.tradingcentral.cn/players/H5QuTuut-iodula4l.html" />
  69. <web-view v-else src="https://videos.tradingcentral.cn/players/SHILp3nA-iodula4l.html" />
  70. </view>
  71. </view>
  72. </view>
  73. </cwg-page-wrapper>
  74. </template>
  75. <script setup>
  76. import { ref, onMounted, onUnmounted, computed } from 'vue'
  77. import { onLoad } from '@dcloudio/uni-app'
  78. import { useI18n } from 'vue-i18n'
  79. import { newsApi } from '@/service/news'
  80. import Config from '@/config/index'
  81. import { adaptCWGEmailForUniApp } from '@/utils/emailAdapter.js';
  82. const { t } = useI18n()
  83. const { Code, Host80, Host05 } = Config
  84. // 路由参数
  85. const type = ref(null)
  86. const id = ref(null)
  87. const currentTitleText = computed(() => {
  88. const map = {
  89. 1: t('News.ViewAnalysis'),
  90. 2: t('News.NewsInformation'),
  91. 3: t('News.Announcement'),
  92. 4: t('News.VideoCommentary'),
  93. 5: t('News.NewsInformation'),
  94. 6: t('News.VideoCommentary'),
  95. 7: t('News.Notice'),
  96. 8: t('News.TradeIdeas'),
  97. 9: t('News.FinancialCalendar'),
  98. 10: t('News.Ebook'),
  99. 11: t('News.VideoCommentary')
  100. }
  101. return map[type.value] || ''
  102. })
  103. // 数据
  104. const Content = ref('')
  105. const imgContent = ref('')
  106. const imgContentIf = ref(false)
  107. const info = ref({})
  108. const imgUrl = Host80
  109. // 语言判断
  110. const isZh = computed(() => ['cn', 'zh', 'zhHant'].includes(locale.value));
  111. // 图片预览
  112. const previewImage = (url) => {
  113. uni.previewImage({
  114. urls: [url]
  115. })
  116. }
  117. // 获取详情(根据 title 调用不同接口)
  118. const getNewsSingle = async () => {
  119. if (!type.value) return
  120. switch (type.value) {
  121. case 1: // 观点分析
  122. const analysisRes = await newsApi.newsAnalysisSingle({ id: id.value })
  123. if (analysisRes.code === Code.StatusOK && analysisRes.data) {
  124. imgContent.value = analysisRes.data.media
  125. Content.value = analysisRes.data.content
  126. imgContentIf.value = !!analysisRes.data.media
  127. } else {
  128. uni.showToast({ title: analysisRes.msg, icon: 'none' })
  129. }
  130. break
  131. case 3: // 公告
  132. const infoRes = await newsApi.newsInformationSingle({ id: id.value })
  133. if (infoRes.code === Code.StatusOK && infoRes.data) {
  134. imgContent.value = Host80 + infoRes.data.coverImage
  135. Content.value = infoRes.data.content
  136. imgContentIf.value = !!infoRes.data.coverImage
  137. } else {
  138. uni.showToast({ title: infoRes.msg, icon: 'none' })
  139. }
  140. break
  141. case 7: // 通知
  142. const noticeRes = await newsApi.newsNoticeSingle({ id: id.value })
  143. if (noticeRes.code === Code.StatusOK && noticeRes.data) {
  144. info.value = { ...noticeRes.data, content1: adaptCWGEmailForUniApp(noticeRes.data.content) }
  145. uni.$emit('open-notice')
  146. } else {
  147. uni.showToast({ title: noticeRes.msg, icon: 'none' })
  148. }
  149. break
  150. case 4: // WebTV 视频
  151. const webTvRes = await newsApi.newsWebTvSearchSingle({ id: id.value })
  152. if (webTvRes.code === Code.StatusOK && webTvRes.data) {
  153. info.value = webTvRes.data
  154. // 视频通过 video 组件自动播放,无需手动初始化 DPlayer
  155. } else {
  156. uni.showToast({ title: webTvRes.msg, icon: 'none' })
  157. }
  158. break
  159. case 5: // 新闻通讯
  160. const newsletterRes = await newsApi.newsInformationNewsletterSingle({ id: id.value })
  161. if (newsletterRes.code === Code.StatusOK && newsletterRes.data) {
  162. imgContent.value = Host05 + newsletterRes.data.coverImage
  163. Content.value = newsletterRes.data.content
  164. imgContentIf.value = !!newsletterRes.data.coverImage
  165. } else {
  166. uni.showToast({ title: newsletterRes.msg, icon: 'none' })
  167. }
  168. break
  169. case 6: // 视频评论
  170. const videoRes = await newsApi.newsVideoSingle({ id: id.value })
  171. if (videoRes.code === Code.StatusOK && videoRes.data) {
  172. info.value = videoRes.data
  173. imgContent.value = videoRes.data.videoUrl.includes('http')
  174. ? videoRes.data.videoUrl
  175. : Host80 + videoRes.data.videoUrl
  176. } else {
  177. uni.showToast({ title: videoRes.msg, icon: 'none' })
  178. }
  179. break
  180. case 8: // 交易观点
  181. const shakeRes = await newsApi.handShakeGet({})
  182. if (shakeRes.code === Code.StatusOK) {
  183. imgContent.value = shakeRes.msg
  184. } else {
  185. uni.showToast({ title: shakeRes.msg, icon: 'none' })
  186. }
  187. break
  188. case 9: // 财经日历
  189. const calRes = await newsApi.handFinancialCalendar({})
  190. if (calRes.code === Code.StatusOK) {
  191. imgContent.value = calRes.msg
  192. } else {
  193. uni.showToast({ title: calRes.msg, icon: 'none' })
  194. }
  195. break
  196. case 10: // 电子书
  197. const ebookRes = await newsApi.newsEbookSingle({ id: id.value })
  198. if (ebookRes.code === Code.StatusOK && ebookRes.data) {
  199. info.value = ebookRes.data
  200. } else {
  201. uni.showToast({ title: ebookRes.msg, icon: 'none' })
  202. }
  203. break
  204. default:
  205. break
  206. }
  207. }
  208. // 页面生命周期:获取路由参数
  209. onLoad((options) => {
  210. type.value = Number(options.type)
  211. id.value = options.id
  212. getNewsSingle()
  213. })
  214. // 如果需要在页面卸载时做一些清理(原组件无,可留空)
  215. onUnmounted(() => {
  216. // 清理可能的视频播放器
  217. })
  218. </script>
  219. <style lang="scss" scoped>
  220. @import "@/uni.scss";
  221. #News_Content {
  222. height: 100%;
  223. .crm-title-box {
  224. display: flex;
  225. justify-content: space-between;
  226. align-items: center;
  227. padding: px2rpx(10);
  228. box-sizing: border-box;
  229. background-color: #fff;
  230. border-bottom: 1px solid #eee;
  231. .tit {
  232. font-size: px2rpx(16);
  233. font-weight: bold;
  234. }
  235. .btn {
  236. display: flex;
  237. align-items: center;
  238. .icon-back {
  239. font-size: px2rpx(18);
  240. margin-right: px2rpx(4);
  241. }
  242. }
  243. }
  244. .content {
  245. width: 100%;
  246. height: calc(100% - 50rpx);
  247. background-color: #fff;
  248. overflow: hidden;
  249. text-align: left;
  250. padding: px2rpx(10);
  251. box-sizing: border-box;
  252. line-height: 1.8;
  253. display: flex;
  254. flex-direction: column;
  255. justify-content: center;
  256. .img {
  257. margin-bottom: px2rpx(10);
  258. image {
  259. width: 100%;
  260. }
  261. }
  262. .con-title {
  263. font-size: px2rpx(18);
  264. font-weight: bold;
  265. margin: px2rpx(10) 0;
  266. text-align: center;
  267. }
  268. .con-time {
  269. margin-bottom: px2rpx(10);
  270. font-size: px2rpx(12);
  271. color: #999;
  272. }
  273. .con-des {
  274. margin: px2rpx(10) 0;
  275. font-size: px2rpx(14);
  276. }
  277. .video-player {
  278. width: 100%;
  279. height: px2rpx(400);
  280. }
  281. .webview {
  282. width: 100%;
  283. height: 100%;
  284. min-height: px2rpx(1200);
  285. }
  286. .ebookBox {
  287. display: flex;
  288. flex-direction: column;
  289. @media (min-width: 768px) {
  290. flex-direction: row;
  291. align-items: center;
  292. }
  293. .ebook-cover {
  294. width: 100%;
  295. max-width: px2rpx(360);
  296. height: auto;
  297. margin-right: 0;
  298. margin-bottom: px2rpx(15);
  299. @media (min-width: 768px) {
  300. margin-right: 25rpx;
  301. margin-bottom: 0;
  302. }
  303. }
  304. .news-title {
  305. color: #EB3F57;
  306. font-size: px2rpx(44);
  307. font-weight: bold;
  308. margin-bottom: px2rpx(10);
  309. }
  310. .news-status {
  311. margin-top: px2rpx(10);
  312. a {
  313. display: inline-block;
  314. background-color: #EB3F57;
  315. color: #fff;
  316. padding: px2rpx(4) px2rpx(30);
  317. border-radius: px2rpx(8);
  318. font-weight: bold;
  319. }
  320. }
  321. }
  322. }
  323. }
  324. // 富文本表格样式(保留)
  325. :deep(.con-des) {
  326. table {
  327. border-collapse: collapse !important;
  328. width: 100% !important;
  329. margin: px2rpx(10) 0 !important;
  330. }
  331. th,
  332. td {
  333. border: 1px solid #dcdfe6 !important;
  334. padding: px2rpx(8) !important;
  335. text-align: left !important;
  336. }
  337. th {
  338. background-color: #f5f7fa !important;
  339. }
  340. }
  341. .rich-text-wrapper {
  342. width: 100%;
  343. overflow-x: auto; // 允许横向滚动
  344. -webkit-overflow-scrolling: touch; // 在 iOS 上提供惯性滚动
  345. }
  346. // 可选:让 rich-text 内的内容不换行(但不一定需要)
  347. .rich-text-wrapper rich-text {
  348. display: block;
  349. width: 100%;
  350. }
  351. </style>
  352. <style>
  353. /* 覆盖 rich-text 内所有段落样式 */
  354. uni-rich-text p {
  355. margin: px2rpx(12) 0 !important;
  356. font-size: px2rpx(14) !important;
  357. /* 对应 14px */
  358. line-height: 1.6 !important;
  359. color: #333;
  360. }
  361. /* 覆盖 span 样式,移除固定字体和大小 */
  362. uni-rich-text span {
  363. font-size: px2rpx(14) !important;
  364. font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
  365. }
  366. /* 图片自适应 */
  367. uni-rich-text img {
  368. max-width: 100% !important;
  369. height: auto;
  370. }
  371. </style>