diff --git a/src/components/ImageShare.vue b/src/components/ImageShare.vue
deleted file mode 100644
index 39d13f3..0000000
--- a/src/components/ImageShare.vue
+++ /dev/null
@@ -1,168 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- {{ user.nickName }}
- {{ user.lvlName }}
-
-
-
-
-
-
-
-
diff --git a/src/components/ShootProgress.vue b/src/components/ShootProgress.vue
index 7615b9a..5e7aea1 100644
--- a/src/components/ShootProgress.vue
+++ b/src/components/ShootProgress.vue
@@ -142,5 +142,6 @@ onUnmounted(() => {
}
.container > view:last-child > text {
z-index: 1;
+ color: #000;
}
diff --git a/src/components/Signin.vue b/src/components/Signin.vue
index 11c4d78..25d85aa 100644
--- a/src/components/Signin.vue
+++ b/src/components/Signin.vue
@@ -86,7 +86,7 @@ const handleLogin = () => {
class="login-btn"
hover-class="none"
>
-
+
点击获取
@@ -94,7 +94,6 @@ const handleLogin = () => {
昵称:
{
.nickname > input {
flex: 1;
font-size: 14px;
- color: #000;
+ color: #fff;
}
.wechat-icon {
width: 24px;
diff --git a/src/pages/image-share.vue b/src/pages/image-share.vue
index 21aa371..186bbc7 100644
--- a/src/pages/image-share.vue
+++ b/src/pages/image-share.vue
@@ -2,14 +2,9 @@
import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import Container from "@/components/Container.vue";
-import {
- renderText,
- renderRankTitle,
- renderLine,
- renderScores,
- drawRoundImage,
-} from "@/util.js";
+import { generateCanvasImage } from "@/util";
import { getPractiseAPI } from "@/apis";
+import { wxShare } from "@/util";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
@@ -19,63 +14,7 @@ onLoad(async (options) => {
const id = options.id || 462;
const data = await getPractiseAPI(id);
if (!data.arrows.length) return;
- var ctx = uni.createCanvasContext("shareCanvas");
- const width = 303;
- const height = 535;
- ctx.drawImage("../static/share-bg.png", 0, 0, 302, 534);
- drawRoundImage(ctx, user.value.avatar, 20, 20, 35, 35, 20);
- ctx.drawImage("../static/avatar-frame.png", 15, 15, 45, 45);
- renderText(ctx, user.value.nickName, 14, "#fff", 77, 35, "center");
- renderRankTitle(ctx, user.value.lvlName, "center");
-
- let titleImage = "../static/first-try-title.png";
- let subTitle = "正式开启弓箭手之路";
- if (options.type > 1) {
- subTitle = `今日弓箭练习打卡 ${data.createdAt
- .split(" ")[0]
- .replaceAll("-", ".")}`;
- }
- if (options.type == 2) {
- titleImage = "../static/practise-one-title.png";
- } else if (options.type == 3) {
- titleImage = "../static/practise-two-title.png";
- }
- ctx.drawImage(titleImage, (width - 160) / 2, 160, 160, 40);
- const subTitleWidth = ctx.measureText(subTitle).width;
- renderText(ctx, subTitle, 18, "#fff", width / 2 - subTitleWidth + 10, 220);
- renderText(ctx, "共", 16, "#fff", 124, 300);
- const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
- renderText(ctx, totalRing, 16, "#fed847", totalRing < 100 ? 144 : 142, 300);
- renderText(ctx, "环", 16, "#fff", 166, 300);
- renderLine(ctx, 80);
- renderLine(ctx, 192);
- renderScores(ctx, data.arrows);
- ctx.drawImage(
- "../static/device-icon.png",
- width * 0.06,
- height * 0.87,
- 55,
- 55
- );
- renderText(ctx, "射灵平台", 16, "#fff", width * 0.28, height * 0.9);
- renderText(
- ctx,
- "快加入我们一起玩吧~",
- 11,
- "rgba(255, 255, 255, 0.5)",
- width * 0.28,
- height * 0.93
- );
- renderText(
- ctx,
- "后羿就是这样练成的",
- 11,
- "rgba(255, 255, 255, 0.5)",
- width * 0.28,
- height * 0.96
- );
- ctx.drawImage("../static/qr-code.png", width * 0.75, height * 0.86, 60, 60);
- ctx.draw();
+ generateCanvasImage("shareCanvas", options.type, user.value, data);
});
const saveImage = () => {
@@ -104,24 +43,23 @@ const saveImage = () => {
@@ -141,14 +79,14 @@ const saveImage = () => {
justify-content: space-around;
margin-top: 50px;
}
-.footer > view {
+.footer > button {
display: flex;
flex-direction: column;
align-items: center;
color: #fff;
font-size: 12px;
}
-.footer > view > image {
+.footer > button > image {
width: 45px;
margin-bottom: 10px;
}
diff --git a/src/util.js b/src/util.js
index deacc2b..b636332 100644
--- a/src/util.js
+++ b/src/util.js
@@ -60,16 +60,16 @@ export function renderText(ctx, text, size, color, x, y, textAlign = "left") {
}
export function renderRankTitle(ctx, text) {
- const fontSize = 10;
+ const fontSize = 8;
const textWidth = ctx.measureText(text).width;
const padding = 8; // 文字与背景边缘的间距
const radius = 10; // 圆角半径
const textX = 85;
- const textY = 55;
- const x = textX - padding - 15; // 文字 x 坐标减去内边距
+ const textY = 52;
+ const x = textX - padding - 12; // 文字 x 坐标减去内边距
const y = textY - fontSize - padding / 2 + 1; // 文字 y 坐标减去字体大小和内边距
- const width = textWidth + padding * 2 - 19; // 背景宽度
- const height = fontSize + padding + 1; // 背景高度
+ const width = textWidth + padding * 2 - 24; // 背景宽度
+ const height = fontSize + padding; // 背景高度
// 开始绘制圆角矩形
ctx.beginPath();
@@ -136,9 +136,9 @@ export function generateCanvasImage(canvasId, type, user, data) {
const width = 303;
const height = 535;
ctx.drawImage("../static/share-bg.png", 0, 0, 302, 534);
- drawRoundImage(ctx, user.avatar, 20, 20, 35, 35, 20);
- ctx.drawImage("../static/avatar-frame.png", 15, 15, 45, 45);
- renderText(ctx, user.nickName, 14, "#fff", 77, 35, "center");
+ drawRoundImage(ctx, user.avatar, 17, 20, 37, 37, 20);
+ ctx.drawImage("../static/avatar-frame.png", 12, 15, 47, 47);
+ renderText(ctx, user.nickName, 14, "#fff", 80, 32, "center");
renderRankTitle(ctx, user.lvlName, "center");
let titleImage = "../static/first-try-title.png";
@@ -155,7 +155,14 @@ export function generateCanvasImage(canvasId, type, user, data) {
}
ctx.drawImage(titleImage, (width - 160) / 2, 160, 160, 40);
const subTitleWidth = ctx.measureText(subTitle).width;
- renderText(ctx, subTitle, 18, "#fff", width / 2 - subTitleWidth + 10, 220);
+ renderText(
+ ctx,
+ subTitle,
+ 18,
+ "#fff",
+ width / 2 - subTitleWidth - (type > 1 ? 15 : 8),
+ 220
+ );
renderText(ctx, "共", 16, "#fff", 124, 300);
const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
renderText(ctx, totalRing, 16, "#fed847", totalRing < 100 ? 144 : 142, 300);