detail.vue 4.9 KB

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