handoutsTree.vue 3.9 KB

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