one version
This commit is contained in:
@@ -49,11 +49,12 @@
|
||||
<script setup>
|
||||
import { onMounted, ref, computed } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { PUT , POST ,GET} from '../../utils/request';
|
||||
|
||||
const players1 = ref([]);
|
||||
const round1 = ref();
|
||||
//存储当前局每个玩家的得分
|
||||
const currentScores = ref([]);
|
||||
|
||||
|
||||
//设置胜负结果
|
||||
const setResult = (index, result) => {
|
||||
@@ -107,7 +108,7 @@ onLoad((options) => {
|
||||
// players1.value = JSON.parse(decodeURIComponent(options.players));
|
||||
round1.value = JSON.parse(decodeURIComponent(options.round));
|
||||
|
||||
console.log("round:",round1.value);
|
||||
// console.log("round:",round1.value);
|
||||
players1.value = rawData.map(player => ({
|
||||
...player,
|
||||
result: "win",
|
||||
@@ -116,7 +117,7 @@ onLoad((options) => {
|
||||
}))
|
||||
|
||||
|
||||
// console.log('数据已更新:', updataScore);
|
||||
// console.log('数据已更新:', players1.value);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,15 +131,64 @@ onLoad((options) => {
|
||||
|
||||
const onsubmit = async () => {
|
||||
const updataScore = players1.value.map(updata => ({
|
||||
roomId: updata.roomId,
|
||||
userId: updata.userId,
|
||||
score: updata.score,
|
||||
roomId: updata.roomId,
|
||||
userId: updata.userId,
|
||||
totalScore: updata.score,
|
||||
}))
|
||||
|
||||
console.log("总分修改接口:",updataScore);
|
||||
|
||||
const detailDatas = players1.value.map(detaildata => ({
|
||||
roomId: detaildata.roomId,
|
||||
userId: detaildata.userId,
|
||||
detailScore: detaildata.score,
|
||||
gameTime: round1.value,
|
||||
}))
|
||||
|
||||
console.log("输入框的值:",updataScore);
|
||||
|
||||
console.log("细分新增接口:",detailDatas);
|
||||
|
||||
if(validateScore1(detailDatas)){
|
||||
console.log("发送网络请求");
|
||||
try{
|
||||
PUT("/system/score/room/user", updataScore);
|
||||
POST("/system/detail", detailDatas);
|
||||
console.log('用户计分成功');
|
||||
wx.navigateTo({
|
||||
url: '/pages/single/single'
|
||||
})
|
||||
}
|
||||
catch(error) {
|
||||
console.error('用户计分失败:', error);
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log("请求中止");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 编写检验非空函数
|
||||
// 单个值检验
|
||||
const isScoreInvaild1 = (score) => {
|
||||
return score === null || score === undefined || score === "";
|
||||
}
|
||||
//批量检验得分
|
||||
const validateScore1 = (arrayData) => {
|
||||
const invalidItems = arrayData.filter(item => isScoreInvaild1(item.detailScore));
|
||||
|
||||
if (invalidItems.length > 0) {
|
||||
console.log('发现有未计分玩家:', invalidItems)
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: `发现 ${invalidItems.length} 个未计分玩家,请检查!`,
|
||||
showCancel: false
|
||||
})
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const usersData = ref([
|
||||
{
|
||||
id: 1,
|
||||
|
||||
Reference in New Issue
Block a user