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/components/IndexCard.vue b/components/IndexCard.vue
index 24d0e7e..ad1ae69 100644
--- a/components/IndexCard.vue
+++ b/components/IndexCard.vue
@@ -1,190 +1,220 @@
+
+
-
-
-
-
- {{ currentPrice }}
-
- {{ changeAmount }}
- {{ changePercent }}
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ {{ currentPrice }}
+
+ {{ changeAmount }}
+ {{ changePercent }}
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
+
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 @@
+
+
-
-
-
-
- {{ tab }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 今日市场情绪温度
-
-
-
-
-
- {{ m.value }}°C
- {{ m.label }}
-
-
-
-
-
-
-
-
-
-
-
-
- {{ sec.price }}
-
-
-
-
-
-
-
-
-
-
-
- {{ stk.name }}
- {{ stk.code }}
-
-
- {{ stk.price }}
-
-
-
- {{ stk.change }}
-
-
-
-
-
-
-
-
-
+
+
+
+
+ {{ tab }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 今日市场情绪温度
+
+
+
+
+
+ {{ m.value }}°C
+ {{ m.label }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ sec.price }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ stk.name }}
+ {{ stk.code }}
+
+
+ {{ stk.price }}
+
+
+
+ {{ stk.change }}
+
+
+
+
+
+
+
+
+
\ 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..1c559b2 100644
--- a/pages/marketSituation/marketDetail.vue
+++ b/pages/marketSituation/marketDetail.vue
@@ -1,481 +1,478 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
- {{ stock.stockName }}
- {{ stock.stockCode }}
-
-
-
- {{ typeof stock.price === 'number' ? stock.price.toFixed(2) : stock.price }}
-
-
-
-
- {{ stock.change || stock.changePercent }}
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ {{ stock.stockName }}
+ {{ stock.stockCode }}
+
+
+
+ {{ typeof stock.price === "number" ? stock.price.toFixed(2) : stock.price }}
+
+
+
+
+ {{ stock.change || stock.changePercent }}
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 @@
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ country }}
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ item.title }}
+
+
+
+
+
+
\ No newline at end of file
+
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/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);
+ },
+ },
+ },
+ }
+);