resultDetails.vue 8.2 KB

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