diff --git a/api/setting/share.js b/api/setting/share.js new file mode 100644 index 0000000..e7806cc --- /dev/null +++ b/api/setting/share.js @@ -0,0 +1,15 @@ +import { http } from '../../utils/http' + + +/** + * 分享接口获取dccode + * @param data + * @returns {*} + */ +export const Share = (data) => { + return http({ + method: 'POST', + url: '/api/my/share', + data: data, + }) +} diff --git a/api/tcpConnection.js b/api/tcpConnection.js index c701ca3..1f55776 100644 --- a/api/tcpConnection.js +++ b/api/tcpConnection.js @@ -21,33 +21,33 @@ const TCP_CONFIG = { * TCP连接管理类 */ class TCPConnection { - constructor() { - this.channelConnections = new Map(); // 存储每个channel的连接状态 - this.connectionCallbacks = []; - this.messageCallbacks = []; - } + constructor() { + this.channelConnections = new Map(); // 存储每个channel的连接状态 + this.connectionCallbacks = []; + this.messageCallbacks = []; + } - /** - * TCP初始化连接 - * @param {Object} config - 连接配置 {ip, port, channel, charsetname} - * @param {Function} callback - 连接状态回调函数 - */ - connect(config = {}, callback = null) { - const channel = config.channel || TCP_CONFIG.channel; - - // 如果该channel已经连接,先断开现有连接 - if (this.channelConnections.get(channel)) { - console.log(`检测到channel ${channel}现有TCP连接,先断开...`); - this.disconnect(config); - // 等待断开完成后再连接 - setTimeout(() => { - this._performConnect(config, callback); - }, 300); - } else { - // 直接连接 - this._performConnect(config, callback); - } + /** + * TCP初始化连接 + * @param {Object} config - 连接配置 {ip, port, channel, charsetname} + * @param {Function} callback - 连接状态回调函数 + */ + connect(config = {}, callback = null) { + const channel = config.channel || TCP_CONFIG.channel; + + // 如果该channel已经连接,先断开现有连接 + if (this.channelConnections.get(channel)) { + console.log(`检测到channel ${channel}现有TCP连接,先断开...`); + this.disconnect(config); + // 等待断开完成后再连接 + setTimeout(() => { + this._performConnect(config, callback); + }, 300); + } else { + // 直接连接 + this._performConnect(config, callback); } + } /** * 执行TCP连接 @@ -66,33 +66,31 @@ class TCPConnection { connectionConfig.charsetname = config.charsetname || TCP_CONFIG.charsetname; } - console.log('开始建立TCP连接:', connectionConfig); - TCPSocket.connect( - connectionConfig, - result => { - /** - * status : 0 连接成功 - * status : 1 断开连接 - * receivedMsg : 服务器返回字符串(普通的字符串交互) - * receivedHexMsg : 服务器返回字节数组(单片机、智能家居等硬件数据交互) - */ - if (result.status == '0') { - // TCP连接成功 - this.channelConnections.set(connectionConfig.channel, true); - console.log(`TCP连接成功 - Channel ${connectionConfig.channel}`); - this._notifyConnectionCallbacks('connected', result, connectionConfig.channel); - } else if (result.status == '1') { - // TCP断开连接 - this.channelConnections.set(connectionConfig.channel, false); - console.log(`TCP断开连接 - Channel ${connectionConfig.channel}`); - this._notifyConnectionCallbacks('disconnected', result, connectionConfig.channel); - } + console.log("开始建立TCP连接:", connectionConfig); + TCPSocket.connect(connectionConfig, (result) => { + /** + * status : 0 连接成功 + * status : 1 断开连接 + * receivedMsg : 服务器返回字符串(普通的字符串交互) + * receivedHexMsg : 服务器返回字节数组(单片机、智能家居等硬件数据交互) + */ + if (result.status == "0") { + // TCP连接成功 + this.channelConnections.set(connectionConfig.channel, true); + console.log(`TCP连接成功 - Channel ${connectionConfig.channel}`); + this._notifyConnectionCallbacks("connected", result, connectionConfig.channel); + } else if (result.status == "1") { + // TCP断开连接 + this.channelConnections.set(connectionConfig.channel, false); + console.log(`TCP断开连接 - Channel ${connectionConfig.channel}`); + this._notifyConnectionCallbacks("disconnected", result, connectionConfig.channel); + } - if (result.receivedMsg) { - // 服务器返回字符串 - console.log('收到字符串消息:', result.receivedMsg); - this._notifyMessageCallbacks('string', result.receivedMsg, null, connectionConfig.channel); - } + if (result.receivedMsg) { + // 服务器返回字符串 + console.log("收到字符串消息:", result.receivedMsg); + this._notifyMessageCallbacks("string", result.receivedMsg, null, connectionConfig.channel); + } // if (result.receivedHexMsg) { // // 硬件服务器返回16进制数据 @@ -115,18 +113,18 @@ class TCPConnection { }); } - /** - * TCP发送消息(普通的字符串交互) - * @param {String|Object} message - 要发送的消息,如果是对象会自动转换为JSON字符串 - * @param {Object} config - 发送配置 {channel, charsetname} - */ - send(message, config = {}) { - const channel = config.channel || '1'; - - if (!this.channelConnections.get(channel)) { - console.warn(`TCP Channel ${channel}未连接,无法发送消息`); - return false; - } + /** + * TCP发送消息(普通的字符串交互) + * @param {String|Object} message - 要发送的消息,如果是对象会自动转换为JSON字符串 + * @param {Object} config - 发送配置 {channel, charsetname} + */ + send(message, config = {}) { + const channel = config.channel || "1"; + + if (!this.channelConnections.get(channel)) { + console.warn(`TCP Channel ${channel}未连接,无法发送消息`); + return false; + } // 如果message是对象,转换为JSON字符串 let messageStr = message; @@ -149,20 +147,20 @@ class TCPConnection { return true; } - /** - * TCP断开连接 - * @param {Object} config - 断开配置 {channel} - */ - disconnect(config = {}) { - const channel = config.channel || TCP_CONFIG.channel; - const disconnectConfig = { - channel: channel - }; + /** + * TCP断开连接 + * @param {Object} config - 断开配置 {channel} + */ + disconnect(config = {}) { + const channel = config.channel || TCP_CONFIG.channel; + const disconnectConfig = { + channel: channel, + }; - TCPSocket.disconnect(disconnectConfig); - this.channelConnections.set(channel, false); - console.log(`TCP连接已断开 - Channel ${channel}`, disconnectConfig); - } + TCPSocket.disconnect(disconnectConfig); + this.channelConnections.set(channel, false); + console.log(`TCP连接已断开 - Channel ${channel}`, disconnectConfig); + } /** * 添加连接状态监听器 @@ -206,50 +204,50 @@ class TCPConnection { } } - /** - * 获取连接状态 - * @param {String} channel - 要检查的channel,如果不指定则返回所有channel的连接状态 - * @returns {Boolean|Object} 连接状态 - */ - getConnectionStatus(channel = null) { - if (channel) { - return this.channelConnections.get(channel) || false; - } - // 返回所有channel的连接状态 - const allConnections = {}; - for (const [ch, status] of this.channelConnections) { - allConnections[ch] = status; - } - return allConnections; + /** + * 获取连接状态 + * @param {String} channel - 要检查的channel,如果不指定则返回所有channel的连接状态 + * @returns {Boolean|Object} 连接状态 + */ + getConnectionStatus(channel = null) { + if (channel) { + return this.channelConnections.get(channel) || false; } - - /** - * 通知连接状态回调 - * @private - */ - _notifyConnectionCallbacks(status, result, channel) { - this.connectionCallbacks.forEach(callback => { - try { - callback(status, result, channel); - } catch (error) { - console.error('连接状态回调执行错误:', error); - } - }); + // 返回所有channel的连接状态 + const allConnections = {}; + for (const [ch, status] of this.channelConnections) { + allConnections[ch] = status; } + return allConnections; + } - /** - * 通知消息回调 - * @private - */ - _notifyMessageCallbacks(type, message, parsedArray = null, channel = null) { - this.messageCallbacks.forEach(callback => { - try { - callback(type, message, parsedArray, channel); - } catch (error) { - console.error('消息回调执行错误:', error); - } - }); - } + /** + * 通知连接状态回调 + * @private + */ + _notifyConnectionCallbacks(status, result, channel) { + this.connectionCallbacks.forEach((callback) => { + try { + callback(status, result, channel); + } catch (error) { + console.error("连接状态回调执行错误:", error); + } + }); + } + + /** + * 通知消息回调 + * @private + */ + _notifyMessageCallbacks(type, message, parsedArray = null, channel = null) { + this.messageCallbacks.forEach((callback) => { + try { + callback(type, message, parsedArray, channel); + } catch (error) { + console.error("消息回调执行错误:", error); + } + }); + } } // 创建TCP连接实例 diff --git a/components/IndexCard.vue b/components/IndexCard.vue index ad1ae69..69a3de3 100644 --- a/components/IndexCard.vue +++ b/components/IndexCard.vue @@ -64,7 +64,6 @@ const props = defineProps({ }); const getMarketFlag = (market) => { - console.log("market", market); let imagePath; if (market === "cn") { @@ -86,8 +85,6 @@ const getMarketFlag = (market) => { } else { imagePath = "/static/marketSituation-image/country-flag/global.png"; } - - console.log("返回的图片路径:", imagePath); return imagePath; }; diff --git a/components/MarketOverview.vue b/components/MarketOverview.vue index c5f56a1..31c04df 100644 --- a/components/MarketOverview.vue +++ b/components/MarketOverview.vue @@ -47,7 +47,7 @@ 市场风险评级: 需警惕潜在风险 - + 早盘解析: 今日高开, 芯片、稀土、公共 @@ -142,6 +142,12 @@ export default { } }, methods: { + // 跳转到早盘解析页面 + goToMorningAnalysis() { + uni.navigateTo({ + url: '/pages/morningMarketAnalysis/morningMarketAnalysis' + }) + }, showMarketSelector() { // 切换显示外汇市场内容 this.showForexMarket = !this.showForexMarket; diff --git a/components/SharePopup.vue b/components/SharePopup.vue new file mode 100644 index 0000000..f335949 --- /dev/null +++ b/components/SharePopup.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/manifest.json b/manifest.json index ee97510..83f218b 100644 --- a/manifest.json +++ b/manifest.json @@ -17,7 +17,8 @@ "delay" : 0 }, "modules" : { - "OAuth" : {} + "OAuth" : {}, + "Share" : {} }, /* 模块配置 */ "distribute" : { @@ -53,6 +54,12 @@ "google" : { "clientid" : "135" } + }, + "share" : { + "weixin" : { + "appid" : "wx6143d111fc5c9ba3", + "UniversalLinks" : "" + } } } }, diff --git a/pages.json b/pages.json index 8549911..bcb036c 100644 --- a/pages.json +++ b/pages.json @@ -88,6 +88,13 @@ } }, { + "path" : "pages/morningMarketAnalysis/morningMarketAnalysis", + "style" : + { + "navigationBarTitleText" : "早盘解析" + } + }, + { "path": "pages/marketSituation/marketSituation", "style": { "navigationStyle": "custom", @@ -331,6 +338,29 @@ "titleNView": false, "bounce": false } + }, + { + "path" : "pages/analysisInstitutionalTrends/analysisInstitutionalTrends", + "style" : + { + "navigationBarTitleText" : "机构动向解析 " + } + }, + { + "path" : "pages/customStockList/customStockList", + "style" : + { + "navigationBarTitleText" : "我的自选", + "app-plus": { + "titleNView": false + }, + "h5": { + "titleNView": false + }, + "mp-weixin": { + "navigationStyle": "custom" + } + } } ], diff --git a/pages/analysisInstitutionalTrends/analysisInstitutionalTrends.vue b/pages/analysisInstitutionalTrends/analysisInstitutionalTrends.vue new file mode 100644 index 0000000..bd8dc48 --- /dev/null +++ b/pages/analysisInstitutionalTrends/analysisInstitutionalTrends.vue @@ -0,0 +1,55 @@ + + + + + \ No newline at end of file diff --git a/pages/customStockList/customStockList.vue b/pages/customStockList/customStockList.vue new file mode 100644 index 0000000..33cb034 --- /dev/null +++ b/pages/customStockList/customStockList.vue @@ -0,0 +1,147 @@ + + + + + + + diff --git a/pages/home/home.vue b/pages/home/home.vue index 3abff99..8ffaa85 100644 --- a/pages/home/home.vue +++ b/pages/home/home.vue @@ -81,7 +81,7 @@ 我的自选 - 添加自选股 + 添加自选股 - + {{ item.ac }} @@ -41,7 +41,7 @@ - + @@ -65,11 +65,12 @@ +.content { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; +} + +.no-data-image { + width: 200px; + height: 200px; + margin-bottom: 20px; +} + +.no-data-text { + font-size: 16px; + color: #999999; + text-align: center; +} + \ No newline at end of file diff --git a/pages/setting/share.vue b/pages/setting/share.vue index 78bf6f8..4fc7447 100644 --- a/pages/setting/share.vue +++ b/pages/setting/share.vue @@ -1,111 +1,299 @@ - \ No newline at end of file + diff --git a/static/my/share/KakaoTalk.png b/static/my/share/KakaoTalk.png new file mode 100644 index 0000000..91f9f8f Binary files /dev/null and b/static/my/share/KakaoTalk.png differ diff --git a/static/my/share/Line.png b/static/my/share/Line.png new file mode 100644 index 0000000..e899f1f Binary files /dev/null and b/static/my/share/Line.png differ diff --git a/static/my/share/WeChat.png b/static/my/share/WeChat.png new file mode 100644 index 0000000..27069da Binary files /dev/null and b/static/my/share/WeChat.png differ diff --git a/static/my/share/WhatsApp.png b/static/my/share/WhatsApp.png new file mode 100644 index 0000000..3133f75 Binary files /dev/null and b/static/my/share/WhatsApp.png differ diff --git a/static/my/share/share.png b/static/my/share/share.png new file mode 100644 index 0000000..c947750 Binary files /dev/null and b/static/my/share/share.png differ diff --git a/static/my/share/success.png b/static/my/share/success.png new file mode 100644 index 0000000..aa4754c Binary files /dev/null and b/static/my/share/success.png differ diff --git a/stores/modules/marketSituation.js b/stores/modules/marketSituation.js index 1f85660..2ae69fe 100644 --- a/stores/modules/marketSituation.js +++ b/stores/modules/marketSituation.js @@ -6,57 +6,14 @@ import { ref } from "vue"; 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, - }, - ]); - + const cardData = ref([]); + const gloablCardData = ref([]); + const marketDetailCardData = ref([]); // 记得 return return { - cardData + cardData, + gloablCardData, + marketDetailCardData, }; }, // TODO: 持久化 diff --git a/utils/http.js b/utils/http.js index e2928d3..dcae7e5 100644 --- a/utils/http.js +++ b/utils/http.js @@ -3,7 +3,7 @@ import { useDeviceStore } from "../stores/modules/deviceInfo" import { useLoginStore } from "../stores/modules/login" const baseURL = "https://dbqb.nfdxy.net/testApi" -// const baseURL = "http://192.168.40.8:9000" + const httpInterceptor = { // 拦截前触发 @@ -44,7 +44,8 @@ const httpInterceptor = { //4 添加token,优先用store,没有则回退到body中的token,保持与Apifox一致 const memberStore = useUserStore() const token = memberStore.userInfo?.token || options.data?.token - // const token = 'a72cf584af42525f214670cb47443820' + // const token = '2d0b5654409646713cdd40ec0d0bb56c' + // const token = '1b3a58424c5324e40d4bf4d085e18047' if (token) { options.header.token = token }