细节优化
This commit is contained in:
@@ -1,9 +0,0 @@
|
|||||||
@serverUrl = http://120.79.241.5:8000/api/shoot
|
|
||||||
|
|
||||||
### 模拟射箭
|
|
||||||
POST {{serverUrl}}/index/arrow
|
|
||||||
Content-Type: application/json
|
|
||||||
|
|
||||||
{
|
|
||||||
"device_id": "H9hL8GaA"
|
|
||||||
}
|
|
||||||
@@ -170,8 +170,8 @@ export const getGameAPI = async (battleId) => {
|
|||||||
goldenRoundRecords = [],
|
goldenRoundRecords = [],
|
||||||
} = result;
|
} = result;
|
||||||
const data = {
|
const data = {
|
||||||
mode: battleStats.mode,
|
mode: battleStats.mode, // 1.几V几 2.大乱斗
|
||||||
gameMode: battleStats.gameMode,
|
gameMode: battleStats.gameMode, // 1.约战 2.排位
|
||||||
};
|
};
|
||||||
if (battleStats && battleStats.mode === 1) {
|
if (battleStats && battleStats.mode === 1) {
|
||||||
data.winner = battleStats.winner;
|
data.winner = battleStats.winner;
|
||||||
|
|||||||
@@ -6,12 +6,22 @@ const props = defineProps({
|
|||||||
default: 0,
|
default: 0,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const bgs = ref(["../static/app-bg.png", "../static/app-bg2.png"]);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view class="background">
|
<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 class="bg-overlay" v-if="type === 0"></view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const onClick = async () => {
|
|||||||
}
|
}
|
||||||
.back-to-game > image:nth-child(2) {
|
.back-to-game > image:nth-child(2) {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 50px;
|
width: 60px;
|
||||||
}
|
}
|
||||||
.back-to-game > text:nth-child(3) {
|
.back-to-game > text:nth-child(3) {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ const simulShoot2 = async () => {
|
|||||||
? 'green'
|
? 'green'
|
||||||
: 'red',
|
: 'red',
|
||||||
}"
|
}"
|
||||||
>{{ index + 1 }}</view
|
><text>{{ index + 1 }}</text></view
|
||||||
>
|
>
|
||||||
</block>
|
</block>
|
||||||
<block v-for="(bow, index) in blueScores" :key="index">
|
<block v-for="(bow, index) in blueScores" :key="index">
|
||||||
@@ -214,7 +214,7 @@ const simulShoot2 = async () => {
|
|||||||
top: calcRealY(bow.y),
|
top: calcRealY(bow.y),
|
||||||
backgroundColor: 'blue',
|
backgroundColor: 'blue',
|
||||||
}"
|
}"
|
||||||
>{{ index + 1 }}</view
|
><text>{{ index + 1 }}</text></view
|
||||||
>
|
>
|
||||||
</block>
|
</block>
|
||||||
<image src="../static/bow-target.png" mode="widthFix" />
|
<image src="../static/bow-target.png" mode="widthFix" />
|
||||||
@@ -288,6 +288,10 @@ const simulShoot2 = async () => {
|
|||||||
transition: all 0.3s ease;
|
transition: all 0.3s ease;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
.hit > text {
|
||||||
|
transform: scaleX(0.7);
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
.header {
|
.header {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -40,12 +40,16 @@ const showGlobalHint = (type) => {
|
|||||||
hintType.value = type;
|
hintType.value = type;
|
||||||
showHint.value = true;
|
showHint.value = true;
|
||||||
};
|
};
|
||||||
|
const hideGlobalHint = () => {
|
||||||
|
showHint.value = false;
|
||||||
|
};
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
const deviceInfo = uni.getDeviceInfo();
|
const deviceInfo = uni.getDeviceInfo();
|
||||||
isIos.value = deviceInfo.osName === "ios";
|
isIos.value = deviceInfo.osName === "ios";
|
||||||
});
|
});
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
uni.$showHint = showGlobalHint;
|
uni.$showHint = showGlobalHint;
|
||||||
|
uni.$hideHint = hideGlobalHint;
|
||||||
showHint.value = false;
|
showHint.value = false;
|
||||||
});
|
});
|
||||||
const backToGame = debounce(async () => {
|
const backToGame = debounce(async () => {
|
||||||
@@ -86,10 +90,10 @@ const goBack = () => {
|
|||||||
<text>离开比赛可能会导致比赛失败,</text>
|
<text>离开比赛可能会导致比赛失败,</text>
|
||||||
<text>确认离开吗?</text>
|
<text>确认离开吗?</text>
|
||||||
<view>
|
<view>
|
||||||
<button hover-class="none" @click="goBack">离开比赛</button>
|
|
||||||
<button hover-class="none" @click="() => (showHint = false)">
|
<button hover-class="none" @click="() => (showHint = false)">
|
||||||
继续比赛
|
继续比赛
|
||||||
</button>
|
</button>
|
||||||
|
<button hover-class="none" @click="goBack">离开比赛</button>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="hintType === 3" class="tip-content">
|
<view v-if="hintType === 3" class="tip-content">
|
||||||
|
|||||||
@@ -551,7 +551,11 @@ onUnmounted(() => {
|
|||||||
:round="currentRound - 1"
|
:round="currentRound - 1"
|
||||||
:bluePoint="currentBluePoint"
|
:bluePoint="currentBluePoint"
|
||||||
:redPoint="currentRedPoint"
|
:redPoint="currentRedPoint"
|
||||||
:roundData="roundResults[roundResults.length - 1]"
|
:roundData="
|
||||||
|
roundResults[roundResults.length - 2]
|
||||||
|
? roundResults[roundResults.length - 2]
|
||||||
|
: []
|
||||||
|
"
|
||||||
:onAutoClose="() => (showRoundTip = false)"
|
:onAutoClose="() => (showRoundTip = false)"
|
||||||
/>
|
/>
|
||||||
</ScreenHint>
|
</ScreenHint>
|
||||||
|
|||||||
@@ -77,10 +77,7 @@ const onCreateRoom = async () => {
|
|||||||
<view class="create-room">
|
<view class="create-room">
|
||||||
<image src="../static/battle-bg.png" mode="widthFix" />
|
<image src="../static/battle-bg.png" mode="widthFix" />
|
||||||
<view>
|
<view>
|
||||||
<image
|
<image :src="user.avatar" mode="widthFix" />
|
||||||
src="https://api.shelingxingqiu.com/attachment/2025-07-12/db9x4i9g536xerkv9i.png"
|
|
||||||
mode="widthFix"
|
|
||||||
/>
|
|
||||||
<image src="../static/versus.png" mode="widthFix" />
|
<image src="../static/versus.png" mode="widthFix" />
|
||||||
<view>
|
<view>
|
||||||
<image src="../static/question-mark.png" mode="widthFix" />
|
<image src="../static/question-mark.png" mode="widthFix" />
|
||||||
@@ -151,6 +148,7 @@ const onCreateRoom = async () => {
|
|||||||
.create-room > image:first-of-type {
|
.create-room > image:first-of-type {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
.create-room > view {
|
.create-room > view {
|
||||||
margin: 0 30px;
|
margin: 0 30px;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ onLoad(async (options) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container title="5人大乱斗 - 靶纸">
|
<Container title="靶纸">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view class="players" v-if="data.players">
|
<view class="players" v-if="data.players">
|
||||||
<view
|
<view
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ onLoad(async (options) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container title="个人练习 - 靶纸">
|
<Container title="靶纸">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<!-- <view class="header">
|
<!-- <view class="header">
|
||||||
<view>
|
<view>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ const onClickTab = (index) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Container title="1v1排位赛 - 靶纸">
|
<Container title="靶纸">
|
||||||
<view class="container">
|
<view class="container">
|
||||||
<view>
|
<view>
|
||||||
<view
|
<view
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ async function onReceiveMessage(messages = []) {
|
|||||||
battleId.value = msg.id;
|
battleId.value = msg.id;
|
||||||
redTeam.value = msg.groupUserStatus.redTeam;
|
redTeam.value = msg.groupUserStatus.redTeam;
|
||||||
blueTeam.value = msg.groupUserStatus.blueTeam;
|
blueTeam.value = msg.groupUserStatus.blueTeam;
|
||||||
|
uni.$hideHint();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (msg.id !== battleId.value) return;
|
if (msg.id !== battleId.value) return;
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 4.3 KiB |
@@ -5,7 +5,7 @@ const defaultUser = {
|
|||||||
nickName: "游客",
|
nickName: "游客",
|
||||||
avatar: "../static/avatar.png",
|
avatar: "../static/avatar.png",
|
||||||
trio: 0, // 大于1表示完成了新手引导
|
trio: 0, // 大于1表示完成了新手引导
|
||||||
lvlName: "砖石1级",
|
lvlName: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLvlName = (score, rankList = []) => {
|
const getLvlName = (score, rankList = []) => {
|
||||||
@@ -80,7 +80,7 @@ export default defineStore("store", {
|
|||||||
const imageInfo = await uni.getImageInfo({ src: user.avatar });
|
const imageInfo = await uni.getImageInfo({ src: user.avatar });
|
||||||
this.user.avatar = imageInfo.path;
|
this.user.avatar = imageInfo.path;
|
||||||
}
|
}
|
||||||
if (this.user.scores) {
|
if (this.user.scores !== undefined) {
|
||||||
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
|
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
|
||||||
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
|
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
|
||||||
if (lvlImage) {
|
if (lvlImage) {
|
||||||
@@ -95,7 +95,7 @@ export default defineStore("store", {
|
|||||||
},
|
},
|
||||||
async updateConfig(config) {
|
async updateConfig(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (this.user.scores) {
|
if (this.user.scores !== undefined) {
|
||||||
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
|
this.user.lvlName = getLvlName(this.user.scores, this.config.randInfos);
|
||||||
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
|
const lvlImage = getLvlImage(this.user.scores, this.config.randInfos);
|
||||||
if (lvlImage) {
|
if (lvlImage) {
|
||||||
|
|||||||
128
src/util.js
128
src/util.js
@@ -180,70 +180,74 @@ export const drawRoundImage = async (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export async function generateCanvasImage(canvasId, type, user, data) {
|
export async function generateCanvasImage(canvasId, type, user, data) {
|
||||||
var ctx = uni.createCanvasContext(canvasId);
|
try {
|
||||||
const width = 300;
|
var ctx = uni.createCanvasContext(canvasId);
|
||||||
const height = 534;
|
const width = 300;
|
||||||
ctx.drawImage("../static/share-bg.png", 0, 0, width, height);
|
const height = 534;
|
||||||
drawRoundImage(ctx, user.avatar, 17, 20, 32, 32, 20);
|
ctx.drawImage("../static/share-bg.png", 0, 0, width, height);
|
||||||
ctx.drawImage(user.lvlImage, 12, 15, 42, 42);
|
drawRoundImage(ctx, user.avatar, 17, 20, 32, 32, 20);
|
||||||
renderText(ctx, user.nickName, 13, "#fff", 58, 34);
|
ctx.drawImage(user.lvlImage, 12, 15, 42, 42);
|
||||||
renderRankTitle(ctx, user.lvlName);
|
renderText(ctx, user.nickName, 13, "#fff", 58, 34);
|
||||||
|
renderRankTitle(ctx, user.lvlName);
|
||||||
|
|
||||||
let titleImage = "../static/first-try-title.png";
|
let titleImage = "../static/first-try-title.png";
|
||||||
let subTitle = "正式开启弓箭手之路";
|
let subTitle = "正式开启弓箭手之路";
|
||||||
if (type > 1) {
|
if (type > 1) {
|
||||||
subTitle = `今日弓箭练习打卡 ${data.createdAt
|
subTitle = `今日弓箭练习打卡 ${data.createdAt
|
||||||
.split(" ")[0]
|
.split(" ")[0]
|
||||||
.replaceAll("-", ".")}`;
|
.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 () => {
|
export const wxShare = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user