handoutsTree.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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: `/pages/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. uni.setStorageSync("nofresh", 1);
  99. },
  100. fail: (err) => {
  101. this.downLoading = false;
  102. uni.showToast({
  103. icon: "none",
  104. title: "文档地址错误",
  105. });
  106. },
  107. });
  108. },
  109. fail: (err) => {
  110. this.downLoading = false;
  111. uni.showModal({
  112. title: "提示",
  113. content: "文档错误," + err.errMsg,
  114. showCancel: false,
  115. });
  116. },
  117. });
  118. // #endif
  119. },
  120. },
  121. components: {
  122. handoutsTree,
  123. },
  124. };
  125. </script>
  126. <style lang="scss" scoped>
  127. .menu_name {
  128. font-size: 26rpx;
  129. font-weight: bold;
  130. color: #333;
  131. margin-left: 14rpx;
  132. .pathtips {
  133. font-size: 24rpx;
  134. color: #999;
  135. }
  136. }
  137. .level1 {
  138. height: 78rpx;
  139. padding-right: 20rpx;
  140. .title {
  141. // flex: 1;
  142. width: 90%;
  143. font-size: 26rpx;
  144. color: #333;
  145. .pathtips {
  146. font-size: 22rpx;
  147. color: #999;
  148. }
  149. }
  150. .loading_down {
  151. transform: rotate(360deg);
  152. animation: rotation 3s linear infinite;
  153. }
  154. image {
  155. width: 40rpx;
  156. height: 40rpx;
  157. }
  158. }
  159. @keyframes rotation {
  160. from {
  161. -webkit-transform: rotate(0deg);
  162. }
  163. to {
  164. -webkit-transform: rotate(360deg);
  165. }
  166. }
  167. </style>