123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <template>
- <view class="rf-category">
- <u-toast ref="uToast" />
- <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" :title-width="350" back-icon-color="#fff"
- title-color="#fff" :title="i18n('InformationDetails')" :background="background">
- <view class="navbar-right" slot="right">
- <view class="right-item" @tap="shareChange">
- <u-icon :name="ifcommon==true?'star-fill':'star'" size="38"></u-icon>
- </view>
- </view>
- </u-navbar>
- <view class="details">
- <view class="title">{{ initData.title }}</view>
- <view class="time">{{ formatDate(initData.createDate) }} | {{$t('common.Source')}}: {{initData.auther}}
- </view>
- <rich-text v-if="initData.contentHtml" class="content"
- :nodes="initData.contentHtml.replace('/api','https://m.geidcp.com/api')">
- </rich-text>
- <view class="statement">
- <text class="statement-text">{{$t('common.contentisreproduced')}}</text>
- </view>
- </view>
- <view class="relevant">
- <text class="name">{{$t('common.RelatedInformation')}}</text>
- <view class="relevant-list">
- <view class="listBox" v-for="(info,index) in initList" :key="info.id">
- <view class="infoList" v-if="initData.id != info.id" @tap="toRankDetail"
- :data-key="info.baseEntityId">
- <div class="leftImg" v-if="info.pictureUrl">
- <image class="img" :src="websiteUrl + info.pictureUrl" mode="">
- </image>
- </div>
- <div class="rightCont" :style="{ width: info.pictureUrl?'460upx':'100%' }">
- <view class="rightContTitle">{{ info.title }}</view>
- <view class="info-cont">
- {{ info.content }}
- </view>
- <view class="title-base">
- <text>{{ info.auther }}</text>
- <text class="baseTime">{{ formatDate(info.publishDate) }}</text>
- </view>
- </div>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- background: {
- backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
- },
- backStyle: {
- color: '#fff'
- },
- initData: '',
- initList: [],
- page: {
- id: '',
- pageSize: 1,
- pageNo: 1,
- },
- // 收藏
- ifcommon: false,
- // 用户信息
- Storage_data: '',
- AuthToken: '',
- }
- },
- async onLoad(e) {
- uni.showLoading({
- title: this.$i18n.locale == 'zh' ? '加载中...' : 'Loading...'
- });
- console.log(e, 1111);
- this.page.id = e.key;
- await this.getData();
- // 获取关注状态 开始
- await this.getMyCollecModel()
- // 获取关注状态 结束
- },
- onShow() {
- // 获取登录状态和用户信息 开始
- this.AuthToken = uni.getStorageSync('Auth-Token');
- if (this.AuthToken) {
- this.Storage_data = JSON.parse(uni.getStorageSync('user'));
- }
- // 获取登录状态和用户信息 结束
- },
- computed: {
- token() {
- return 'Bearer ' + uni.getStorageSync('Auth-Token');
- }
- },
- methods: {
- i18n(data) {
- return this.$t('common.' + data);
- },
- async getData() {
- this.page.language = this.$i18n.locale.toUpperCase()
- const res = await this.$myRequest({
- url: '/cms/cmsInformationEntitys/weatherArticleDetail/',
- data: this.page
- });
- this.initData = res.data.weatherArticleDetail[0];
- uni.hideLoading();
- this.getRelevantList(this.initData.typeDict, this.$i18n.locale.toUpperCase());
- },
- async getRelevantList(type, language) { //相关资讯
- let page = {
- typeDict: type,
- language: language,
- pageSize: 5,
- pageNo: 1,
- businessType: "information",
- }
- const res = await this.$myRequest({
- url: '/cms/cmsInformationViews/appGetInformationList/',
- data: page
- });
- this.initList = res.data.allDataList || [];
- this.initList.forEach(element => {
- element.content = element.content.replace(/<[^>]+>|&[^>]+;/g, "")
- });
- },
- toRankDetail(e) {
- let key = e.currentTarget.dataset.key;
- uni.navigateTo({
- url: './rankDetail?key=' + key
- });
- },
- // 收藏
- shareChange() {
- if (this.AuthToken) {
- if (!this.ifcommon) {
- this.saveFollowModelDo("collect");
- } else {
- this.saveFollowModelDo("uncollect");
- }
- } else {
- if (this.$i18n.locale == 'zh') {
- this.$refs.uToast.show({
- title: '请登录',
- type: 'warning',
- url: '/pages/public/login',
- params: {
- back: 1
- }
- })
- } else {
- this.$refs.uToast.show({
- title: 'please log in',
- type: 'warning',
- url: '/pages/public/login',
- params: {
- back: 1
- }
- })
- }
- }
- },
- async getMyCollecModel() {
- const that = this;
- if (this.AuthToken) {
- var users = this.Storage_data;
- let MyCollecModel = {
- modelType: 'message',
- userId: users.id,
- modelEntityId: this.initData.baseEntityId,
- };
- const res = await this.$myRequest({
- url: '/op/basePortalModelCollectInfos/getPortalMyCollectModelByResearch',
- data: {
- modelEntityId: this.initData.baseEntityId,
- modelType: 'message',
- userId: users.id,
- }
- });
- if (res) {
- this.ifcommon = res.data.result;
- }
- }
- },
- // 关注操作方法
- //收藏接口
- async saveFollowModelDo(followType) {
- if (!this.AuthToken) {} else {
- var users = this.Storage_data;
- let MyCollecModel = {
- followType: followType,
- modelId: this.initData.baseEntityId,
- modelType: 'message',
- userId: users.id,
- };
- const res = await this.$myRequest({
- url: '/op/basePortalModelCollectInfos/addCollectInfo',
- method: 'post',
- headers: {
- token: this.token
- },
- data: {
- collectType: followType,
- modelId: this.initData.baseEntityId,
- modelType: 'message',
- userId: users.id,
- }
- });
- if (res.status == 200) {
- if (followType == 'uncollect') {
- if (this.$i18n.locale == 'zh') {
- this.$refs.uToast.show({
- title: '取消收藏',
- type: 'success',
- })
- } else {
- this.$refs.uToast.show({
- title: 'Cancel collected',
- type: 'success',
- })
- }
- } else if (followType == 'collect') {
- if (this.$i18n.locale == 'zh') {
- this.$refs.uToast.show({
- title: '已收藏',
- type: 'success',
- })
- } else {
- this.$refs.uToast.show({
- title: 'Already collected',
- type: 'success',
- })
- }
- }
- this.ifcommon = !this.ifcommon;
- }
- }
- },
- }
- }
- </script>
- <style scoped>
- /deep/ img,
- /deep/ image {
- width: 100%;
- height: 350rpx;
- }
- .details {
- padding: 30upx;
- background-color: #FFFFFF;
- }
- /deep/ .content p,
- /deep/ .content span {
- font-size: 32upx !important;
- padding: 0 1%;
- }
- .statement {
- margin-top: 30upx;
- padding: 0 1%;
- }
- .statement-text {
- font-size: 28upx;
- color: #666666;
- }
- .relevant {
- padding: 20upx 30upx;
- background-color: #FFFFFF;
- margin-top: 20upx;
- }
- .navbar-right {
- margin-right: 24upx;
- display: flex;
- }
- .right-item {
- margin: 0 20upx;
- position: relative;
- color: #ffffff;
- display: flex;
- }
- .title {
- font-size: 34upx;
- font-weight: 700;
- text-align: center;
- }
- .time {
- font-size: 30upx;
- color: #666666;
- margin: 20upx 0;
- text-align: center;
- }
- .detail-pic {
- width: 96%;
- height: 360upx;
- margin-left: 2%;
- border-radius: 20upx;
- overflow: hidden;
- }
- .first-pic {
- width: 100%;
- height: 100%;
- }
- .img {
- width: 100%;
- height: 100%;
- }
- .relevant {
- margin-top: 20upx;
- }
- .name {
- font-size: 34upx;
- color: #333333;
- font-weight: 700;
- position: relative;
- padding-left: 20upx;
- }
- .name:before {
- width: 10upx;
- height: 34upx;
- content: '';
- position: absolute;
- left: 0;
- top: 2upx;
- background-color: #6DD400;
- }
- .infoList {
- padding-top: 30upx;
- display: flex;
- justify-content: space-between;
- border-bottom: 1px solid #F1F1F1;
- }
- .relevant-list .listBox:last-child .infoList {
- border-bottom: none;
- }
- .leftImg {
- width: 185upx;
- height: 140upx;
- }
- .rightCont {
- width: 460upx;
- padding-bottom: 30upx;
- }
- .rightContTitle {
- color: #333333;
- font-size: 32upx;
- font-weight: 700;
- overflow: hidden;
- lines: 2;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .title-base {
- font-size: 28upx;
- color: #999999;
- margin-top: 15upx;
- }
- .baseTime {
- margin-left: 30upx;
- }
- .info-cont {
- margin-top: 15upx;
- font-size: 32upx;
- overflow: hidden;
- lines: 2;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .listBox:last-child .rightCont {
- border-bottom: none;
- }
- </style>
|