From 3bfff8bd1e39bd75aa635db4469cf939d0e0587b Mon Sep 17 00:00:00 2001 From: lihuilin Date: Wed, 29 Oct 2025 21:23:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .hbuilderx/launch.json | 7 +- api/setting/general.js | 8 ++ api/setting/market.js | 19 +++++ api/tcpConnection.js | 92 ++++++++++---------- pages/home/home.vue | 2 +- pages/home/member.vue | 1 + pages/setting/account.vue | 29 +++++-- pages/setting/bind.vue | 11 ++- pages/setting/createPwd.vue | 26 ++++-- pages/setting/font.vue | 48 +++++++---- pages/setting/market.vue | 198 ++++++++++++++++++++++++++++++++++++-------- pages/setting/password.vue | 10 +++ pages/setting/server.vue | 48 +++++++---- pages/setting/theme.vue | 45 +++++++--- utils/http.js | 9 +- 15 files changed, 403 insertions(+), 150 deletions(-) create mode 100644 api/setting/market.js diff --git a/.hbuilderx/launch.json b/.hbuilderx/launch.json index 2a3f43d..f1dfc07 100644 --- a/.hbuilderx/launch.json +++ b/.hbuilderx/launch.json @@ -3,10 +3,11 @@ "configurations" : [ { "customPlaygroundType" : "local", - "playground" : "custom", + "playground" : "standard", "type" : "uni-app:app-android" - // "playground" : "standard", - // "type" : "uni-app:app-ios" } ] } +// "playground" : "standard", +// "type" : "uni-app:app-ios" + diff --git a/api/setting/general.js b/api/setting/general.js index d5e45d1..63b4892 100644 --- a/api/setting/general.js +++ b/api/setting/general.js @@ -9,3 +9,11 @@ export const getSetting = (data) => { data: data, }) } + +export const updateSetting = (data) => { + return http({ + method: 'POST', + url: '/api/my/updateSetting', + data: data, + }) +} diff --git a/api/setting/market.js b/api/setting/market.js new file mode 100644 index 0000000..6601f4f --- /dev/null +++ b/api/setting/market.js @@ -0,0 +1,19 @@ +import { http } from '../../utils/http' + + + +export const getMarketSetting = (data) => { + return http({ + method: 'POST', + url: '/api/my/getQuotationSetting', + data: data, + }) +} + +export const updateMarketSetting = (data) => { + return http({ + method: 'POST', + url: '/api/my/updateQuotationSetting', + data: data, + }) +} diff --git a/api/tcpConnection.js b/api/tcpConnection.js index c31188e..819051f 100644 --- a/api/tcpConnection.js +++ b/api/tcpConnection.js @@ -6,7 +6,7 @@ */ // 引用TCP插件 -const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin'); +//const TCPSocket = uni.requireNativePlugin('Aimer-TCPPlugin'); // const TCPSocket = uni.requireNativePlugin("Aimer-TCPPlugin"); // TCP连接配置 @@ -67,52 +67,52 @@ class TCPConnection { } console.log('开始建立TCP连接:', connectionConfig); - TCPSocket.connect( - connectionConfig, - result => { - /** - * status : 0 连接成功 - * status : 1 断开连接 - * receivedMsg : 服务器返回字符串(普通的字符串交互) - * receivedHexMsg : 服务器返回字节数组(单片机、智能家居等硬件数据交互) - */ - if (result.status == '0') { - // TCP连接成功 - this.channelConnections.set(connectionConfig.channel, true); - console.log(`TCP连接成功 - Channel ${connectionConfig.channel}`); - this._notifyConnectionCallbacks('connected', result, connectionConfig.channel); - } else if (result.status == '1') { - // TCP断开连接 - this.channelConnections.set(connectionConfig.channel, false); - console.log(`TCP断开连接 - Channel ${connectionConfig.channel}`); - this._notifyConnectionCallbacks('disconnected', result, connectionConfig.channel); - } + // TCPSocket.connect( + // connectionConfig, + // result => { + // /** + // * status : 0 连接成功 + // * status : 1 断开连接 + // * receivedMsg : 服务器返回字符串(普通的字符串交互) + // * receivedHexMsg : 服务器返回字节数组(单片机、智能家居等硬件数据交互) + // */ + // if (result.status == '0') { + // // TCP连接成功 + // this.channelConnections.set(connectionConfig.channel, true); + // console.log(`TCP连接成功 - Channel ${connectionConfig.channel}`); + // this._notifyConnectionCallbacks('connected', result, connectionConfig.channel); + // } else if (result.status == '1') { + // // TCP断开连接 + // this.channelConnections.set(connectionConfig.channel, false); + // console.log(`TCP断开连接 - Channel ${connectionConfig.channel}`); + // this._notifyConnectionCallbacks('disconnected', result, connectionConfig.channel); + // } - if (result.receivedMsg) { - // 服务器返回字符串 - console.log('收到字符串消息:', result.receivedMsg); - this._notifyMessageCallbacks('string', result.receivedMsg, null, connectionConfig.channel); - } + // if (result.receivedMsg) { + // // 服务器返回字符串 + // console.log('收到字符串消息:', result.receivedMsg); + // this._notifyMessageCallbacks('string', result.receivedMsg, null, connectionConfig.channel); + // } - // if (result.receivedHexMsg) { - // // 硬件服务器返回16进制数据 - // console.log('收到16进制消息:', result.receivedHexMsg); - // let msg = result.receivedHexMsg; - // let sum = msg.length / 2; - // let arr = []; - // for (let k = 0; k < sum; k++) { - // let i = msg.substring(k * 2, k * 2 + 2); - // arr.push(i); - // } - // console.log('解析后的16进制数组:', arr); - // this._notifyMessageCallbacks('hex', result.receivedHexMsg, arr); - // } + // // if (result.receivedHexMsg) { + // // // 硬件服务器返回16进制数据 + // // console.log('收到16进制消息:', result.receivedHexMsg); + // // let msg = result.receivedHexMsg; + // // let sum = msg.length / 2; + // // let arr = []; + // // for (let k = 0; k < sum; k++) { + // // let i = msg.substring(k * 2, k * 2 + 2); + // // arr.push(i); + // // } + // // console.log('解析后的16进制数组:', arr); + // // this._notifyMessageCallbacks('hex', result.receivedHexMsg, arr); + // // } - // 执行回调函数 - if (callback && typeof callback === "function") { - callback(result); - } - }); + // // 执行回调函数 + // if (callback && typeof callback === "function") { + // callback(result); + // } + // }); } /** @@ -144,7 +144,7 @@ class TCPConnection { sendConfig.charsetname = config.charsetname; } - TCPSocket.send(sendConfig); + //TCPSocket.send(sendConfig); console.log("js成功发送TCP消息:", messageStr); return true; } @@ -159,7 +159,7 @@ class TCPConnection { channel: channel }; - TCPSocket.disconnect(disconnectConfig); + //TCPSocket.disconnect(disconnectConfig); this.channelConnections.set(channel, false); console.log(`TCP连接已断开 - Channel ${channel}`, disconnectConfig); } diff --git a/pages/home/home.vue b/pages/home/home.vue index 92f54cf..80337d5 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -191,7 +191,7 @@ import footerBar from '../../components/footerBar.vue' import MarketOverview from '../../components/MarketOverview.vue' import DeepMate from '../../components/DeepMate.vue' -import tcpConnection from '../../api/tcpConnection.js' +// import tcpConnection from '../../api/tcpConnection.js' import th from '../../static/language/th' export default { diff --git a/pages/home/member.vue b/pages/home/member.vue index af72e68..5ea9e75 100644 --- a/pages/home/member.vue +++ b/pages/home/member.vue @@ -1,4 +1,5 @@ @@ -206,7 +332,7 @@ .indicator-text { font-size: 28rpx; - flex:1; + flex: 1; } .indicator-icons { diff --git a/pages/setting/password.vue b/pages/setting/password.vue index f2db2fd..d65798d 100644 --- a/pages/setting/password.vue +++ b/pages/setting/password.vue @@ -84,6 +84,7 @@ } const goToPwdNext = async () => { + if (activeTab.value === 'email') { if (!userEmail.value) { uni.showToast({ title: '请输入邮箱', @@ -91,6 +92,15 @@ const goToPwdNext = async () => { }) return } + }else{ + if (!userPhone.value) { + uni.showToast({ + title: '请输入手机号', + icon: 'none' + }) + return + } + } if (!verifyCode.value) { uni.showToast({ title: '请输入验证码', diff --git a/pages/setting/server.vue b/pages/setting/server.vue index 9524cfc..4ff2def 100644 --- a/pages/setting/server.vue +++ b/pages/setting/server.vue @@ -5,17 +5,17 @@ 自动选择 + :checked="selectedIndex === 0" @click="selectFont('auto')" /> 新加坡服务器 + :checked="selectedIndex === 1" @click="selectFont('singapore')" /> 香港服务器 + :checked="selectedIndex === 2" @click="selectFont('hongkong')" /> @@ -27,33 +27,51 @@ onMounted } from 'vue' import { - getSetting + getSetting, + updateSetting } from "@/api/setting/general" const iSMT = ref(0) const selectedIndex = ref(0) + const servertypeMap = { + 'auto': 0, + 'singapore': 1, + 'hongkong': 2 + } const getServer = async () => { try { const res = await getSetting() if (res.code === 200) { - const fontSize = res.data.fontSize - const sizeMap = { - 'auto': 0, - 'singapore': 1, - 'hongkong': 2 - } - console.log('看看服务器', res.data.fontSize) - selectedIndex.value = sizeMap[fontSize] ?? 0; + const serverSelection = res.data.serverSelection + selectedIndex.value = servertypeMap[serverSelection] ?? 0; } } catch (err) { console.error("获取服务器设置失败:", err); } } - const selectFont = (index) => { - selectedIndex.value = index - console.log('看看选中状态',selectedIndex.value) + const selectFont = async (servertype) => { + try { + selectedIndex.value = servertypeMap[servertype] + console.log('服务器类型:', servertype, ',looklook索引:', selectedIndex.value) + + const updateRes = await updateSetting({ + serverSelection: servertype + }) + if (updateRes.code === 200) { + uni.showToast({ + title: '服务器大小设置成功', + icon: 'none' + }) + } + } catch (err) { + console.error("更新服务器设置失败:", err); + uni.showToast({ + title: '设置失败,请重试', + icon: 'none' + }) + } } onMounted(() => { diff --git a/pages/setting/theme.vue b/pages/setting/theme.vue index 43573d9..1ee0658 100644 --- a/pages/setting/theme.vue +++ b/pages/setting/theme.vue @@ -5,12 +5,12 @@ + @click="updateTheme('light')" /> + @click="updateTheme('dark')" /> @@ -22,32 +22,51 @@ onMounted } from 'vue' import { - getSetting + getSetting, + updateSetting } from "@/api/setting/general" const iSMT = ref(0) const selectedIndex = ref(0) - + const themeTypeMap = { + 'light': 0, + 'dark': 1 + } + const getTheme = async () => { try { const res = await getSetting() if (res.code === 200) { const theme = res.data.theme - const sizeMap = { - 'light': 0, - 'dark': 1 - } - console.log('看看主题', res.data.theme) - selectedIndex.value = sizeMap[theme] ?? 0; + selectedIndex.value = themeTypeMap[theme] ?? 0 } } catch (err) { console.error("获取主题设置失败:", err); } } - const selectFont = (index) => { - selectedIndex.value = index - console.log('看看选中状态', selectedIndex.value) + const updateTheme = async (themeType) => { + try { + selectedIndex.value = themeTypeMap[themeType] + console.log('主题:', themeType, ',looklook索引:', selectedIndex.value) + + const updateRes = await updateSetting({ + theme: themeType + }) + if (updateRes.code === 200) { + uni.showToast({ + title: '主题设置成功', + icon: 'none' + }) + } + } catch (err) { + console.error("更新主题设置失败:", err); + uni.showToast({ + title: '设置失败,请重试', + icon: 'none' + }) + } } + onMounted(() => { // 状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; diff --git a/utils/http.js b/utils/http.js index 125a156..bf57ee7 100644 --- a/utils/http.js +++ b/utils/http.js @@ -1,8 +1,8 @@ import { useUserStore } from "../stores/modules/userInfo" import { useDeviceStore } from "../stores/modules/deviceInfo" -const baseURL = "https://dbqb.nfdxy.net/testApi" - +// const baseURL = "https://dbqb.nfdxy.net/testApi" +const baseURL = "http://192.168.40.8:9000" const httpInterceptor = { // 拦截前触发 @@ -37,13 +37,14 @@ const httpInterceptor = { 'content-type': 'application/json', 'contentType': 'application/json', 'version': uni.getSystemInfoSync().appVersion, - 'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android', + //'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android', + 'client':'android', 'deviceId': deviceInfo.deviceInfo.deviceId } //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 const memberStore = useUserStore() const token = memberStore.userInfo?.token || options.data?.token - // const token = '1b3a58424c5324e40d4bf4d085e18047' + //const token = '9cd87893b9282b6a7a6cc9b780c905db' if (token) { options.header.token = token }