修复练习不能分享的问题
This commit is contained in:
@@ -13,7 +13,7 @@ import BowPower from "@/components/BowPower.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { generateCanvasImage, wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -79,23 +79,23 @@ async function onReceiveMessage(messages = []) {
|
||||
arrows: JSON.parse(msg.practice.arrows),
|
||||
lvl: msg.lvl,
|
||||
};
|
||||
generateCanvasImage(
|
||||
"shareCanvas",
|
||||
1,
|
||||
user.value,
|
||||
practiseResult.value
|
||||
);
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await generateCanvasImage("shareCanvas", 1, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("share-image", onClickShare);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -103,6 +103,7 @@ onBeforeUnmount(() => {
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("share-image", onClickShare);
|
||||
});
|
||||
|
||||
const nextStep = async () => {
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { getPractiseAPI } from "@/apis";
|
||||
import { wxShare } from "@/util";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
|
||||
onLoad(async (options) => {
|
||||
const id = options.id || 461;
|
||||
const data = await getPractiseAPI(id);
|
||||
if (!data.arrows.length) return;
|
||||
generateCanvasImage("shareCanvas", options.type, user.value, data);
|
||||
});
|
||||
|
||||
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" });
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Container>
|
||||
<view class="content">
|
||||
<view :style="{ overflow: 'hidden', borderRadius: '10px' }">
|
||||
<canvas
|
||||
:style="{ width: '300px', height: '534px' }"
|
||||
canvas-id="shareCanvas"
|
||||
></canvas>
|
||||
</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;
|
||||
}
|
||||
.footer > button {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
}
|
||||
.footer > button > image {
|
||||
width: 45px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
@@ -11,7 +11,7 @@ import BowPower from "@/components/BowPower.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { generateCanvasImage, wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPES, roundsName } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -62,12 +62,6 @@ async function onReceiveMessage(messages = []) {
|
||||
arrows: JSON.parse(msg.practice.arrows),
|
||||
lvl: msg.lvl,
|
||||
};
|
||||
generateCanvasImage(
|
||||
"shareCanvas",
|
||||
2,
|
||||
user.value,
|
||||
practiseResult.value
|
||||
);
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
@@ -89,11 +83,17 @@ async function onComplete() {
|
||||
}
|
||||
}
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await generateCanvasImage("shareCanvas", 2, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("share-image", onClickShare);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -101,6 +101,7 @@ onBeforeUnmount(() => {
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("share-image", onClickShare);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import BowPower from "@/components/BowPower.vue";
|
||||
import TestDistance from "@/components/TestDistance.vue";
|
||||
import BubbleTip from "@/components/BubbleTip.vue";
|
||||
import { createPractiseAPI } from "@/apis";
|
||||
import { generateCanvasImage } from "@/util";
|
||||
import { generateCanvasImage, wxShare, debounce } from "@/util";
|
||||
import { MESSAGETYPES } from "@/constants";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
@@ -56,12 +56,6 @@ async function onReceiveMessage(messages = []) {
|
||||
arrows: JSON.parse(msg.practice.arrows),
|
||||
lvl: msg.lvl,
|
||||
};
|
||||
generateCanvasImage(
|
||||
"shareCanvas",
|
||||
3,
|
||||
user.value,
|
||||
practiseResult.value
|
||||
);
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
@@ -82,11 +76,17 @@ async function onComplete() {
|
||||
}
|
||||
}
|
||||
|
||||
const onClickShare = debounce(async () => {
|
||||
await generateCanvasImage("shareCanvas", 3, user.value, practiseResult.value);
|
||||
await wxShare("shareCanvas");
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
uni.setKeepScreenOn({
|
||||
keepScreenOn: true,
|
||||
});
|
||||
uni.$on("socket-inbox", onReceiveMessage);
|
||||
uni.$on("share-image", onClickShare);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
@@ -94,6 +94,7 @@ onBeforeUnmount(() => {
|
||||
keepScreenOn: false,
|
||||
});
|
||||
uni.$off("socket-inbox", onReceiveMessage);
|
||||
uni.$off("share-image", onClickShare);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user