detail.vue 13 KB

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