three version
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="function-list">
|
||||
<view class="function-item">
|
||||
<view class="function-item" @click="gotoNewPage1">
|
||||
<view class="function-icon">
|
||||
<image src="https://t14.baidu.com/it/u=3165460156,649373630&fm=224&app=112&f=JPEG?w=500&h=500"></image>
|
||||
</view>
|
||||
@@ -62,10 +62,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="">
|
||||
{{roomData}}
|
||||
|
||||
</view>
|
||||
<!-- -->
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -110,35 +107,6 @@ const gotoNewPage = async () => {
|
||||
bossId: roomData.value.userId,
|
||||
roomName: `${roomData.value.nickName}的房间`,
|
||||
});
|
||||
//再次发送get请求,拿到当前roomId
|
||||
// const response1 = await GET('/system/room/list',{
|
||||
// roomStatus: 1,
|
||||
// });
|
||||
// const dataArray1 = response1.data;
|
||||
// console.log('new的房间号为:', dataArray1[0].roomId);
|
||||
// console.log("再次发送get请求",response1)
|
||||
// var roomId1 = dataArray1[0].roomId;
|
||||
|
||||
|
||||
|
||||
// const userData = {
|
||||
// nickName: "孤心", // 使用 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 POST('/system/score/user/add', userData);
|
||||
|
||||
|
||||
|
||||
// POST("/system/score/room/user",{
|
||||
// roomId: roomId1,
|
||||
// userId: roomData.value.userId,
|
||||
// totalScore: "0",
|
||||
// playerType: "user",
|
||||
// nickName: "孤心",
|
||||
// avatars: "https://q3.itc.cn/q_70/images03/20250110/1e71eecf56b34344bcae6a5b85c0bec2.jpeg",
|
||||
// });
|
||||
}
|
||||
} else {
|
||||
console.error('接口请求失败:', response.msg);
|
||||
@@ -152,6 +120,41 @@ const gotoNewPage = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const gotoNewPage1 = async () => {
|
||||
//判断有无历史房间记录
|
||||
const response = await GET('/system/room/createUser/'+ roomData.value.userId);
|
||||
//检查是否请求成功
|
||||
if (response.code = 200) {
|
||||
//检查数组是否有对象
|
||||
const dataArray = response.data;
|
||||
if (dataArray && dataArray.length > 0) {
|
||||
console.log(`查询到 ${dataArray.length} 条房间记录`);
|
||||
|
||||
} else {
|
||||
// 数据条数为0,执行B方法
|
||||
console.log('未查询到房间记录,新建个人房间');
|
||||
//创建新房间
|
||||
POST('/system/room', {
|
||||
createUser: roomData.value.userId,
|
||||
odds: 1,
|
||||
roomStatus: 1,
|
||||
bossId: roomData.value.userId,
|
||||
roomName: `${roomData.value.nickName}的房间`,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.error('接口请求失败:', response.msg);
|
||||
uni.showToast({
|
||||
title: '查询失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: '/pages/multiplayer/multiplayer'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user