download.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="download">
  3. <view class="workark-empty" v-if="list.length === 0">
  4. <uv-empty icon="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/fa57e25b38c442ebb0ba023cace796bb"
  5. :isImg="true" textSize="28" width="360" text="暂无文件">
  6. </uv-empty>
  7. </view>
  8. <view class="down-list" v-else>
  9. <view class="down-item" v-for="(item,index) in list" :key="item.id">
  10. <view class="down-content">
  11. <view class="down-icon">
  12. <uv-icon color="#fff" size="52" name="file-text-fill">
  13. </uv-icon>
  14. </view>
  15. <view class="content">
  16. <view class="title hui-ellipsis">{{item.fileName}}</view>
  17. <view class="date">{{item.date}}</view>
  18. </view>
  19. </view>
  20. <view class="down-operation">
  21. <view class="down-operation-item" @tap="openDocument(index)">
  22. <uv-icon color="#8c8c8c" size="40" name="order">
  23. </uv-icon>
  24. <text class="text">打开</text>
  25. </view>
  26. <view class="down-operation-item" @tap="shareFile(index)">
  27. <uv-icon color="#8c8c8c" size="40" name="share">
  28. </uv-icon>
  29. <text class="text">分享</text>
  30. </view>
  31. <view class="down-operation-item" @tap="deleteFile(index)">
  32. <uv-icon color="#8c8c8c" size="40" name="trash">
  33. </uv-icon>
  34. <text class="text">删除</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. list: [],
  46. deviceId: ''
  47. }
  48. },
  49. onLoad() {
  50. this.init();
  51. },
  52. methods: {
  53. init() {
  54. let file = !uni.getStorageSync('downliadFile') ? [] : JSON.parse(uni.getStorageSync(
  55. 'downliadFile'));
  56. this.list = file.filter(node => node.userId === this.$store.getters.user.userId);
  57. },
  58. deleteFile(index) {
  59. let _self = this;
  60. let file = !uni.getStorageSync('downliadFile') ? [] : JSON.parse(uni
  61. .getStorageSync('downliadFile'));
  62. let item = _self.list[index];
  63. uni.showModal({
  64. title: '有极提示',
  65. content: '是否删除该文件?',
  66. success: res => {
  67. if (res.confirm) {
  68. let index = file.findIndex(node => node.wxUrl === item.wxUrl);
  69. file.splice(index, 1);
  70. uni.setStorageSync('downliadFile', JSON.stringify(file));
  71. _self.init();
  72. }
  73. }
  74. });
  75. },
  76. shareFile(index) {
  77. let item = this.list[index];
  78. wx.shareFileMessage({
  79. filePath: item.wxUrl,
  80. fileName: item.fileName,
  81. success(data) {}
  82. })
  83. },
  84. openDocument(index) {
  85. let item = this.list[index];
  86. uni.openDocument({
  87. filePath: item.wxUrl,
  88. fileType: item.type,
  89. success: (res) => {},
  90. fail: (error) => {
  91. this.$toast('打开失败')
  92. }
  93. });
  94. }
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. .down-list {
  100. padding: 30rpx;
  101. .down-item {
  102. padding: 40rpx 40rpx 0px 40rpx;
  103. background: #fff;
  104. border-radius: 12rpx;
  105. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  106. margin-bottom: 30rpx;
  107. }
  108. .down-operation {
  109. border-top: 2rpx solid $uv-border-color;
  110. display: flex;
  111. align-items: center;
  112. }
  113. .down-operation-item {
  114. display: flex;
  115. align-items: center;
  116. color: $uv-content-color;
  117. flex: 1;
  118. justify-content: center;
  119. padding: 30rpx 0;
  120. }
  121. .down-content {
  122. display: flex;
  123. align-items: center;
  124. padding-bottom: 40rpx;
  125. }
  126. .content {
  127. margin-left: 12rpx;
  128. flex: 1;
  129. width: 0;
  130. overflow: hidden;
  131. }
  132. .title {
  133. font-size: 32rpx;
  134. font-weight: 600;
  135. margin-bottom: 10rpx;
  136. width: 100%;
  137. }
  138. .date {
  139. font-weight: 300;
  140. font-size: 24rpx;
  141. margin-top: 10rpx;
  142. color: $uv-content-color;
  143. }
  144. .down-icon {
  145. width: 80rpx;
  146. height: 80rpx;
  147. border-radius: 12rpx;
  148. background: $uv-primary;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. }
  153. }
  154. </style>