handoutsTree.vue 4.0 KB

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