handoutsTree.vue 3.9 KB

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