handoutsTree.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. uni.navigateTo({
  84. url: `/pages5/webview/sdlink?url=https://preview.xyyxt.net?src=${url}`,
  85. });
  86. // #endif
  87. // #ifdef MP-WEIXIN
  88. this.downLoading = true;
  89. uni.downloadFile({
  90. url: url,
  91. success: (res) => {
  92. var filePath = res.tempFilePath;
  93. uni.openDocument({
  94. filePath: filePath,
  95. showMenu: this.canDownload == 1 ? true : false,
  96. success: (res) => {
  97. this.downLoading = false;
  98. },
  99. fail: (err) => {
  100. this.downLoading = false;
  101. uni.showToast({
  102. icon: "none",
  103. title: "文档地址错误",
  104. });
  105. },
  106. });
  107. },
  108. fail: (err) => {
  109. this.downLoading = false;
  110. uni.showModal({
  111. title: "提示",
  112. content: "文档错误," + err.errMsg,
  113. showCancel: false,
  114. });
  115. },
  116. });
  117. // #endif
  118. },
  119. },
  120. components: {
  121. handoutsTree,
  122. },
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. .menu_name {
  127. font-size: 26rpx;
  128. font-weight: bold;
  129. color: #333;
  130. margin-left: 14rpx;
  131. .pathtips {
  132. font-size: 24rpx;
  133. color: #999;
  134. }
  135. }
  136. .level1 {
  137. height: 78rpx;
  138. padding-right: 20rpx;
  139. .title {
  140. // flex: 1;
  141. width: 90%;
  142. font-size: 26rpx;
  143. color: #333;
  144. .pathtips {
  145. font-size: 22rpx;
  146. color: #999;
  147. }
  148. }
  149. .loading_down {
  150. transform: rotate(360deg);
  151. animation: rotation 3s linear infinite;
  152. }
  153. image {
  154. width: 40rpx;
  155. height: 40rpx;
  156. }
  157. }
  158. @keyframes rotation {
  159. from {
  160. -webkit-transform: rotate(0deg);
  161. }
  162. to {
  163. -webkit-transform: rotate(360deg);
  164. }
  165. }
  166. </style>