This commit is contained in:
2025-11-24 16:01:45 +08:00
parent aa160793e7
commit 46c975591b
45 changed files with 1311 additions and 559 deletions

View File

@@ -7046,9 +7046,9 @@ function isConsoleWritable() {
return isWritable;
}
function initRuntimeSocketService() {
const hosts = "192.168.124.114,127.0.0.1";
const hosts = "10.87.64.114,127.0.0.1";
const port = "8090";
const id = "mp-weixin_rbm27H";
const id = "mp-weixin_RXuSqC";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();

View File

@@ -1,21 +1,12 @@
"use strict";
const common_vendor = require("../../../common/vendor.js");
const app = require("../../../app.js");
if (!Array) {
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
_easycom_uni_icons2();
}
const _easycom_uni_icons = () => "../../../uni_modules/uni-icons/components/uni-icons/uni-icons.js";
if (!Math) {
_easycom_uni_icons();
}
const _sfc_main = {
__name: "change",
setup(__props) {
const userInfo = common_vendor.ref({
id: "",
nickName: "",
avatarUrl: ""
name: "",
avatar: ""
});
common_vendor.onLoad((options) => {
if (options.userData) {
@@ -23,21 +14,12 @@ const _sfc_main = {
const data = JSON.parse(decodeURIComponent(options.userData));
userInfo.value = { ...data };
} catch (e) {
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:55", "解析用户数据失败:", e);
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:45", "解析用户数据失败:", e);
}
}
if (options.from) {
common_vendor.index.__f__("log", "at pages/index/singleplay/change.vue:61", "来源页面:", options.from);
}
});
const goBack = () => {
if (userInfo.value.nickName.trim()) {
app.updateGlobalUserInfo(userInfo.value);
}
common_vendor.wx$1.navigateBack();
};
const chooseNewAvatar = () => {
common_vendor.wx$1.chooseMedia({
common_vendor.index.chooseMedia({
count: 1,
mediaType: ["image"],
sourceType: ["album", "camera"],
@@ -46,18 +28,18 @@ const _sfc_main = {
success: (res) => {
try {
const tempFilePath = res.tempFiles[0].tempFilePath;
userInfo.value.avatarUrl = tempFilePath;
userInfo.value.avatar = tempFilePath;
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:90", "处理头像文件路径失败:", error);
common_vendor.wx$1.showToast({
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:69", "处理头像文件路径失败:", error);
common_vendor.index.showToast({
title: "头像设置失败",
icon: "none"
});
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:98", "选择图片失败:", err);
common_vendor.wx$1.showToast({
common_vendor.index.__f__("error", "at pages/index/singleplay/change.vue:77", "选择图片失败:", err);
common_vendor.index.showToast({
title: "选择图片失败",
icon: "none"
});
@@ -65,47 +47,41 @@ const _sfc_main = {
});
};
const saveUserInfo = () => {
if (!userInfo.value.nickName.trim()) {
common_vendor.wx$1.showToast({
if (!userInfo.value.name.trim()) {
common_vendor.index.showToast({
title: "昵称不能为空",
icon: "none"
});
return;
}
app.updateGlobalUserInfo(userInfo.value);
const pages = getCurrentPages();
const prevPage = pages[pages.length - 2];
if (prevPage) {
if (prevPage.$vm && prevPage.$vm.updateUserData) {
prevPage.$vm.updateUserData(userInfo.value);
} else {
common_vendor.wx$1.$emit && common_vendor.wx$1.$emit("userDataUpdated", userInfo.value);
}
}
common_vendor.wx$1.showToast({
common_vendor.index.$emit("userDataUpdated", userInfo.value);
common_vendor.index.setStorageSync("userInfo", userInfo.value);
common_vendor.index.setStorageSync("currentUserInfo", userInfo.value);
common_vendor.index.showToast({
title: "保存成功",
icon: "success",
duration: 1500,
success: () => {
setTimeout(() => {
common_vendor.wx$1.navigateBack();
common_vendor.index.navigateBack();
}, 1500);
}
});
};
return (_ctx, _cache) => {
return {
a: common_vendor.p({
type: "left",
size: "22",
color: "#fff"
}),
b: common_vendor.o(goBack),
c: userInfo.value.nickName,
d: common_vendor.o(($event) => userInfo.value.nickName = $event.detail.value),
e: userInfo.value.avatarUrl || "/static/logo.png",
f: common_vendor.o(chooseNewAvatar),
g: common_vendor.o(saveUserInfo)
a: userInfo.value.name,
b: common_vendor.o(($event) => userInfo.value.name = $event.detail.value),
c: userInfo.value.avatar || "/static/logo.png",
d: common_vendor.o(chooseNewAvatar),
e: common_vendor.o(saveUserInfo)
};
};
}

View File

@@ -1,7 +1,5 @@
{
"navigationBarTitleText": "用户信息",
"navigationBarHidden": true,
"usingComponents": {
"uni-icons": "../../../uni_modules/uni-icons/components/uni-icons/uni-icons"
}
"usingComponents": {}
}

View File

@@ -1 +1 @@
<view class="container data-v-9c38dc47"><view class="header data-v-9c38dc47"><view class="back-btn data-v-9c38dc47" bindtap="{{b}}"><uni-icons wx:if="{{a}}" class="data-v-9c38dc47" u-i="9c38dc47-0" bind:__l="__l" u-p="{{a}}"/></view><view class="title data-v-9c38dc47">用户信息</view><view class="placeholder data-v-9c38dc47"></view></view><view class="content data-v-9c38dc47"><view class="form-item data-v-9c38dc47"><view class="label data-v-9c38dc47">昵称:</view><input class="input data-v-9c38dc47" placeholder="请输入昵称" value="{{c}}" bindinput="{{d}}"/></view><view class="form-item data-v-9c38dc47"><view class="label data-v-9c38dc47">头像:</view><view class="avatar-wrapper data-v-9c38dc47" bindtap="{{f}}"><image src="{{e}}" mode="aspectFill" class="avatar data-v-9c38dc47"/><view class="avatar-tip data-v-9c38dc47">点击更新头像</view></view></view><button class="save-btn data-v-9c38dc47" bindtap="{{g}}">保存</button></view></view>
<view class="container data-v-9c38dc47"><view class="content data-v-9c38dc47"><view class="form-item data-v-9c38dc47"><view class="label data-v-9c38dc47">昵称:</view><input class="input data-v-9c38dc47" placeholder="请输入昵称" value="{{a}}" bindinput="{{b}}"/></view><view class="form-item data-v-9c38dc47"><view class="label data-v-9c38dc47">头像:</view><view class="avatar-wrapper data-v-9c38dc47" bindtap="{{d}}"><image src="{{c}}" mode="aspectFill" class="avatar data-v-9c38dc47"/><view class="avatar-tip data-v-9c38dc47">点击更新头像</view></view></view><button class="save-btn data-v-9c38dc47" bindtap="{{e}}">保存</button></view></view>

View File

@@ -1,9 +1,7 @@
.container.data-v-9c38dc47 {
min-height: 100vh;
background-color: #f5f5f5;
}
/* 自定义头部 */
.header.data-v-9c38dc47 {
display: flex;
@@ -32,7 +30,6 @@
.placeholder.data-v-9c38dc47 {
width: 40px;
}
/* 内容区域 */
.content.data-v-9c38dc47 {
padding: 20rpx;
@@ -62,7 +59,6 @@
border: 1px solid #e0e0e0;
border-radius: 8rpx;
}
/* 头像样式 */
.avatar-wrapper.data-v-9c38dc47 {
flex: 1;
@@ -80,7 +76,6 @@
font-size: 24rpx;
color: #999;
}
/* 保存按钮 */
.save-btn.data-v-9c38dc47 {
width: 100%;

View File

@@ -32,7 +32,7 @@ const _sfc_main = {
saveHistoryState();
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/singleplay/scoring.vue:142", "加载玩家数据失败:", error);
common_vendor.index.__f__("error", "at pages/index/singleplay/scoring.vue:141", "加载玩家数据失败:", error);
common_vendor.index.showToast({
title: "加载数据失败",
icon: "none"
@@ -187,26 +187,6 @@ const _sfc_main = {
icon: "success"
});
};
const nextRound = () => {
common_vendor.index.showModal({
title: "确认",
content: "确定要开始下一局吗?",
success: (res) => {
if (res.confirm) {
saveHistoryState();
players.value.forEach((player) => {
player.score = 0;
player.result = "";
});
roundCount.value++;
common_vendor.index.showToast({
title: `${roundCount.value}`,
icon: "none"
});
}
}
});
};
const playSound = () => {
const innerAudioContext = common_vendor.index.createInnerAudioContext();
innerAudioContext.src = "/static/sound/click.mp3";
@@ -257,7 +237,7 @@ const _sfc_main = {
}
});
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/singleplay/scoring.vue:454", "结束对局失败:", error);
common_vendor.index.__f__("error", "at pages/index/singleplay/scoring.vue:453", "结束对局失败:", error);
common_vendor.index.showToast({
title: "操作失败",
icon: "none"
@@ -268,12 +248,19 @@ const _sfc_main = {
});
};
common_vendor.onMounted(() => {
common_vendor.index.__f__("log", "at pages/index/singleplay/scoring.vue:467", "计分页面加载完成");
common_vendor.index.__f__("log", "at pages/index/singleplay/scoring.vue:466", "计分页面加载完成");
loadPlayersData();
const savedSound = common_vendor.index.getStorageSync("soundEnabled");
if (savedSound !== "") {
soundEnabled.value = savedSound;
}
const selectedIndex = common_vendor.index.getStorageSync("selectedPlayerIndex");
if (selectedIndex !== "" && players.value.length > 0) {
setTimeout(() => {
selectPlayer(parseInt(selectedIndex));
common_vendor.index.removeStorageSync("selectedPlayerIndex");
}, 100);
}
});
common_vendor.onUnmounted(() => {
});
@@ -328,8 +315,7 @@ const _sfc_main = {
} : {}, {
y: !showKeyboard.value
}, !showKeyboard.value ? {
z: common_vendor.o(nextRound),
A: common_vendor.o(endGame)
z: common_vendor.o(endGame)
} : {});
};
}

View File

@@ -1 +1 @@
<view class="scoring-page data-v-94d9c592"><view class="header data-v-94d9c592"><view class="back-btn data-v-94d9c592" bindtap="{{b}}"><uni-icons wx:if="{{a}}" class="data-v-94d9c592" u-i="94d9c592-0" bind:__l="__l" u-p="{{a}}"></uni-icons></view><view class="title data-v-94d9c592">第{{c}}局</view><view class="header-right data-v-94d9c592"><view class="more-btn data-v-94d9c592" bindtap="{{d}}">...</view><view class="separator data-v-94d9c592"></view><view class="sound-toggle data-v-94d9c592" bindtap="{{f}}"><text class="sound-icon data-v-94d9c592">{{e}}</text></view></view></view><view class="players-list data-v-94d9c592"><view class="list-header data-v-94d9c592"><view class="col-player data-v-94d9c592">玩家</view><view class="col-result data-v-94d9c592">胜负</view><view class="col-score data-v-94d9c592">得分</view></view><view wx:for="{{g}}" wx:for-item="player" wx:key="l" class="{{['player-row', 'data-v-94d9c592', player.m && 'selected']}}" bindtap="{{player.n}}"><view class="col-player data-v-94d9c592"><image src="{{player.a}}" mode="aspectFill" class="player-avatar data-v-94d9c592"></image><text class="player-name data-v-94d9c592">{{player.b}}</text></view><view class="col-result data-v-94d9c592"><view class="result-buttons data-v-94d9c592"><button class="{{['result-btn', 'win', 'data-v-94d9c592', player.c && 'active']}}" catchtap="{{player.d}}">胜</button><button class="{{['result-btn', 'lose', 'data-v-94d9c592', player.e && 'active']}}" catchtap="{{player.f}}">负</button></view></view><view class="col-score data-v-94d9c592"><view class="score-input-container data-v-94d9c592"><input type="number" class="score-input data-v-94d9c592" value="{{player.g}}" catchfocus="{{player.h}}" catchtap="{{player.i}}" readonly disabled/><button class="combine-btn data-v-94d9c592" catchtap="{{player.j}}" disabled="{{player.k}}">合分</button></view></view></view></view><view wx:if="{{h}}" class="number-keyboard data-v-94d9c592"><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{i}}">1</view><view class="key data-v-94d9c592" bindtap="{{j}}">2</view><view class="key data-v-94d9c592" bindtap="{{k}}">3</view><view class="key operation data-v-94d9c592" bindtap="{{l}}">+</view><view class="key delete data-v-94d9c592" bindtap="{{m}}"><text class="data-v-94d9c592">⌫</text></view></view><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{n}}">4</view><view class="key data-v-94d9c592" bindtap="{{o}}">5</view><view class="key data-v-94d9c592" bindtap="{{p}}">6</view><view class="key operation data-v-94d9c592" bindtap="{{q}}">-</view><view class="key empty data-v-94d9c592"></view></view><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{r}}">7</view><view class="key data-v-94d9c592" bindtap="{{s}}">8</view><view class="key data-v-94d9c592" bindtap="{{t}}">9</view><view class="key operation data-v-94d9c592" bindtap="{{v}}">C</view><view class="key confirm data-v-94d9c592" bindtap="{{w}}">提交</view></view><view class="keyboard-row data-v-94d9c592"><view class="key zero data-v-94d9c592" bindtap="{{x}}">0</view></view></view><view wx:if="{{y}}" class="bottom-actions data-v-94d9c592"><button class="action-btn data-v-94d9c592" type="default" bindtap="{{z}}">下一局</button><button class="action-btn primary data-v-94d9c592" type="primary" bindtap="{{A}}">结束对局</button></view></view>
<view class="scoring-page data-v-94d9c592"><view class="header data-v-94d9c592"><view class="back-btn data-v-94d9c592" bindtap="{{b}}"><uni-icons wx:if="{{a}}" class="data-v-94d9c592" u-i="94d9c592-0" bind:__l="__l" u-p="{{a}}"></uni-icons></view><view class="title data-v-94d9c592">第{{c}}局</view><view class="header-right data-v-94d9c592"><view class="more-btn data-v-94d9c592" bindtap="{{d}}">...</view><view class="separator data-v-94d9c592"></view><view class="sound-toggle data-v-94d9c592" bindtap="{{f}}"><text class="sound-icon data-v-94d9c592">{{e}}</text></view></view></view><view class="players-list data-v-94d9c592"><view class="list-header data-v-94d9c592"><view class="col-player data-v-94d9c592">玩家</view><view class="col-result data-v-94d9c592">胜负</view><view class="col-score data-v-94d9c592">得分</view></view><view wx:for="{{g}}" wx:for-item="player" wx:key="l" class="{{['player-row', 'data-v-94d9c592', player.m && 'selected']}}" bindtap="{{player.n}}"><view class="col-player data-v-94d9c592"><image src="{{player.a}}" mode="aspectFill" class="player-avatar data-v-94d9c592"></image><text class="player-name data-v-94d9c592">{{player.b}}</text></view><view class="col-result data-v-94d9c592"><view class="result-buttons data-v-94d9c592"><button class="{{['result-btn', 'win', 'data-v-94d9c592', player.c && 'active']}}" catchtap="{{player.d}}">胜</button><button class="{{['result-btn', 'lose', 'data-v-94d9c592', player.e && 'active']}}" catchtap="{{player.f}}">负</button></view></view><view class="col-score data-v-94d9c592"><view class="score-input-container data-v-94d9c592"><input type="number" class="score-input data-v-94d9c592" value="{{player.g}}" catchfocus="{{player.h}}" catchtap="{{player.i}}" readonly disabled/><button class="combine-btn data-v-94d9c592" catchtap="{{player.j}}" disabled="{{player.k}}">合分</button></view></view></view></view><view wx:if="{{h}}" class="number-keyboard data-v-94d9c592"><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{i}}">1</view><view class="key data-v-94d9c592" bindtap="{{j}}">2</view><view class="key data-v-94d9c592" bindtap="{{k}}">3</view><view class="key operation data-v-94d9c592" bindtap="{{l}}">+</view><view class="key delete data-v-94d9c592" bindtap="{{m}}"><text class="data-v-94d9c592">⌫</text></view></view><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{n}}">4</view><view class="key data-v-94d9c592" bindtap="{{o}}">5</view><view class="key data-v-94d9c592" bindtap="{{p}}">6</view><view class="key operation data-v-94d9c592" bindtap="{{q}}">-</view><view class="key empty data-v-94d9c592"></view></view><view class="keyboard-row data-v-94d9c592"><view class="key data-v-94d9c592" bindtap="{{r}}">7</view><view class="key data-v-94d9c592" bindtap="{{s}}">8</view><view class="key data-v-94d9c592" bindtap="{{t}}">9</view><view class="key operation data-v-94d9c592" bindtap="{{v}}">C</view><view class="key confirm data-v-94d9c592" bindtap="{{w}}">提交</view></view><view class="keyboard-row data-v-94d9c592"><view class="key zero data-v-94d9c592" bindtap="{{x}}">0</view></view></view><view wx:if="{{y}}" class="bottom-actions data-v-94d9c592"><button class="action-btn primary data-v-94d9c592" type="primary" bindtap="{{z}}">结束对局</button></view></view>

View File

@@ -1,30 +1,92 @@
"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_CommonValues = require("../../../utils/CommonValues.js");
const _sfc_main = {
__name: "singleplay",
setup(__props) {
common_vendor.ref(null);
const getuserinfo = () => {
utils_request.GET("/score/info/list", null).then((res) => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:113", "获取用户信息成功:", res.data);
if (res.data && res.data.code === 200 && Array.isArray(res.data.rows)) {
const userList = res.data.rows;
const selfPlayer = players.value.find((p) => p.id === "self");
players.value = selfPlayer ? [selfPlayer] : [];
userList.forEach((user) => {
if (user.nickName) {
let avatarUrl = user.avatars;
if (avatarUrl) {
if (avatarUrl.startsWith("/")) {
avatarUrl = `${utils_CommonValues.BASE_URL}${avatarUrl}`;
} else if (!avatarUrl.startsWith("http://") && !avatarUrl.startsWith("https://")) {
avatarUrl = `${utils_CommonValues.BASE_URL}/${avatarUrl}`;
}
} else {
avatarUrl = "/static/avatar14.png";
}
const newPlayer = {
id: `player_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
name: user.nickName,
// 使用API返回的nickName作为玩家名称
avatar: avatarUrl,
// 使用处理后的头像URL
score: 0,
roundScores: []
};
players.value.push(newPlayer);
}
});
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:152", "玩家列表更新完成:", players.value);
common_vendor.index.showToast({
title: `成功添加${userList.length}位玩家`,
icon: "success"
});
} else {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:158", "API返回数据结构异常:", res.data);
common_vendor.index.showToast({
title: "获取玩家信息失败,数据结构异常",
icon: "none"
});
}
}).catch((err) => {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:165", "获取用户信息失败:", err);
const errorMsg = err.userFriendlyMsg || "获取玩家信息失败";
common_vendor.index.showToast({
title: errorMsg,
icon: "none",
duration: 2e3
});
});
};
const voiceBroadcast = common_vendor.ref(false);
const tableMode = common_vendor.ref(false);
const roomId = common_vendor.ref("");
const storedUserInfo = common_vendor.index.getStorageSync("userInfo");
const currentUser = common_vendor.ref({
id: "self",
name: "玩家50950",
avatar: "https://t14.baidu.com/it/u=3165460156,649373630&fm=224&app=112&f=JPEG?w=500&h=500"
name: (storedUserInfo == null ? void 0 : storedUserInfo.name) || "玩家50920",
avatar: (storedUserInfo == null ? void 0 : storedUserInfo.avatar) || "/static/logo.png"
});
const rounds = common_vendor.ref([]);
const players = common_vendor.ref([
{
id: "self",
name: "玩家50950",
avatar: "https://t14.baidu.com/it/u=3165460156,649373630&fm=224&app=112&f=JPEG?w=500&h=500",
score: 0
name: currentUser.value.name || "玩家50920",
avatar: currentUser.value.avatar || "/static/logo.png",
score: 0,
roundScores: []
// 存储每局的分数
}
]);
const tablePlayer = {
id: "table",
name: "台板",
avatar: "/static/robot.png",
score: 0
score: 0,
roundScores: []
// 存储每局的分数
};
const displayPlayers = common_vendor.computed(() => {
if (tableMode.value) {
@@ -38,7 +100,7 @@ const _sfc_main = {
}
});
const addPlayer = () => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:130", "添加玩家");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:237", "添加玩家");
const defaultPlayerName = "请输入玩家名称";
common_vendor.index.showModal({
title: "添加玩家",
@@ -54,8 +116,10 @@ const _sfc_main = {
const newPlayer = {
id: `player_${Date.now()}`,
name: playerName,
avatar: "/static/people.png",
score: 0
avatar: "/static/avatar14.png",
score: 0,
roundScores: []
// 存储每局的分数
};
players.value.push(newPlayer);
if (voiceBroadcast.value) {
@@ -72,12 +136,12 @@ const _sfc_main = {
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:177", "添加玩家失败:", err);
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:285", "添加玩家失败:", err);
}
});
};
const transferScorer = () => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:184", "转让计分员");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:292", "转让计分员");
common_vendor.index.showModal({
title: "提示",
content: "房间内暂无扫码或分享加入房间的玩家,无法转让计分员。",
@@ -85,81 +149,55 @@ const _sfc_main = {
confirmText: "确定",
success: (res) => {
if (res.confirm) {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:196", "用户确认提示");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:304", "用户确认提示");
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:200", "显示提示失败:", err);
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:308", "显示提示失败:", err);
}
});
};
const editUserInfo = () => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:207", "跳转到用户信息编辑页面");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:315", "跳转到用户信息编辑页面");
common_vendor.index.navigateTo({
url: `/pages/index/singleplay/change?userData=${encodeURIComponent(JSON.stringify(currentUser.value))}`
});
};
const editScore = (index) => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:246", "编辑分数", index);
const player = displayPlayers.value[index];
if (player.id === "table") {
common_vendor.index.showModal({
title: "修改台板分数",
content: `当前分数: ${player.score}`,
editable: true,
placeholderText: "请输入新分数",
success: (res) => {
if (res.confirm && res.content !== null) {
const newScore = parseInt(res.content);
if (!isNaN(newScore)) {
const tableIndex = players.value.findIndex((p) => p.id === "table");
if (tableIndex !== -1) {
players.value[tableIndex].score = newScore;
} else {
tablePlayer.score = newScore;
}
if (voiceBroadcast.value) {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:272", `语音播报: 台板 分数更新为 ${newScore}`);
}
} else {
common_vendor.index.showToast({
title: "请输入有效的数字",
icon: "none"
});
}
}
}
const updateUserData = (updatedUser) => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:325", "更新用户数据", updatedUser);
currentUser.value = { ...updatedUser };
const selfPlayerIndex = players.value.findIndex((p) => p.id === "self");
if (selfPlayerIndex !== -1) {
players.value[selfPlayerIndex] = {
...players.value[selfPlayerIndex],
name: updatedUser.name,
avatar: updatedUser.avatar
};
}
common_vendor.index.setStorageSync("userInfo", updatedUser);
common_vendor.index.setStorageSync("currentUserInfo", updatedUser);
};
const editScore = (playerIndex) => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:347", "编辑分数,玩家索引:", playerIndex);
displayPlayers.value[playerIndex];
if (rounds.value.length === 0) {
common_vendor.index.showToast({
title: "暂无局数记录,无法编辑分数",
icon: "none"
});
return;
}
common_vendor.index.showModal({
title: "修改分数",
content: `${player.score}`,
editable: true,
placeholderText: "请输入新分数",
success: (res) => {
if (res.confirm && res.content !== null) {
const newScore = parseInt(res.content);
if (!isNaN(newScore)) {
const playerIndex = players.value.findIndex((p) => p.id === player.id);
if (playerIndex !== -1) {
players.value[playerIndex].score = newScore;
}
if (voiceBroadcast.value) {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:304", `语音播报: ${player.name} 分数更新为 ${newScore}`);
}
} else {
common_vendor.index.showToast({
title: "请输入有效的数字",
icon: "none"
});
}
}
}
const currentRound = rounds.value.length;
const playersToPass = [...displayPlayers.value];
common_vendor.index.setStorageSync("currentPlayers", JSON.stringify(playersToPass));
common_vendor.index.setStorageSync("currentRound", currentRound);
common_vendor.index.setStorageSync("selectedPlayerIndex", playerIndex);
common_vendor.index.navigateTo({
url: "/pages/index/singleplay/scoring"
});
};
const startScoring = () => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:319", "开局计分");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:383", "开局计分");
if (displayPlayers.value.length < 2) {
common_vendor.index.showToast({
title: "玩家数不超过两个人时无法点击进行开始计分",
@@ -167,20 +205,17 @@ const _sfc_main = {
});
return;
}
players.value.forEach((player) => {
player.score = 0;
});
if (tableMode.value) {
tablePlayer.score = 0;
}
const newRound = rounds.value.length + 1;
rounds.value.push(newRound);
const playersToPass = [...displayPlayers.value];
common_vendor.index.setStorageSync("currentPlayers", JSON.stringify(playersToPass));
common_vendor.index.setStorageSync("currentRound", newRound);
common_vendor.index.navigateTo({
url: "/pages/index/singleplay/scoring"
});
};
const settleRoom = () => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:354", "结算房间");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:414", "结算房间");
let result = "结算结果:\n";
displayPlayers.value.forEach((player) => {
result += `${player.name}: ${player.score}
@@ -202,7 +237,8 @@ const _sfc_main = {
});
};
common_vendor.onMounted(() => {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:381", "单人模式页面加载完成");
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:441", "单人模式页面加载完成");
getuserinfo();
roomId.value = Math.floor(1e3 + Math.random() * 9e3).toString();
common_vendor.index.setNavigationBarTitle({
title: `单人 - ${roomId.value}号房间`
@@ -212,28 +248,60 @@ const _sfc_main = {
if (updatedPlayers) {
try {
const parsedPlayers = JSON.parse(updatedPlayers);
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:399", "收到更新的玩家数据:", parsedPlayers);
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:460", "收到更新的玩家数据:", parsedPlayers);
const currentRound = common_vendor.index.getStorageSync("currentRound") || 1;
const roundIndex = currentRound - 1;
parsedPlayers.forEach((updatedPlayer) => {
const playerIndex = players.value.findIndex((p) => p.id === updatedPlayer.id);
if (playerIndex !== -1) {
players.value[playerIndex].score = updatedPlayer.score;
if (players.value[playerIndex].roundScores.length <= roundIndex) {
players.value[playerIndex].roundScores.length = roundIndex + 1;
}
players.value[playerIndex].roundScores[roundIndex] = updatedPlayer.score;
players.value[playerIndex].score = players.value[playerIndex].roundScores.reduce((sum, score) => sum + (score || 0), 0);
} else if (updatedPlayer.id === "table") {
tablePlayer.score = updatedPlayer.score;
if (tablePlayer.roundScores.length <= roundIndex) {
tablePlayer.roundScores.length = roundIndex + 1;
}
tablePlayer.roundScores[roundIndex] = updatedPlayer.score;
tablePlayer.score = tablePlayer.roundScores.reduce((sum, score) => sum + (score || 0), 0);
}
});
common_vendor.index.removeStorageSync("updatedPlayers");
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:417", "解析更新的玩家数据失败:", error);
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:496", "解析更新的玩家数据失败:", error);
}
}
};
common_vendor.index.$on("updatePlayers", updateListener);
const userDataListener = (updatedUser) => {
updateUserData(updatedUser);
};
common_vendor.index.$on("userDataUpdated", userDataListener);
common_vendor.index.onShow(() => {
updateListener();
try {
const storedUserInfo2 = common_vendor.index.getStorageSync("userInfo");
if (storedUserInfo2) {
common_vendor.index.__f__("log", "at pages/index/singleplay/singleplay.vue:518", "从本地存储加载用户信息:", storedUserInfo2);
currentUser.value = { ...storedUserInfo2 };
const selfPlayerIndex = players.value.findIndex((p) => p.id === "self");
if (selfPlayerIndex !== -1) {
players.value[selfPlayerIndex] = {
...players.value[selfPlayerIndex],
name: storedUserInfo2.name,
avatar: storedUserInfo2.avatar
};
}
}
} catch (error) {
common_vendor.index.__f__("error", "at pages/index/singleplay/singleplay.vue:533", "从本地存储获取用户信息失败:", error);
}
});
common_vendor.onUnmounted(() => {
common_vendor.index.$off("updatePlayers", updateListener);
});
});
common_vendor.onUnmounted(() => {
common_vendor.index.$off("updatePlayers");
common_vendor.index.$off("userDataUpdated");
});
return (_ctx, _cache) => {
return {
@@ -253,13 +321,30 @@ const _sfc_main = {
return {
a: player.avatar,
b: common_vendor.t(player.name),
c: common_vendor.t(player.score),
d: common_vendor.o(($event) => editScore(index), player.id),
e: player.id
c: player.id
};
}),
n: common_vendor.o(startScoring),
o: common_vendor.o(settleRoom)
n: common_vendor.f(displayPlayers.value, (player, index, i0) => {
return {
a: common_vendor.t(player.score),
b: player.id
};
}),
o: common_vendor.f(rounds.value, (round, roundIndex, i0) => {
return {
a: common_vendor.t(round),
b: common_vendor.f(displayPlayers.value, (player, playerIndex, i1) => {
return {
a: common_vendor.t(player.roundScores[roundIndex] || 0),
b: common_vendor.o(($event) => editScore(_ctx.index), player.id),
c: player.id
};
}),
c: round
};
}),
p: common_vendor.o(startScoring),
q: common_vendor.o(settleRoom)
};
};
}

View File

@@ -1 +1 @@
<view class="singleplay data-v-d36a0b1a"><view class="top-functions data-v-d36a0b1a"><view class="function-btn data-v-d36a0b1a" bindtap="{{b}}"><image src="{{a}}" class="btn-icon data-v-d36a0b1a" mode="aspectFill"></image><text class="data-v-d36a0b1a">添加玩家</text></view><view class="function-btn data-v-d36a0b1a" bindtap="{{d}}"><image src="{{c}}" class="btn-icon data-v-d36a0b1a" mode="aspectFill"></image><text class="data-v-d36a0b1a">转让计分员</text></view><view class="switch-group data-v-d36a0b1a"><text class="data-v-d36a0b1a">语音播报</text><switch class="data-v-d36a0b1a" checked="{{e}}" bindchange="{{f}}" color="#007aff"/></view><view class="switch-group data-v-d36a0b1a"><text class="data-v-d36a0b1a">台板</text><switch class="data-v-d36a0b1a" checked="{{g}}" bindchange="{{h}}" color="#007aff"/></view></view><view class="game-record data-v-d36a0b1a"><view class="record-title data-v-d36a0b1a"> 对局记录 <text class="hint data-v-d36a0b1a">点击对局分数进行修改</text></view><view class="user-section data-v-d36a0b1a"><text class="user-hint data-v-d36a0b1a">点击自己头像编辑用户头像和昵称~</text><view class="user-info data-v-d36a0b1a" bindtap="{{k}}"><image class="user-avatar data-v-d36a0b1a" src="{{i}}" mode="aspectFill"></image><view class="user-details data-v-d36a0b1a"><view class="user-name data-v-d36a0b1a">{{j}} <text class="self-tag data-v-d36a0b1a">自己</text></view></view></view></view><view class="players-section data-v-d36a0b1a"><view class="section-header data-v-d36a0b1a"><text class="header-title data-v-d36a0b1a">玩家</text><text class="player-count data-v-d36a0b1a">({{l}}位)</text></view><view class="players-table data-v-d36a0b1a"><view class="table-header data-v-d36a0b1a"><view class="player-column data-v-d36a0b1a">玩家</view><view class="score-column data-v-d36a0b1a">总分</view></view><view class="table-body data-v-d36a0b1a"><view wx:for="{{m}}" wx:for-item="player" wx:key="e" class="player-row data-v-d36a0b1a"><view class="player-info data-v-d36a0b1a"><image class="data-v-d36a0b1a" src="{{player.a}}" mode="aspectFill"></image><text class="data-v-d36a0b1a">{{player.b}}</text></view><view class="score-display data-v-d36a0b1a" bindtap="{{player.d}}">{{player.c}}</view></view></view></view></view></view><view class="bottom-buttons data-v-d36a0b1a"><button class="start-btn data-v-d36a0b1a" type="primary" bindtap="{{n}}">开局计分</button><button class="settle-btn data-v-d36a0b1a" type="default" bindtap="{{o}}">结算房间</button></view></view>
<view class="singleplay data-v-d36a0b1a"><view class="top-functions data-v-d36a0b1a"><view class="function-btn data-v-d36a0b1a" bindtap="{{b}}"><image src="{{a}}" class="btn-icon data-v-d36a0b1a" mode="aspectFill"></image><text class="data-v-d36a0b1a">添加玩家</text></view><view class="function-btn data-v-d36a0b1a" bindtap="{{d}}"><image src="{{c}}" class="btn-icon data-v-d36a0b1a" mode="aspectFill"></image><text class="data-v-d36a0b1a">转让计分员</text></view><view class="switch-group data-v-d36a0b1a"><text class="data-v-d36a0b1a">语音播报</text><switch class="data-v-d36a0b1a" checked="{{e}}" bindchange="{{f}}" color="#007aff"/></view><view class="switch-group data-v-d36a0b1a"><text class="data-v-d36a0b1a">台板</text><switch class="data-v-d36a0b1a" checked="{{g}}" bindchange="{{h}}" color="#007aff"/></view></view><view class="game-record data-v-d36a0b1a"><view class="record-title data-v-d36a0b1a"> 对局记录 <text class="hint data-v-d36a0b1a">点击对局分数进行修改</text></view><view class="user-section data-v-d36a0b1a"><text class="user-hint data-v-d36a0b1a">点击自己头像编辑用户头像和昵称~</text><view class="user-info data-v-d36a0b1a" bindtap="{{k}}"><image class="user-avatar data-v-d36a0b1a" src="{{i}}" mode="aspectFill"></image><view class="user-details data-v-d36a0b1a"><view class="user-name data-v-d36a0b1a">{{j}} <text class="self-tag data-v-d36a0b1a">自己</text></view></view></view></view><view class="players-section data-v-d36a0b1a"><view class="section-header data-v-d36a0b1a"><text class="header-title data-v-d36a0b1a">玩家</text><text class="player-count data-v-d36a0b1a">({{l}}位)</text></view><view class="players-table-container vertical data-v-d36a0b1a"><view class="players-table vertical data-v-d36a0b1a"><view class="table-row header-row data-v-d36a0b1a"><view class="header-cell player-column data-v-d36a0b1a">玩家</view><view wx:for="{{m}}" wx:for-item="player" wx:key="c" class="data-cell data-v-d36a0b1a"><view class="player-info data-v-d36a0b1a"><image class="data-v-d36a0b1a" src="{{player.a}}" mode="aspectFill"></image><text class="data-v-d36a0b1a">{{player.b}}</text></view></view></view><view class="table-row data-v-d36a0b1a"><view class="header-cell score-column data-v-d36a0b1a">总分</view><view wx:for="{{n}}" wx:for-item="player" wx:key="b" class="data-cell score-display data-v-d36a0b1a">{{player.a}}</view></view><view wx:for="{{o}}" wx:for-item="round" wx:key="c" class="table-row data-v-d36a0b1a"><view class="header-cell score-column data-v-d36a0b1a">第{{round.a}}局</view><view wx:for="{{round.b}}" wx:for-item="player" wx:key="c" bindtap="{{player.b}}" class="data-cell score-display data-v-d36a0b1a">{{player.a}}</view></view></view></view></view></view><view class="bottom-buttons data-v-d36a0b1a"><button class="start-btn data-v-d36a0b1a" type="primary" bindtap="{{p}}">开局计分</button><button class="settle-btn data-v-d36a0b1a" type="default" bindtap="{{q}}">结算房间</button></view></view>

View File

@@ -133,83 +133,111 @@
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
margin-bottom: 15rpx;
}
.players-section .section-header .header-title.data-v-d36a0b1a {
font-size: 28rpx;
font-weight: bold;
color: #333;
align-items: center;
justify-content: center;
}
.players-section .section-header .player-count.data-v-d36a0b1a {
font-size: 24rpx;
color: #666;
margin-left: 10rpx;
}
/* 玩家表格容器 - 实现横向滚动 */
.players-table-container.data-v-d36a0b1a {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
border-radius: 10rpx;
border: 1rpx solid #e0e0e0;
}
/* 垂直表格容器 - 实现垂直滚动和横向滑动 */
.players-table-container.vertical.data-v-d36a0b1a {
overflow-y: auto;
overflow-x: auto;
max-height: 500rpx;
-webkit-overflow-scrolling: touch;
/* 优化移动端滚动体验 */
}
/* 玩家表格 */
.players-table.data-v-d36a0b1a {
border: 1rpx solid #e0e0e0;
border-radius: 10rpx;
overflow: hidden;
min-width: 100%;
overflow: visible;
}
.players-table .table-header.data-v-d36a0b1a {
display: flex;
flex-direction: row;
background-color: #f5f5f5;
border-bottom: 1rpx solid #e0e0e0;
}
.players-table .table-header .player-column.data-v-d36a0b1a {
flex: 2;
padding: 15rpx;
font-size: 26rpx;
font-weight: bold;
color: #333;
border-right: 1rpx solid #e0e0e0;
}
.players-table .table-header .score-column.data-v-d36a0b1a {
flex: 1;
padding: 15rpx;
font-size: 26rpx;
font-weight: bold;
color: #333;
text-align: center;
}
.players-table .table-body .player-row.data-v-d36a0b1a {
/* 垂直表格样式 */
.players-table.vertical .table-row.data-v-d36a0b1a {
display: flex;
flex-direction: row;
border-bottom: 1rpx solid #e0e0e0;
}
.players-table .table-body .player-row.data-v-d36a0b1a:last-child {
.players-table.vertical .table-row.data-v-d36a0b1a:last-child {
border-bottom: none;
}
.players-table .table-body .player-row .player-info.data-v-d36a0b1a {
flex: 2;
.players-table.vertical .header-row.data-v-d36a0b1a {
background-color: #f5f5f5;
}
.players-table.vertical .header-cell.data-v-d36a0b1a {
width: 150rpx;
flex-shrink: 0;
padding: 15rpx;
font-size: 26rpx;
font-weight: bold;
color: #333;
border-right: 1rpx solid #e0e0e0;
background-color: #f5f5f5;
display: flex;
flex-direction: row;
align-items: center;
gap: 15rpx;
justify-content: center;
}
.players-table.vertical .player-column.data-v-d36a0b1a {
justify-content: flex-start;
align-items: center;
justify-content: center;
}
.players-table.vertical .score-column.data-v-d36a0b1a {
text-align: center;
}
.players-table.vertical .data-cell.data-v-d36a0b1a {
min-width: 120rpx;
flex-shrink: 0;
padding: 15rpx;
border-right: 1rpx solid #e0e0e0;
display: flex;
align-items: center;
justify-content: center;
/* 最后一列不需要右边框 */
}
.players-table .table-body .player-row .player-info image.data-v-d36a0b1a {
.players-table.vertical .data-cell.data-v-d36a0b1a:last-child {
border-right: none;
}
.players-table.vertical .player-info.data-v-d36a0b1a {
display: flex;
flex-direction: column;
align-items: center;
gap: 8rpx;
width: 100%;
}
.players-table.vertical .player-info image.data-v-d36a0b1a {
width: 60rpx;
height: 60rpx;
border-radius: 50%;
}
.players-table .table-body .player-row .player-info text.data-v-d36a0b1a {
font-size: 26rpx;
.players-table.vertical .player-info text.data-v-d36a0b1a {
font-size: 24rpx;
color: #333;
text-align: center;
word-break: break-word;
}
.players-table .table-body .player-row .score-display.data-v-d36a0b1a {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 15rpx;
.players-table.vertical .score-display.data-v-d36a0b1a {
font-size: 28rpx;
font-weight: bold;
color: #007aff;
}
.players-table .table-body .player-row .score-display.data-v-d36a0b1a:active {
.players-table.vertical .score-display.data-v-d36a0b1a:active {
background-color: #f0f8ff;
}
/* 底部操作按钮 */

View File

@@ -1,14 +1,14 @@
{
"libVersion": "3.11.1",
"projectname": "scoring",
"setting": {
"urlCheck": true,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"skylineRenderEnable": false,
"preloadBackgroundData": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"compileHotReLoad": true
}
"libVersion": "3.11.1",
"projectname": "scoring",
"setting": {
"urlCheck": false,
"coverView": true,
"lazyloadPlaceholderEnable": false,
"skylineRenderEnable": false,
"preloadBackgroundData": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"compileHotReLoad": true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,4 +1,4 @@
"use strict";
const BASE_URL = "http://172.20.10.2:8080";
const BASE_URL = "http://10.87.64.114:8080";
exports.BASE_URL = BASE_URL;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/CommonValues.js.map

View File

@@ -2,6 +2,9 @@
const common_vendor = require("../common/vendor.js");
const utils_CommonValues = require("./CommonValues.js");
const api_login = require("../api/login.js");
function GET(url, data) {
return SIMPLE(url, data, "GET");
}
function GET_TOKEN(url, data, token) {
return SIMPLE_TOKEN(url, data, token, "GET");
}
@@ -10,19 +13,24 @@ function POST(url, data) {
}
let requestTime = 0;
async function SIMPLE(url, data, method) {
if (requestTime == 0) {
token = await api_login.loginSystem();
if (token.data) {
SIMPLE(url, data, method);
return;
let token = common_vendor.index.getStorageSync("APP_TOKEN") || "";
if (requestTime == 0 && false) {
try {
token = await api_login.loginSystem();
if (typeof token === "string") {
requestTime += 1;
}
} catch (error) {
common_vendor.index.__f__("log", "at utils/request.js:44", "登录系统失败:", error);
}
} else if (requestTime == 0) {
requestTime += 1;
} else {
var token = common_vendor.index.getStorageSync("APP_TOKEN");
}
const fullUrl = `${utils_CommonValues.BASE_URL}${url}`;
common_vendor.index.__f__("log", "at utils/request.js:51", `[网络请求] ${method} ${fullUrl}`, data);
return new Promise((resolve, reject) => {
common_vendor.index.request({
url: `${utils_CommonValues.BASE_URL}${url}`,
url: fullUrl,
method,
header: {
"Content-Type": "application/json;charset=utf-8",
@@ -31,22 +39,46 @@ async function SIMPLE(url, data, method) {
dataType: "json",
data,
success: (res) => {
if (res.data.code == "200" || res.data.statusCode == "200") {
resolve(res.data);
common_vendor.index.__f__("log", "at utils/request.js:64", `[网络响应] ${method} ${fullUrl}`, res.data);
if (res.statusCode === 200) {
resolve(res);
} else {
reject(res);
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at utils/request.js:74", `[网络错误] ${method} ${fullUrl}`, err);
let errorMsg = "网络请求失败";
if (err.errMsg && err.errMsg.includes("url not in domain list")) {
errorMsg = "请求地址未在小程序管理后台配置,请联系管理员";
{
common_vendor.index.__f__("error", "at utils/request.js:81", "\n=== 开发环境网络请求错误解决方案 ===");
common_vendor.index.__f__("error", "at utils/request.js:82", "错误原因请求的URL不在小程序合法域名列表中");
common_vendor.index.__f__("error", "at utils/request.js:83", "当前请求URL", fullUrl);
common_vendor.index.__f__("error", "at utils/request.js:84", "解决方案:");
common_vendor.index.__f__("error", "at utils/request.js:85", '1. 在微信开发者工具中,点击右上角的"详情"');
common_vendor.index.__f__("error", "at utils/request.js:86", '2. 选择"本地设置"');
common_vendor.index.__f__("error", "at utils/request.js:87", '3. 勾选"不校验合法域名、web-view业务域名、TLS 版本以及 HTTPS 证书"');
common_vendor.index.__f__("error", "at utils/request.js:88", "4. 重新编译小程序");
common_vendor.index.__f__("error", "at utils/request.js:89", "==================================\n");
}
} else if (err.errMsg && err.errMsg.includes("connect fail")) {
errorMsg = "网络连接失败,请检查网络设置";
} else if (err.errMsg && err.errMsg.includes("localhost")) {
errorMsg = "无法连接到本地服务器请检查BASE_URL配置";
}
err.userFriendlyMsg = errorMsg;
reject(err);
}
});
});
}
function SIMPLE_TOKEN(url, data, token, method) {
const fullUrl = `${utils_CommonValues.BASE_URL}${url}`;
common_vendor.index.__f__("log", "at utils/request.js:105", `[网络请求] ${method} ${fullUrl}`, data);
return new Promise((resolve, reject) => {
common_vendor.index.request({
url: `${utils_CommonValues.BASE_URL}${url}`,
url: fullUrl,
method,
header: {
"Content-Type": "application/json;charset=utf-8",
@@ -55,18 +87,28 @@ function SIMPLE_TOKEN(url, data, token, method) {
dataType: "json",
data,
success: (res) => {
if (res.data.code == "200" || res.data.statusCode == "200") {
resolve(res.data);
common_vendor.index.__f__("log", "at utils/request.js:118", `[网络响应] ${method} ${fullUrl}`, res.data);
if (res.statusCode === 200) {
resolve(res);
} else {
reject(res);
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at utils/request.js:128", `[网络错误] ${method} ${fullUrl}`, err);
let errorMsg = "网络请求失败";
if (err.errMsg && err.errMsg.includes("url not in domain list")) {
errorMsg = "请求地址未在小程序管理后台配置,请联系管理员";
} else if (err.errMsg && err.errMsg.includes("connect fail")) {
errorMsg = "网络连接失败,请检查网络设置";
}
err.userFriendlyMsg = errorMsg;
reject(err);
}
});
});
}
exports.GET = GET;
exports.GET_TOKEN = GET_TOKEN;
exports.POST = POST;
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/request.js.map