123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <view style="padding-left: 20rpx">
- <view v-if="fileInfo.type == 2">
- <view
- @click="handelClick"
- class="fl u-border-bottom"
- style="height: 78rpx; padding-right: 30rpx"
- >
- <u-icon name="arrow-down" color="#999" size="24" v-if="!down"></u-icon>
- <u-icon name="arrow-right" color="#999" size="24" v-if="down"></u-icon>
- <view class="menu_name">
- <view class="u-line-1">{{ fileInfo.urlName }}</view>
- <view v-if="fileInfo.filePath" class="pathtips u-line-1">
- {{ fileInfo.filePath }}
- </view>
- </view>
- </view>
- <view v-show="!down">
- <view v-for="item in fileInfo.children" :key="item.fileId">
- <handouts-tree
- :isShowDownIcon="isShowDownIcon"
- :canDownload="canDownload"
- :fileInfo="item"
- ></handouts-tree>
- </view>
- </view>
- </view>
- <view v-if="fileInfo.type == 1">
- <view class="fl_c u-border-bottom level1">
- <view class="title">
- <view class="u-line-1">{{ fileInfo.urlName }}</view>
- <view v-if="fileInfo.filePath" class="pathtips u-line-1">
- {{ fileInfo.filePath }}
- </view>
- </view>
- <view @click="openDocument" v-if="isShowDownIcon">
- <image
- v-if="!downLoading"
- src="/pages3/static/imgs/downLoad.png"
- ></image>
- <image
- v-else
- src="/pages3/static/imgs/downLoading.png"
- class="loading_down"
- ></image>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import handoutsTree from "@/components/course/handoutsTree.vue";
- export default {
- name: "handoutsTree",
- props: {
- fileInfo: {
- type: Object,
- default: () => {
- return {};
- },
- },
- canDownload: {
- type: Number,
- },
- isShowDownIcon: {
- type: Boolean,
- default: true,
- },
- },
- data() {
- return {
- down: true,
- downLoading: false,
- };
- },
- methods: {
- handelClick() {
- this.down = !this.down;
- },
- openDocument() {
- let url = this.$method.splitImgHost(this.fileInfo.url);
- // #ifdef H5
- uni.navigateTo({
- url: `/pages/webview/sdlink?url=http://192.168.1.57:8080/?src=${url}`,
- });
- // #endif
- // #ifdef MP-WEIXIN
- this.downLoading = true;
- uni.downloadFile({
- url: url,
- success: (res) => {
- var filePath = res.tempFilePath;
- // h5不支持
- uni.openDocument({
- filePath: filePath,
- showMenu: this.canDownload == 1 ? true : false,
- success: (res) => {
- this.downLoading = false;
- uni.setStorageSync("nofresh", 1);
- },
- fail: (err) => {
- this.downLoading = false;
- uni.showToast({
- icon: "none",
- title: "文档地址错误",
- });
- },
- });
- },
- fail: (err) => {
- this.downLoading = false;
- uni.showModal({
- title: "提示",
- content: "文档错误," + err.errMsg,
- showCancel: false,
- });
- },
- });
- // #endif
- },
- },
- components: {
- handoutsTree,
- },
- };
- </script>
- <style lang="scss" scoped>
- .menu_name {
- font-size: 26rpx;
- font-weight: bold;
- color: #333;
- margin-left: 14rpx;
- .pathtips {
- font-size: 24rpx;
- color: #999;
- }
- }
- .level1 {
- height: 78rpx;
- padding-right: 20rpx;
- .title {
- // flex: 1;
- width: 90%;
- font-size: 26rpx;
- color: #333;
- .pathtips {
- font-size: 22rpx;
- color: #999;
- }
- }
- .loading_down {
- transform: rotate(360deg);
- animation: rotation 3s linear infinite;
- }
- image {
- width: 40rpx;
- height: 40rpx;
- }
- }
- @keyframes rotation {
- from {
- -webkit-transform: rotate(0deg);
- }
- to {
- -webkit-transform: rotate(360deg);
- }
- }
- </style>
|