rankDetail.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. <template>
  2. <view class="rf-category">
  3. <u-toast ref="uToast" />
  4. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" :title-width="350" back-icon-color="#fff"
  5. title-color="#fff" :title="i18n('InformationDetails')" :background="background">
  6. <view class="navbar-right" slot="right">
  7. <view class="right-item" @tap="shareChange">
  8. <u-icon :name="ifcommon==true?'star-fill':'star'" size="38"></u-icon>
  9. </view>
  10. </view>
  11. </u-navbar>
  12. <view class="details">
  13. <view class="title">{{ initData.title }}</view>
  14. <view class="time">{{ formatDate(initData.publishDate) }} | {{$t('common.Source')}}: {{initData.auther}}
  15. </view>
  16. <rich-text v-if="initData.contentHtml" class="content"
  17. :nodes="initData.contentHtml.replace('https://www.geidcp.com/api','https://m.geidcp.com/api')">
  18. </rich-text>
  19. <view class="statement">
  20. <text class="statement-text">{{$t('common.contentisreproduced')}}</text>
  21. </view>
  22. </view>
  23. <view class="relevant">
  24. <text class="name">{{$t('common.RelatedInformation')}}</text>
  25. <view class="relevant-list">
  26. <view class="listBox" v-for="(info,index) in initList" :key="info.id">
  27. <view class="infoList" v-if="initData.id != info.id" @tap="toRankDetail"
  28. :data-key="info.baseEntityId">
  29. <div class="leftImg" v-if="info.pictureUrl">
  30. <image class="img" :src="websiteUrl + info.pictureUrl" mode="">
  31. </image>
  32. </div>
  33. <div class="rightCont" :style="{ width: info.pictureUrl?'460upx':'100%' }">
  34. <view class="rightContTitle">{{ info.title }}</view>
  35. <view class="info-cont">
  36. {{ info.content }}
  37. </view>
  38. <view class="title-base">
  39. <text>{{ info.auther }}</text>
  40. <text class="baseTime">{{ formatDate(info.publishDate) }}</text>
  41. </view>
  42. </div>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. addIntegral
  52. } from '@/components/addPointDetailByTaskDict.js'
  53. export default {
  54. components: {
  55. addIntegral
  56. },
  57. data() {
  58. return {
  59. background: {
  60. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  61. },
  62. backStyle: {
  63. color: '#fff'
  64. },
  65. initData: '',
  66. initList: [],
  67. page: {
  68. baseId: ''
  69. },
  70. // 收藏
  71. ifcommon: false,
  72. // 用户信息
  73. Storage_data: '',
  74. AuthToken: '',
  75. }
  76. },
  77. async onLoad(e) {
  78. uni.showLoading({
  79. title: this.$i18n.locale == 'zh' ? '加载中...' : 'Loading...'
  80. });
  81. console.log(e, 1111);
  82. this.page.baseId = e.key;
  83. await this.getData();
  84. // 获取关注状态 开始
  85. await this.getMyCollecModel()
  86. // 获取关注状态 结束
  87. },
  88. onShow() {
  89. // 获取登录状态和用户信息 开始
  90. this.AuthToken = uni.getStorageSync('Auth-Token');
  91. if (this.AuthToken) {
  92. this.Storage_data = JSON.parse(uni.getStorageSync('user'));
  93. setTimeout(() => {
  94. addIntegral('point_read_information', '2')
  95. console.log('已完成');
  96. }, 1000);
  97. }
  98. // 获取登录状态和用户信息 结束
  99. },
  100. computed: {
  101. token() {
  102. return 'Bearer ' + uni.getStorageSync('Auth-Token');
  103. }
  104. },
  105. methods: {
  106. i18n(data) {
  107. return this.$t('common.' + data);
  108. },
  109. async getData() {
  110. this.page.language = this.$i18n.locale.toUpperCase()
  111. const res = await this.$myRequest({
  112. url: '/cms/cmsInformationViews/getInformationById/',
  113. data: this.page
  114. });
  115. this.initData = res.data.cmsInformationViewAPP;
  116. uni.hideLoading();
  117. this.getRelevantList(this.initData.typeDict, this.$i18n.locale.toUpperCase());
  118. },
  119. async getRelevantList(type, language) { //相关资讯
  120. let page = {
  121. typeDict: type,
  122. language: language,
  123. pageSize: 5,
  124. pageNo: 1,
  125. businessType: "information",
  126. }
  127. const res = await this.$myRequest({
  128. url: '/cms/cmsInformationViews/appGetInformationList/',
  129. data: page
  130. });
  131. this.initList = res.data.allDataList || [];
  132. this.initList.forEach(element => {
  133. element.content = element.content.replace(/<[^>]+>|&[^>]+;/g, "")
  134. });
  135. },
  136. toRankDetail(e) {
  137. let key = e.currentTarget.dataset.key;
  138. uni.navigateTo({
  139. url: './rankDetail?key=' + key
  140. });
  141. },
  142. // 收藏
  143. shareChange() {
  144. if (this.AuthToken) {
  145. if (!this.ifcommon) {
  146. this.saveFollowModelDo("collect");
  147. } else {
  148. this.saveFollowModelDo("uncollect");
  149. }
  150. } else {
  151. if (this.$i18n.locale == 'zh') {
  152. this.$refs.uToast.show({
  153. title: '请登录',
  154. type: 'warning',
  155. url: '/pages/public/login',
  156. params: {
  157. back: 1
  158. }
  159. })
  160. } else {
  161. this.$refs.uToast.show({
  162. title: 'please log in',
  163. type: 'warning',
  164. url: '/pages/public/login',
  165. params: {
  166. back: 1
  167. }
  168. })
  169. }
  170. }
  171. },
  172. async getMyCollecModel() {
  173. const that = this;
  174. if (this.AuthToken) {
  175. var users = this.Storage_data;
  176. let MyCollecModel = {
  177. modelType: 'message',
  178. userId: users.id,
  179. modelEntityId: this.initData.baseEntityId,
  180. };
  181. const res = await this.$myRequest({
  182. url: '/op/basePortalModelCollectInfos/getPortalMyCollectModelByResearch',
  183. data: {
  184. modelEntityId: this.initData.baseEntityId,
  185. modelType: 'message',
  186. userId: users.id,
  187. }
  188. });
  189. if (res) {
  190. this.ifcommon = res.data.result;
  191. }
  192. }
  193. },
  194. // 关注操作方法
  195. //收藏接口
  196. async saveFollowModelDo(followType) {
  197. if (!this.AuthToken) {} else {
  198. var users = this.Storage_data;
  199. let MyCollecModel = {
  200. followType: followType,
  201. modelId: this.initData.baseEntityId,
  202. modelType: 'message',
  203. userId: users.id,
  204. };
  205. const res = await this.$myRequest({
  206. url: '/op/basePortalModelCollectInfos/addCollectInfo',
  207. method: 'post',
  208. headers: {
  209. token: this.token
  210. },
  211. data: {
  212. collectType: followType,
  213. modelId: this.initData.baseEntityId,
  214. modelType: 'message',
  215. userId: users.id,
  216. }
  217. });
  218. if (res.status == 200) {
  219. if (followType == 'uncollect') {
  220. if (this.$i18n.locale == 'zh') {
  221. this.$refs.uToast.show({
  222. title: '取消收藏',
  223. type: 'success',
  224. })
  225. } else {
  226. this.$refs.uToast.show({
  227. title: 'Cancel collected',
  228. type: 'success',
  229. })
  230. }
  231. } else if (followType == 'collect') {
  232. if (this.$i18n.locale == 'zh') {
  233. this.$refs.uToast.show({
  234. title: '已收藏',
  235. type: 'success',
  236. })
  237. } else {
  238. this.$refs.uToast.show({
  239. title: 'Already collected',
  240. type: 'success',
  241. })
  242. }
  243. }
  244. this.ifcommon = !this.ifcommon;
  245. }
  246. }
  247. },
  248. }
  249. }
  250. </script>
  251. <style scoped>
  252. /deep/ img,
  253. /deep/ image {
  254. width: 100%;
  255. height: 350rpx;
  256. }
  257. .details {
  258. padding: 30upx;
  259. background-color: #FFFFFF;
  260. }
  261. /deep/ .content p,
  262. /deep/ .content span {
  263. font-size: 32upx !important;
  264. }
  265. .statement {
  266. margin-top: 30upx;
  267. }
  268. .statement-text {
  269. font-size: 28upx;
  270. color: #666666;
  271. }
  272. .relevant {
  273. padding: 20upx 30upx;
  274. background-color: #FFFFFF;
  275. margin-top: 20upx;
  276. }
  277. .navbar-right {
  278. margin-right: 24upx;
  279. display: flex;
  280. }
  281. .right-item {
  282. margin: 0 20upx;
  283. position: relative;
  284. color: #ffffff;
  285. display: flex;
  286. }
  287. .title {
  288. font-size: 34upx;
  289. font-weight: 700;
  290. text-align: center;
  291. }
  292. .time {
  293. font-size: 30upx;
  294. color: #666666;
  295. margin: 20upx 0;
  296. text-align: center;
  297. }
  298. .img {
  299. width: 100%;
  300. height: 100%;
  301. }
  302. .relevant {
  303. margin-top: 20upx;
  304. }
  305. .name {
  306. font-size: 34upx;
  307. color: #333333;
  308. font-weight: 700;
  309. position: relative;
  310. padding-left: 20upx;
  311. }
  312. .name:before {
  313. width: 10upx;
  314. height: 34upx;
  315. content: '';
  316. position: absolute;
  317. left: 0;
  318. top: 2upx;
  319. background-color: #6DD400;
  320. }
  321. .infoList {
  322. padding-top: 30upx;
  323. display: flex;
  324. justify-content: space-between;
  325. border-bottom: 1px solid #F1F1F1;
  326. }
  327. .relevant-list .listBox:last-child .infoList {
  328. border-bottom: none;
  329. }
  330. .leftImg {
  331. width: 185upx;
  332. height: 140upx;
  333. }
  334. .rightCont {
  335. width: 460upx;
  336. padding-bottom: 30upx;
  337. }
  338. .rightContTitle {
  339. color: #333333;
  340. font-size: 32upx;
  341. font-weight: 700;
  342. overflow: hidden;
  343. lines: 2;
  344. text-overflow: ellipsis;
  345. display: -webkit-box;
  346. -webkit-line-clamp: 2;
  347. -webkit-box-orient: vertical;
  348. }
  349. .title-base {
  350. font-size: 28upx;
  351. color: #999999;
  352. margin-top: 15upx;
  353. }
  354. .baseTime {
  355. margin-left: 30upx;
  356. }
  357. .info-cont {
  358. margin-top: 15upx;
  359. font-size: 32upx;
  360. overflow: hidden;
  361. lines: 2;
  362. text-overflow: ellipsis;
  363. display: -webkit-box;
  364. -webkit-line-clamp: 2;
  365. -webkit-box-orient: vertical;
  366. }
  367. .listBox:last-child .rightCont {
  368. border-bottom: none;
  369. }
  370. </style>