123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- <template>
- <view class="content">
- <!-- 导航 -->
- <view class="nav">
- <view class="leftView" @click="back">
- <image src="../../static/mobile/backBtn.png" mode=""
- style="width: 22rpx; height: 40rpx; padding-left: 24rpx;"></image>
- </view>
- <view class="navTitle">详情</view>
- <view class="rightView">
- </view>
- </view>
- <!-- content -->
- <view class="top">{{detailData.title}}</view>
- <view class="time">{{detailData.createTime}}</view>
- <!-- <rich-text :nodes="couContent"></rich-text> -->
- <view class="html" v-html="detailData.contents"></view>
- <!-- item -->
- <view class="itemBg" v-if="itemArr.length != 0">
- <view v-for="(item,index) in itemArr" :key="index" class="twoItem"
- :class="{grayLine:index < itemArr.length-1}">
- <view class="itemLeftView">
- <image src="../../static/mobile/icon_fujian.png" mode="" class="img2"></image>
- <view class="title" @click="goUrl(item)">{{item.fileName}}</view>
- <!-- <a class="title" :href='item.fileUrl'>{{item.fileName}}</a> -->
- </view>
- </view>
- </view>
- <view style="display: flex;">
- <view class="category">{{detailData.parentName}}</view>
- </view>
- <view class="gotop" @click="gotoTop">
- <image src="../../static/pcimg/btn_top@2x.png" mode="" class="gotopImg"></image>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id: '',
- detailData: {},
- couContent: '',
- itemArr: [],
- userType: '',
- }
- },
- onLoad(opt) {
- console.log('opt', opt);
- this.id = opt.id
- this.getDetailData()
- // uni.setNavigationBarTitle({
- // title: this.topName
- // })
- this.userType = uni.getStorageSync("userType");
- console.log('userType', this.userType);
- },
- methods: {
- goUrl(item) {
- // console.log('item',item);
-
- if (this.userType == 'app') {
- uni.navigateTo({
- url: 'accessory_app?fileName=' + item.fileName + '&fileUrl=' + item.fileUrl
- })
- } else {
- window.location.href = item.fileUrl
- }
- },
- gotoTop() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 300
- });
- },
- getDetailData() {
- uni.showLoading({
- title: '加载中'
- })
- let url = '/trainingOpenApiV2/articleDetail',
- params = {
- id: this.id,
- }
- this.$http(url, params, 'GET').then(res => {
- uni.hideLoading();
- var data = res.data
- // 处理 undefined和null转为空白字符串
- for (const key in data) {
- data[key] = this.$praseStrEmpty(data[key])
- }
- this.detailData = data
- console.log('contents1111', this.detailData.contents);
- if (this.detailData.contents) {
- var replaceStr = "application/x-shockwave-flash"
- this.detailData.contents=this.detailData.contents.replace(new RegExp(replaceStr,'gm'),'video/webm')//(/''/g,"video/webm")
- this.detailData.contents=this.detailData.contents.replace(/<embed([\s\w"-=\/\.:;]+)/ig, '<embed style="width: 100%;" $1');
- }
- if (this.detailData.contents) {
- this.detailData.contents = this.detailData.contents.replace(/<iframe([\s\w"-=\/\.:;]+)/ig,
- '<iframe style="width: 100%;height:300px;" $1');
- }
- if (this.detailData.contents) {
- this.detailData.contents = this.detailData.contents.replace(
- /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
- .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
- .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
- .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
- .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
- .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
- .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');
- }
- console.log('contents', this.detailData.contents);
- this.itemArr = this.detailData.fileList
- })
- },
- back() {
- uni.navigateBack({
- })
- },
- // // 下拉刷新 上拉加载更多
- // onPullDownRefresh() {
- // this.page = 1;
- // this.getItemData()
- // this.getDetailData()
- // setTimeout(function() {
- // uni.stopPullDownRefresh();
- // }, 1000);
- // },
- // onReachBottom() {
- // this.page++;
- // this.getItemData()
- // }
- }
- }
- </script>
- <style scoped>
- .content {
- min-height: 100vh;
- background-color: #FFFFFF;
- padding-top: 88rpx;
- padding-bottom: 10rpx;
- margin: 0 24rpx;
- }
- .nav {
- position: fixed;
- left: 0;
- top: 0;
- width: 100vw;
- height: 88rpx;
- background-color: #FFFFFF;
- display: flex;
- justify-content: space-between;
- align-items: center;
- z-index: 999;
- border-bottom: #eeeeee 2rpx solid;
- }
- .navTitle {
- font-size: 36rpx;
- font-weight: bold;
- color: #3c3c3c;
- text-align: center;
- }
- .leftView {
- width: 30%;
- }
- .rightView {
- width: 30%;
- display: flex;
- justify-content: flex-end;
- padding-right: 24rpx;
- }
- .rightImg {
- width: 40rpx;
- height: 40rpx;
- }
- .top {
- background-color: #FFFFFF;
- padding-top: 40rpx;
- font-weight: bold;
- color: #3c3c3c;
- font-size: 32rpx;
- text-align: left;
- }
- .time {
- font-size: 24rpx;
- color: #999999;
- padding-top: 15rpx;
- padding-bottom: 30rpx;
- border-bottom: #EEEEEE 2rpx solid;
- }
- .html {
- padding-top: 18px;
- }
- .html img {
- width: 100% !important;
- }
- .itemBg {
- background-color: #FFFFFF;
- border-radius: 10rpx;
- border: #eeeeee 1rpx solid;
- }
- .twoItem {
- display: flex;
- justify-content: space-between;
- align-items: center;
- background-color: #FFFFFF;
- margin: 0 15rpx;
- padding-top: 24rpx;
- padding-bottom: 30rpx;
- }
- .grayLine {
- border-bottom: #EEEEEE 1rpx solid;
- }
- .itemLeftView {
- display: flex;
- align-items: center;
- width: 100%;
- }
- .title {
- font-size: 28rpx;
- color: #333333;
- width: 100%;
- word-break: break-all;
- text-decoration:underline;
-
- }
- .title2 {
- background-color: #3F90F7;
- border-radius: 6rpx;
- width: 90rpx;
- height: 52rpx;
- line-height: 52rpx;
- text-align: center;
- margin-right: 15rpx;
- }
- .table-btn {
- color: #FFFFFF;
- font-size: 26rpx;
- text-decoration: none;
- }
- .img2 {
- width: 28rpx;
- height: 28rpx;
- margin-right: 6rpx;
- }
- .category {
- background: rgba(63, 144, 247, 0.1);
- font-size: 22rpx;
- color: #3F90F7;
- height: 36rpx;
- line-height: 36rpx;
- border-radius: 18rpx;
- padding: 3rpx 14rpx;
- min-width: 0;
- max-width: 138rpx;
- margin-bottom: 10rpx;
- text-align: center;
- margin: 30rpx 0;
- /* 隐藏文字显示 ...不换行 */
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .gotopImg {
- width: 100rpx;
- height: 100rpx;
- }
- .gotop {
- position: fixed;
- right: 15rpx;
- bottom: 50rpx;
- cursor: pointer;
- z-index: 999;
- }
- </style>
|