index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <page-layout class="video-container">
  3. <nav-bar title="观众指南" @init="onInitNavbar"></nav-bar>
  4. <u-scroll-view :tabbar-conflict="true">
  5. <view class="main-container">
  6. <view class="file-list">
  7. <template v-for="(item,index) in list">
  8. <view class="file-item"
  9. :key="index"
  10. v-if="item.url && item.name"
  11. @click="downloadFile(item.url)">
  12. <view class="iconfont icon-Filled"></view>
  13. <span class="file-name">{{item.name ? item.name : '观众指南文件'}}</span>
  14. <view class="iconfont icon-Download"></view>
  15. </view>
  16. </template>
  17. </view>
  18. </view>
  19. </u-scroll-view>
  20. <float-button></float-button>
  21. </page-layout>
  22. </template>
  23. <script>
  24. import NavBar from '@/components/layout/nav-bar'
  25. import UScrollView from '@/components/common/u-scroll-view'
  26. import VanOverlay from '@/wxcomponents/vant/overlay/index'
  27. import floatButton from "@/components/layout/float-button"
  28. import {
  29. getDashboardInfo
  30. } from '@/api'
  31. import PageLayout from "@/components/layout/page-layout";
  32. export default {
  33. components: {
  34. PageLayout,
  35. NavBar,
  36. UScrollView,
  37. VanOverlay,
  38. floatButton
  39. },
  40. data() {
  41. return {
  42. list: []
  43. }
  44. },
  45. props: {
  46. imageMode: {
  47. type: String,
  48. default: 'aspectFill' // 参考https://zh.uniapp.dcloud.io/component/image.html
  49. }
  50. },
  51. mounted() {
  52. this.getDashboardData()
  53. },
  54. methods: {
  55. isImageUrl(url) {
  56. const imageExtensions = /\.(webp|jpg|jpeg|png|gif|bmp|svg)$/i;
  57. return imageExtensions.test(url);
  58. },
  59. downloadFile(url) {
  60. if (url) {
  61. let that= this
  62. that.showLoading({title: '加载文件中'})
  63. uni.downloadFile({
  64. // 示例 url,并非真实存在
  65. url: url,
  66. success: function (res) {
  67. const filePath = res.tempFilePath
  68. if (that.isImageUrl(url)) {
  69. uni.saveImageToPhotosAlbum({
  70. filePath: filePath
  71. })
  72. } else {
  73. uni.openDocument({
  74. showMenu:true,
  75. filePath: filePath,
  76. success: function (res) {
  77. }
  78. })
  79. }
  80. that.hideLoading()
  81. }
  82. })
  83. }
  84. },
  85. getDashboardData() {
  86. getDashboardInfo('', process.env.CONFERENCE_WEBSITE).then(res => {
  87. if (res.data.module2 && res.data.module2[6] && res.data.module2[6].fileList) {
  88. this.list = res.data.module2[6].fileList
  89. }
  90. })
  91. },
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .file-list {
  97. display: flex;
  98. flex-direction: column;
  99. grid-gap: 20rpx;
  100. .file-item {
  101. display: flex;
  102. align-items: center;
  103. grid-gap: 10rpx;
  104. padding: 40rpx;
  105. background: #ffffff;
  106. box-shadow: 5rpx 5rpx 10rpx #cccccc;
  107. .file-name {
  108. flex: 1;
  109. min-width: 1px;
  110. font-size: $fontSize3;
  111. }
  112. .iconfont {
  113. font-size: 36rpx;
  114. }
  115. }
  116. }
  117. </style>