detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="content">
  3. <pcNav></pcNav>
  4. <view style="height: 72px;"></view>
  5. <view class="top">
  6. <view class="topline" @click="goIndex">首页</view>
  7. <view class="topjt">></view>
  8. <view class="topline" :class="{'c999':!twoName}" @click="goList()">{{topName}}</view>
  9. <view class="topjt" v-if="twoName">></view>
  10. <view class="topline" :class="{'c999':twoName}">{{twoName}}</view>
  11. </view>
  12. <view class="htmlBox">
  13. <view class="htmlTitle">{{detailData.name}}</view>
  14. <view class="time">{{detailData.publishTime}}</view>
  15. <view class="html" v-html="detailData.contents"></view>
  16. </view>
  17. <view class="itemArr" v-if="itemArr.length>0">
  18. <view class="itemArrLine" v-for="(item,index) in itemArr">
  19. <view class="itemArrLeft" >
  20. <image src="../../static/pcimg/icon_fujian@2x.png" mode="" class="fileIcon"></image>
  21. <view class="fileName" @click="gofile(item.fileUrl)">{{item.fileName}}</view>
  22. </view>
  23. <!-- <view class="dload">
  24. <a class="dloadbtn" :href="item.fileUrl" target='_blank' >下载</a>
  25. </view> -->
  26. </view>
  27. </view>
  28. <view class="lbel">
  29. <view class="topName">{{topName}}</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import pcNav from '../../components/pcNav/pcNav.vue'
  35. export default {
  36. components: {
  37. pcNav,
  38. },
  39. data() {
  40. return {
  41. id: '',
  42. detailData: {},
  43. couContent: '',
  44. itemArr: [],
  45. topName:'',
  46. twoName:'',
  47. comment:'',
  48. parentCode:'',
  49. }
  50. },
  51. onLoad(opt) {
  52. console.log('opt', opt);
  53. this.id = opt.id
  54. this.topName=opt.topName;
  55. this.twoName=opt.twoName;
  56. this.comment=opt.comment;
  57. this.parentCode=opt.parentCode
  58. this.getDetailData()
  59. // uni.setNavigationBarTitle({
  60. // title: this.topName
  61. // })
  62. },
  63. methods: {
  64. gofile(url){
  65. window.location.href=url
  66. },
  67. goList(){
  68. uni.navigateTo({
  69. url:'list?code='+this.parentCode+'&topName='+this.topName+'&comment='+this.comment
  70. })
  71. },
  72. goIndex(){
  73. uni.navigateTo({
  74. url:'index'
  75. })
  76. },
  77. getDetailData() {
  78. uni.showLoading({
  79. title: '加载中'
  80. })
  81. let url = '/trainingOpenApi/articleDetail',
  82. params = {
  83. id: this.id,
  84. }
  85. this.$http(url, params, 'GET').then(res => {
  86. uni.hideLoading();
  87. var data = res.data
  88. // 处理 undefined和null转为空白字符串
  89. for (const key in data) {
  90. data[key] = this.$praseStrEmpty(data[key])
  91. }
  92. this.detailData = data;
  93. console.log()
  94. if (this.detailData.contents) {
  95. var replaceStr = "application/x-shockwave-flash"
  96. this.detailData.contents=this.detailData.contents.replace(new RegExp(replaceStr,'gm'),'video/webm')//(/''/g,"video/webm")
  97. this.detailData.contents=this.detailData.contents.replace(/<embed([\s\w"-=\/\.:;]+)/ig, '<embed style="width: 100%;height:500px;" $1');
  98. }
  99. if (this.detailData.contents) {
  100. this.detailData.contents = this.detailData.contents.replace(
  101. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  102. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  103. .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
  104. .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
  105. .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
  106. .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
  107. .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');
  108. this.detailData.contents = this.detailData.contents.replace(
  109. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  110. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  111. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<iframe$1')
  112. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<iframe$1')
  113. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<iframe$1')
  114. .replace(/<iframe([\s\w"-=\/\.:;]+)/ig, '<iframe style="width: 100%;height:500px;" $1');
  115. }
  116. this.itemArr = this.detailData.fileList
  117. console.log(this.itemArr)
  118. })
  119. },
  120. // }
  121. }
  122. }
  123. </script>
  124. <style scoped>
  125. .top{
  126. width: 1200px;
  127. margin: 0 auto;
  128. display: flex;
  129. padding: 30px 0;
  130. font-size: 14px;
  131. }
  132. .htmlBox{
  133. width: 720px;
  134. margin: 0 auto;
  135. }
  136. .topline{
  137. padding-right: 10px;
  138. cursor: pointer;
  139. color: #3C3C3C;
  140. }
  141. .topjt{
  142. color: #AAAAAA;
  143. padding-right: 10px;
  144. }
  145. .htmlTitle{
  146. font-size: 24px;
  147. font-weight: 500;
  148. color: #3C3C3C;
  149. line-height: 33px;
  150. }
  151. .time{
  152. font-size: 14px;
  153. padding-top: 16px;
  154. color: #999999;
  155. line-height: 20px;
  156. border-bottom: 1px solid #EEEEEE;
  157. padding-bottom: 19px;
  158. }
  159. .html{
  160. padding-top: 18px;
  161. }
  162. .fileIcon{
  163. width: 14px;
  164. height: 14px;
  165. margin-top: 4px;
  166. margin-right: 4px;
  167. }
  168. .itemArrLeft{
  169. display: flex;
  170. }
  171. .itemArrLine{
  172. display: flex;
  173. justify-content: space-between;
  174. padding: 16px 0;
  175. border-bottom: 1px solid #EEEEEE;
  176. color: #333333;
  177. line-height: 22px;
  178. font-size: 16px;
  179. width: 720px;
  180. }
  181. .itemArr{
  182. width: 686px;
  183. margin: 0 auto;
  184. margin-top: 30px;
  185. border-radius: 6px;
  186. border: 1px solid #EEEEEE;
  187. padding: 0 16px;
  188. }
  189. .dloadbtn{
  190. display: block;
  191. width: 68px;
  192. height: 28px;
  193. background: #3F90F7;
  194. border-radius: 6px;
  195. color: #FFFFFF;
  196. text-align: center;
  197. line-height:28px ;
  198. font-size: 14px;
  199. text-decoration:none;
  200. }
  201. .lbel{
  202. width: 720px;
  203. margin: 0 auto;
  204. margin-top: 30px;
  205. padding-bottom: 30px;
  206. }
  207. .topName{
  208. width: 84px;
  209. height: 24px;
  210. background: rgba(63, 144, 247, 0.1);
  211. border-radius: 14px;
  212. font-size: 12px;
  213. color: #3F90F7;
  214. line-height: 24px;
  215. text-align: center;
  216. }
  217. .fileName{
  218. text-decoration:underline;
  219. color: #3F90F7;
  220. }
  221. .c999{
  222. color: #999999;
  223. }
  224. </style>