weatherListDetail.vue 8.6 KB

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