diff --git a/src/apis.js b/src/apis.js index cf4eb4d..bb40f0b 100644 --- a/src/apis.js +++ b/src/apis.js @@ -6,10 +6,10 @@ try { switch (envVersion) { case "develop": // 开发版 - BASE_URL = "https://api.shelingxingqiu.com/api/shoot"; + BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; break; case "trial": // 体验版 - BASE_URL = "https://api.shelingxingqiu.com/api/shoot"; + BASE_URL = "https://apitest.shelingxingqiu.com/api/shoot"; break; case "release": // 正式版 BASE_URL = "https://api.shelingxingqiu.com/api/shoot"; diff --git a/src/components/UserHeader.vue b/src/components/UserHeader.vue index 9d613ee..31c43f1 100644 --- a/src/components/UserHeader.vue +++ b/src/components/UserHeader.vue @@ -15,7 +15,7 @@ const props = defineProps({ default: () => {}, }, }); -const nextLvlPoints = ref(""); +const nextLvlPoints = ref(0); const containerWidth = computed(() => props.showRank ? "72%" : "calc(100% - 15px)" ); @@ -52,6 +52,7 @@ watch( }, { immediate: true, + deep: true, } ); diff --git a/src/store.js b/src/store.js index 1edb369..e346aff 100644 --- a/src/store.js +++ b/src/store.js @@ -9,6 +9,7 @@ const defaultUser = { }; const getLvlName = (score, rankList = []) => { + if (!rankList) return; let lvlName = ""; rankList.some((r, index) => { lvlName = rankList[index].name; @@ -24,6 +25,7 @@ const getLvlName = (score, rankList = []) => { }; const getLvlImage = (rankLvl, rankList = []) => { + if (!rankList) return; let lvlImage = ""; rankList.some((r, index) => { if (r.rank_id === rankLvl) { diff --git a/src/websocket.js b/src/websocket.js index 1dc00cf..492706c 100644 --- a/src/websocket.js +++ b/src/websocket.js @@ -7,7 +7,29 @@ let reconnectTimer = null; * 建立 WebSocket 连接 */ function createWebSocket(token, onMessage) { - const url = `wss://api.shelingxingqiu.com/socket?authorization=${token}`; + let url = "wss://api.shelingxingqiu.com/socket"; + try { + const accountInfo = uni.getAccountInfoSync(); + const envVersion = accountInfo.miniProgram.envVersion; + + switch (envVersion) { + case "develop": // 开发版 + url = "wss://apitest.shelingxingqiu.com/socket"; + break; + case "trial": // 体验版 + url = "wss://apitest.shelingxingqiu.com/socket"; + break; + case "release": // 正式版 + url = "wss://api.shelingxingqiu.com/socket"; + break; + default: + // 保持默认值 + break; + } + } catch (e) { + console.error("获取环境信息失败,使用默认正式环境", e); + } + url += `?authorization=${token}`; socket = uni.connectSocket({ url, success: () => {