diff --git a/api/customerServicePlatform/customerServicePlatform.js b/api/customerServicePlatform/customerServicePlatform.js new file mode 100644 index 0000000..0f20be0 --- /dev/null +++ b/api/customerServicePlatform/customerServicePlatform.js @@ -0,0 +1,46 @@ +import { http } from '@/utils/http.js' + +const baseURL = "http://39.101.133.168:8828" +//图片上传 +export const uploadImageApi = (data) => { + return http({ + method: 'POST', + url: baseURL +'/hljw/api/aws/upload', + data + }) +} + +//问题回答 +export const getAnswerApi = (data) => { + return http({ + method: 'POST', + url: 'http://pbb6edde.natappfree.cc' +'/api/customer/askQuestion', + data + }) +} + +//获取随机5条猜你想问问题 +export const getQuestionApi = (data) => { + return http({ + method: 'GET', + url: 'http://pbb6edde.natappfree.cc' +'/api/customer/getQuestion', + }) +} + + +//反馈添加 +export const addFeedbackRecordApi = (data) => { + return http({ + method: 'POST', + url: baseURL +'/link/third/dcFeedBack/feedback/add', + data + }) +} +//反馈历史记录 +export const getFeedbackRecordsApi = (data) => { + return http({ + method: 'POST', + url: baseURL+'/link/third/dcFeedBack/feedback/select', + data + }) +} \ No newline at end of file diff --git a/api/home/mySelections.js b/api/home/mySelections.js new file mode 100644 index 0000000..6801ebc --- /dev/null +++ b/api/home/mySelections.js @@ -0,0 +1,185 @@ +/** + * 我的自选股相关API接口封装 + * 使用utils/http.js中的拦截器封装请求方法 + */ + +import { http } from '../../utils/http.js' + +/** + * 我的自选股API接口类 + */ +class MySelectionsAPI { + + /** + * 判断用户是否存在自选股分组 + * @param {Function} successCallback - 成功回调函数 + * @param {Function} failCallback - 失败回调函数 + * @param {Object} data - 请求参数 + * @returns {Promise} + */ + static async checkExist(successCallback, failCallback = null, data = {}) { + const url = '/api/homePage/userStock/checkExist' + + try { + const response = await http({ + url: url, + method: 'POST', + data: data + }) + + console.log('检查用户自选股分组存在性 - 响应:', response) + if (successCallback && typeof successCallback === 'function') { + successCallback(response) + } + return response + } catch (error) { + console.error('检查用户自选股分组存在性 - 失败:', error) + if (failCallback && typeof failCallback === 'function') { + failCallback(error) + } + throw error + } + } + + /** + * 查询用户所有自选股分组 + * @param {Function} successCallback - 成功回调函数 + * @param {Function} failCallback - 失败回调函数 + * @param {Object} data - 请求参数 + * @returns {Promise} + */ + static async getUserStockGroupList(successCallback, failCallback = null, data = {}) { + const url = '/api/homePage/userStockGroup/list' + + try { + const response = await http({ + url: url, + method: 'POST', + data: data + }) + + console.log('查询用户自选股分组列表 - 响应:', response) + if (successCallback && typeof successCallback === 'function') { + successCallback(response) + } + return response + } catch (error) { + console.error('查询用户自选股分组列表 - 失败:', error) + if (failCallback && typeof failCallback === 'function') { + failCallback(error) + } + throw error + } + } + + /** + * 分页查询某一个分组下的所有自选股 + * @param {Function} successCallback - 成功回调函数 + * @param {Function} failCallback - 失败回调函数 + * @param {Object} data - 请求参数 {groupId, pageNum, pageSize, ...} + * @returns {Promise} + */ + static async getUserStockList(successCallback, failCallback = null, data = {}) { + const url = '/api/homePage/userStock/list' + + // 设置默认分页参数 + const requestData = { + pageNum: 1, + pageSize: 20, + ...data + } + + try { + const response = await http({ + url: url, + method: 'POST', + data: requestData + }) + + console.log('分页查询分组自选股 - 响应:', response) + if (successCallback && typeof successCallback === 'function') { + successCallback(response) + } + return response + } catch (error) { + console.error('分页查询分组自选股 - 失败:', error) + if (failCallback && typeof failCallback === 'function') { + failCallback(error) + } + throw error + } + } + + /** + * 查询默认自选股 + * @param {Function} successCallback - 成功回调函数 + * @param {Function} failCallback - 失败回调函数 + * @param {Object} data - 请求参数 + * @returns {Promise} + */ + static async getUserOrDefault(successCallback, failCallback = null, data = {}) { + const url = '/api/homePage/userStock/getUserOrDefault' + + try { + const response = await http({ + url: url, + method: 'POST', + data: data + }) + + console.log('查询默认自选股 - 响应:', response) + if (successCallback && typeof successCallback === 'function') { + successCallback(response) + } + return response + } catch (error) { + console.error('查询默认自选股 - 失败:', error) + if (failCallback && typeof failCallback === 'function') { + failCallback(error) + } + throw error + } + } + + /** + * 游客查询默认自选股 + * @param {Function} successCallback - 成功回调函数 + * @param {Function} failCallback - 失败回调函数 + * @returns {Promise} + */ + static async getDefaultStocks(successCallback, failCallback = null) { + const url = '/api/homePage/userStock/getDefaultStocks' + + try { + const response = await http({ + url: url, + method: 'POST', + data: {} + }) + + console.log('游客查询默认自选股 - 响应:', response) + if (successCallback && typeof successCallback === 'function') { + successCallback(response) + } + return response + } catch (error) { + console.error('游客查询默认自选股 - 失败:', error) + if (failCallback && typeof failCallback === 'function') { + failCallback(error) + } + throw error + } + } +} + +// 导出API类 +export default MySelectionsAPI + +// 也可以导出单个方法供直接使用 +export const { + checkExist, + getUserStockGroupList, + getUserStockList, + getUserOrDefault, + getDefaultStocks +} = MySelectionsAPI \ No newline at end of file diff --git a/api/marketSituation/marketSituation.js b/api/marketSituation/marketSituation.js new file mode 100644 index 0000000..9452062 --- /dev/null +++ b/api/marketSituation/marketSituation.js @@ -0,0 +1,70 @@ +/** @format */ + +import { http } from "../../utils/http"; + +export const getData = () => { + return http({ + method: "GET", + url: "/ka", + }); +}; + +/** + * 获取全球指数 + * POST /api/global/getGlobalIndex + */ +export const getGlobalIndexAPI = (data) => { + return http({ + method: "POST", + url: "/api/global/getGlobalIndex", + data, + }); +}; + +/** + * 获取地区分组列表 + * POST /api/global/regionalGroup + */ +export const getRegionalGroupAPI = (data) => { + return http({ + method: "POST", + url: "/api/global/regionalGroup", + data, + }); +}; + +/** + * 获取地区详情 + * POST /api/global/regionalGroupList + */ +export const getRegionalGroupListAPI = (data) => { + return http({ + method: "POST", + url: "/api/global/regionalGroupList", + data, + }); +}; + +/** + * 一次性查询所有Tab栏父子结构 + * POST /api/homework/tab/getAll + */ +export const getAllTabsAPI = (data) => { + return http({ + method: "POST", + url: "/api/homework/tab/getAll", + data, + }); +}; + +/** + * 通用市场数据分页查询接口(默认1页20条) + * POST /api/market/data/page/query + */ +export const queryStockDataAPI = (data) => { + return http({ + method: "POST", + url: "/api/market/data/page/query", + data, + }); +}; 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/FeedbackModal.vue b/components/FeedbackModal.vue new file mode 100644 index 0000000..a4bc5e4 --- /dev/null +++ b/components/FeedbackModal.vue @@ -0,0 +1,196 @@ + + + + + \ No newline at end of file diff --git a/components/IndexCard.vue b/components/IndexCard.vue index 24d0e7e..ad1ae69 100644 --- a/components/IndexCard.vue +++ b/components/IndexCard.vue @@ -1,190 +1,220 @@ + + \ No newline at end of file + 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 4d302be..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/customerServicePlatform/historyRecord.vue b/pages/customerServicePlatform/historyRecord.vue new file mode 100644 index 0000000..5e5e61e --- /dev/null +++ b/pages/customerServicePlatform/historyRecord.vue @@ -0,0 +1,358 @@ + + + + + \ No newline at end of file diff --git a/pages/customerServicePlatform/questionDetail.vue b/pages/customerServicePlatform/questionDetail.vue new file mode 100644 index 0000000..e1bdef5 --- /dev/null +++ b/pages/customerServicePlatform/questionDetail.vue @@ -0,0 +1,340 @@ + + + + + \ No newline at end of file diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue index 7ca432a..90e0f70 100644 --- a/pages/deepMate/deepMate.vue +++ b/pages/deepMate/deepMate.vue @@ -19,7 +19,8 @@ ${text}

`; +}; // 设置 marked 选项 marked.setOptions({ renderer: new marked.Renderer(), @@ -621,13 +627,20 @@ const simulateBotResponse = async (userMessage) => { isSending.value = true; // 首先进行意图识别 - const res = await postIntent({ - content: userMessage, - language: "cn", - marketList: "hk,cn,usa,my,sg,vi,in,gb", - token: - "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", - }); + let res; + try { + res = await postIntent({ + content: userMessage, + language: "cn", + marketList: "hk,cn,usa,my,sg,vi,in,gb", + token: + "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", + }); + } catch (error) { + + } finally { + isSending.value = false; + } console.log("res" + res); @@ -694,31 +707,39 @@ const simulateBotResponse = async (userMessage) => { // 获取股票信息 const StockInfo = await postStock({ - language: 'cn', - token: 'pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q', + language: "cn", + token: + "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", recordId: Number(recordId), parentId: Number(parentId), stockId: Number(stockId), }); - console.log('postStock payload', { language: 'cn', token: '790750702588f1ea79f24dc56ccd5d8a', recordId, parentId, stockId }); - console.log('StockInfo', StockInfo); + console.log("postStock payload", { + language: "cn", + token: "790750702588f1ea79f24dc56ccd5d8a", + recordId, + parentId, + stockId, + }); + console.log("StockInfo", StockInfo); const cftl = StockInfo?.cftl || {}; - const date = StockInfo?.date || ''; - + const date = StockInfo?.date || ""; if (StockInfo && StockInfo.code !== 200) { - const errMsg = `postStock失败(${StockInfo.code}): ${StockInfo.message || '未知错误'}` - console.warn(errMsg, StockInfo) - messages.value[messages.value.length - 1].isThinking = false - messages.value[messages.value.length - 1].isTyping = false - messages.value[messages.value.length - 1].content = errMsg - isSending.value = false - return + const errMsg = `postStock失败(${StockInfo.code}): ${ + StockInfo.message || "未知错误" + }`; + console.warn(errMsg, StockInfo); + messages.value[messages.value.length - 1].isThinking = false; + messages.value[messages.value.length - 1].isTyping = false; + messages.value[messages.value.length - 1].content = errMsg; + isSending.value = false; + return; } - const markdown = StockInfo?.data?.markdown || '抱歉,未找到该股票'; - console.log('StockInfo', StockInfo); + const markdown = StockInfo?.data?.markdown || "抱歉,未找到该股票"; + console.log("StockInfo", StockInfo); // 添加请求延迟 // const toDataInfo = await getData(); @@ -926,6 +947,8 @@ async function itemClick(item) { isTyping: false, isThinking: false, }; + + onDrawerBackClick(); messages.value.push(botMsg); } } diff --git a/pages/home/home.vue b/pages/home/home.vue index 80337d5..f9c46a3 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -2,7 +2,8 @@ - + + @@ -26,8 +27,8 @@ - - + + @@ -193,7 +194,8 @@ import MarketOverview from '../../components/MarketOverview.vue' import DeepMate from '../../components/DeepMate.vue' // import tcpConnection from '../../api/tcpConnection.js' import th from '../../static/language/th' - +import MySelectionsAPI from '../../api/home/mySelections.js' +import { useUserStore } from '../../stores/modules/userInfo' export default { components: { footerBar, @@ -205,6 +207,9 @@ export default { type: 'home', iSMT: 0, + // 用户信息 store + userStore: null, + // 深度探索数据 explorationItems: [ { title: '主力追踪', icon: '/static/c1.png' }, @@ -213,6 +218,15 @@ export default { { title: '主力资金流', icon: '/static/c4.png' } ], + // 轮播图片数据 + swiperImages: [ + 'https://d31zlh4on95l9h.cloudfront.net/images/44ec37501cf3ecf5438d401c3d66fcd3.png', + 'https://d31zlh4on95l9h.cloudfront.net/images/80274b6626bb403d717469b3672333c9.png', + 'https://d31zlh4on95l9h.cloudfront.net/images/14481c76b09509977d3879ba3141ebc7.png', + 'https://d31zlh4on95l9h.cloudfront.net/images/19e4c5542e5f974e1c6938897aa20ef9.png', + 'https://d31zlh4on95l9h.cloudfront.net/images/d0bc1c1bb71917132865b82dab99831b.png' + ], + // 我的自选股票数据 myStocks: [ { name: '特斯拉', code: 'TSLA', price: '482.00', change: 2.80, chartImg: '/static/c5.png' }, @@ -251,6 +265,9 @@ export default { type: '' }, + // 当前TCP使用的股票代码 + currentStockCodes: ['SH.000001', 'SH.000002', 'SH.000003'], + // 我的自选TCP股票数据存储 myStocksTcpData: { count: 0, @@ -319,6 +336,9 @@ export default { // 状态栏高度 this.iSMT = uni.getSystemInfoSync().statusBarHeight; + // 初始化用户信息 store + this.userStore = useUserStore(); + // 预加载图片资源 this.myStocks.forEach(stock => { // 使用uni.getImageInfo替代Image对象 @@ -333,10 +353,25 @@ export default { } }) }) - + + + // 检查用户登录状态,只有已登录并且不是游客才加载自选股数据 + if (this.userStore.userInfo && !this.userStore.userInfo.isVisitor) { + console.log('是用户登录,加载自选股数据', this.userStore.userInfo) + this.loadMySelectionsData() + } else if (this.userStore.userInfo && this.userStore.userInfo.isVisitor){ + console.log('是游客登录,加载默认自选股',this.userStore.userInfo) + this.loadGuestDefaultStocks() + }else { + console.log('用户未登录',this.userStore.userInfo) + } + // 初始化TCP连接监听器 this.initTcpListeners() + // 监听游客登录成功事件 + uni.$on('visitorLoginSuccess', this.handleVisitorLoginSuccess) + // 页面渲染完成后自动连接两个TCP连接 this.$nextTick(() => { console.log('页面渲染完成,开始自动连接TCP服务器...') @@ -389,9 +424,36 @@ export default { // 移除TCP监听器,防止内存泄漏 this.removeTcpListeners() + + // 移除游客登录成功事件监听器 + uni.$off('visitorLoginSuccess', this.handleVisitorLoginSuccess) }, methods: { + // 处理游客登录成功事件 + handleVisitorLoginSuccess(data) { + console.log('收到游客登录成功事件:', data) + // 重新加载页面数据 + this.reloadPageData() + }, + + // 重新加载页面数据 + reloadPageData() { + console.log('重新加载页面数据...') + + // 更新用户信息store + this.userStore = useUserStore() + + // 根据新的用户状态加载相应的数据 + if (this.userStore.userInfo && this.userStore.userInfo.isVisitor) { + console.log('游客登录成功,加载默认自选股') + this.loadGuestDefaultStocks() + } else if (this.userStore.userInfo && !this.userStore.userInfo.isVisitor) { + console.log('用户登录,加载自选股数据') + this.loadMySelectionsData() + } + }, + // 防抖函数 debounce(fn, delay = 300) { if (this.debounceTimer) clearTimeout(this.debounceTimer) @@ -401,6 +463,186 @@ export default { }, delay) }, + // 自选股数据加载相关方法 + + // 加载自选股数据的主方法 + async loadMySelectionsData() { + try { + console.log('开始加载自选股数据...') + + // 调用checkExist判断用户是否存在自选股 + const checkResult = await MySelectionsAPI.checkExist() + console.log('检查用户自选股存在性结果:', checkResult) + + if (checkResult.code === 200) { + const isHave = checkResult.data.is_have + + if (isHave === 1) { + // 用户有自选股,查询所有分组 + console.log('用户存在自选股,查询所有分组...') + await this.loadUserStockGroups() + } else { + // 用户没有自选股,查询默认自选股 + console.log('用户不存在自选股,查询默认自选股...') + await this.loadDefaultStocks() + } + } else { + console.error('检查用户自选股存在性失败:', checkResult.message) + // 失败时也尝试加载默认自选股 + // await this.loadDefaultStocks() + } + } catch (error) { + console.error('加载自选股数据失败:', error) + // 出错时尝试加载默认自选股 + await this.loadDefaultStocks() + } + }, + + // 加载用户自选股分组 + async loadUserStockGroups() { + try { + const groupResult = await MySelectionsAPI.getUserStockGroupList() + console.log('查询用户自选股分组结果:', groupResult) + + if (groupResult.code === 200 && groupResult.data && groupResult.data.length > 0) { + // 找到id最小的分组 + const minIdGroup = groupResult.data.reduce((min, current) => { + return current.id < min.id ? current : min + }) + + console.log('找到最小id分组:', minIdGroup) + + // 查询该分组下的股票 + await this.loadGroupStocks(minIdGroup.id) + } else { + console.log('没有找到用户自选股分组,加载默认自选股') + await this.loadDefaultStocks() + } + } catch (error) { + console.error('加载用户自选股分组失败:', error) + await this.loadDefaultStocks() + } + }, + + // 加载指定分组下的股票 + async loadGroupStocks(groupId) { + try { + const stockResult = await MySelectionsAPI.getUserStockList(null, null, { + groupId: groupId, + pageNum: 1, + pageSize: 20 + }) + + console.log('查询分组自选股结果:', stockResult) + + if (stockResult.code === 200 && stockResult.data) { + this.processStockData(stockResult.data) + } else { + console.log('分组下没有股票数据,加载默认自选股') + await this.loadDefaultStocks() + } + } catch (error) { + console.error('加载分组股票失败:', error) + await this.loadDefaultStocks() + } + }, + + // 加载默认自选股 + async loadDefaultStocks() { + try { + const defaultResult = await MySelectionsAPI.getUserOrDefault() + console.log('查询默认自选股结果:', defaultResult) + + if (defaultResult.code === 200 && defaultResult.data) { + this.processStockData(defaultResult.data) + } else { + console.log('没有默认自选股数据') + } + } catch (error) { + console.error('加载默认自选股失败:', error) + } + }, + + // 游客加载默认自选股 + async loadGuestDefaultStocks() { + try { + console.log('游客开始加载默认自选股...') + const guestResult = await MySelectionsAPI.getDefaultStocks() + console.log('游客查询默认自选股结果:', guestResult) + + if (guestResult.code === 200 && guestResult.data) { + this.processStockData(guestResult.data) + } else { + console.log('游客没有默认自选股数据') + } + } catch (error) { + console.error('游客加载默认自选股失败:', error) + } + }, + + // 处理股票数据 + processStockData(stockData) { + console.log('处理股票数据:', stockData) + + // 根据返回的数据结构更新myStocks数组 + // 这里需要根据实际API返回的数据结构进行调整 + if (Array.isArray(stockData)) { + // 如果是数组格式 + this.myStocks = stockData.map(stock => ({ + name: stock.name || stock.stock_name || '', + code: stock.code || stock.stock_code || '', + // price: stock.price || stock.current_price || '0.00', + // change: stock.change || stock.change_percent || 0, + chartImg: stock.chartImg || '/static/c5.png' // 默认图片 + })) + //重新赋值机构动向简报 + this.institutionalReports = stockData.map(stock => ({ + stock: stock.name || stock.stock_name || '', + status: stock.code || stock.stock_code || '', + + })) + } else if (stockData.list && Array.isArray(stockData.list)) { + // 如果是分页格式 + this.myStocks = stockData.list.map(stock => ({ + name: stock.name || stock.stock_name || '', + code: stock.code || stock.stock_code || '', + // price: stock.price || stock.current_price || '0.00', + // change: stock.change || stock.change_percent || 0, + chartImg: stock.chartImg || '/static/c5.png' // 默认图片 + })) + //重新赋值机构动向简报 + //重新赋值机构动向简报 + this.institutionalReports = stockData.map(stock => ({ + stock: stock.name || stock.stock_name || '', + status: stock.code || stock.stock_code || '', + })) + } + + console.log('更新后的自选股数据:', this.myStocks) + + // 更新TCP消息中的股票代码 + this.updateTcpStockCodes() + }, + + // 更新TCP消息中的股票代码 + updateTcpStockCodes() { + // 从myStocks中提取前3个股票代码 + const stockCodes = this.myStocks.slice(0, 3).map(stock => stock.code).filter(code => code) + console.log('更新TCP消息股票代码:', stockCodes) + + // 如果有股票代码,更新TCP消息 + if (stockCodes.length > 0) { + // 补充到3个代码(如果不足3个,用默认代码补充) + while (stockCodes.length < 3) { + stockCodes.push('SH.000001') // 默认代码 + } + + // 保存到组件数据中,供TCP方法使用 + this.currentStockCodes = stockCodes + console.log('当前TCP使用的股票代码:', this.currentStockCodes) + } + }, + // TCP连接相关方法 // 初始化TCP监听器 @@ -856,7 +1098,7 @@ export default { // } // {"command": "stock_list"} // {"command": "batch_real_time", "stock_codes": ["SH.000001"]} - {"command": "batch_real_time", "stock_codes": ["SH.000001","SH.000002","SH.000003"]} + {"command": "batch_real_time", "stock_codes": this.currentStockCodes} // 发送消息 const success = tcpConnection.send(messageData) @@ -873,7 +1115,7 @@ export default { // 发送我的自选TCP消息 sendMyStocksTcpMessage() { // 构造要发送的消息对象 - 我的自选股票数据请求 - const messageData = {"command": "batch_real_time", "stock_codes": ["SH.000001","SH.000002","SH.000003"]} + const messageData = {"command": "batch_real_time", "stock_codes": this.currentStockCodes} // 发送消息到channel 2(我的自选TCP连接) const success = tcpConnection.send(messageData, { channel: '2' }) @@ -1424,7 +1666,7 @@ export default { .welcome-swiper { width: 100%; - height: 150px; + height: 110px; border-radius: 0; overflow: hidden; } diff --git a/pages/marketSituation/countryMarket.vue b/pages/marketSituation/countryMarket.vue index 9bb0a30..465e8e7 100644 --- a/pages/marketSituation/countryMarket.vue +++ b/pages/marketSituation/countryMarket.vue @@ -1,493 +1,498 @@ + + \ No newline at end of file + diff --git a/pages/marketSituation/globalIndex.vue b/pages/marketSituation/globalIndex.vue index beb2fc4..662c11d 100644 --- a/pages/marketSituation/globalIndex.vue +++ b/pages/marketSituation/globalIndex.vue @@ -1,586 +1,566 @@ + + \ No newline at end of file + diff --git a/pages/marketSituation/marketCondition.vue b/pages/marketSituation/marketCondition.vue index b244d26..5c29c5e 100644 --- a/pages/marketSituation/marketCondition.vue +++ b/pages/marketSituation/marketCondition.vue @@ -8,12 +8,12 @@ - + {{ stockInformation.stockName }} {{ stockInformation.stockCode }} - + ··· @@ -240,6 +240,10 @@ const tcpConnected = ref(false); const connectionListener = ref(null); const messageListener = ref(null); +// 股票来源 +const currentStockFrom = ref(); +// 当前股票位置 +const currentStockIndex = ref(-1); // 股票信息栏变量 const stockInformation = ref({ stockName: "----", //股票名称 @@ -511,6 +515,35 @@ const backToHomepage = () => { } }; +const toLeftPage = () => { + if(currentStockFrom.value == "marketOverview"){ + return; + } + if (currentStockIndex.value > 0) { + currentStockIndex.value--; + // updateStockInformation(); + } else { + uni.showToast({ + title: "没有更多股票了", + icon: "none", + duration: 1000, + }); + } +}; + +const toRightPage = () => { + if (currentStockIndex.value < stockList.length - 1) { + currentStockIndex.value++; + // updateStockInformation(); + } else { + uni.showToast({ + title: "没有更多股票了", + icon: "none", + duration: 1000, + }); + } +}; + const openStockDetail = () => { isStockDetail.value = true; }; @@ -2136,10 +2169,10 @@ const startAddDataTimer = () => { onLoad((options) => { console.log("页面接收到的参数:", options); - // 处理通过data参数传递的复杂对象 - if (options.data) { + // 处理通过stockInformation参数传递的复杂对象 + if (options.stockInformation) { try { - const stockData = JSON.parse(decodeURIComponent(options.data)); + const stockData = JSON.parse(decodeURIComponent(options.stockInformation)); console.log("解析的股票数据:", stockData); // 更新stockInformation @@ -2152,30 +2185,17 @@ onLoad((options) => { } } - // 处理通过stockInformation参数传递的数据(兼容globalIndex.vue的传参方式) - if (options.stockInformation) { - try { - const stockData = JSON.parse(decodeURIComponent(options.stockInformation)); - console.log("解析的股票信息:", stockData); - - // 更新stockInformation - if (stockData) { - stockInformation.value = { - ...stockInformation.value, - ...stockData, - }; - } - } catch (error) { - console.error("解析股票信息失败:", error); - } + // 处理index参数(股票在列表中的位置) + if (options.index !== undefined) { + const stockIndex = parseInt(options.index); + console.log("股票在列表中的索引:", stockIndex); + // 将index保存到响应式变量中,用于后续的左右切换功能 + currentStockIndex.value = stockIndex; } - // 处理简单参数 - if (options.stockCode) { - stockInformation.value.stockCode = options.stockCode; - } - if (options.stockName) { - stockInformation.value.stockName = decodeURIComponent(options.stockName); + // 处理stockFrom参数(股票来源) + if (options.stockFrom) { + currentStockFrom.value = options.stockFrom; } }); diff --git a/pages/marketSituation/marketDetail.vue b/pages/marketSituation/marketDetail.vue index 0252547..945d194 100644 --- a/pages/marketSituation/marketDetail.vue +++ b/pages/marketSituation/marketDetail.vue @@ -1,481 +1,481 @@ + + \ No newline at end of file + diff --git a/pages/marketSituation/marketOverview.vue b/pages/marketSituation/marketOverview.vue index b9da06d..fa68843 100644 --- a/pages/marketSituation/marketOverview.vue +++ b/pages/marketSituation/marketOverview.vue @@ -20,8 +20,16 @@ - - + + @@ -41,6 +49,9 @@ import { ref, onMounted, watch, nextTick, computed } from "vue"; import util from "../../common/util.js"; import IndexCard from "../../components/IndexCard.vue"; +import { useMarketSituationStore } from "../../stores/modules/marketSituation.js"; +const marketSituationStore = useMarketSituationStore(); +import { getGlobalIndexAPI } from "../../api/marketSituation/marketSituation.js"; const iSMT = ref(0); const searchValue = ref(""); @@ -63,95 +74,7 @@ const warnTextClass = computed(() => { return isWarnTextOverflow.value ? "warn_text scroll-active" : "warn_text"; }); -// 弹窗相关数据 -const showCountryModal = ref(false); -const selectedCountry = ref("概况"); -const countryList = ref(["概况", "新加坡", "马来西亚", "印度尼西亚", "美国", "中国香港", "泰国", "中国", "加拿大", "越南", "外汇", "贵金属"]); - -// 卡片数据 -const cardData = ref([ - { - flagIcon: "🇺🇸", - stockName: "道琼斯", - stockCode: "noCode", - currentPrice: "45757.90", - changeAmount: "-125.22", - changePercent: "-0.27%", - isRising: false, - }, - { - flagIcon: "🇺🇸", - stockName: "纳斯达克", - stockCode: "noCode", - currentPrice: "22333.96", - changeAmount: "+125.22", - changePercent: "+0.47%", - isRising: true, - }, - { - flagIcon: "🇺🇸", - stockName: "标普500", - stockCode: "noCode", - currentPrice: "6606.08", - changeAmount: "+125.22", - changePercent: "+0.27%", - isRising: true, - }, - { - flagIcon: "🇨🇳", - stockName: "上证指数", - stockCode: "noCode", - currentPrice: "3333.96", - changeAmount: "+125.22", - changePercent: "+0.27%", - isRising: true, - }, - { - flagIcon: "🇨🇳", - stockName: "科创50", - stockCode: "noCode", - currentPrice: "757.90", - changeAmount: "-25.22", - changePercent: "-0.27%", - isRising: false, - }, - { - flagIcon: "🇭🇰", - stockName: "恒生指数", - stockCode: "noCode", - currentPrice: "19757.90", - changeAmount: "-125.22", - changePercent: "-0.63%", - isRising: false, - }, - { - flagIcon: "🇸🇬", - stockName: "道琼斯", - stockCode: "noCode", - currentPrice: "3757.90", - changeAmount: "+85.22", - changePercent: "+2.31%", - isRising: true, - }, - { - flagIcon: "🇲🇾", - stockName: "纳斯达克", - stockCode: "noCode", - currentPrice: "1657.90", - changeAmount: "-15.22", - changePercent: "-0.91%", - isRising: false, - }, - { - flagIcon: "🇹🇭", - stockName: "标普500", - stockCode: "noCode", - currentPrice: "1457.90", - changeAmount: "+35.22", - changePercent: "+2.48%", - isRising: true, - }, -]); +const globalIndexArray = ref([]); // 搜索输入事件 const onSearchInput = (e) => { @@ -216,7 +139,7 @@ const checkWarnTextOverflow = () => { }; // 方法:查看指数详情 -const viewIndexDetail = (item) => { +const viewIndexDetail = (item, index) => { console.log("查看指数详情:", item.stockName); // uni.showToast({ // title: `查看 ${item.stockName} 详情`, @@ -225,7 +148,7 @@ const viewIndexDetail = (item) => { // }) // 这里可以跳转到具体的指数详情页面 uni.navigateTo({ - url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}`, + url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}&index=${index}&from=marketOverview`, }); }; @@ -236,7 +159,17 @@ const goToGlobalIndex = () => { }); }; -onMounted(() => { +const getGlobalIndex = async () => { + try { + const result = await getGlobalIndexAPI(); + globalIndexArray.value = result.data; + } catch (e) { + console.log("获取全球指数失败", e); + } +}; + +onMounted(async () => { + await getGlobalIndex(); // 状态栏高度 iSMT.value = uni.getSystemInfoSync().statusBarHeight; diff --git a/pages/marketSituation/marketSituation.vue b/pages/marketSituation/marketSituation.vue index e76aa2d..af09fdf 100644 --- a/pages/marketSituation/marketSituation.vue +++ b/pages/marketSituation/marketSituation.vue @@ -1,593 +1,589 @@ + + \ No newline at end of file + diff --git a/pages/start/Registration/Registration.vue b/pages/start/Registration/Registration.vue index fc07232..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(""); 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/customer-service-platform/camera.png b/static/customer-service-platform/camera.png new file mode 100644 index 0000000..9988605 Binary files /dev/null and b/static/customer-service-platform/camera.png differ diff --git a/static/customer-service-platform/cs-platform-back.png b/static/customer-service-platform/cs-platform-back.png new file mode 100644 index 0000000..4af54c5 Binary files /dev/null and b/static/customer-service-platform/cs-platform-back.png differ diff --git a/static/customer-service-platform/ellipse-dc-img.png b/static/customer-service-platform/ellipse-dc-img.png new file mode 100644 index 0000000..195a4c4 Binary files /dev/null and b/static/customer-service-platform/ellipse-dc-img.png differ diff --git a/static/customer-service-platform/empty-content.png b/static/customer-service-platform/empty-content.png new file mode 100644 index 0000000..9c83ead Binary files /dev/null and b/static/customer-service-platform/empty-content.png differ diff --git a/static/customer-service-platform/fail-icon.png b/static/customer-service-platform/fail-icon.png new file mode 100644 index 0000000..d6cb9db Binary files /dev/null and b/static/customer-service-platform/fail-icon.png differ diff --git a/static/customer-service-platform/message.png b/static/customer-service-platform/message.png new file mode 100644 index 0000000..0cfce4b Binary files /dev/null and b/static/customer-service-platform/message.png differ diff --git a/static/customer-service-platform/refresh-icon.png b/static/customer-service-platform/refresh-icon.png new file mode 100644 index 0000000..316687f Binary files /dev/null and b/static/customer-service-platform/refresh-icon.png differ diff --git a/static/customer-service-platform/robot-head.png b/static/customer-service-platform/robot-head.png new file mode 100644 index 0000000..f741d09 Binary files /dev/null and b/static/customer-service-platform/robot-head.png differ diff --git a/static/customer-service-platform/smile-icon.png b/static/customer-service-platform/smile-icon.png new file mode 100644 index 0000000..1532095 Binary files /dev/null and b/static/customer-service-platform/smile-icon.png differ diff --git a/static/customer-service-platform/success-icon.png b/static/customer-service-platform/success-icon.png new file mode 100644 index 0000000..8c2cc8a Binary files /dev/null and b/static/customer-service-platform/success-icon.png differ diff --git a/static/marketSituation-image/country-flag/can.png b/static/marketSituation-image/country-flag/can.png new file mode 100644 index 0000000..35fd6ca Binary files /dev/null and b/static/marketSituation-image/country-flag/can.png differ diff --git a/static/marketSituation-image/country-flag/cn.png b/static/marketSituation-image/country-flag/cn.png new file mode 100644 index 0000000..f9337f6 Binary files /dev/null and b/static/marketSituation-image/country-flag/cn.png differ diff --git a/static/marketSituation-image/country-flag/global.png b/static/marketSituation-image/country-flag/global.png new file mode 100644 index 0000000..a9a008a Binary files /dev/null and b/static/marketSituation-image/country-flag/global.png differ diff --git a/static/marketSituation-image/country-flag/hk.png b/static/marketSituation-image/country-flag/hk.png new file mode 100644 index 0000000..dc6c352 Binary files /dev/null and b/static/marketSituation-image/country-flag/hk.png differ diff --git a/static/marketSituation-image/country-flag/my.png b/static/marketSituation-image/country-flag/my.png new file mode 100644 index 0000000..2f1907f Binary files /dev/null and b/static/marketSituation-image/country-flag/my.png differ diff --git a/static/marketSituation-image/country-flag/sg.png b/static/marketSituation-image/country-flag/sg.png new file mode 100644 index 0000000..18f5dba Binary files /dev/null and b/static/marketSituation-image/country-flag/sg.png differ diff --git a/static/marketSituation-image/country-flag/th.png b/static/marketSituation-image/country-flag/th.png new file mode 100644 index 0000000..ad61536 Binary files /dev/null and b/static/marketSituation-image/country-flag/th.png differ diff --git a/static/marketSituation-image/country-flag/us.png b/static/marketSituation-image/country-flag/us.png new file mode 100644 index 0000000..5c20fee Binary files /dev/null and b/static/marketSituation-image/country-flag/us.png differ diff --git a/static/marketSituation-image/country-flag/vi.png b/static/marketSituation-image/country-flag/vi.png new file mode 100644 index 0000000..5c52706 Binary files /dev/null and b/static/marketSituation-image/country-flag/vi.png differ 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/stores/modules/marketSituation.js b/stores/modules/marketSituation.js new file mode 100644 index 0000000..1f85660 --- /dev/null +++ b/stores/modules/marketSituation.js @@ -0,0 +1,78 @@ +/** @format */ + +import { defineStore } from "pinia"; +import { ref } from "vue"; +// 定义 Store +export const useMarketSituationStore = defineStore( + "marketSituation", + () => { + const cardData = ref([ + { + market: "usa", + stockName: "道琼斯", + stockCode: "noCode", + currentPrice: "45757.90", + changeAmount: "-125.22", + changePercent: "-0.27%", + isRising: false, + }, + { + market: "usa", + stockName: "纳斯达克", + stockCode: "noCode", + currentPrice: "22333.96", + changeAmount: "+125.22", + changePercent: "+0.47%", + isRising: true, + }, + { + market: "usa", + stockName: "标普500", + stockCode: "noCode", + currentPrice: "6606.08", + changeAmount: "+125.22", + changePercent: "+0.27%", + isRising: true, + }, + { + market: "cn", + stockName: "上证指数", + stockCode: "noCode", + currentPrice: "3333.96", + changeAmount: "+125.22", + changePercent: "+0.27%", + isRising: true, + }, + { + market: "cn", + stockName: "科创50", + stockCode: "noCode", + currentPrice: "757.90", + changeAmount: "-25.22", + changePercent: "-0.27%", + isRising: false, + }, + ]); + + // 记得 return + return { + cardData + }; + }, + // 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 bf57ee7..dcae7e5 100644 --- a/utils/http.js +++ b/utils/http.js @@ -1,8 +1,9 @@ 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" -// const baseURL = "https://dbqb.nfdxy.net/testApi" -const baseURL = "http://192.168.40.8:9000" const httpInterceptor = { // 拦截前触发 @@ -28,7 +29,7 @@ const httpInterceptor = { const sys = uni.getSystemInfoSync(); // 为对齐后端文档示例,client 固定为 ios(如需按平台设置再改回) - const deviceInfo =useDeviceStore() + const deviceInfo = useDeviceStore() options.header = { @@ -37,17 +38,18 @@ const httpInterceptor = { 'content-type': 'application/json', 'contentType': 'application/json', 'version': uni.getSystemInfoSync().appVersion, - //'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android', - 'client':'android', + 'client': uni.getSystemInfoSync().platform == 'ios' ? 'ios' : 'android', 'deviceId': deviceInfo.deviceInfo.deviceId } //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 const memberStore = useUserStore() const token = memberStore.userInfo?.token || options.data?.token - //const token = '9cd87893b9282b6a7a6cc9b780c905db' + // const token = '2d0b5654409646713cdd40ec0d0bb56c' + // const token = '1b3a58424c5324e40d4bf4d085e18047' if (token) { options.header.token = token } + console.log("最终请求参数:",options) // 避免误用 Authorization 头,后端要求的是 token 头 // if (options.header.Authorization) delete options.header.Authorization return options @@ -65,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'