newDetail.vue 7.1 KB

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