|
@@ -1,41 +1,92 @@
|
|
|
<template>
|
|
|
- <view class='app-container'>
|
|
|
- <uv-parse :content="form.content" selectable @linktap="linktap" />
|
|
|
+ <view class="detail">
|
|
|
+ <!-- <uv-parse :content="downUrl" :preview-img="false" /> -->
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { detail } from '@/api/agreement.js'
|
|
|
+import { detail } from "@/api/explain.js";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- // 表单
|
|
|
- form: {}
|
|
|
- }
|
|
|
+ downUrl: "",
|
|
|
+ };
|
|
|
},
|
|
|
+
|
|
|
onLoad(e) {
|
|
|
- this.getDetail(e.type)
|
|
|
+ var that = this;
|
|
|
+ that.getDetail(e.id);
|
|
|
},
|
|
|
+
|
|
|
methods: {
|
|
|
- getDetail(type) {
|
|
|
- detail({
|
|
|
- type: type
|
|
|
- }).then(res => {
|
|
|
+ // {"data":{"id":"1866721048372842496","name":"猫王.旅行者2号",
|
|
|
+ // "fileUrl":"https://music-play.oss-cn-shenzhen.aliyuncs.com/backOss/file/f5f5ed93fae74fb683e8d116c40a884c.xlsx",
|
|
|
+ // "codeUrl":null,"status":0,"sort":1,"createTime":"2024-12-11T05:45:55.000+00:00",
|
|
|
+ // "updateTime":"2024-12-11T07:21:11.000+00:00","categoryId":419013412782082,
|
|
|
+ // "createTimeStr":"2024-12-11 13:45:55","updateTimeStr":"2024-12-11 15:21:11",
|
|
|
+ // "categoryName":"音箱","copyUrl":"http://testweb.radio1964.com/"},
|
|
|
+ // "code":0,"message":"","requestId":null,"success":true}
|
|
|
+ getDetail(id) {
|
|
|
+ var that = this;
|
|
|
+ detail(id).then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- this.form = res.data
|
|
|
+ that.downUrl = res.data.fileUrl;
|
|
|
+ that.downloadFile();
|
|
|
}
|
|
|
- })
|
|
|
+ // else {
|
|
|
+ // uni.showToast({
|
|
|
+ // title: res.data.message,
|
|
|
+ // icon: "error",
|
|
|
+ // mask: true,
|
|
|
+ // duration: 2000,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ });
|
|
|
},
|
|
|
- // 点击链接
|
|
|
- linktap(e) {
|
|
|
- window.location.href = e.href
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
+ async downloadFile() {
|
|
|
+ var that = this;
|
|
|
+ try {
|
|
|
+ // https://music-play.oss-cn-shenzhen.aliyuncs.com/backOss/file/f5f5ed93fae74fb683e8d116c40a884c.xlsx
|
|
|
+ const fileUrl = that.downUrl; // 替换为你的文件路径
|
|
|
+ const response = await fetch(fileUrl);
|
|
|
+
|
|
|
+ if (!response.ok) {
|
|
|
+ throw new Error(`HTTP error! status: ${response.status}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ const blob = await response.blob();
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.style.display = "none";
|
|
|
+ a.href = url;
|
|
|
+ var fileName = that.getFileExtension(fileUrl);
|
|
|
+ a.download = new Date().getTime() + "." + fileName;
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
+ } catch (error) {}
|
|
|
+ },
|
|
|
+
|
|
|
+ getFileExtension(fileUrl) {
|
|
|
+ const filename = fileUrl.split("/").pop();
|
|
|
+ const lastDotIndex = filename.lastIndexOf(".");
|
|
|
+ if (lastDotIndex === -1 || lastDotIndex === filename.length - 1) {
|
|
|
+ return "";
|
|
|
+ } else {
|
|
|
+ return filename.substring(lastDotIndex + 1).toLowerCase();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.app-container{
|
|
|
+.detail {
|
|
|
white-space: pre-wrap;
|
|
|
}
|
|
|
+
|
|
|
+::v-deep img {
|
|
|
+ display: block;
|
|
|
+}
|
|
|
</style>
|