diff --git a/api/deepExploration/deepExploration.js b/api/deepExploration/deepExploration.js index 800b626..be5cd8b 100644 --- a/api/deepExploration/deepExploration.js +++ b/api/deepExploration/deepExploration.js @@ -74,7 +74,24 @@ export const getModel4Second = (data) => { }) } +//不搜索时走这个 +export const getModeldefault = (data) => { + return http({ + method: 'POST', + url: '/api/coze/default', + data + }) +} + +//k线数据 +export const getData = (data) => { + return http({ + method: 'POST', + url: '/api/coze/WorkFlowData', + data + }) +} //历史记录列表 export const RecordListApi = (data) => { diff --git a/api/member.js b/api/member.js new file mode 100644 index 0000000..58dd7fc --- /dev/null +++ b/api/member.js @@ -0,0 +1,37 @@ +import util from '../common/util.js' + +/*export const getUserInfo = (data = {}) => { + return util.request( + '/api/my/userInfo', + (res) => { + console.log('用户信息请求成功:', res); + }, + {data}, + + (err) => { + console.log('用户信息请求失败:', err); + } + ); +}; +*/ + +import { + http +} from '../utils/http' + + +/** + * 用户信息获取接口 + * @param data + * @returns {Promise} + */ +export const getUserInfo = (data) => { + return http({ + method: 'POST', + url: '/api/my/userInfo', + data: data, + header:{ + token:'014de5283d2930af6481ede591afd087' + } + }) +} \ No newline at end of file diff --git a/api/setting/general.js b/api/setting/general.js new file mode 100644 index 0000000..d5e45d1 --- /dev/null +++ b/api/setting/general.js @@ -0,0 +1,11 @@ +import { http } from '../../utils/http' + + + +export const getSetting = (data) => { + return http({ + method: 'POST', + url: '/api/my/getSetting', + data: data, + }) +} diff --git a/api/setting/nextPwd.js b/api/setting/nextPwd.js new file mode 100644 index 0000000..3508c99 --- /dev/null +++ b/api/setting/nextPwd.js @@ -0,0 +1,16 @@ +import {http} from '../../utils/http' + +/** + * 修改密码 + * @param data + * @returns {*} + */ +export const updatePassword = (data) => { + return http({ + method: 'POST', + url: '/api/my/updatePassword', + data: + data + , + }) +} diff --git a/api/setting/password.js b/api/setting/password.js new file mode 100644 index 0000000..e175656 --- /dev/null +++ b/api/setting/password.js @@ -0,0 +1,45 @@ +import { + http +} from '../../utils/http' + +/** + * 验证码发送 + * @param data + * @returns {*} + */ +export const sendEmail = (data) => { + return http({ + method: 'POST', + url: '/UserLogin/sendEmail', + data: data, + }) +} + +/** + * 验证码验证 + * @param data + * @returns {*} + */ +export const validateCode = (data) => { + return http({ + method: 'POST', + url: '/api/my/validateCode', + data: data, + }) +} + +export const sendPhone = (data) => { + return http({ + method: 'POST', + url: '/UserLogin/sendPhone', + data: data, + }) +} + +export const changeBind = (data) => { + return http({ + method: 'POST', + url: '/api/my/bindEmailOrPhone', + data: data, + }) +} \ No newline at end of file diff --git a/api/start/login.js b/api/start/login.js index aecf0cf..699a30f 100644 --- a/api/start/login.js +++ b/api/start/login.js @@ -67,6 +67,36 @@ export const registerApi = (data) => { }) } + + +/** + * 忘记密码校验验证码 + */ + +export const verifyCodeApi = (data) => { + return http({ + method: 'POST', + url: '/UserLogin/verifyCode', + data: data, + }) +} + + + +/** + * 忘记密码输入新的密码 + */ + +export const forgetApi = (data) => { + return http({ + method: 'POST', + url: '/UserLogin/forget', + data: data, + }) +} + + + /** * 修改密码 * diff --git a/components/deepExploration_header.vue b/components/deepExploration_header.vue index daae53c..cddab00 100644 --- a/components/deepExploration_header.vue +++ b/components/deepExploration_header.vue @@ -72,6 +72,7 @@ {{ item.stockName }} ({{ item.stockCode }}) + ({{ item.stockCode }}) {{ formatTimeForHistory(item.createdTime) @@ -98,6 +99,7 @@ const props = defineProps({ }, }); const showHistoryDrawer = ref(false); +const modelType = ref(''); const drawerOffsetY = ref(0); // const handleHistory = () => { // showHistoryDrawer.value = true; diff --git a/components/login-prompt.vue b/components/login-prompt.vue index 0b9af30..23dd653 100644 --- a/components/login-prompt.vue +++ b/components/login-prompt.vue @@ -15,20 +15,40 @@ \ No newline at end of file diff --git a/pages/marketSituation/chartExample.vue b/pages/marketSituation/chartExample.vue deleted file mode 100644 index 47ab2a3..0000000 --- a/pages/marketSituation/chartExample.vue +++ /dev/null @@ -1,655 +0,0 @@ - - diff --git a/pages/marketSituation/marketCondition.vue b/pages/marketSituation/marketCondition.vue index e1f6696..b244d26 100644 --- a/pages/marketSituation/marketCondition.vue +++ b/pages/marketSituation/marketCondition.vue @@ -145,7 +145,7 @@ - + - + - - {{ item }} - K线图开发中... @@ -240,21 +237,6 @@ import tcpConnection, { TCPConnection, TCP_CONFIG } from "@/api/tcpConnection.js // TCP相关响应式变量 const tcpConnected = ref(false); -const tcpMessages = ref([]); -const tcpStockData = ref({ - count: 0, - data: {}, - stock_count: 0, - timestamp: "", - type: "", -}); -const currentStockInfo = ref({ - stock_name: "未知股票", - current_price: "0.00", - change: "0.00%", - change_value: 0, - change_percent: 0, -}); const connectionListener = ref(null); const messageListener = ref(null); @@ -465,11 +447,54 @@ const confirmStockColor = (price, lastDayStockClosePrice) => { // 股票K线类型方法 const selectKlineTab = (tabId) => { klineTab.value = tabId; - - if (klineTab.value == 1) { - sendTcpMessage("init_real_time"); + if (klineTab.value) { + sendTcpMessage("stop_real_time"); + } + switch (klineTab.value) { + case 1: + sendTcpMessage("init_real_time"); + break; + case 2: + sendTcpMessage("daily_data"); + break; + case 3: + sendTcpMessage("weekly_data"); + break; + case 4: + sendTcpMessage("monthly_data"); + break; + case 5: + sendTcpMessage("daily_one_minutes_data"); + break; + case 6: + sendTcpMessage("daily_five_minutes_data"); + break; + case 7: + sendTcpMessage("daily_fifteen_minutes_data"); + break; + case 8: + sendTcpMessage("daily_thirty_minutes_data"); + break; + case 9: + sendTcpMessage("daily_sixty_minutes_data"); + break; + case 10: + uni.showToast({ + title: "暂无季K数据", + icon: "none", + duration: 2000, + }); + break; + case 11: + uni.showToast({ + title: "暂无年K数据", + icon: "none", + duration: 2000, + }); + break; + default: + break; } - initCanvas(); // startAddDataTimer(); }; @@ -938,6 +963,7 @@ const drawChart = () => { return; } const data = klineTab.value == 1 ? timeData.value : klineData.value; + console.log("data", data); chartRange.value = []; // 清除画布 // HCharts.setCanvasColor(ctx.value, width, height, CANVAS_BACKGROUND_COLOR); @@ -1246,6 +1272,7 @@ const touchMove = (e) => { } } } else { + return; if (klineTab.value === 2) { // if(currentY) if (currentX < touchState.startX) { @@ -1413,10 +1440,6 @@ const initTcpListeners = () => { timestamp: new Date().toLocaleTimeString(), direction: "received", }; - console.log("0000"); - tcpMessages.value.push(messageObj); - // console.log('收到TCP消息:', messageObj) - console.log("home开始调用parseStockData", messageObj); // 解析股票数据 parseStockData(message); @@ -1469,46 +1492,62 @@ const sendTcpMessage = (command) => { command: "stock_list", }; break; + // 日线数据 case "daily_data": messageData = { command: "daily_data", stock_code: "GBPAUD.FXCM", - start_date: "20251001", - end_date: "20251023", + start_date: "20250801", + end_date: "20251029", }; break; + // 周线数据 case "weekly_data": messageData = { command: "weekly_data", stock_code: "000001.SZ", - start_date: "20251001", - end_date: "20251023", + start_date: "2024912", + end_date: "20251029", }; break; + // 周线数据 + case "monthly_data": + messageData = { + command: "monthly_data", + stock_code: "000001.SZ", + start_date: "20201130", + end_date: "20251029", + }; + break; + // 1分钟线数据 case "daily_one_minutes_data": messageData = { command: "daily_one_minutes_data", stock_code: "000001.SZ", }; break; + // 5分钟线数据 case "daily_five_minutes_data": messageData = { command: "daily_five_minutes_data", stock_code: "000001.SZ", }; break; + // 15分钟线数据 case "daily_fifteen_minutes_data": messageData = { command: "daily_fifteen_minutes_data", stock_code: "000001.SZ", }; break; + // 30分钟线数据 case "daily_thirty_minutes_data": messageData = { command: "daily_thirty_minutes_data", stock_code: "000001.SZ", }; break; + // 60分钟线数据 case "daily_sixty_minutes_data": messageData = { command: "daily_sixty_minutes_data", @@ -1531,7 +1570,7 @@ const sendTcpMessage = (command) => { uni.showToast({ title: "命令不存在", icon: "none", - duration: 1500, + duration: 1000, }); return; } else { @@ -1543,7 +1582,7 @@ const sendTcpMessage = (command) => { uni.showToast({ title: "消息发送成功", icon: "success", - duration: 1500, + duration: 1000, }); } } catch (error) { @@ -1551,34 +1590,102 @@ const sendTcpMessage = (command) => { uni.showToast({ title: "消息发送失败", icon: "none", - duration: 1500, + duration: 1000, }); } } }; -// 清空消息记录 -const clearTcpMessages = () => { - tcpMessages.value = []; - uni.showToast({ - title: "消息记录已清空", - icon: "success", - duration: 1500, - }); -}; - // 获取TCP连接状态 const getTcpStatus = () => { const status = tcpConnection.getConnectionStatus(); uni.showModal({ title: "TCP连接状态", - content: `当前状态: ${status ? "已连接" : "未连接"}\n消息数量: ${tcpMessages.value.length}`, + content: `当前状态: ${status ? "已连接" : "未连接"}`, showCancel: false, }); }; -let isMorePacket = false; +let isMorePacket = { + init_real_time: false, + daily_data: false, + weekly_data: false, + monthly_data: false, + daily_one_minutes_data: false, + daily_five_minutes_data: false, + daily_fifteen_minutes_data: false, + daily_thirty_minutes_data: false, + daily_sixty_minutes_data: false, +}; let receivedMessage; +const findJsonPacket = (message, command) => { + let jsonStartIndex = 0; + let jsonEndIndex = message.indexOf(command); + let jsonStartCount = 0; + let jsonEndCount = 0; + + for (let i = 0; i < message.length - 1; ++i) { + if (message[i] == "{") { + jsonStartCount++; + if (jsonStartCount == 2) { + jsonStartIndex = i; + break; + } + } + } + for (let i = message.indexOf(command); i >= 0; --i) { + if (message[i] == "}" || i == jsonStartIndex) { + jsonEndCount++; + if (jsonEndCount == 1) { + jsonEndIndex = i; + break; + } + } + } + + // 检查JSON字符串是否有效 + if (jsonStartIndex >= jsonEndIndex) { + return { error: true }; + } + + return { json: JSON.parse(message.substring(jsonStartIndex, jsonEndIndex + 1)) }; +}; + +// 根据timeData中最后一个时间生成下一个时间 +const generateNextTime = () => { + if (timeData.value.length === 0) { + return "09:30"; // 如果没有数据,返回开盘时间 + } + + const lastTime = timeData.value[timeData.value.length - 1].time; + if (!lastTime) { + return "09:30"; + } + + // 解析时间字符串,格式为 "HH:MM" + const [hours, minutes] = lastTime.split(":").map(Number); + + // 计算下一分钟 + let nextMinutes = minutes + 1; + let nextHours = hours; + + // 处理分钟进位 + if (nextMinutes >= 60) { + nextMinutes = 0; + nextHours += 1; + } + + // 处理小时进位(24小时制) + if (nextHours >= 24) { + nextHours = 0; + } + + // 格式化为 "HH:MM" 格式 + const formattedHours = nextHours.toString().padStart(2, "0"); + const formattedMinutes = nextMinutes.toString().padStart(2, "0"); + + return `${formattedHours}:${formattedMinutes}`; +}; // 解析TCP股票数据 const parseStockData = (message) => { try { @@ -1592,105 +1699,390 @@ const parseStockData = (message) => { console.log("服务器命令列表,不予处理"); return; } - if ((typeof message === "string" && message.includes("init_real_data_start")) || isMorePacket) { + if (message.includes("real_time")) { + let startIndex = 0; + let endIndex = message.length; + for (let i = 0; i < message.length - 1; ++i) { + if (message[i] == "{") { + startIndex = i; + break; + } + } + for (let i = message.length - 1; i >= 0; --i) { + if (message[i] == "}") { + endIndex = i; + break; + } + } + parsedMessage = JSON.parse(message.substring(startIndex, endIndex + 1)); + console.log("实时数据解析", parsedMessage); + // 处理实时数据 + timeData.value.push({ + time: generateNextTime(), + price: parsedMessage.current_price, + volume: parsedMessage.volume, + amount: parsedMessage.amount, + }); + // 实时更新股票信息 + stockInformation.value.currentPrice = parsedMessage.current_price; + stockInformation.value.openPrice = parsedMessage.open_price; + stockInformation.value.closePrice = parsedMessage.close_price; + stockInformation.value.highPrice = parsedMessage.high_price; + stockInformation.value.lowPrice = parsedMessage.low_price; + stockInformation.value.volume = parsedMessage.volume; + stockInformation.value.amount = parsedMessage.amount; + stockInformation.value.turnoverRatio = parsedMessage.turnover_ratio; + stockInformation.value.marketValue = parsedMessage.total_market_value; + stockInformation.value.currentValue = stockInformation.value.currentPrice - stockInformation.value.lastDayStockClosePrice; + stockInformation.value.currentRatio = ((stockInformation.value.currentPrice - stockInformation.value.lastDayStockClosePrice) / stockInformation.value.lastDayStockClosePrice) * 100; + console.log("重绘画面"); + drawChart(); + if (timeData.value.length >= 240) { + sendTcpMessage("stop_real_time"); + } + return; + } else if ((typeof message === "string" && message.includes("init_real_data_start")) || isMorePacket.init_real_time) { if (typeof message === "string" && message.includes("init_real_data_start")) { console.log("开始接受分包数据"); receivedMessage = ""; } else { console.log("接收分包数据过程中"); } - isMorePacket = true; + isMorePacket.init_real_time = true; receivedMessage += message; // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 if (receivedMessage.includes("init_real_data_complete")) { console.log("接受分包数据结束"); - isMorePacket = false; + isMorePacket.init_real_time = false; + + console.log("展示数据", receivedMessage); + + const result = findJsonPacket(receivedMessage, "init_real_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_data") { + timeData.value = parsedMessage.data; + stockInformation.value.lastDayStockClosePrice = parsedMessage.pre_close; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + sendTcpMessage("stop_real_time"); + sendTcpMessage("real_time"); + } + } + } + } else if ((typeof message === "string" && message.includes("daily_data_start")) || isMorePacket.daily_data) { + if (typeof message === "string" && message.includes("daily_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.daily_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_data = false; + + console.log("展示数据", receivedMessage); + + const result = findJsonPacket(receivedMessage, "daily_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.ask_open, + close: item.ask_close, + high: item.ask_high, + low: item.ask_low, + volume: item.tick_qty, + date: item.trade_date ? `${item.trade_date.slice(0, 4)}-${item.trade_date.slice(4, 6)}-${item.trade_date.slice(6, 8)}` : item.trade_date, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + } + } + } + } else if ((typeof message === "string" && message.includes("weekly_data_start")) || isMorePacket.weekly_data) { + if (typeof message === "string" && message.includes("weekly_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.weekly_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("weekly_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.weekly_data = false; console.log("展示数据", receivedMessage); - // 获取JSON字符串的开头和结尾的坐标 - let jsonStartIndex = 0; - let jsonEndIndex = receivedMessage.indexOf("init_real_data_complete"); - let jsonStartCount = 0; - let jsonEndCount = 0; - for (let i = 0; i < receivedMessage.length - 1; ++i) { - if (receivedMessage[i] == "{") { - jsonStartCount++; - if (jsonStartCount == 2) { - jsonStartIndex = i; - break; - } + + const result = findJsonPacket(receivedMessage, "weekly_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "weekly_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.bid_open, + close: item.bid_close, + high: item.bid_high, + low: item.bid_low, + volume: item.vol, + amount: item.amount, + date: item.trade_date ? `${item.trade_date.slice(0, 4)}-${item.trade_date.slice(4, 6)}-${item.trade_date.slice(6, 8)}` : item.trade_date, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); } } + } + } else if ((typeof message === "string" && message.includes("monthly_data_start")) || isMorePacket.monthly_data) { + if (typeof message === "string" && message.includes("monthly_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.monthly_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("monthly_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.monthly_data = false; + + console.log("展示数据", receivedMessage); - for (let i = receivedMessage.indexOf("init_real_data_complete"); i >= 0; --i) { - if (receivedMessage[i] == "}" || i == jsonStartIndex) { - jsonEndCount++; - if (jsonEndCount == 1) { - jsonEndIndex = i; - break; - } + const result = findJsonPacket(receivedMessage, "monthly_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "monthly_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.bid_open, + close: item.bid_close, + high: item.bid_high, + low: item.bid_low, + volume: item.vol, + amount: item.amount, + date: item.trade_date ? `${item.trade_date.slice(0, 4)}-${item.trade_date.slice(4, 6)}-${item.trade_date.slice(6, 8)}` : item.trade_date, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); } } - // 检查JSON字符串是否有效 - if (jsonStartIndex >= jsonEndIndex) { - throw new Error("JSON字符串格式错误"); + } + } else if ((typeof message === "string" && message.includes("daily_one_minutes_data_start")) || isMorePacket.daily_one_minutes_data) { + if (typeof message === "string" && message.includes("daily_one_minutes_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.daily_one_minutes_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_one_minutes_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_one_minutes_data = false; + + console.log("展示数据", receivedMessage); + + const result = findJsonPacket(receivedMessage, "daily_one_minutes_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_one_minutes_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.open, + close: item.close, + high: Math.max(item.low, item.high), + low: Math.min(item.low, item.high), + volume: item.volume, + amount: item.amount, + date: item.timestamp, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + } } + } + } else if ((typeof message === "string" && message.includes("daily_five_minutes_data_start")) || isMorePacket.daily_five_minutes_data) { + if (typeof message === "string" && message.includes("daily_five_minutes_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.daily_five_minutes_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_five_minutes_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_five_minutes_data = false; + + console.log("展示数据", receivedMessage); - console.log("检测到JSON字符串,开始解析"); - parsedMessage = JSON.parse(receivedMessage.substring(jsonStartIndex, jsonEndIndex + 1)); - console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); - if (parsedMessage.type === "daily_data") { - timeData.value = parsedMessage.data; - stockInformation.value.lastDayStockClosePrice = parsedMessage.pre_close; - console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); - drawChart(); + const result = findJsonPacket(receivedMessage, "daily_five_minutes_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_five_minutes_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.open, + close: item.close, + high: Math.max(item.low, item.high), + low: Math.min(item.low, item.high), + volume: item.volume, + amount: item.amount, + date: item.timestamp, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + } } } - // 通过了JSON解析判断,说明返回的数据是需要的正确数据,进行股票实时数据检查 - console.log("开始处理解析后的数据"); - - // 检查是否是股票数据(支持batch_data_chunk和batch_realtime_data两种类型) - if ((parsedMessage.type === "batch_data_chunk" || parsedMessage.type === "batch_realtime_data") && parsedMessage.data) { - console.log("开始更新TCP股票数据存储"); - // 更新TCP股票数据存储 - tcpStockData.value = { - count: parsedMessage.count || 0, - data: parsedMessage.data || {}, - stock_count: parsedMessage.stock_count || 0, - timestamp: parsedMessage.timestamp || "", - type: parsedMessage.type || "", - }; + } else if ((typeof message === "string" && message.includes("daily_fifteen_minutes_data_start")) || isMorePacket.daily_fifteen_minutes_data) { + if (typeof message === "string" && message.includes("daily_fifteen_minutes_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.daily_fifteen_minutes_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_fifteen_minutes_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_fifteen_minutes_data = false; + + console.log("展示数据", receivedMessage); - // 获取第一个股票的数据用于显示 - const stockCodes = Object.keys(parsedMessage.data); - if (stockCodes.length > 0) { - const firstStockCode = stockCodes[0]; - - // 检查数据结构 - if (parsedMessage.data[firstStockCode] && Array.isArray(parsedMessage.data[firstStockCode]) && parsedMessage.data[firstStockCode].length > 0) { - const stockData = parsedMessage.data[firstStockCode][0]; // 取第一条数据 - - if (stockData && stockData.current_price !== undefined && stockData.pre_close !== undefined) { - // 计算涨跌幅 - const changeValue = stockData.current_price - stockData.pre_close; - const changePercent = ((changeValue / stockData.pre_close) * 100).toFixed(2); - const changeSign = changeValue >= 0 ? "+" : ""; - - // 更新当前显示的股票信息 - currentStockInfo.value = { - stock_name: stockData.stock_name || "未知股票", - current_price: stockData.current_price ? stockData.current_price.toFixed(2) : "0.00", - change: `${changeSign}${changePercent}%`, - change_value: changeValue, - change_percent: parseFloat(changePercent), - }; - - console.log("股票数据更新成功:", currentStockInfo.value); - } + const result = findJsonPacket(receivedMessage, "daily_fifteen_minutes_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_fifteen_minutes_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.open, + close: item.close, + high: Math.max(item.low, item.high), + low: Math.min(item.low, item.high), + volume: item.volume, + amount: item.amount, + date: item.timestamp, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); } } + } + } else if ((typeof message === "string" && message.includes("daily_thirty_minutes_data_start")) || isMorePacket.daily_thirty_minutes_data) { + if (typeof message === "string" && message.includes("daily_thirty_minutes_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; } else { - console.log("不是batch_data_chunk或batch_realtime_data类型的消息,跳过处理"); + console.log("接收分包数据过程中"); + } + isMorePacket.daily_thirty_minutes_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_thirty_minutes_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_thirty_minutes_data = false; + + console.log("展示数据", receivedMessage); + + const result = findJsonPacket(receivedMessage, "daily_thirty_minutes_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_thirty_minutes_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.open, + close: item.close, + high: Math.max(item.low, item.high), + low: Math.min(item.low, item.high), + volume: item.volume, + amount: item.amount, + date: item.timestamp, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + } + } + } + } else if ((typeof message === "string" && message.includes("daily_sixty_minutes_data_start")) || isMorePacket.daily_sixty_minutes_data) { + if (typeof message === "string" && message.includes("daily_sixty_minutes_data_start")) { + console.log("开始接受分包数据"); + receivedMessage = ""; + } else { + console.log("接收分包数据过程中"); + } + isMorePacket.daily_sixty_minutes_data = true; + receivedMessage += message; + // 如果当前消息包含},说明收到JSON字符串结尾,结束接收,开始解析 + if (receivedMessage.includes("daily_sixty_minutes_data_complete")) { + console.log("接受分包数据结束"); + isMorePacket.daily_sixty_minutes_data = false; + + console.log("展示数据", receivedMessage); + + const result = findJsonPacket(receivedMessage, "daily_sixty_minutes_data_complete"); + if (result.error) { + throw new Error("解析JSON字符串失败"); + } else { + parsedMessage = result.json; + console.log("JSON解析成功,解析后类型:", typeof parsedMessage, parsedMessage); + if (parsedMessage.type === "daily_sixty_minutes_data") { + klineData.value = parsedMessage.data.map((item) => ({ + open: item.open, + close: item.close, + high: Math.max(item.low, item.high), + low: Math.min(item.low, item.high), + volume: item.volume, + amount: item.amount, + date: item.timestamp, + })); + stockInformation.value.lastDayStockClosePrice = klineData.value[klineData.value.length - 2].close; + touchState.offset = canvasWidth.value / klineData.value.length / 2; + console.log("lastDayStockClosePrice", stockInformation.value.lastDayStockClosePrice); + drawChart(); + } + } } } else { // 没有通过JSON解析判断,说明不是需要的数据 @@ -1789,7 +2181,8 @@ onLoad((options) => { // 保存定时器,用于页面卸载时清理 onUnmounted(() => { - // disconnect(); + removeTcpListeners(); + disconnect(); if (timer) { console.log("卸载定时器"); clearInterval(timer); @@ -1829,7 +2222,9 @@ onMounted(async () => { console.warn("没有时间数据,跳过股票信息计算"); } await nextTick(); - initCanvas(); + setTimeout(() => { + initCanvas(); + }, 100); console.log("所有初始化步骤完成"); } catch (error) { console.error("初始化过程中出现错误:", error); diff --git a/pages/marketSituation/marketOverview.vue b/pages/marketSituation/marketOverview.vue index ad25c7b..b9da06d 100644 --- a/pages/marketSituation/marketOverview.vue +++ b/pages/marketSituation/marketOverview.vue @@ -5,7 +5,6 @@ - @@ -52,13 +51,6 @@ const isWarnTextOverflow = ref(false); // warn文字是否溢出 const pageIndex = ref(0); const scrollToView = ref(""); -// 跳转图表示例页面 -const goToChartExample = () => { - uni.navigateTo({ - url: "/pages/marketSituation/chartExample", - }); -}; - // 计算属性:精准计算content区域的top值 const contentTopPosition = computed(() => { const statusBarHeight = iSMT.value || 0; @@ -650,8 +642,7 @@ watch(headerHeight, (newHeight) => { margin: 0; box-sizing: border-box; width: 100%; - padding: 30rpx 20rpx; - gap: 20rpx; + padding: 30rpx 0; } .card_item { @@ -665,7 +656,7 @@ watch(headerHeight, (newHeight) => { @media (max-width: 600rpx) { .cards_grid { grid-template-columns: repeat(2, 1fr); - padding: 30rpx 20rpx; + padding: 30rpx 0; } } @@ -673,7 +664,7 @@ watch(headerHeight, (newHeight) => { @media (max-width: 400rpx) { .cards_grid { grid-template-columns: 1fr; - padding: 30rpx 20rpx; + padding: 30rpx 0; } } diff --git a/pages/setting/account.vue b/pages/setting/account.vue index d03f1d1..fd64eed 100644 --- a/pages/setting/account.vue +++ b/pages/setting/account.vue @@ -9,41 +9,37 @@ 头像 - + 昵称 - DeepChart - + {{userInfoRes.dcname}} + ID - {{ jwcode }} - - - - - 密码 - - qwertyuiop - + {{ userInfoRes.dccode }} - 修改密码 - + + + + 注销账号 - + 绑定账号 - + @@ -73,8 +69,12 @@ } from 'vue' import {useUserStore} from "../../stores/modules/userInfo" + import { + getUserInfo + } from "@/api/member"; const iSMT = ref(0) - const jwcode = ref('90047681') + // const dccode = ref('') + const userInfoRes = ref({}) const showLogout = ref(false) const userStore = useUserStore() @@ -86,20 +86,30 @@ title: '退出登录成功', icon: 'none', }) - } - - const goToBind = () =>{ + uni.navigateTo({ - url:'../setting/bind' + url: '/pages/start/login/login' }) } - - const goToPassword = () =>{ + + const goToBind = () => { uni.navigateTo({ - url:'../setting/password' + url: '../setting/bind' }) } + const goToPassword = () => { + if (userInfoRes.value.hasPwd === 0) { + uni.navigateTo({ + url: '../setting/createPwd' + }) + } else { + uni.navigateTo({ + url: '../setting/password' + }) + } + } + onMounted(() => { iSMT.value = uni.getSystemInfoSync().statusBarHeight; }) @@ -107,7 +117,7 @@ \ No newline at end of file diff --git a/pages/setting/email.vue b/pages/setting/email.vue index b3016f6..cc39b5b 100644 --- a/pages/setting/email.vue +++ b/pages/setting/email.vue @@ -15,11 +15,10 @@ - +86 - + - @@ -35,7 +34,7 @@ - + @@ -45,23 +44,67 @@ ref, onMounted } from 'vue' + import { + getUserInfo + } from "@/api/member" + import { + sendEmail, + changeBind + } from "@/api/setting/password" const iSMT = ref(0) - const email = ref('analsak@16.com') + const email = ref('') const gettingCode = ref(false) const time = ref(60) + const userEmail = ref('') + + const userInfoPromise = getUserInfo() + userInfoPromise.then(res => { + if (res.code === 200) { + console.log('个人信息', res.data) + email.value = res.data.email + } else { + uni.showToast({ + title: '用户信息请求失败', + icon: 'none', + }) + } + }) - const getVerification = () => { + const changeAccount = () => { + const res = changeBind({ + verificateType: 0, + account: userEmail.value + }) + if(res.code === 200){ + uni.showToast({ + title: '绑定成功', + icon: 'none', + }) + }else { + uni.showToast({ + title: '用户绑定失败', + icon: 'none', + }) + } + } + + const getCode = () => { if (gettingCode.value) return gettingCode.value = true - time.value = 60 + time.value = 2 + const timer = setInterval(() => { time.value-- if (time.value <= 0) { clearInterval(timer) gettingCode.value = false + time.value = 2 } }, 1000) + sendEmail({ + email: userEmail.value + }) } onMounted(() => { @@ -131,7 +174,7 @@ .change-btn { height: 85rpx; width: 610rpx; - padding:0 20rpx; + padding: 0 20rpx; background-color: black; color: white; border-radius: 40rpx; diff --git a/pages/setting/font.vue b/pages/setting/font.vue index 357739f..cd3efaf 100644 --- a/pages/setting/font.vue +++ b/pages/setting/font.vue @@ -4,18 +4,18 @@ 标准 - + 中号 - + 大号 - + @@ -26,17 +26,39 @@ ref, onMounted } from 'vue' + import { + getSetting + } from "@/api/setting/general" const iSMT = ref(0) const selectedIndex = ref(0) + const getFont = async () => { + try { + const res = await getSetting() + if (res.code === 200) { + const fontSize = res.data.fontSize + const sizeMap = { + small: 0, + medium: 1, + large: 2 + } + console.log('看看字体', res.data.fontSize) + selectedIndex.value = sizeMap[fontSize] ?? 0; + } + } catch (err) { + console.error("获取字体设置失败:", err); + } + } + const selectFont = (index) => { selectedIndex.value = index - console.log('看看选中状态',selectedIndex.value) + console.log('看看选中状态', selectedIndex.value) } onMounted(() => { // 状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; console.log('看看高度', iSMT.value) + getFont() }) @@ -53,7 +75,7 @@ display: flex; align-items: center; margin: 0 40rpx; - padding:0 10rpx; + padding: 0 10rpx; border-bottom: 1rpx solid #eee; } diff --git a/pages/setting/general.vue b/pages/setting/general.vue index cbf21c0..d60d59d 100644 --- a/pages/setting/general.vue +++ b/pages/setting/general.vue @@ -1,165 +1,186 @@ \ No newline at end of file diff --git a/pages/setting/introduce.vue b/pages/setting/introduce.vue index ff98778..6a5d07a 100644 --- a/pages/setting/introduce.vue +++ b/pages/setting/introduce.vue @@ -13,7 +13,7 @@ 的品牌标签(DeepChart=全球最懂机构行为的AI),主打"深度解读机构行为"的APP。 2.产品介绍 - DeepChart是一款以"Al智能体”为决策核心的智能投资分析平台, + DeepChart是一款以"Al智能体"为决策核心的智能投资分析平台, 专注于深度研究机构行为,专为全球散户投资者量身打造。它重新定义了人与投资工具之间的关系, 是一个真正懂投资、懂市场、更懂用户的AI投资伙伴。 diff --git a/pages/setting/market.vue b/pages/setting/market.vue index f25dcf7..170b3cb 100644 --- a/pages/setting/market.vue +++ b/pages/setting/market.vue @@ -206,6 +206,7 @@ .indicator-text { font-size: 28rpx; + flex:1; } .indicator-icons { diff --git a/pages/setting/message.vue b/pages/setting/message.vue index b40720b..e600648 100644 --- a/pages/setting/message.vue +++ b/pages/setting/message.vue @@ -3,10 +3,10 @@ - 语言 + 消息推送 通知已开启 通知未开启 - + @@ -51,12 +51,11 @@ } .message { - margin-left: 60%; font-size: 14px; color: rgb(203, 203, 203); } - - .arrow { - margin-left: auto; + + .text{ + flex:1; } \ No newline at end of file diff --git a/pages/setting/nextPwd.vue b/pages/setting/nextPwd.vue index e55d771..7d410d5 100644 --- a/pages/setting/nextPwd.vue +++ b/pages/setting/nextPwd.vue @@ -1,144 +1,175 @@ \ No newline at end of file diff --git a/pages/setting/password.vue b/pages/setting/password.vue index fec980a..f2db2fd 100644 --- a/pages/setting/password.vue +++ b/pages/setting/password.vue @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -41,34 +41,107 @@ ref, onMounted } from 'vue' + import { + sendEmail, + validateCode, + sendPhone + } from "@/api/setting/password"; const iSMT = ref(0) const activeTab = ref('email') const gettingCode = ref(false) const time = ref(60) + const userEmail = ref('') + const userPhone = ref('') + const verifyCode = ref('') + + const getCode = () => { if (gettingCode.value) return gettingCode.value = true - time.value = 60 + time.value = 2 const timer = setInterval(() => { time.value-- if (time.value <= 0) { clearInterval(timer) gettingCode.value = false - time.value = 60 + time.value = 2 } }, 1000) + if (activeTab.value === 'email') { + sendEmail({ + email: userEmail.value + }) + } else { + sendPhone({ + phone: userPhone.value + }) + } + } - - const goToPwdNext = () =>{ - uni.navigateTo({ - url:'../setting/nextPwd' - }) + +const goToPwdNext = async () => { + if (!userEmail.value) { + uni.showToast({ + title: '请输入邮箱', + icon: 'none' + }) + return + } + if (!verifyCode.value) { + uni.showToast({ + title: '请输入验证码', + icon: 'none' + }) + return + } + + try { + let param; + if (activeTab.value === 'email') { + param = { + loginType: 'EMAIL', + account: userEmail.value, + verifyCode: verifyCode.value + } + } else { + param = { + loginType: 'PHONE', + account: userPhone.value, + verifyCode: verifyCode.value + } + } + const res = await validateCode(param) + console.log('看看参数', param) + console.log('看看结果', res) + // 如果返回成功 + if (res.code === 200) { + uni.showToast({ + title: '验证成功', + icon: 'success' + }) + uni.navigateTo({ + url: '../setting/nextPwd' + }) + } else { + uni.showToast({ + title: res.msg || '验证失败', + icon: 'none' + }) + } + } catch (err) { + console.error(err) + uni.showToast({ + title: '请求出错', + icon: 'none' + }) + } } + onMounted(() => { // 获取状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; @@ -105,7 +178,8 @@ transform: translateX(-50%); width: 40rpx; height: 6rpx; - background-color: #000;/* ????? */ + background-color: #000; + /* ????? */ } .switch-tab { @@ -149,9 +223,9 @@ background-color: #ccc; color: #999; } - - .btn-area{ - height:8vh; + + .btn-area { + height: 8vh; background-color: white; padding-top: 120rpx; } diff --git a/pages/setting/phone.vue b/pages/setting/phone.vue index c33bddb..a74c916 100644 --- a/pages/setting/phone.vue +++ b/pages/setting/phone.vue @@ -11,15 +11,14 @@ 已绑手机号:{{ phone }} - +86 - + - @@ -35,7 +34,7 @@ - + @@ -45,12 +44,34 @@ ref, onMounted } from 'vue' + import { + sendPhone, + changeBind + } from "@/api/setting/password" + import { + getUserInfo + } from "@/api/member" + const iSMT = ref(0) - const phone = ref('15105421566') + const phone = ref('') const gettingCode = ref(false) const time = ref(60) + const userPhone = ref('') + + const userInfoPromise = getUserInfo() + userInfoPromise.then(res => { + if (res.code === 200) { + console.log('个人信息', res.data) + phone.value = res.data.phone + } else { + uni.showToast({ + title: '用户信息请求失败', + icon: 'none', + }) + } + }) - const getVerification = () => { + const getCode = () => { if (gettingCode.value) return gettingCode.value = true @@ -63,6 +84,27 @@ gettingCode.value = false } }, 1000) + sendPhone({ + phone: userPhone.value + }) + } + + const changeAccount = () => { + const res = changeBind({ + verificateType: 1, + account: userPhone.value + }) + if(res.code === 200){ + uni.showToast({ + title: '绑定成功', + icon: 'none', + }) + }else { + uni.showToast({ + title: '用户绑定失败', + icon: 'none', + }) + } } onMounted(() => { diff --git a/pages/setting/push.vue b/pages/setting/push.vue index 2aaecf4..9ab36c1 100644 --- a/pages/setting/push.vue +++ b/pages/setting/push.vue @@ -3,25 +3,35 @@ - 公共消息 - 重大咨询、财经要闻等系统提醒 - + 公共消息 + + 重大咨询、财经要闻等系统提醒 + + - 字体大小 - + 指标消息提醒 + + 所有指标消息的提醒 + + - 盯盘预警 - + 盯盘预警 + + 自选股预警和个性化预警设置 + + - 订阅服务 - 45.5M - + 订阅服务 + + 订阅你感兴趣的专题服务 + + @@ -53,7 +63,6 @@ height: 7vh; display: flex; align-items: center; - justify-content: center; margin: 0 40rpx; padding: 0 10rpx; border-bottom: 1rpx solid #eee; @@ -63,25 +72,24 @@ border-bottom: none; } + .right { + display: flex; + align-items: center; + gap: 10rpx; + } + .switch-btn { - width: 100rpx; transform: scale(0.6); transform-origin: center right; } .public { - width: 450rpx; - margin-left: auto; font-size: 10px; color: rgb(203, 203, 203); } - .arrow { - margin-left: auto; - } - .bottom { - height: 13.5vh; + height: 14vh; background-color: white; margin-top: 1vh; } @@ -105,4 +113,8 @@ .bottom-list:last-child { border-bottom: none; } + + .label { + flex: 1; + } \ No newline at end of file diff --git a/pages/setting/server.vue b/pages/setting/server.vue index 044d6aa..9524cfc 100644 --- a/pages/setting/server.vue +++ b/pages/setting/server.vue @@ -26,9 +26,31 @@ ref, onMounted } from 'vue' + import { + getSetting + } from "@/api/setting/general" + const iSMT = ref(0) const selectedIndex = ref(0) + 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; + } + } catch (err) { + console.error("获取服务器设置失败:", err); + } + } + const selectFont = (index) => { selectedIndex.value = index console.log('看看选中状态',selectedIndex.value) @@ -38,6 +60,7 @@ // 状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; console.log('看看高度', iSMT.value) + getServer() }) diff --git a/pages/setting/theme.vue b/pages/setting/theme.vue index 3752eab..43573d9 100644 --- a/pages/setting/theme.vue +++ b/pages/setting/theme.vue @@ -21,8 +21,28 @@ ref, onMounted } from 'vue' + import { + getSetting + } from "@/api/setting/general" const iSMT = ref(0) const selectedIndex = ref(0) + + 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; + } + } catch (err) { + console.error("获取主题设置失败:", err); + } + } const selectFont = (index) => { selectedIndex.value = index @@ -32,6 +52,7 @@ // 状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; console.log('看看高度', iSMT.value) + getTheme() }) diff --git a/pages/start/Registration/Registration.vue b/pages/start/Registration/Registration.vue index e786964..1e919e1 100644 --- a/pages/start/Registration/Registration.vue +++ b/pages/start/Registration/Registration.vue @@ -198,6 +198,7 @@ import { SendPhoneCodeApi, } from "../../../api/start/login"; import { useDeviceStore} from "../../../stores/modules/deviceInfo" +import { useUserStore} from "../../../stores/modules/userInfo" const type = ref(""); const email = ref(""); @@ -246,7 +247,7 @@ function showCountryPicker() { function goToIndex() { // 返回上一页 uni.navigateTo({ - url: "/pages/start/index/index", + url: "/pages/start/login/login", }); } diff --git a/pages/start/index/index.vue b/pages/start/index/index.vue deleted file mode 100644 index 30c8683..0000000 --- a/pages/start/index/index.vue +++ /dev/null @@ -1,56 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/start/recoverPassword/recoverPassword.vue b/pages/start/recoverPassword/recoverPassword.vue index 1bdca81..97530c5 100644 --- a/pages/start/recoverPassword/recoverPassword.vue +++ b/pages/start/recoverPassword/recoverPassword.vue @@ -209,10 +209,10 @@ - 已有账号? - 登录 - - + 已有账号? + 登录 + @@ -235,7 +235,12 @@ import countryList from "../login/list"; import footerBar from "../../../components/footerBar"; import uniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; import { verificationPhone, verificationEmail } from "../login/verification"; -import { SendEmailCodeApi, SendPhoneCodeApi } from "../../../api/start/login"; +import { + SendEmailCodeApi, + SendPhoneCodeApi, + verifyCodeApi, + forgetApi, +} from "../../../api/start/login"; const type = ref(""); const email = ref(""); @@ -254,6 +259,7 @@ const verifyCode = ref(""); const isRecovering = ref(false); const newPasswordLookFirst = ref(false); const newPasswordLookSecond = ref(false); +const account = ref(""); // 使用从list.js导入的完整国家列表数据 const countries = ref( @@ -301,7 +307,7 @@ function switchPhone() { verifyCode.value = ""; } -function register() { +async function register() { if (isRecovering.value) { if (!newPasswordFirst.value || !newPasswordSecond.value) { uni.showToast({ @@ -319,6 +325,32 @@ function register() { return; } + const account = changeAccount(); + + const res = await forgetApi({ + account: account, + password: newPasswordSecond.value, + }); + + console.log("res", res); + + if (res.code !== 200) { + uni.showToast({ + title: res.message, + icon: "none", + }); + return; + } + + uni.showToast({ + title: res.message, + icon: "none", + }); + + uni.navigateTo({ + url: "/pages/start/login/login", + }); + // 密码逻辑 return; } @@ -384,13 +416,54 @@ function register() { console.log("登录:", email.value); } + const account = changeAccount(); + const loginType = changeLoginType(); + + const res = await verifyCodeApi({ + loginType: loginType, //登录方式EMAIL,PHONE + account: account, //登陆账号 手机号/邮箱 + verifyCode: verifyCode.value, + }); + + if (res.code !== 200) { + uni.showToast({ + title: res.message, + icon: "none", + }); + return; + } + isRecovering.value = !isRecovering.value; +} - // 如果已经同意,则继续登录流程 - // uni.showToast({ - // title: "登录成功", - // icon: "success", - // }); +// 请求账户 +function changeAccount() { + if (switchType.value === "User") { + account.value = deepChartID.value; + } + + if (switchType.value === "Phone") { + account.value = `${country.value}${phone.value}`; + } + if (switchType.value === "Email") { + account.value = email.value; + } + + return account.value; +} + +// 改变请求时的type +function changeLoginType() { + if (switchType.value === "User") { + return "DCCODE"; + } + + if (switchType.value === "Phone") { + return "PHONE"; + } + if (switchType.value === "Email") { + return "EMAIL"; + } } function goToLogin() { diff --git a/static/language/en.js b/static/language/en.js index 4165665..3fb3b04 100644 --- a/static/language/en.js +++ b/static/language/en.js @@ -1,14 +1,21 @@ +/** @format */ + export default { - language: { - "name": "Simplified Chinese" - }, - components: { - footerBar: { - homepage: '首页', - marketSituation: '行情', - deepMate: 'DeepMate', - deepExploration: '深度探索', - member: '我的', - }, - } -} \ No newline at end of file + language: { + name: "Simplified Chinese", + }, + components: { + footerBar: { + homepage: "首页", + marketSituation: "行情", + deepMate: "DeepMate", + deepExploration: "深度探索", + member: "我的", + }, + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, +}; diff --git a/static/language/ms.js b/static/language/ms.js index 511083a..1b5488f 100644 --- a/static/language/ms.js +++ b/static/language/ms.js @@ -10,5 +10,10 @@ export default { deepExploration: '深度探索', member: '我的', }, - } + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, } \ No newline at end of file diff --git a/static/language/th.js b/static/language/th.js index 4a6ad2e..5b3179b 100644 --- a/static/language/th.js +++ b/static/language/th.js @@ -10,5 +10,10 @@ export default { deepExploration: '深度探索', member: '我的', }, - } + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, } diff --git a/static/language/vi.js b/static/language/vi.js index cc829a2..862aa11 100644 --- a/static/language/vi.js +++ b/static/language/vi.js @@ -10,5 +10,10 @@ export default { deepExploration: '深度探索', member: '我的', }, - } + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, } \ No newline at end of file diff --git a/static/language/zh_CN.js b/static/language/zh_CN.js index 1569257..b939954 100644 --- a/static/language/zh_CN.js +++ b/static/language/zh_CN.js @@ -1,15 +1,22 @@ +/** @format */ + // 中文简体 export default { - language: { - name: '中文简体' - }, - components: { - footerBar:{ - homepage: '首页', - marketSituation: '行情', - deepMate: 'DeepMate', - deepExploration: '深度探索', - member: '我的', - }, - }, -} + language: { + name: "中文简体", + }, + components: { + footerBar: { + homepage: "首页", + marketSituation: "行情", + deepMate: "DeepMate", + deepExploration: "深度探索", + member: "我的", + }, + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, +}; diff --git a/static/language/zh_HK.js b/static/language/zh_HK.js index 14c440f..76d90f9 100644 --- a/static/language/zh_HK.js +++ b/static/language/zh_HK.js @@ -1,15 +1,22 @@ +/** @format */ + // 中文繁体 export default { - language: { - name: "中文繁体" - }, - components: { - footerBar: { - homepage: '首页', - marketSituation: '行情', - deepMate: 'DeepMate', - deepExploration: '深度探索', - member: '我的', - }, - }, -} \ No newline at end of file + language: { + name: "中文繁体", + }, + components: { + footerBar: { + homepage: "首页", + marketSituation: "行情", + deepMate: "DeepMate", + deepExploration: "深度探索", + member: "我的", + }, + }, + marketSituation: { + globalIndex: "全球指数", + globalIndexMore:'查看更多', + warn:'全球指数为试运行,免费开放,有诸多不足请见谅' + }, +}; diff --git a/stores/index.js b/stores/index.js index ada9fd8..56ec367 100644 --- a/stores/index.js +++ b/stores/index.js @@ -10,5 +10,6 @@ pinia.use(persist) export * from './modules/userInfo' export * from './modules/deviceInfo' export * from './modules/deepExploration' +export * from './modules/login' // 默认导出,给 main.js 使用 export default pinia \ No newline at end of file diff --git a/stores/modules/login.js b/stores/modules/login.js new file mode 100644 index 0000000..b2041ea --- /dev/null +++ b/stores/modules/login.js @@ -0,0 +1,44 @@ +import { defineStore } from 'pinia' +import { ref } from 'vue' + +// 定义 Store +export const useLoginStore = defineStore( + 'login', + () => { + // 会员信息 + const loginInfo = ref("true") + + // 保存会员信息,登录时使用 + const setLoginInfo = (val) => { + loginInfo.value = val + } + + // 清理会员信息,退出时使用 + const clearLoginInfo = () => { + loginInfo.value = undefined + } + + // 记得 return + return { + loginInfo, + setLoginInfo, + clearLoginInfo, + } + }, + // TODO: 持久化 + { + // 网页端持久化 + // persist: true, + // 小程序端持久化 + persist: { + storage: { + getItem(key) { + return uni.getStorageSync(key) + }, + setItem(key, value) { + uni.setStorageSync(key, value) + }, + }, + }, + }, +) diff --git a/utils/http.js b/utils/http.js index 7d94278..dcae7e5 100644 --- a/utils/http.js +++ b/utils/http.js @@ -1,5 +1,6 @@ import { useUserStore } from "../stores/modules/userInfo" import { useDeviceStore } from "../stores/modules/deviceInfo" +import { useLoginStore } from "../stores/modules/login" const baseURL = "https://dbqb.nfdxy.net/testApi" @@ -22,13 +23,13 @@ const httpInterceptor = { // 打印最终请求地址 console.log('HTTP(finalUrl)=', options.url) // 2.请求超时,默认60s - options.timeout = 60000 + options.timeout = 10000 console.log(options) //3 添加小程序端请求头 const sys = uni.getSystemInfoSync(); // 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回) - const deviceInfo =useDeviceStore() + const deviceInfo = useDeviceStore() options.header = { @@ -37,7 +38,7 @@ 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', 'deviceId': deviceInfo.deviceInfo.deviceId } //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 @@ -66,6 +67,14 @@ export const http = (options) => { success: (result) => { if (result.statusCode >= 200 && result.statusCode < 300) { if (result.data.code === 401) { + + const loginStore = useLoginStore() + loginStore.setLoginInfo("true") + console.log("1loginStore.loginInfo", loginStore.loginInfo); + + loginStore.setLoginInfo("false") + console.log("2loginStore.loginInfo", loginStore.loginInfo); + uni.showToast({ title: '请先登录', icon: 'none' @@ -93,7 +102,7 @@ export const http = (options) => { fail: (err) => { reject(err) uni.showToast({ - title: '网络错误', + title: '请求超时', icon: 'none' }) } diff --git a/vue.config.js b/vue.config.js index 76eaa5d..0345309 100644 --- a/vue.config.js +++ b/vue.config.js @@ -1,14 +1,24 @@ module.exports = { devServer: { - proxy: { + /* proxy: { '/api': { // 你的目标服务器的请求路径前缀 target: 'https://hwjb.homilychart.com', // 目标服务器的地址 changeOrigin: true, // 是否跨域 secure: false, // 如果是https接口,需要配置这个参数 pathRewrite: { - '^/': '/testApi' // 将 /api 替换为 /testApi,以便正确请求目标服务器的资源 + '^/api': '' // 将 /api 替换为 /testApi,以便正确请求目标服务器的资源 } } - } + } */ + proxy: { + '/api': { // 你的目标服务器的请求路径前缀 + target: 'http://192.168.40.8:9000', // 目标服务器的地址 + changeOrigin: true, // 是否跨域 + secure: false, // 如果是https接口,需要配置这个参数 + pathRewrite: { + '^/api': '' // 将 /api 替换为 /testApi,以便正确请求目标服务器的资源 + } + } + } } } \ No newline at end of file