细节优化

This commit is contained in:
kron
2025-07-14 13:39:10 +08:00
parent d73d52f752
commit cde905c680
15 changed files with 106 additions and 90 deletions

View File

@@ -1,9 +0,0 @@
@serverUrl = http://120.79.241.5:8000/api/shoot
### 模拟射箭
POST {{serverUrl}}/index/arrow
Content-Type: application/json
{
"device_id": "H9hL8GaA"
}

View File

@@ -170,8 +170,8 @@ export const getGameAPI = async (battleId) => {
goldenRoundRecords = [],
} = result;
const data = {
mode: battleStats.mode,
gameMode: battleStats.gameMode,
mode: battleStats.mode, // 1.几V几 2.大乱斗
gameMode: battleStats.gameMode, // 1.约战 2.排位
};
if (battleStats && battleStats.mode === 1) {
data.winner = battleStats.winner;

View File

@@ -6,12 +6,22 @@ const props = defineProps({
default: 0,
},
});
const bgs = ref(["../static/app-bg.png", "../static/app-bg2.png"]);
</script>
<template>
<view class="background">
<image class="bg-image" :src="bgs[type]" mode="widthFix" />
<image
class="bg-image"
v-if="type === 0"
src="../static/app-bg.png"
mode="widthFix"
/>
<image
class="bg-image"
v-if="type === 1"
src="../static/app-bg2.png"
mode="widthFix"
/>
<view class="bg-overlay" v-if="type === 0"></view>
</view>
</template>

View File

@@ -45,7 +45,7 @@ const onClick = async () => {
}
.back-to-game > image:nth-child(2) {
position: relative;
width: 50px;
width: 60px;
}
.back-to-game > text:nth-child(3) {
position: relative;

View File

@@ -198,7 +198,7 @@ const simulShoot2 = async () => {
? 'green'
: 'red',
}"
>{{ index + 1 }}</view
><text>{{ index + 1 }}</text></view
>
</block>
<block v-for="(bow, index) in blueScores" :key="index">
@@ -214,7 +214,7 @@ const simulShoot2 = async () => {
top: calcRealY(bow.y),
backgroundColor: 'blue',
}"
>{{ index + 1 }}</view
><text>{{ index + 1 }}</text></view
>
</block>
<image src="../static/bow-target.png" mode="widthFix" />
@@ -288,6 +288,10 @@ const simulShoot2 = async () => {
transition: all 0.3s ease;
box-sizing: border-box;
}
.hit > text {
transform: scaleX(0.7);
display: block;
}
.header {
width: 100%;
display: flex;

View File

@@ -40,12 +40,16 @@ const showGlobalHint = (type) => {
hintType.value = type;
showHint.value = true;
};
const hideGlobalHint = () => {
showHint.value = false;
};
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
});
onShow(() => {
uni.$showHint = showGlobalHint;
uni.$hideHint = hideGlobalHint;
showHint.value = false;
});
const backToGame = debounce(async () => {
@@ -86,10 +90,10 @@ const goBack = () => {
<text>离开比赛可能会导致比赛失败</text>
<text>确认离开吗</text>
<view>
<button hover-class="none" @click="goBack">离开比赛</button>
<button hover-class="none" @click="() => (showHint = false)">
继续比赛
</button>
<button hover-class="none" @click="goBack">离开比赛</button>
</view>
</view>
<view v-if="hintType === 3" class="tip-content">

View File

@@ -551,7 +551,11 @@ onUnmounted(() => {
:round="currentRound - 1"
:bluePoint="currentBluePoint"
:redPoint="currentRedPoint"
:roundData="roundResults[roundResults.length - 1]"
:roundData="
roundResults[roundResults.length - 2]
? roundResults[roundResults.length - 2]
: []
"
:onAutoClose="() => (showRoundTip = false)"
/>
</ScreenHint>

View File

@@ -77,10 +77,7 @@ const onCreateRoom = async () => {
<view class="create-room">
<image src="../static/battle-bg.png" mode="widthFix" />
<view>
<image
src="https://api.shelingxingqiu.com/attachment/2025-07-12/db9x4i9g536xerkv9i.png"
mode="widthFix"
/>
<image :src="user.avatar" mode="widthFix" />
<image src="../static/versus.png" mode="widthFix" />
<view>
<image src="../static/question-mark.png" mode="widthFix" />
@@ -151,6 +148,7 @@ const onCreateRoom = async () => {
.create-room > image:first-of-type {
position: absolute;
width: 100%;
border-radius: 50%;
}
.create-room > view {
margin: 0 30px;

View File

@@ -31,7 +31,7 @@ onLoad(async (options) => {
</script>
<template>
<Container title="5人大乱斗 - 靶纸">
<Container title="靶纸">
<view class="container">
<view class="players" v-if="data.players">
<view

View File

@@ -21,7 +21,7 @@ onLoad(async (options) => {
</script>
<template>
<Container title="个人练习 - 靶纸">
<Container title="靶纸">
<view class="container">
<!-- <view class="header">
<view>

View File

@@ -85,7 +85,7 @@ const onClickTab = (index) => {
</script>
<template>
<Container title="1v1排位赛 - 靶纸">
<Container title="靶纸">
<view class="container">
<view>
<view

View File

@@ -124,6 +124,7 @@ async function onReceiveMessage(messages = []) {
battleId.value = msg.id;
redTeam.value = msg.groupUserStatus.redTeam;
blueTeam.value = msg.groupUserStatus.blueTeam;
uni.$hideHint();
};
}
if (msg.id !== battleId.value) return;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@@ -5,7 +5,7 @@ const defaultUser = {
nickName: "游客",
avatar: "../static/avatar.png",
trio: 0, // 大于1表示完成了新手引导
lvlName: "砖石1级",
lvlName: "",
};
const getLvlName = (score, rankList = []) => {
@@ -80,7 +80,7 @@ export default defineStore("store", {
const imageInfo = await uni.getImageInfo({ src: user.avatar });
this.user.avatar = imageInfo.path;
}
if (this.user.scores) {
if (this.user.scores !== undefined) {
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
if (lvlImage) {
@@ -95,7 +95,7 @@ export default defineStore("store", {
},
async updateConfig(config) {
this.config = config;
if (this.user.scores) {
if (this.user.scores !== undefined) {
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
if (lvlImage) {

View File

@@ -180,70 +180,74 @@ export const drawRoundImage = async (
};
export async function generateCanvasImage(canvasId, type, user, data) {
var ctx = uni.createCanvasContext(canvasId);
const width = 300;
const height = 534;
ctx.drawImage("../static/share-bg.png", 0, 0, width, height);
drawRoundImage(ctx, user.avatar, 17, 20, 32, 32, 20);
ctx.drawImage(user.lvlImage, 12, 15, 42, 42);
renderText(ctx, user.nickName, 13, "#fff", 58, 34);
renderRankTitle(ctx, user.lvlName);
try {
var ctx = uni.createCanvasContext(canvasId);
const width = 300;
const height = 534;
ctx.drawImage("../static/share-bg.png", 0, 0, width, height);
drawRoundImage(ctx, user.avatar, 17, 20, 32, 32, 20);
ctx.drawImage(user.lvlImage, 12, 15, 42, 42);
renderText(ctx, user.nickName, 13, "#fff", 58, 34);
renderRankTitle(ctx, user.lvlName);
let titleImage = "../static/first-try-title.png";
let subTitle = "正式开启弓箭手之路";
if (type > 1) {
subTitle = `今日弓箭练习打卡 ${data.createdAt
.split(" ")[0]
.replaceAll("-", ".")}`;
let titleImage = "../static/first-try-title.png";
let subTitle = "正式开启弓箭手之路";
if (type > 1) {
subTitle = `今日弓箭练习打卡 ${data.createdAt
.split(" ")[0]
.replaceAll("-", ".")}`;
}
if (type == 2) {
titleImage = "../static/practise-one-title.png";
} else if (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 - (type > 1 ? 15 : 9),
220
);
renderText(ctx, "共", 14, "#fff", 122, 300);
const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
renderText(ctx, totalRing, 14, "#fed847", 148, 300, "center");
renderText(ctx, "环", 14, "#fff", 161, 300);
renderLine(ctx, 77);
renderLine(ctx, 185);
renderScores(ctx, data.arrows);
ctx.drawImage(
"../static/device-icon.png",
width * 0.06,
height * 0.87,
48,
48
);
renderText(ctx, "射灵平台", 14, "#fff", width * 0.25, height * 0.9);
renderText(
ctx,
"快加入我们一起玩吧~",
10,
"rgba(255, 255, 255, 0.5)",
width * 0.25,
height * 0.93
);
renderText(
ctx,
"后羿就是这样练成的",
10,
"rgba(255, 255, 255, 0.5)",
width * 0.25,
height * 0.955
);
ctx.drawImage("../static/qr-code.png", width * 0.75, height * 0.86, 56, 56);
ctx.draw();
} catch (err) {
console.log(err);
}
if (type == 2) {
titleImage = "../static/practise-one-title.png";
} else if (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 - (type > 1 ? 15 : 9),
220
);
renderText(ctx, "共", 14, "#fff", 122, 300);
const totalRing = data.arrows.reduce((last, next) => last + next.ring, 0);
renderText(ctx, totalRing, 14, "#fed847", 148, 300, "center");
renderText(ctx, "环", 14, "#fff", 161, 300);
renderLine(ctx, 77);
renderLine(ctx, 185);
renderScores(ctx, data.arrows);
ctx.drawImage(
"../static/device-icon.png",
width * 0.06,
height * 0.87,
48,
48
);
renderText(ctx, "射灵平台", 14, "#fff", width * 0.25, height * 0.9);
renderText(
ctx,
"快加入我们一起玩吧~",
10,
"rgba(255, 255, 255, 0.5)",
width * 0.25,
height * 0.93
);
renderText(
ctx,
"后羿就是这样练成的",
10,
"rgba(255, 255, 255, 0.5)",
width * 0.25,
height * 0.955
);
ctx.drawImage("../static/qr-code.png", width * 0.75, height * 0.86, 56, 56);
ctx.draw();
}
export const wxShare = async () => {