detail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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">{{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. uni.setNavigationBarTitle({
  94. title: this.detailData.title
  95. });
  96. console.log()
  97. if (this.detailData.contents) {
  98. var replaceStr = "application/x-shockwave-flash"
  99. this.detailData.contents=this.detailData.contents.replace(new RegExp(replaceStr,'gm'),'video/webm')//(/''/g,"video/webm")
  100. this.detailData.contents=this.detailData.contents.replace(/<embed([\s\w"-=\/\.:;]+)/ig, '<embed style="width: 100%;height:500px;" $1');
  101. }
  102. if (this.detailData.contents) {
  103. this.detailData.contents = this.detailData.contents.replace(
  104. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  105. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  106. .replace(/<img([\s\w"-=\/\.:;]+)((?:(height="[^"]+")))/ig, '<img$1')
  107. .replace(/<img([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<img$1')
  108. .replace(/<img([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<img$1')
  109. .replace(/<img([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<img$1')
  110. .replace(/<img([\s\w"-=\/\.:;]+)/ig, '<img style="width: 100%;" $1');
  111. this.detailData.contents = this.detailData.contents.replace(
  112. /<p([\s\w"=\/\.:;]+)((?:(style="[^"]+")))/ig, '<p')
  113. .replace(/<p>/ig, '<p style="font-size: 15px; line-height: 25px;">')
  114. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(width="[^"]+")))/ig, '<iframe$1')
  115. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(style="[^"]+")))/ig, '<iframe$1')
  116. .replace(/<iframe([\s\w"-=\/\.:;]+)((?:(alt="[^"]+")))/ig, '<iframe$1')
  117. .replace(/<iframe([\s\w"-=\/\.:;]+)/ig, '<iframe style="width: 100%;height:500px;" $1');
  118. }
  119. this.itemArr = this.detailData.fileList
  120. console.log(this.itemArr)
  121. })
  122. },
  123. // }
  124. }
  125. }
  126. </script>
  127. <style scoped>
  128. .top{
  129. width: 1200px;
  130. margin: 0 auto;
  131. display: flex;
  132. padding: 30px 0;
  133. font-size: 14px;
  134. }
  135. .content{
  136. font-family: PingFangSC-Regular, PingFang SC;
  137. }
  138. .htmlBox{
  139. width: 720px;
  140. margin: 0 auto;
  141. }
  142. .topline{
  143. padding-right: 10px;
  144. cursor: pointer;
  145. color: #3C3C3C;
  146. }
  147. .topjt{
  148. color: #AAAAAA;
  149. padding-right: 10px;
  150. }
  151. .htmlTitle{
  152. font-size: 24px;
  153. font-weight: 500;
  154. color: #3C3C3C;
  155. line-height: 33px;
  156. font-family: PingFangSC-Medium, PingFang SC;
  157. }
  158. .time{
  159. font-size: 14px;
  160. padding-top: 16px;
  161. color: #999999;
  162. line-height: 20px;
  163. border-bottom: 1px solid #EEEEEE;
  164. padding-bottom: 19px;
  165. }
  166. .html{
  167. padding-top: 18px;
  168. }
  169. .fileIcon{
  170. width: 14px;
  171. height: 14px;
  172. margin-top: 4px;
  173. margin-right: 4px;
  174. }
  175. .itemArrLeft{
  176. display: flex;
  177. }
  178. .itemArrLine{
  179. display: flex;
  180. justify-content: space-between;
  181. padding: 16px 0;
  182. color: #333333;
  183. line-height: 22px;
  184. font-size: 16px;
  185. width: 720px;
  186. }
  187. .itemArrLineBottom{
  188. border-bottom: 1px solid #EEEEEE;
  189. }
  190. .itemArr{
  191. width: 686px;
  192. margin: 0 auto;
  193. margin-top: 30px;
  194. border-radius: 6px;
  195. border: 1px solid #EEEEEE;
  196. padding: 0 16px;
  197. }
  198. .dloadbtn{
  199. display: block;
  200. width: 68px;
  201. height: 28px;
  202. background: #3F90F7;
  203. border-radius: 6px;
  204. color: #FFFFFF;
  205. text-align: center;
  206. line-height:28px ;
  207. font-size: 14px;
  208. text-decoration:none;
  209. }
  210. .lbel{
  211. width: 720px;
  212. margin: 0 auto;
  213. margin-top: 30px;
  214. padding-bottom: 30px;
  215. }
  216. .topName{
  217. width: 84px;
  218. height: 24px;
  219. background: rgba(63, 144, 247, 0.1);
  220. border-radius: 14px;
  221. font-size: 14px;
  222. color: #3F90F7;
  223. line-height: 24px;
  224. text-align: center;
  225. }
  226. .fileName{
  227. text-decoration:underline;
  228. color: #3F90F7;
  229. }
  230. .c999{
  231. color: #999999;
  232. }
  233. </style>