newsContent.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view style="padding:0 40rpx 20rpx;box-sizing: border-box" v-if="content != null">
  3. <view style="font-size: 34rpx;font-weight: bold;color: #303133;margin-top: 20rpx;">
  4. {{content.title}}
  5. </view>
  6. <!-- <view style="font-size: 30rpx;color:#606266;padding: 20rpx 0;">
  7. 发布人:
  8. </view> -->
  9. <view style="font-size: 28rpx;color:#909399;margin: 20rpx 0;display: flex;align-items: center;">
  10. <view>
  11. {{$u.timeFormat(content.publishTime, 'yyyy-mm-dd hh:MM:ss')}}
  12. </view>
  13. <view style="margin-left: 40rpx;">
  14. {{content.createBy}}
  15. </view>
  16. </view>
  17. <u-divider ></u-divider>
  18. <view>
  19. <u-parse :content="content.content"></u-parse>
  20. </view>
  21. <view style="border-radius: 8rpx;background-color: #f3f3f3;margin-top: 40rpx;padding: 20rpx 40rpx;" v-if="content.fjFiles != null && content.fjFiles.length != 0">
  22. <view style="display: flex;align-items: center;margin-bottom: 20rpx;f">
  23. <u-icon name="file-text-fill" color="#000"></u-icon>
  24. 附件
  25. </view>
  26. <view style="margin-bottom: 30rpx;" v-for="v in content.fjFiles" :key="v.fileId">
  27. <u--text :lines="1" size="15" color="#2979FF" decoration="underline" :text="v.name" @click="downLoad(v)"></u--text>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. content:null,
  37. list1:[],
  38. list2:[]
  39. }
  40. },
  41. onLoad(options){
  42. this.getNewsContent(options.id)
  43. },
  44. methods: {
  45. getNewsContent(id){
  46. uni.$u.http.get('/oa/article/detail/'+id).then(res=>{
  47. // console.log(res)
  48. this.content = res.data
  49. uni.setNavigationBarTitle({
  50. title: res.data.title
  51. })
  52. })
  53. },
  54. //下载附件
  55. downLoad(v){
  56. let that = this
  57. uni.showLoading({
  58. title:"打开中...",
  59. })
  60. if(v.path == null){
  61. let qaz = v.url.slice(10).replace(/[\\]/g,'/')
  62. if(that.list1.indexOf(v.url.slice(10)) == -1){
  63. uni.downloadFile({
  64. url:getApp().globalData.updateUrl+qaz,
  65. success: function(res) {
  66. if (res.statusCode === 200) {
  67. that.list1.push(v.url.slice(10))
  68. that.list2.push(res.tempFilePath)
  69. uni.openDocument({
  70. filePath: res.tempFilePath,
  71. success: function (qwe) {
  72. uni.hideLoading();
  73. }
  74. });
  75. }else{
  76. uni.hideLoading()
  77. uni.showToast({
  78. title:"下载失败",
  79. icon:'none'
  80. })
  81. }
  82. },fail:function(){
  83. uni.hideLoading()
  84. uni.showToast({
  85. title:"下载失败",
  86. icon:'none'
  87. })
  88. }
  89. });
  90. }else{
  91. uni.openDocument({
  92. filePath: that.list2[that.list1.indexOf(v.url.slice(10))],
  93. success: function (res) {
  94. uni.hideLoading();
  95. }
  96. });
  97. }
  98. }else{
  99. if(that.list1.indexOf(v.path) == -1){
  100. uni.downloadFile({
  101. url:getApp().globalData.saveUrl+v.path,
  102. success: function(res) {
  103. if (res.statusCode === 200) {
  104. that.list1.push(v.path)
  105. that.list2.push(res.tempFilePath)
  106. uni.openDocument({
  107. filePath: res.tempFilePath,
  108. success: function (qwe) {
  109. uni.hideLoading();
  110. }
  111. });
  112. }else{
  113. uni.hideLoading()
  114. uni.showToast({
  115. title:"下载失败",
  116. icon:'none'
  117. })
  118. }
  119. },fail:function(){
  120. uni.hideLoading()
  121. uni.showToast({
  122. title:"下载失败",
  123. icon:'none'
  124. })
  125. }
  126. });
  127. }else{
  128. uni.openDocument({
  129. filePath: that.list2[that.list1.indexOf(v.path)],
  130. success: function (res) {
  131. uni.hideLoading();
  132. }
  133. });
  134. }
  135. }
  136. }
  137. }
  138. }
  139. </script>
  140. <style>
  141. </style>