2025-06-21 03:34:10 +08:00
|
|
|
<script setup>
|
2025-06-21 12:59:59 +08:00
|
|
|
import { ref } from "vue";
|
|
|
|
|
import { onLoad } from "@dcloudio/uni-app";
|
2025-06-21 03:34:10 +08:00
|
|
|
import Container from "@/components/Container.vue";
|
2025-06-21 22:22:19 +08:00
|
|
|
import { generateCanvasImage } from "@/util";
|
2025-06-21 12:59:59 +08:00
|
|
|
import { getPractiseAPI } from "@/apis";
|
2025-06-21 22:22:19 +08:00
|
|
|
import { wxShare } from "@/util";
|
2025-06-21 12:59:59 +08:00
|
|
|
import useStore from "@/store";
|
|
|
|
|
import { storeToRefs } from "pinia";
|
|
|
|
|
const store = useStore();
|
|
|
|
|
const { user } = storeToRefs(store);
|
2025-06-21 03:34:10 +08:00
|
|
|
|
2025-06-21 12:59:59 +08:00
|
|
|
onLoad(async (options) => {
|
|
|
|
|
const id = options.id || 462;
|
|
|
|
|
const data = await getPractiseAPI(id);
|
|
|
|
|
if (!data.arrows.length) return;
|
2025-06-21 22:22:19 +08:00
|
|
|
generateCanvasImage("shareCanvas", options.type, user.value, data);
|
2025-06-21 03:34:10 +08:00
|
|
|
});
|
2025-06-21 12:59:59 +08:00
|
|
|
|
|
|
|
|
const saveImage = () => {
|
|
|
|
|
uni.canvasToTempFilePath({
|
|
|
|
|
canvasId: "shareCanvas",
|
|
|
|
|
success: (res) => {
|
|
|
|
|
const tempFilePath = res.tempFilePath;
|
|
|
|
|
|
|
|
|
|
// 保存图片到相册
|
|
|
|
|
uni.saveImageToPhotosAlbum({
|
|
|
|
|
filePath: tempFilePath,
|
|
|
|
|
success: () => {
|
|
|
|
|
uni.showToast({ title: "保存成功" });
|
|
|
|
|
},
|
|
|
|
|
fail: () => {
|
|
|
|
|
uni.showToast({ title: "保存失败", icon: "error" });
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
2025-06-21 03:34:10 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<Container>
|
|
|
|
|
<view class="content">
|
2025-06-21 12:59:59 +08:00
|
|
|
<view :style="{ overflow: 'hidden', borderRadius: '10px' }">
|
|
|
|
|
<canvas
|
2025-06-21 22:22:19 +08:00
|
|
|
:style="{ width: '302px', height: '534px' }"
|
2025-06-21 12:59:59 +08:00
|
|
|
canvas-id="shareCanvas"
|
|
|
|
|
></canvas>
|
|
|
|
|
</view>
|
2025-06-21 03:34:10 +08:00
|
|
|
<view class="footer">
|
2025-06-21 22:22:19 +08:00
|
|
|
<button hover-class="none" @click="wxShare">
|
2025-06-21 03:34:10 +08:00
|
|
|
<image src="../static/wechat-outline.png" mode="widthFix" />
|
|
|
|
|
<text>微信好友</text>
|
2025-06-21 22:22:19 +08:00
|
|
|
</button>
|
|
|
|
|
<button hover-class="none">
|
2025-06-21 03:34:10 +08:00
|
|
|
<image src="../static/wechat-moment.png" mode="widthFix" />
|
|
|
|
|
<text>朋友圈</text>
|
2025-06-21 22:22:19 +08:00
|
|
|
</button>
|
|
|
|
|
<button hover-class="none" @click="saveImage">
|
2025-06-21 03:34:10 +08:00
|
|
|
<image src="../static/download.png" mode="widthFix" />
|
|
|
|
|
<text>保存到相册</text>
|
2025-06-21 22:22:19 +08:00
|
|
|
</button>
|
2025-06-21 03:34:10 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</Container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.content {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
.footer {
|
|
|
|
|
width: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
margin-top: 50px;
|
|
|
|
|
}
|
2025-06-21 22:22:19 +08:00
|
|
|
.footer > button {
|
2025-06-21 03:34:10 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: #fff;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
2025-06-21 22:22:19 +08:00
|
|
|
.footer > button > image {
|
2025-06-21 03:34:10 +08:00
|
|
|
width: 45px;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|