two version

This commit is contained in:
2025-12-01 15:09:09 +08:00
parent 80b00d9e5d
commit 4d267d4eba
11 changed files with 28 additions and 14 deletions

View File

@@ -62,10 +62,10 @@
</view>
</view>
</view>
<!-- <view class="">
<view class="">
{{roomData}}
</view> -->
</view>
</view>
</view>
</template>
@@ -75,14 +75,17 @@ import { ref, onMounted } from 'vue'
import { getOpenId } from '@/utils/wxutils.js'
import { GET, POST } from '../../utils/request'
import StaticValue from '@/utils/StaticValue.js';
import { login } from '../../api/user';
const loading = ref(false);
//定义承接本地用户信息对象
const roomData = ref([]);
onMounted(() => {
const getUserInfo = StaticValue.getUserInfo;
roomData.value = getUserInfo();
console.log("roomData:",roomData.value.userId)
})

View File

@@ -97,16 +97,20 @@ const getUserInfo = async () => {
if(!userInfo.value?.userId) {
// 如果没有登录, 获取到当前用户的openid
const openIdRes = await getOpenId();
const openId = openIdRes.openid;
userInfo.value = {
openId: openId,
nickName: '用户'+openId.substring(0, 6)
};
console.log("userInfo为",userInfo.value);
register(userInfo.value).then(res => {
// 注册成功就执行登录
console.log("openIdRes为",openIdRes);
login(userInfo.value).then(loginRes => {
userInfo.value = loginRes.data;
// 存储用户信息到本地
console.log("userInfo为",userInfo.value);
proxy.$StaticValue.setUserInfo(userInfo.value);
});
});

View File

@@ -164,7 +164,7 @@ const confirmAddPlayer = async () => {
const userResponse = await POST('/system/score/user/add', userData);
const userResponse = await POST('/system/score/user', userData);
if (userResponse.code === 200) {
// 关键修改正确获取后端返回的userId
@@ -330,6 +330,7 @@ const isPopupVisible = ref(false);
const addplayer = ()=>{
isPopupVisible.value = true;
newPlayerName.value =null;
}
const closeplayer = ()=>{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -19,15 +19,16 @@ const _sfc_main = {
common_vendor.onMounted(() => {
const getUserInfo = utils_StaticValue.StaticValue.getUserInfo;
roomData.value = getUserInfo();
common_vendor.index.__f__("log", "at pages/index/index.vue:88", "roomData:", roomData.value.userId);
});
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:97", `查询到 ${dataArray.length} 条房间记录`);
common_vendor.index.__f__("log", "at pages/index/index.vue:100", `查询到 ${dataArray.length} 条房间记录`);
} else {
common_vendor.index.__f__("log", "at pages/index/index.vue:101", "未查询到房间记录,新建个人房间");
common_vendor.index.__f__("log", "at pages/index/index.vue:104", "未查询到房间记录,新建个人房间");
utils_request.POST("/system/room", {
createUser: roomData.value.userId,
odds: 1,
@@ -37,7 +38,7 @@ const _sfc_main = {
});
}
} else {
common_vendor.index.__f__("error", "at pages/index/index.vue:141", "接口请求失败:", response.msg);
common_vendor.index.__f__("error", "at pages/index/index.vue:144", "接口请求失败:", response.msg);
common_vendor.index.showToast({
title: "查询失败",
icon: "none"
@@ -53,7 +54,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

@@ -26,9 +26,12 @@ const _sfc_main = {
openId,
nickName: "用户" + openId.substring(0, 6)
};
common_vendor.index.__f__("log", "at pages/my/my.vue:106", "userInfo为", userInfo.value);
api_user.register(userInfo.value).then((res) => {
common_vendor.index.__f__("log", "at pages/my/my.vue:109", "openIdRes为", openIdRes);
api_user.login(userInfo.value).then((loginRes) => {
userInfo.value = loginRes.data;
common_vendor.index.__f__("log", "at pages/my/my.vue:113", "userInfo为", userInfo.value);
proxy.$StaticValue.setUserInfo(userInfo.value);
});
});

View File

@@ -40,7 +40,7 @@ const _sfc_main = {
avatars: "https://q3.itc.cn/q_70/images03/20250110/1e71eecf56b34344bcae6a5b85c0bec2.jpeg",
openId: generateTenDigitRandom().toString()
};
const userResponse = await utils_request.POST("/system/score/user/add", userData);
const userResponse = await utils_request.POST("/system/score/user", userData);
if (userResponse.code === 200) {
const userId1 = userResponse.data.userId;
common_vendor.index.__f__("log", "at pages/single/single.vue:173", "新创建的用户ID:", userId1);
@@ -154,6 +154,7 @@ const _sfc_main = {
const isPopupVisible = common_vendor.ref(false);
const addplayer = () => {
isPopupVisible.value = true;
newPlayerName.value = null;
};
const virtueplayer = common_vendor.ref(false);
const addvirtue = () => {
@@ -180,7 +181,7 @@ const _sfc_main = {
};
const oddvalue = common_vendor.ref();
const overmultiple = () => {
common_vendor.index.__f__("log", "at pages/single/single.vue:380", "输入的倍率为:", oddvalue.value);
common_vendor.index.__f__("log", "at pages/single/single.vue:381", "输入的倍率为:", oddvalue.value);
const encodedMultiple = encodeURIComponent(JSON.stringify(oddvalue.value));
isPopupVisible2.value = false;
common_vendor.wx$1.redirectTo({