detail.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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" :class="{'itemArrLineBottom':itemArr.length!=(index+1)}" 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" v-if="topName">
  29. <view class="topName" @click="goList">{{topName}}</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import pcNav from '../../components/pcNavLh/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. var code=this.parentCode.substring(0,3)
  69. uni.navigateTo({
  70. url:'list?code='+code+'&topName='+this.topName+'&comment='+this.comment
  71. })
  72. },
  73. goIndex(){
  74. uni.navigateTo({
  75. url:'index'
  76. })
  77. },
  78. getDetailData() {
  79. uni.showLoading({
  80. title: '加载中'
  81. })
  82. let url = '/trainingOpenApiV2/articleDetail',
  83. params = {
  84. id: this.id,
  85. }
  86. this.$http(url, params, 'GET').then(res => {
  87. uni.hideLoading();
  88. var data = res.data
  89. // 处理 undefined和null转为空白字符串
  90. for (const key in data) {
  91. data[key] = this.$praseStrEmpty(data[key])
  92. }
  93. this.detailData = data;
  94. uni.setNavigationBarTitle({
  95. title: this.detailData.title
  96. });
  97. console.log()
  98. if (this.detailData.contents) {
  99. var replaceStr = "application/x-shockwave-flash"
  100. this.detailData.contents=this.detailData.contents.replace(new RegExp(replaceStr,'gm'),'video/webm')//(/''/g,"video/webm")
  101. this.detailData.contents=this.detailData.contents.replace(/<embed([\s\w"-=\/\.:;]+)/ig, '<embed style="width: 100%;height:500px;" $1');
  102. }
  103. if (this.detailData.contents) {
  104. this.detailData.contents = this.detailData.contents.replace(
  105. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  106. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  107. .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
  108. .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
  109. .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
  110. .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
  111. .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');
  112. this.detailData.contents = this.detailData.contents.replace(
  113. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  114. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  115. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<iframe$1')
  116. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<iframe$1')
  117. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<iframe$1')
  118. .replace(/<iframe([\s\w"-=\/\.:;]+)/ig, '<iframe style="width: 100%;height:500px;" $1');
  119. }
  120. this.itemArr = this.detailData.fileList
  121. console.log(this.itemArr)
  122. })
  123. },
  124. // }
  125. }
  126. }
  127. </script>
  128. <style scoped>
  129. .top{
  130. width: 1200px;
  131. margin: 0 auto;
  132. display: flex;
  133. padding: 30px 0;
  134. font-size: 14px;
  135. }
  136. .content{
  137. font-family: PingFangSC-Regular, PingFang SC;
  138. }
  139. .htmlBox{
  140. width: 720px;
  141. margin: 0 auto;
  142. }
  143. .topline{
  144. padding-right: 10px;
  145. cursor: pointer;
  146. color: #3C3C3C;
  147. }
  148. .topjt{
  149. color: #AAAAAA;
  150. padding-right: 10px;
  151. }
  152. .htmlTitle{
  153. font-size: 24px;
  154. font-weight: 500;
  155. color: #3C3C3C;
  156. line-height: 33px;
  157. font-family: PingFangSC-Medium, PingFang SC;
  158. }
  159. .time{
  160. font-size: 14px;
  161. padding-top: 16px;
  162. color: #999999;
  163. line-height: 20px;
  164. border-bottom: 1px solid #EEEEEE;
  165. padding-bottom: 19px;
  166. }
  167. .html{
  168. padding-top: 18px;
  169. }
  170. .fileIcon{
  171. width: 14px;
  172. height: 14px;
  173. margin-top: 4px;
  174. margin-right: 4px;
  175. }
  176. .itemArrLeft{
  177. display: flex;
  178. }
  179. .itemArrLine{
  180. display: flex;
  181. justify-content: space-between;
  182. padding: 16px 0;
  183. color: #333333;
  184. line-height: 22px;
  185. font-size: 16px;
  186. width: 720px;
  187. }
  188. .itemArrLineBottom{
  189. border-bottom: 1px solid #EEEEEE;
  190. }
  191. .itemArr{
  192. width: 686px;
  193. margin: 0 auto;
  194. margin-top: 30px;
  195. border-radius: 6px;
  196. border: 1px solid #EEEEEE;
  197. padding: 0 16px;
  198. }
  199. .dloadbtn{
  200. display: block;
  201. width: 68px;
  202. height: 28px;
  203. background: #3F90F7;
  204. border-radius: 6px;
  205. color: #FFFFFF;
  206. text-align: center;
  207. line-height:28px ;
  208. font-size: 14px;
  209. text-decoration:none;
  210. }
  211. .lbel{
  212. width: 720px;
  213. margin: 0 auto;
  214. margin-top: 30px;
  215. padding-bottom: 30px;
  216. }
  217. .topName{
  218. width: 84px;
  219. height: 24px;
  220. background: rgba(63, 144, 247, 0.1);
  221. border-radius: 14px;
  222. font-size: 14px;
  223. color: #3F90F7;
  224. line-height: 24px;
  225. text-align: center;
  226. cursor: pointer;
  227. }
  228. .fileName{
  229. text-decoration:underline;
  230. color: #3F90F7;
  231. }
  232. .c999{
  233. color: #999999;
  234. }
  235. </style>