This commit is contained in:
2025-11-24 16:00:42 +08:00
parent 375b1b449b
commit 0520603957
43 changed files with 1318 additions and 940 deletions

View File

@@ -1,197 +1,111 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
if (!Array) {
const _component_ellipse = common_vendor.resolveComponent("ellipse");
const _component_circle = common_vendor.resolveComponent("circle");
const _component_path = common_vendor.resolveComponent("path");
const _component_rect = common_vendor.resolveComponent("rect");
const _component_svg = common_vendor.resolveComponent("svg");
(_component_ellipse + _component_circle + _component_path + _component_rect + _component_svg)();
}
const _sfc_main = {
__name: "compute",
setup(__props) {
const result = common_vendor.ref("win");
const score = common_vendor.ref("0");
const keys = [
{ value: "1", display: "1", type: "number" },
{ value: "2", display: "2", type: "number" },
{ value: "3", display: "3", type: "number" },
{ value: "+", display: "+", type: "operator" },
{ value: "×", display: "×", type: "delete" },
{ value: "4", display: "4", type: "number" },
{ value: "5", display: "5", type: "number" },
{ value: "6", display: "6", type: "number" },
{ value: "-", display: "-", type: "operator" },
{ value: "√", display: "√", type: "operator" },
{ value: "7", display: "7", type: "number" },
{ value: "8", display: "8", type: "number" },
{ value: "9", display: "9", type: "number" },
{ value: "submit", display: "提交", type: "submit" },
// 提交按钮在0的左侧
{ value: "0", display: "0", type: "number" }
];
const setResult = (res) => {
result.value = res;
};
const pressKey = (key, type) => {
if (type === "submit") {
if (score.value !== "0") {
common_vendor.index.showToast({
title: `分数 ${score.value} 已提交`,
icon: "success"
});
common_vendor.index.__f__("log", "at pages/compute/compute.vue:110", "提交分数:", score.value);
setTimeout(() => {
score.value = "0";
}, 1500);
}
} else if (key === "×") {
if (score.value.length > 1) {
score.value = score.value.slice(0, -1);
} else {
score.value = "0";
}
} else if (key === "√") {
try {
const result2 = Math.sqrt(parseFloat(score.value));
score.value = result2.toString();
} catch (error) {
score.value = "错误";
setTimeout(() => {
score.value = "0";
}, 1e3);
}
} else {
if (score.value === "0") {
score.value = key;
} else {
score.value += key;
}
const players1 = common_vendor.ref([]);
const round1 = common_vendor.ref();
common_vendor.ref([]);
const setResult = (index, result) => {
players1.value[index].result = result;
if (players1.value[index].score) {
validateScore(index);
}
};
const sumScore = () => {
common_vendor.index.showToast({
title: "合分功能需要与后端API交互",
icon: "none"
});
const validateScore = (index) => {
const player = players1.value[index];
const score = parseFloat(player.score);
if (isNaN(score)) {
player.score = "";
return;
}
if (player.result === "win" && score < 0) {
player.score = Math.abs(score).toString();
} else if (player.result === "lose" && score > 0) {
player.score = (-score).toString();
}
};
common_vendor.computed(() => {
if (!players1.value.length)
return 0;
let max = 0;
players1.value.forEach((user) => {
if (user.details && user.details.length > 0) {
user.details.forEach((detail) => {
if (detail.gameTime > max)
max = detail.gameTime;
});
}
});
return max;
});
common_vendor.onMounted(() => {
});
common_vendor.onLoad((options) => {
try {
const rawData = JSON.parse(decodeURIComponent(options.players));
round1.value = JSON.parse(decodeURIComponent(options.round));
common_vendor.index.__f__("log", "at pages/compute/compute.vue:110", "round:", round1.value);
players1.value = rawData.map((player) => ({
...player,
result: "win",
score: "",
gameTime: round1.value
}));
} catch (error) {
common_vendor.index.__f__("error", "at pages/compute/compute.vue:125", "解析失败:", error);
players1.value = [];
}
});
const onsubmit = async () => {
const updataScore = players1.value.map((updata) => ({
roomId: updata.roomId,
userId: updata.userId,
score: updata.score
}));
common_vendor.index.__f__("log", "at pages/compute/compute.vue:138", "输入框的值:", updataScore);
};
const usersData = common_vendor.ref([
{
id: 1,
nickName: "玩家12324",
image: "https://img1.baidu.com/it/u=3612220943,2414740890&fm=253&app=138&f=JPEG?w=526&h=500",
result: "win",
score: ""
},
{
id: 2,
nickName: "赵云",
image: "https://q3.itc.cn/q_70/images03/20250110/1e71eecf56b34344bcae6a5b85c0bec2.jpeg",
result: "win",
score: ""
},
{
id: 3,
nickName: "刘备",
image: "https://q3.itc.cn/q_70/images03/20250110/1e71eecf56b34344bcae6a5b85c0bec2.jpeg",
result: "win",
score: ""
}
]);
return (_ctx, _cache) => {
return {
a: common_vendor.p({
cx: "15",
cy: "20",
rx: "9",
ry: "6",
fill: "#ffffff"
}),
b: common_vendor.p({
cx: "15",
cy: "12",
r: "7",
fill: "#ffffff"
}),
c: common_vendor.p({
cx: "12",
cy: "8",
rx: "2",
ry: "4",
fill: "#ffffff"
}),
d: common_vendor.p({
cx: "18",
cy: "8",
rx: "2",
ry: "4",
fill: "#ffffff"
}),
e: common_vendor.p({
cx: "12",
cy: "8",
rx: "1",
ry: "3",
fill: "#ffb6c1"
}),
f: common_vendor.p({
cx: "18",
cy: "8",
rx: "1",
ry: "3",
fill: "#ffb6c1"
}),
g: common_vendor.p({
cx: "13",
cy: "12",
r: "1",
fill: "#333333"
}),
h: common_vendor.p({
cx: "17",
cy: "12",
r: "1",
fill: "#333333"
}),
i: common_vendor.p({
cx: "15",
cy: "14",
r: "0.8",
fill: "#ff69b4"
}),
j: common_vendor.p({
d: "M14,16 Q15,17 16,16",
stroke: "#ff69b4",
["stroke-width"]: "0.5",
fill: "none"
}),
k: common_vendor.p({
cx: "11",
cy: "13",
r: "1.5",
fill: "#ffb6c1",
opacity: "0.6"
}),
l: common_vendor.p({
cx: "19",
cy: "13",
r: "1.5",
fill: "#ffb6c1",
opacity: "0.6"
}),
m: common_vendor.p({
x: "10",
cy: "19",
width: "10",
height: "4",
fill: "#4169e1",
rx: "1"
}),
n: common_vendor.p({
cx: "20",
cy: "21",
r: "2",
fill: "#ffd700"
}),
o: common_vendor.p({
width: "30",
height: "30",
viewBox: "0 0 30 30"
}),
p: result.value === "win" ? 1 : "",
q: common_vendor.o(($event) => setResult("win")),
r: result.value === "lose" ? 1 : "",
s: common_vendor.o(($event) => setResult("lose")),
t: common_vendor.t(score.value),
v: common_vendor.o(sumScore),
w: common_vendor.f(keys, (key, k0, i0) => {
a: common_vendor.f(players1.value, (item, index, i0) => {
return {
a: common_vendor.t(key.display),
b: key.value,
c: key.type === "operator" ? 1 : "",
d: key.value === "-" ? 1 : "",
e: key.type === "submit" ? 1 : "",
f: common_vendor.o(($event) => pressKey(key.value, key.type), key.value)
a: item.avatars,
b: common_vendor.t(item.nickName),
c: item.result === "win" ? 1 : "",
d: common_vendor.o(($event) => setResult(index, "win"), usersData.value.useId),
e: item.result === "lose" ? 1 : "",
f: common_vendor.o(($event) => setResult(index, "lose"), usersData.value.useId),
g: common_vendor.n(item.result === "win" ? "positive" : "negative"),
h: common_vendor.o([($event) => item.score = $event.detail.value, ($event) => validateScore(index)], usersData.value.useId),
i: item.score
};
})
}),
b: usersData.value.useId,
c: common_vendor.t(round1.value),
d: common_vendor.o(($event) => onsubmit())
};
};
}

View File

@@ -1 +1 @@
<view class="container data-v-5af9b656"><view class="table-header data-v-5af9b656"><view class="header-player data-v-5af9b656">玩家</view><view class="header-result data-v-5af9b656">胜负</view><view class="header-score data-v-5af9b656">得分</view></view><view class="player-row data-v-5af9b656"><view class="player-info data-v-5af9b656"><view class="player-avatar data-v-5af9b656"><svg wx:if="{{o}}" class="data-v-5af9b656" u-s="{{['d']}}" u-i="5af9b656-0" bind:__l="__l" u-p="{{o}}"><ellipse wx:if="{{a}}" class="data-v-5af9b656" u-i="5af9b656-1,5af9b656-0" bind:__l="__l" u-p="{{a}}"/><circle wx:if="{{b}}" class="data-v-5af9b656" u-i="5af9b656-2,5af9b656-0" bind:__l="__l" u-p="{{b}}"/><ellipse wx:if="{{c}}" class="data-v-5af9b656" u-i="5af9b656-3,5af9b656-0" bind:__l="__l" u-p="{{c}}"/><ellipse wx:if="{{d}}" class="data-v-5af9b656" u-i="5af9b656-4,5af9b656-0" bind:__l="__l" u-p="{{d}}"/><ellipse wx:if="{{e}}" class="data-v-5af9b656" u-i="5af9b656-5,5af9b656-0" bind:__l="__l" u-p="{{e}}"/><ellipse wx:if="{{f}}" class="data-v-5af9b656" u-i="5af9b656-6,5af9b656-0" bind:__l="__l" u-p="{{f}}"/><circle wx:if="{{g}}" class="data-v-5af9b656" u-i="5af9b656-7,5af9b656-0" bind:__l="__l" u-p="{{g}}"/><circle wx:if="{{h}}" class="data-v-5af9b656" u-i="5af9b656-8,5af9b656-0" bind:__l="__l" u-p="{{h}}"/><circle wx:if="{{i}}" class="data-v-5af9b656" u-i="5af9b656-9,5af9b656-0" bind:__l="__l" u-p="{{i}}"/><path wx:if="{{j}}" class="data-v-5af9b656" u-i="5af9b656-10,5af9b656-0" bind:__l="__l" u-p="{{j}}"/><circle wx:if="{{k}}" class="data-v-5af9b656" u-i="5af9b656-11,5af9b656-0" bind:__l="__l" u-p="{{k}}"/><circle wx:if="{{l}}" class="data-v-5af9b656" u-i="5af9b656-12,5af9b656-0" bind:__l="__l" u-p="{{l}}"/><rect wx:if="{{m}}" class="data-v-5af9b656" u-i="5af9b656-13,5af9b656-0" bind:__l="__l" u-p="{{m}}"/><circle wx:if="{{n}}" class="data-v-5af9b656" u-i="5af9b656-14,5af9b656-0" bind:__l="__l" u-p="{{n}}"/></svg></view><text class="player-name data-v-5af9b656">玩家59306</text></view><view class="result-buttons data-v-5af9b656"><view class="{{['result-btn', 'data-v-5af9b656', p && 'active']}}" bindtap="{{q}}">胜</view><view class="{{['result-btn', 'data-v-5af9b656', r && 'active']}}" bindtap="{{s}}">负</view></view><view class="score-display data-v-5af9b656"><text class="score-value data-v-5af9b656">{{t}}</text><button class="sum-btn data-v-5af9b656" bindtap="{{v}}">Σ 合分</button></view></view><view class="keyboard data-v-5af9b656"><view wx:for="{{w}}" wx:for-item="key" wx:key="b" class="{{['key', 'data-v-5af9b656', key.c && 'operator', key.d && 'minus', key.e && 'submit-key']}}" bindtap="{{key.f}}">{{key.a}}</view></view></view>
<view class="compute data-v-5af9b656"><view class="compute-lan data-v-5af9b656"><text class="player data-v-5af9b656">玩家</text><text class="vd data-v-5af9b656">胜负</text><text class="score data-v-5af9b656">得分</text></view><view wx:for="{{a}}" wx:for-item="item" wx:key="b" class="compute-detail data-v-5af9b656"><view class="compute-detail-player data-v-5af9b656"><image class="data-v-5af9b656" src="{{item.a}}" mode="widthFix"></image><text class="data-v-5af9b656">{{item.b}}</text></view><view class="compute-detail-vd data-v-5af9b656"><view class="{{['result-btn', 'data-v-5af9b656', item.c && 'active']}}" bindtap="{{item.d}}">胜</view><view class="{{['result-btn', 'data-v-5af9b656', item.e && 'active']}}" bindtap="{{item.f}}">负</view></view><view class="compute-detail-score data-v-5af9b656"><input class="{{['score-input', 'data-v-5af9b656', item.g]}}" bindinput="{{item.h}}" placeholder="0" type="number" value="{{item.i}}"/></view></view><view class=" data-v-5af9b656">{{c}}</view><button class="data-v-5af9b656" bindtap="{{d}}"> 提交 </button></view>

View File

@@ -1,178 +1,79 @@
.container.data-v-5af9b656 {
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 240rpx; /* 为底部键盘留出空间 */
}
/* 顶部表头 */
.table-header.data-v-5af9b656 {
.compute.data-v-5af9b656 {
display: flex;
background-color: white;
padding: 30rpx 40rpx;
border-bottom: 1px solid #e0e0e0;
position: -webkit-sticky;
position: sticky;
top: 0;
z-index: 10;
flex-direction: column;
}
.header-player.data-v-5af9b656 {
flex: 1;
font-size: 32rpx;
color: #333;
font-weight: 500;
}
.header-result.data-v-5af9b656 {
width: 200rpx;
font-size: 32rpx;
color: #333;
font-weight: 500;
text-align: center;
}
.header-score.data-v-5af9b656 {
width: 200rpx;
font-size: 32rpx;
color: #333;
font-weight: 500;
text-align: center;
}
/* 玩家信息区域 */
.player-row.data-v-5af9b656 {
.compute .compute-lan.data-v-5af9b656 {
display: flex;
align-items: center;
padding: 30rpx 40rpx;
border-bottom: 1px solid #f5f5f5;
background-color: white;
}
.player-info.data-v-5af9b656 {
flex: 1;
display: flex;
align-items: center;
}
.player-avatar.data-v-5af9b656 {
width: 80rpx;
height: 80rpx;
border-radius: 16rpx;
background-color: #1e3a8a;
padding: 0 15rpx;
border-bottom: 1px solid #eee;
}
.compute .compute-lan .player.data-v-5af9b656 {
margin-right: 270rpx;
}
.compute .compute-lan .vd.data-v-5af9b656 {
margin-right: 210rpx;
}
.compute .compute-detail.data-v-5af9b656 {
display: flex;
padding: 20rpx 0;
align-items: center;
margin-top: 10rpx;
}
.compute .compute-detail .compute-detail-player.data-v-5af9b656 {
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
width: 230rpx;
}
.player-name.data-v-5af9b656 {
font-size: 32rpx;
color: #333;
.compute .compute-detail .compute-detail-player text.data-v-5af9b656 {
font-size: 27rpx;
}
.result-buttons.data-v-5af9b656 {
width: 200rpx;
.compute .compute-detail .compute-detail-player image.data-v-5af9b656 {
width: 70rpx;
padding: 0 16rpx;
}
.compute .compute-detail .compute-detail-vd.data-v-5af9b656 {
display: flex;
background-color: #f0f0f0;
border-radius: 8rpx;
padding: 4rpx;
align-items: center;
width: 200rpx;
padding-left: 50rpx;
}
.result-btn.data-v-5af9b656 {
.compute .compute-detail .compute-detail-vd .result-btn.data-v-5af9b656 {
flex: 1;
padding: 12rpx 0;
text-align: center;
font-size: 28rpx;
border-radius: 6rpx;
}
.result-btn.active.data-v-5af9b656 {
background-color: #6a5acd;
.compute .compute-detail .compute-detail-vd .result-btn.active.data-v-5af9b656 {
background-color: #372fac;
color: white;
}
.score-display.data-v-5af9b656 {
width: 200rpx;
display: flex;
align-items: center;
justify-content: space-between;
.compute .compute-detail .compute-detail-score.data-v-5af9b656 {
padding-left: 133rpx;
}
.score-value.data-v-5af9b656 {
font-size: 36rpx;
color: #333;
font-weight: 500;
.compute .compute-detail .compute-detail-score .score-input.data-v-5af9b656 {
width: 50rpx;
border-radius: 10rpx;
border: 1px solid #eee;
padding-left: 30rpx;
}
.sum-btn.data-v-5af9b656 {
background-color: #6a5acd;
color: white;
border: none;
border-radius: 8rpx;
padding: 12rpx 20rpx;
font-size: 28rpx;
.compute .compute-detail .compute-detail-score .score-input.positive.data-v-5af9b656 {
border-color: #4caf50;
background-color: rgba(76, 175, 80, 0.05);
}
/* 固定在底部的数字键盘 */
.keyboard.data-v-5af9b656 {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 1px;
background-color: #e0e0e0;
padding: 1px;
.compute .compute-detail .compute-detail-score .score-input.negative.data-v-5af9b656 {
border-color: #f44336;
background-color: rgba(244, 67, 54, 0.05);
}
.compute button.data-v-5af9b656 {
position: fixed;
bottom: 0;
bottom: 40rpx;
left: 0;
right: 0;
max-width: 750rpx;
margin: 0 auto;
}
.key.data-v-5af9b656 {
background-color: white;
display: flex;
align-items: center;
justify-content: center;
height: 120rpx;
font-size: 40rpx;
}
.key.data-v-5af9b656:active {
background-color: #f0f0f0;
}
.operator.data-v-5af9b656 {
color: #6a5acd;
}
.minus.data-v-5af9b656 {
color: #ff4757;
}
.submit-key.data-v-5af9b656 {
background-color: #8a2be2;
color: white;
font-weight: 500;
}
/* 调整键盘布局使提交按钮在0的左侧 */
.keyboard.data-v-5af9b656 {
grid-template-areas:
"num1 num2 num3 plus delete"
"num4 num5 num6 minus sqrt"
"num7 num8 num9 submit num0";
}
.key.data-v-5af9b656:nth-child(1) { grid-area: num1;
}
.key.data-v-5af9b656:nth-child(2) { grid-area: num2;
}
.key.data-v-5af9b656:nth-child(3) { grid-area: num3;
}
.key.data-v-5af9b656:nth-child(4) { grid-area: plus;
}
.key.data-v-5af9b656:nth-child(5) { grid-area: delete;
}
.key.data-v-5af9b656:nth-child(6) { grid-area: num4;
}
.key.data-v-5af9b656:nth-child(7) { grid-area: num5;
}
.key.data-v-5af9b656:nth-child(8) { grid-area: num6;
}
.key.data-v-5af9b656:nth-child(9) { grid-area: minus;
}
.key.data-v-5af9b656:nth-child(10) { grid-area: sqrt;
}
.key.data-v-5af9b656:nth-child(11) { grid-area: num7;
}
.key.data-v-5af9b656:nth-child(12) { grid-area: num8;
}
.key.data-v-5af9b656:nth-child(13) { grid-area: num9;
}
.key.data-v-5af9b656:nth-child(14) { grid-area: submit;
}
.key.data-v-5af9b656:nth-child(15) { grid-area: num0;
border-radius: 15rpx;
background-color: #372fac;
color: #fff;
width: 650rpx;
}

View File

@@ -1,6 +1,8 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const utils_request = require("../../utils/request.js");
require("../../api/login.js");
const utils_StaticValue = require("../../utils/StaticValue.js");
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
_easycom_uni_icons2();
@@ -12,7 +14,35 @@ if (!Math) {
const _sfc_main = {
__name: "index",
setup(__props) {
const gotoNewPage = () => {
common_vendor.ref(false);
const roomData = common_vendor.ref([]);
common_vendor.onMounted(() => {
const getUserInfo = utils_StaticValue.StaticValue.getUserInfo;
roomData.value = getUserInfo();
});
const gotoNewPage = async () => {
const response = await utils_request.GET("/system/room/createUser/" + roomData.value.userId);
if (response.code = 200) {
const dataArray = response.data;
if (dataArray && dataArray.length > 0) {
common_vendor.index.__f__("log", "at pages/index/index.vue:96", `查询到 ${dataArray.length} 条房间记录`);
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:100", "未查询到房间记录,新建个人房间");
utils_request.POST("/system/room", {
createUser: roomData.value.userId,
odds: 1,
roomStatus: 1,
bossId: roomData.value.userId,
roomName: `${roomData.value.nickName}的房间`
});
}
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:111", "接口请求失败:", response.msg);
common_vendor.index.showToast({
title: "查询失败",
icon: "none"
});
}
common_vendor.wx$1.navigateTo({
url: "/pages/single/single"
});
@@ -23,7 +53,8 @@ const _sfc_main = {
type: "sound",
size: "20"
}),
b: common_vendor.o(gotoNewPage)
b: common_vendor.o(gotoNewPage),
c: common_vendor.t(roomData.value)
};
};
}

View File

@@ -1 +1 @@
<view class="index data-v-1cf27b2a"><view class="notice data-v-1cf27b2a"><view class="icon data-v-1cf27b2a"><uni-icons wx:if="{{a}}" class="data-v-1cf27b2a" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{a}}"></uni-icons></view><view class="text data-v-1cf27b2a"> 您还有未结束的对局, <text class="underline data-v-1cf27b2a">点击前往</text></view></view><view class="function-list data-v-1cf27b2a"><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://t14.baidu.com/it/u=3165460156,649373630&fm=224&app=112&f=JPEG?w=500&h=500"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 多人模式 </view><view class="function-desc data-v-1cf27b2a"> 所有玩家自己计分 </view></view></view><view class="function-item data-v-1cf27b2a" bindtap="{{b}}"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 单人模式 </view><view class="function-desc data-v-1cf27b2a"> 房主给所有玩家计分 </view></view></view><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 手动进入房间 </view><view class="function-desc data-v-1cf27b2a"> 输入房间id进入房间 </view></view></view><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 扫码加入房间 </view><view class="function-desc data-v-1cf27b2a"> 扫码房间二维码加入房间 </view></view></view></view></view>
<view class="index data-v-1cf27b2a"><view class="notice data-v-1cf27b2a"><view class="icon data-v-1cf27b2a"><uni-icons wx:if="{{a}}" class="data-v-1cf27b2a" u-i="1cf27b2a-0" bind:__l="__l" u-p="{{a}}"></uni-icons></view><view class="text data-v-1cf27b2a"> 您还有未结束的对局, <text class="underline data-v-1cf27b2a">点击前往</text></view></view><view class="function-list data-v-1cf27b2a"><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://t14.baidu.com/it/u=3165460156,649373630&fm=224&app=112&f=JPEG?w=500&h=500"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 多人模式 </view><view class="function-desc data-v-1cf27b2a"> 所有玩家自己计分 </view></view></view><view class="function-item data-v-1cf27b2a" bindtap="{{b}}"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 单人模式 </view><view class="function-desc data-v-1cf27b2a"> 房主给所有玩家计分 </view></view></view><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 手动进入房间 </view><view class="function-desc data-v-1cf27b2a"> 输入房间id进入房间 </view></view></view><view class="function-item data-v-1cf27b2a"><view class="function-icon data-v-1cf27b2a"><image class="data-v-1cf27b2a" src="https://pic.rmb.bdstatic.com/bjh/down/1742bc3845cbbcf0c78c01eb59bb1c1a.jpeg"></image></view><view class="function-introduce data-v-1cf27b2a"><view class="function-name data-v-1cf27b2a"> 扫码加入房间 </view><view class="function-desc data-v-1cf27b2a"> 扫码房间二维码加入房间 </view></view></view><view class=" data-v-1cf27b2a">{{c}}</view></view></view>

View File

@@ -1,11 +1,14 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const common_assets = require("../../common/assets.js");
const utils_request = require("../../utils/request.js");
const utils_StaticValue = require("../../utils/StaticValue.js");
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
const _easycom_l_popup2 = common_vendor.resolveComponent("l-popup");
const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
(_easycom_uni_icons2 + _easycom_l_popup2 + _easycom_uni_easyinput2)();
const _component_uni_load_more = common_vendor.resolveComponent("uni-load-more");
(_easycom_uni_icons2 + _easycom_l_popup2 + _easycom_uni_easyinput2 + _component_uni_load_more)();
}
const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
const _easycom_l_popup = () => "../../uni_modules/lime-popup/components/l-popup/l-popup.js";
@@ -16,14 +19,107 @@ if (!Math) {
const _sfc_main = {
__name: "single",
setup(__props) {
const gotoNewPage = () => {
common_vendor.wx$1.navigateTo({
url: "/pages/user-detail/user-detail"
});
const roomData = common_vendor.ref([]);
const isLoading = common_vendor.ref(false);
const newPlayerName = common_vendor.ref("");
const userScores = common_vendor.ref([]);
const confirmAddPlayer = async () => {
const response = await utils_request.GET("/system/room/createUser/" + roomData.value.userId);
common_vendor.index.__f__("log", "at pages/single/single.vue:147", response);
if (response.code === 200) {
common_vendor.index.showToast({
title: "查询roomId成功",
icon: "success"
});
const dataArray = response.data;
common_vendor.index.__f__("log", "at pages/single/single.vue:155", "dataArray.roomId:", dataArray[0].roomId);
const trimmedName = newPlayerName.value.trim();
const userData = {
nickName: trimmedName,
// 使用 trim() 处理后的名称
avatars: "https://img1.baidu.com/it/u=3612220943,2414740890&fm=253&app=138&f=JPEG?w=526&h=500",
openId: generateTenDigitRandom().toString()
};
const userResponse = await utils_request.POST("/system/score/user/add", userData);
if (userResponse.code === 200) {
const userId1 = userResponse.data.userId;
common_vendor.index.__f__("log", "at pages/single/single.vue:171", "新创建的用户ID:", userId1);
const roomUserData = {
roomId: dataArray[0].roomId,
userId: userId1,
// 使用后端返回的userId
totalScore: 0,
playerType: "robot",
nickName: trimmedName,
avatars: "https://img1.baidu.com/it/u=3612220943,2414740890&fm=253&app=138&f=JPEG?w=526&h=500"
};
const response2 = await utils_request.POST("/system/score/room/user", roomUserData);
common_vendor.index.__f__("log", "at pages/single/single.vue:184", "返回结果: ", response2);
if (response2.code === 200) {
fetchUserScores();
common_vendor.index.__f__("log", "at pages/single/single.vue:188", "添加新玩家成功");
common_vendor.index.showToast({
title: "添加成功,数据已更新",
icon: "success"
});
}
virtueplayer.value = false;
}
}
};
function generateTenDigitRandom() {
return Math.floor(Math.random() * 9e9) + 1e9;
}
const maxRounds = common_vendor.computed(() => {
if (!userScores.value.length)
return 0;
let max = 0;
userScores.value.forEach((user) => {
if (user.details && user.details.length > 0) {
user.details.forEach((detail) => {
if (detail.gameTime > max)
max = detail.gameTime;
});
}
});
return max;
});
const round = common_vendor.computed(() => {
const rounds = maxRounds.value;
return isNaN(rounds) ? 0 : Math.max(0, rounds + 1);
});
common_vendor.index.__f__("log", "at pages/single/single.vue:222", "round:", round);
const formatScore = (score) => {
return score > 0 ? `+${score}` : `${score}`;
};
const fetchUserScores = async () => {
try {
const response2 = await utils_request.GET("/system/room/createUser/" + roomData.value.userId);
common_vendor.index.__f__("log", "at pages/single/single.vue:234", response2);
const dataArray1 = response2.data;
common_vendor.index.__f__("log", "at pages/single/single.vue:237", "房间号为:", dataArray1[0].roomId);
var roomId1 = dataArray1[0].roomId;
const response3 = await utils_request.GET(`/system/score/room/user/user-details/${roomId1}`);
if (response3.code === 200) {
userScores.value = response3.data;
common_vendor.index.__f__("log", "at pages/single/single.vue:244", "用户得分数据加载成功");
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/single/single.vue:247", "获取用户得分失败:", error);
}
};
common_vendor.onMounted(() => {
const getUserInfo = utils_StaticValue.StaticValue.getUserInfo;
roomData.value = getUserInfo();
fetchUserScores();
common_vendor.index.__f__("log", "at pages/single/single.vue:255", "userScores为", userScores);
});
const gotoNewPage1 = () => {
const roomUserData1 = common_vendor.ref(userScores);
const encodedPlayers = encodeURIComponent(JSON.stringify(roomUserData1.value));
const encodedRound = encodeURIComponent(JSON.stringify(round.value));
common_vendor.wx$1.navigateTo({
url: "/pages/compute/compute"
url: `/pages/compute/compute?players=${encodedPlayers}&round=${encodedRound}`
});
};
const isPopupVisible = common_vendor.ref(false);
@@ -52,59 +148,8 @@ const _sfc_main = {
const closemultiple = () => {
isPopupVisible2.value = false;
};
const matchs = common_vendor.ref([
{
id: 1,
gametime: 1,
details: [
{ id: 101, score: "+10" },
{ id: 102, score: "+20" },
{ id: 103, score: "-30" }
]
},
{
id: 2,
gametime: 2,
details: [
{ id: 201, score: "+10" },
{ id: 202, score: "+20" },
{ id: 203, score: "-30" }
]
}
]);
const allscores = common_vendor.ref([
{
id: 301,
allscore: "+20"
},
{
id: 302,
allscore: "+40"
},
{
id: 303,
allscore: "-60"
}
]);
const players = common_vendor.ref([
{
id: 401,
name: "刘备",
avatar: "https://img1.baidu.com/it/u=3612220943,2414740890&fm=253&app=138&f=JPEG?w=526&h=500"
},
{
id: 401,
name: "赵云",
avatar: "https://q3.itc.cn/q_70/images03/20250110/1e71eecf56b34344bcae6a5b85c0bec2.jpeg"
},
{
id: 401,
name: "张飞",
avatar: "https://q1.itc.cn/q_70/images03/20241119/197701bb9ef34b20b6497720081a9972.jpeg"
}
]);
return (_ctx, _cache) => {
return {
return common_vendor.e({
a: common_vendor.p({
type: "plus"
}),
@@ -117,32 +162,27 @@ const _sfc_main = {
}),
f: common_vendor.o(() => {
}),
g: common_vendor.f(players.value, (item, index, i0) => {
g: common_vendor.f(maxRounds.value, (n, k0, i0) => {
return {
a: item.avatar,
b: common_vendor.t(item.name),
c: index,
d: common_vendor.o(gotoNewPage, index)
a: common_vendor.t(n),
b: n
};
}),
h: common_vendor.f(allscores.value, (item, index, i0) => {
h: common_vendor.f(userScores.value, (item, index, i0) => {
return {
a: common_vendor.t(item.allscore),
b: item.id
};
}),
i: common_vendor.f(matchs.value, (match, k0, i0) => {
return {
a: common_vendor.t(match.gametime),
b: common_vendor.f(match.details, (item, index, i1) => {
a: item.avatars,
b: common_vendor.t(item.nickName),
c: common_vendor.t(formatScore(item.totalScore)),
d: common_vendor.f(item.details, (detail, k1, i1) => {
return {
a: common_vendor.t(item.score),
b: item.id
a: common_vendor.t(formatScore(detail.detailScore)),
b: detail.gameTime
};
}),
c: match.id
e: item.userId
};
}),
i: common_vendor.t(userScores.value),
j: common_vendor.o(gotoNewPage1),
k: common_vendor.o(multiple),
l: common_assets._imports_0,
@@ -158,31 +198,37 @@ const _sfc_main = {
closeable: true,
modelValue: isPopupVisible1.value
}),
s: common_vendor.o(($event) => _ctx.value = $event),
t: common_vendor.p({
s: common_vendor.o(confirmAddPlayer),
t: common_vendor.o(($event) => newPlayerName.value = $event),
v: common_vendor.p({
placeholder: "请输入名称",
modelValue: _ctx.value
modelValue: newPlayerName.value
}),
v: common_vendor.o(closevirtue),
w: common_vendor.o(closevirtue),
x: common_vendor.o(($event) => virtueplayer.value = $event),
y: common_vendor.p({
x: common_vendor.o(confirmAddPlayer),
y: common_vendor.o(($event) => virtueplayer.value = $event),
z: common_vendor.p({
closeable: true,
modelValue: virtueplayer.value
}),
z: common_vendor.o(($event) => _ctx.value = $event),
A: common_vendor.p({
A: common_vendor.o(($event) => _ctx.value = $event),
B: common_vendor.p({
placeholder: "请输入倍率",
modelValue: _ctx.value
}),
B: common_vendor.o(closemultiple),
C: common_vendor.o(closemultiple),
D: common_vendor.o(($event) => isPopupVisible2.value = $event),
E: common_vendor.p({
D: common_vendor.o(closemultiple),
E: common_vendor.o(($event) => isPopupVisible2.value = $event),
F: common_vendor.p({
closeable: true,
modelValue: isPopupVisible2.value
}),
G: isLoading.value
}, isLoading.value ? {
H: common_vendor.p({
status: "loading"
})
};
} : {});
};
}
};

View File

@@ -1 +1 @@
<view class="single data-v-6410b918"><view class="single-lan data-v-6410b918"><button class="data-v-6410b918" bindtap="{{b}}"><uni-icons wx:if="{{a}}" class="data-v-6410b918" u-i="6410b918-0" bind:__l="__l" u-p="{{a}}"></uni-icons><text class="data-v-6410b918">添加玩家</text></button><button class="data-v-6410b918" bindtap="{{d}}"><uni-icons wx:if="{{c}}" class="data-v-6410b918" u-i="6410b918-1" bind:__l="__l" u-p="{{c}}"></uni-icons><text class="data-v-6410b918">转让计分员</text></button><view class="lan-switch data-v-6410b918"><switch class="data-v-6410b918" bindchange="{{e}}"/><text class="data-v-6410b918">语音播报</text></view><view class="lan-switch data-v-6410b918"><switch class="data-v-6410b918" bindchange="{{f}}"/><text class="data-v-6410b918">台版</text></view></view><view class="single-detail data-v-6410b918"><text class="sing-detail-title data-v-6410b918">对局记录</text><text class="data-v-6410b918">点击对局分数进行修改</text></view><view class="single-score data-v-6410b918"><text style="color:red" class="score-remind data-v-6410b918"> 点击头像编辑自己的昵称和性别~ </text><view class="single-score-record data-v-6410b918"><view class="score-record-player data-v-6410b918"><text class="score-head data-v-6410b918">玩家</text><view wx:for="{{g}}" wx:for-item="item" wx:key="c" class="player data-v-6410b918" bindtap="{{item.d}}"><image class="data-v-6410b918" src="{{item.a}}" mode="widthFix"></image><text class="data-v-6410b918">{{item.b}}</text></view></view><view class="score-record-all data-v-6410b918"><text class="score-head data-v-6410b918">总分</text><view wx:for="{{h}}" wx:for-item="item" wx:key="b" class="all-score data-v-6410b918">{{item.a}}</view></view><view wx:for="{{i}}" wx:for-item="match" wx:key="c" class="score-record-all data-v-6410b918"><text class="score-head data-v-6410b918">{{match.a}}</text><view wx:for="{{match.b}}" wx:for-item="item" wx:key="b" class="all-score data-v-6410b918">{{item.a}}</view></view></view></view><view class="single-bottom data-v-6410b918"><button class="data-v-6410b918" style="color:aliceblue;background-color:rgb(55, 47, 172)" bindtap="{{j}}"> 开局计分</button><button class="data-v-6410b918" bindtap="{{k}}">结算房间</button></view><l-popup wx:if="{{o}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-2" bind:__l="__l" bindupdateModelValue="{{n}}" u-p="{{o}}"><view class="popup-add data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">扫码加入房间</text></view><view class="line data-v-6410b918"></view><text class="small data-v-6410b918">邀请好友扫描下方二维码加入房间</text><image class="data-v-6410b918" src="{{l}}" mode=""></image><button class="share data-v-6410b918">分享给好友邀请加入房间</button><button class="hand data-v-6410b918" bindtap="{{m}}">手动添加虚拟玩家</button></view></l-popup><l-popup wx:if="{{r}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-3" bind:__l="__l" bindupdateModelValue="{{q}}" u-p="{{r}}"><view class="popup-add data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">提示</text></view><view class="line data-v-6410b918"></view><text class="small data-v-6410b918">房间内暂无扫码或分享加入房间的玩家,暂时无法转让计分员</text><button class="data-v-6410b918" bindtap="{{p}}">确定</button></view></l-popup><l-popup wx:if="{{y}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-4" bind:__l="__l" bindupdateModelValue="{{x}}" u-p="{{y}}"><view class="popup-virtue data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">添加玩家</text></view><view class="line data-v-6410b918"></view><view class="lan-input data-v-6410b918"><uni-easyinput wx:if="{{t}}" class="data-v-6410b918" style="width:500rpx" u-i="6410b918-5,6410b918-4" bind:__l="__l" bindupdateModelValue="{{s}}" u-p="{{t}}"></uni-easyinput></view><view class="lan-button data-v-6410b918"><button class="data-v-6410b918" bindtap="{{v}}">取消</button><button class="data-v-6410b918" bindtap="{{w}}">确定</button></view></view></l-popup><l-popup wx:if="{{E}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-6" bind:__l="__l" bindupdateModelValue="{{D}}" u-p="{{E}}"><view class="popup-virtue data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918" style="font-weight:600">输入倍率,快速结算!</text></view><view class="line data-v-6410b918"></view><view class="lan-input data-v-6410b918"><uni-easyinput wx:if="{{A}}" class="data-v-6410b918" style="width:400rpx" u-i="6410b918-7,6410b918-6" bind:__l="__l" bindupdateModelValue="{{z}}" u-p="{{A}}"></uni-easyinput></view><view class="lan-button data-v-6410b918"><button class="data-v-6410b918" bindtap="{{B}}">取消</button><button class="data-v-6410b918" bindtap="{{C}}">确定</button></view></view></l-popup></view>
<view class="single data-v-6410b918"><view class="single-lan data-v-6410b918"><button class="data-v-6410b918" bindtap="{{b}}"><uni-icons wx:if="{{a}}" class="data-v-6410b918" u-i="6410b918-0" bind:__l="__l" u-p="{{a}}"></uni-icons><text class="data-v-6410b918">添加玩家</text></button><button class="data-v-6410b918" bindtap="{{d}}"><uni-icons wx:if="{{c}}" class="data-v-6410b918" u-i="6410b918-1" bind:__l="__l" u-p="{{c}}"></uni-icons><text class="data-v-6410b918">转让计分员</text></button><view class="lan-switch data-v-6410b918"><switch class="data-v-6410b918" bindchange="{{e}}"/><text class="data-v-6410b918">语音播报</text></view><view class="lan-switch data-v-6410b918"><switch class="data-v-6410b918" bindchange="{{f}}"/><text class="data-v-6410b918">台版</text></view></view><view class="single-detail data-v-6410b918"><text class="sing-detail-title data-v-6410b918">对局记录</text><text class="data-v-6410b918">点击对局分数进行修改</text></view><scroll-view class="single-score data-v-6410b918" scroll-x="true"><text style="color:red" class="score-remind data-v-6410b918"> 点击头像编辑自己的昵称和性别~ </text><view class="single-score-record data-v-6410b918"><view class="tab-head data-v-6410b918"><text class="tab-head-player data-v-6410b918">玩家</text><text class="tab-head-total data-v-6410b918">总分</text><view wx:for="{{g}}" wx:for-item="n" wx:key="b" class="tab-head-detail data-v-6410b918"> 第{{n.a}}局 </view></view><view wx:for="{{h}}" wx:for-item="item" wx:key="e" class="tab-body data-v-6410b918"><view class="tab-body-player data-v-6410b918"><image class="data-v-6410b918" src="{{item.a}}" mode="widthFix"></image><text class="data-v-6410b918">{{item.b}}</text></view><view class="tab-total-score data-v-6410b918">{{item.c}}</view><view wx:for="{{item.d}}" wx:for-item="detail" wx:key="b" class="round-score data-v-6410b918">{{detail.a}}</view></view> {{i}}</view></scroll-view><view class="single-bottom data-v-6410b918"><button class="data-v-6410b918" style="color:aliceblue;background-color:rgb(55, 47, 172)" bindtap="{{j}}"> 开局计分</button><button class="data-v-6410b918" bindtap="{{k}}">结算房间</button></view><l-popup wx:if="{{o}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-2" bind:__l="__l" bindupdateModelValue="{{n}}" u-p="{{o}}"><view class="popup-add data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">扫码加入房间</text></view><view class="line data-v-6410b918"></view><text class="small data-v-6410b918">邀请好友扫描下方二维码加入房间</text><image class="data-v-6410b918" src="{{l}}" mode=""></image><button class="share data-v-6410b918">分享给好友邀请加入房间</button><button class="hand data-v-6410b918" bindtap="{{m}}">手动添加虚拟玩家</button></view></l-popup><l-popup wx:if="{{r}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-3" bind:__l="__l" bindupdateModelValue="{{q}}" u-p="{{r}}"><view class="popup-add data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">提示</text></view><view class="line data-v-6410b918"></view><text class="small data-v-6410b918">房间内暂无扫码或分享加入房间的玩家,暂时无法转让计分员</text><button class="data-v-6410b918" bindtap="{{p}}">确定</button></view></l-popup><l-popup wx:if="{{z}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-4" bind:__l="__l" bindupdateModelValue="{{y}}" u-p="{{z}}"><view class="popup-virtue data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918">添加玩家</text></view><view class="line data-v-6410b918"></view><view class="lan-input data-v-6410b918"><uni-easyinput wx:if="{{v}}" class="data-v-6410b918" style="width:500rpx" bindconfirm="{{s}}" u-i="6410b918-5,6410b918-4" bind:__l="__l" bindupdateModelValue="{{t}}" u-p="{{v}}"></uni-easyinput></view><view class="lan-button data-v-6410b918"><button class="data-v-6410b918" bindtap="{{w}}">取消</button><button class="data-v-6410b918" bindtap="{{x}}">确定</button></view></view></l-popup><l-popup wx:if="{{F}}" class="data-v-6410b918" u-s="{{['d']}}" u-i="6410b918-6" bind:__l="__l" bindupdateModelValue="{{E}}" u-p="{{F}}"><view class="popup-virtue data-v-6410b918"><view class="tilte data-v-6410b918"><text class="title data-v-6410b918" style="font-weight:600">输入倍率,快速结算!</text></view><view class="line data-v-6410b918"></view><view class="lan-input data-v-6410b918"><uni-easyinput wx:if="{{B}}" class="data-v-6410b918" style="width:400rpx" u-i="6410b918-7,6410b918-6" bind:__l="__l" bindupdateModelValue="{{A}}" u-p="{{B}}"></uni-easyinput></view><view class="lan-button data-v-6410b918"><button class="data-v-6410b918" bindtap="{{C}}">取消</button><button class="data-v-6410b918" bindtap="{{D}}">确定</button></view></view></l-popup><uni-load-more wx:if="{{G}}" class="data-v-6410b918" u-i="6410b918-8" bind:__l="__l" u-p="{{H}}"/></view>

View File

@@ -51,6 +51,62 @@
display: flex;
flex-direction: column;
}
.single .single-score .single-score-record.data-v-6410b918 {
display: flex;
margin-top: 20rpx;
}
.single .single-score .single-score-record .tab-head.data-v-6410b918 {
display: flex;
flex-direction: column;
margin-left: 20rpx;
margin-right: 30rpx;
width: 100rpx;
align-items: center;
}
.single .single-score .single-score-record .tab-head .tab-head-player.data-v-6410b918 {
padding-top: 30rpx;
height: 90rpx;
width: 100rpx;
}
.single .single-score .single-score-record .tab-head .tab-head-total.data-v-6410b918 {
padding-top: 20rpx;
width: 100rpx;
}
.single .single-score .single-score-record .tab-head .tab-head-detail.data-v-6410b918 {
margin-top: 60rpx;
width: 100rpx;
}
.single .single-score .single-score-record .tab-body.data-v-6410b918 {
display: flex;
flex-direction: column;
align-items: center;
margin-right: 60rpx;
}
.single .single-score .single-score-record .tab-body .tab-body-player.data-v-6410b918 {
display: flex;
flex-direction: column;
align-items: center;
height: 120rpx;
width: 100rpx;
}
.single .single-score .single-score-record .tab-body .tab-body-player image.data-v-6410b918 {
width: 80rpx;
}
.single .single-score .single-score-record .tab-body .tab-body-player text.data-v-6410b918 {
font-size: 30rpx;
}
.single .single-score .single-score-record .tab-body .tab-total-score.data-v-6410b918 {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 20rpx;
}
.single .single-score .single-score-record .tab-body .round-score.data-v-6410b918 {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 60rpx;
}
.single .single-score .score-remind.data-v-6410b918 {
align-self: center;
font-size: 29rpx;