|
@@ -26,8 +26,18 @@
|
|
<u-parse :content="detail.course ? detail.course.description : '暂无课程信息'"></u-parse>
|
|
<u-parse :content="detail.course ? detail.course.description : '暂无课程信息'"></u-parse>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
- <view class="topBtn" @click="downLoad(detail.status)">
|
|
|
|
|
|
+ <!-- <view class="topBtn" @click="downLoad(detail.status)">
|
|
查看学习资料
|
|
查看学习资料
|
|
|
|
+ </view> -->
|
|
|
|
+ <view class="topBtn" @click="handleShowRes">
|
|
|
|
+ {{resShow?'收起学习资料':'查看学习资料'}}
|
|
|
|
+ </view>
|
|
|
|
+
|
|
|
|
+ <view class="res" v-if="resShow&&this.detail.course">
|
|
|
|
+ <view class="inner" v-for="(i,index) in this.detail.course.content" @click="downLoad(i)">
|
|
|
|
+ <text style="text-decoration: underline;">
|
|
|
|
+ {{'学习资料'+(index+1)}}</text><text>{{i.slice(i.lastIndexOf('.'))}}</text>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
<view class="divLine">
|
|
<view class="divLine">
|
|
@@ -87,7 +97,9 @@
|
|
tobheight: 45,
|
|
tobheight: 45,
|
|
detail: {},
|
|
detail: {},
|
|
|
|
|
|
- orderId: ''
|
|
|
|
|
|
+ orderId: '',
|
|
|
|
+
|
|
|
|
+ resShow: false
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -105,14 +117,8 @@
|
|
console.log('课程详情', this.detail);
|
|
console.log('课程详情', this.detail);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- goPay() {
|
|
|
|
- let pay = new ShoproPay(this.orderId);
|
|
|
|
- },
|
|
|
|
- downLoad(status) {
|
|
|
|
- // uni.navigateTo({
|
|
|
|
- // url: '/pages/test/index'
|
|
|
|
- // })
|
|
|
|
- if (status == 0) {
|
|
|
|
|
|
+ handleShowRes() {
|
|
|
|
+ if (this.detail.status == 0) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: '待支付课程不能查看学习资料',
|
|
title: '待支付课程不能查看学习资料',
|
|
icon: 'none',
|
|
icon: 'none',
|
|
@@ -130,73 +136,29 @@
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- if (this.detail.course.content.endsWith('.mp4')) {
|
|
|
|
- console.log('.mp4', this.detail.course.content);
|
|
|
|
-
|
|
|
|
- // row.fileAdd 文件地址 row.fileName 文件名称,需要加上文件后缀
|
|
|
|
- // fetch(this.detail.course.content)
|
|
|
|
- // .then(response => response.blob())
|
|
|
|
- // .then(blob => {
|
|
|
|
- // const url = URL.createObjectURL(blob);
|
|
|
|
- // const link = document.createElement('a');
|
|
|
|
- // link.href = url;
|
|
|
|
- // link.setAttribute('download', '123456.mp4');
|
|
|
|
- // document.body.appendChild(link);
|
|
|
|
- // link.click();
|
|
|
|
- // })
|
|
|
|
- // .catch(console.error);
|
|
|
|
-
|
|
|
|
|
|
+ this.resShow = !this.resShow
|
|
|
|
+ },
|
|
|
|
+ goPay() {
|
|
|
|
+ let pay = new ShoproPay(this.orderId);
|
|
|
|
+ },
|
|
|
|
+ downLoad(fileName) {
|
|
|
|
+ if (fileName.endsWith('.mp4') || fileName.endsWith('.pdf')) {
|
|
let plat = uni.getSystemInfoSync().platform
|
|
let plat = uni.getSystemInfoSync().platform
|
|
-
|
|
|
|
if (plat == 'android' || plat == 'ios') {
|
|
if (plat == 'android' || plat == 'ios') {
|
|
console.log("plat == 'android' || plat == 'ios'");
|
|
console.log("plat == 'android' || plat == 'ios'");
|
|
-
|
|
|
|
- // uni.downloadFile({
|
|
|
|
- // url: this.detail.course.content, //仅为示例,并非真实的资源
|
|
|
|
- // success: (res) => {
|
|
|
|
- // if (res.statusCode === 200) {
|
|
|
|
- // console.log('下载成功', res.tempFilePath);
|
|
|
|
- // downLoad2(res.tempFilePath, this.detail.course.name + '-学习资料')
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
window.open(
|
|
window.open(
|
|
- this.detail.course.content
|
|
|
|
|
|
+ fileName
|
|
)
|
|
)
|
|
- // fetch(this.detail.course.content)
|
|
|
|
- // .then(response => {
|
|
|
|
- // return response.blob()
|
|
|
|
- // })
|
|
|
|
- // .then(blob => {
|
|
|
|
- // const url = URL.createObjectURL(blob);
|
|
|
|
- // const link = document.createElement('a');
|
|
|
|
- // link.href = url;
|
|
|
|
- // link.setAttribute('download', '123456.mp4');
|
|
|
|
- // document.body.appendChild(link);
|
|
|
|
- // link.click();
|
|
|
|
- // })
|
|
|
|
- // .catch(console.error);
|
|
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
- console.log("pc");
|
|
|
|
- downLoad2(this.detail.course.content, this.detail.course.name + '-学习资料', 'video/mp4')
|
|
|
|
|
|
+ downLoad2(fileName, this.detail.course.name + '-学习资料', 'video/mp4和zip')
|
|
}
|
|
}
|
|
-
|
|
|
|
- // saveAs(this.detail.course.content, '测试文件名')
|
|
|
|
} else {
|
|
} else {
|
|
- let plat = uni.getSystemInfoSync().platform
|
|
|
|
- if (plat == 'android' || plat == 'ios') {
|
|
|
|
- console.log("plat == 'android' || plat == 'ios'");
|
|
|
|
- window.open(
|
|
|
|
- this.detail.course.content
|
|
|
|
- )
|
|
|
|
- } else {
|
|
|
|
- console.log("pc");
|
|
|
|
- downLoad2(this.detail.course.content, this.detail.course.name + '-学习资料', 'application/pdf')
|
|
|
|
- }
|
|
|
|
|
|
+ window.open(
|
|
|
|
+ fileName
|
|
|
|
+ )
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ },
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|