handoutsTree.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view style="padding-left: 20rpx">
  3. <view v-if="fileInfo.type == 2">
  4. <view
  5. @click="handelClick"
  6. class="fl u-border-bottom"
  7. style="height: 78rpx; padding-right: 30rpx"
  8. >
  9. <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
  10. <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
  11. <view class="menu_name">
  12. <view class="u-line-1">{{ fileInfo.urlName }}</view>
  13. <view v-if="fileInfo.filePath" class="pathtips u-line-1">
  14. {{ fileInfo.filePath }}
  15. </view>
  16. </view>
  17. </view>
  18. <view v-show="!down">
  19. <view v-for="item in fileInfo.children" :key="item.fileId">
  20. <handouts-tree
  21. :canDownload="canDownload"
  22. :fileInfo="item"
  23. ></handouts-tree>
  24. </view>
  25. </view>
  26. </view>
  27. <view v-if="fileInfo.type == 1">
  28. <view class="fl_c u-border-bottom level1">
  29. <view class="title">
  30. <view class="u-line-1">{{ fileInfo.urlName }}</view>
  31. <view v-if="fileInfo.filePath" class="pathtips u-line-1">
  32. {{ fileInfo.filePath }}
  33. </view>
  34. </view>
  35. <view @click="openDocument">
  36. <image
  37. v-if="!downLoading"
  38. src="/pages3/static/imgs/downLoad.png"
  39. ></image>
  40. <image
  41. v-else
  42. src="/pages3/static/imgs/downLoading.png"
  43. class="loading_down"
  44. ></image>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import handoutsTree from "@/components/course/handoutsTree.vue";
  52. export default {
  53. name: "handoutsTree",
  54. props: {
  55. fileInfo: {
  56. type: Object,
  57. default: () => {
  58. return {};
  59. },
  60. },
  61. canDownload: {
  62. type: Number,
  63. },
  64. },
  65. data() {
  66. return {
  67. down: true,
  68. downLoading: false,
  69. };
  70. },
  71. methods: {
  72. handelClick() {
  73. this.down = !this.down;
  74. },
  75. openDocument() {
  76. let url = this.$method.splitImgHost(this.fileInfo.url);
  77. // #ifdef H5
  78. window.location.href = url;
  79. // uni.navigateTo({
  80. // url: `/pages/webview/sdlink?url=` + url,
  81. // });
  82. // #endif
  83. // #ifdef MP-WEIXIN
  84. this.downLoading = true;
  85. uni.downloadFile({
  86. url: url,
  87. success: (res) => {
  88. var filePath = res.tempFilePath;
  89. // h5不支持
  90. uni.openDocument({
  91. filePath: filePath,
  92. showMenu: this.canDownload == 1 ? true : false,
  93. success: (res) => {
  94. this.downLoading = false;
  95. uni.setStorageSync("nofresh", 1);
  96. },
  97. fail: (err) => {
  98. this.downLoading = false;
  99. uni.showToast({
  100. icon: "none",
  101. title: "文档地址错误",
  102. });
  103. },
  104. });
  105. },
  106. fail: (err) => {
  107. this.downLoading = false;
  108. uni.showModal({
  109. title: "提示",
  110. content: "文档错误," + err.errMsg,
  111. showCancel: false,
  112. });
  113. },
  114. });
  115. // #endif
  116. },
  117. },
  118. components: {
  119. handoutsTree,
  120. },
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. .menu_name {
  125. font-size: 26rpx;
  126. font-weight: bold;
  127. color: #333;
  128. margin-left: 14rpx;
  129. .pathtips {
  130. font-size: 24rpx;
  131. color: #999;
  132. }
  133. }
  134. .level1 {
  135. height: 78rpx;
  136. padding-right: 20rpx;
  137. .title {
  138. flex: 1;
  139. font-size: 26rpx;
  140. color: #333;
  141. .pathtips {
  142. font-size: 22rpx;
  143. color: #999;
  144. }
  145. }
  146. .loading_down {
  147. transform: rotate(360deg);
  148. animation: rotation 3s linear infinite;
  149. }
  150. image {
  151. width: 40rpx;
  152. height: 40rpx;
  153. }
  154. }
  155. @keyframes rotation {
  156. from {
  157. -webkit-transform: rotate(0deg);
  158. }
  159. to {
  160. -webkit-transform: rotate(360deg);
  161. }
  162. }
  163. </style>