|
|
|
@ -1,3 +1,5 @@ |
|
|
|
<!-- @format --> |
|
|
|
|
|
|
|
<template> |
|
|
|
<view class="main"> |
|
|
|
<!-- 固定头部 --> |
|
|
|
@ -7,11 +9,8 @@ |
|
|
|
<image src="/static/marketSituation-image/back.png" mode=""></image> |
|
|
|
</view> |
|
|
|
<view class="header_input_wrapper"> |
|
|
|
<image class="search_icon" src="/static/marketSituation-image/search.png" mode="" |
|
|
|
@click="onSearchClick"></image> |
|
|
|
<input class="header_input" type="text" placeholder="搜索" |
|
|
|
placeholder-style="color: #A6A6A6; font-size: 22rpx;" v-model="searchValue" |
|
|
|
@input="onSearchInput" @confirm="onSearchConfirm" /> |
|
|
|
<image class="search_icon" src="/static/marketSituation-image/search.png" mode="" @click="onSearchClick"></image> |
|
|
|
<input class="header_input" type="text" placeholder="搜索" placeholder-style="color: #A6A6A6; font-size: 22rpx;" v-model="searchValue" @input="onSearchInput" @confirm="onSearchConfirm" /> |
|
|
|
</view> |
|
|
|
<view class="header_icons"> |
|
|
|
<view class="header_icon" @click="selected"> |
|
|
|
@ -25,7 +24,7 @@ |
|
|
|
<view class="warn"> |
|
|
|
<image src="/static/marketSituation-image/warn.png" mode="aspectFit"></image> |
|
|
|
<view class="warn_text_container"> |
|
|
|
<text :class="warnTextClass">{{ $t('marketSituation.warn') }}</text> |
|
|
|
<text :class="warnTextClass">{{ $t("marketSituation.warn") }}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -33,58 +32,25 @@ |
|
|
|
<!-- 内容区域 --> |
|
|
|
<scroll-view class="content" :style="{ top: contentTopPosition + 'px' }" scroll-y="true"> |
|
|
|
<!-- 亚太-中华 --> |
|
|
|
<view class="market-section"> |
|
|
|
<view class="market-header"> |
|
|
|
<text class="market-title">亚太-中华</text> |
|
|
|
<view class="market-more" @click="viewMore('asia-china')"> |
|
|
|
<text class="more-text">查看更多</text> |
|
|
|
<text class="more-arrow">></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="cards-grid-three"> |
|
|
|
<view v-for="(item, index) in asiachinaIndexes" :key="index" class="card-item"> |
|
|
|
<IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName" |
|
|
|
:currentPrice="item.currentPrice" :changeAmount="item.changeAmount" |
|
|
|
:changePercent="item.changePercent" :isRising="item.isRising" |
|
|
|
@click="viewIndexDetail(item)" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 亚太 --> |
|
|
|
<view class="market-section"> |
|
|
|
<view class="market-section" v-for="item in globalIndexArray" :key="item"> |
|
|
|
<view class="market-header"> |
|
|
|
<text class="market-title">亚太</text> |
|
|
|
<view class="market-more" @click="viewMore('asia')"> |
|
|
|
<text class="market-title">{{ item.ac }}</text> |
|
|
|
<view class="market-more" @click="viewMore(item.ac)"> |
|
|
|
<text class="more-text">查看更多</text> |
|
|
|
<text class="more-arrow">></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="cards-grid-three"> |
|
|
|
<view v-for="(item, index) in asiaIndexes" :key="index" class="card-item"> |
|
|
|
<IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName" |
|
|
|
:currentPrice="item.currentPrice" :changeAmount="item.changeAmount" |
|
|
|
:changePercent="item.changePercent" :isRising="item.isRising" |
|
|
|
@click="viewIndexDetail(item)" /> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<!-- 美洲 --> |
|
|
|
<view class="market-section"> |
|
|
|
<view class="market-header"> |
|
|
|
<text class="market-title">美洲</text> |
|
|
|
<view class="market-more" @click="viewMore('america')"> |
|
|
|
<text class="more-text">查看更多</text> |
|
|
|
<text class="more-arrow">></text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="cards-grid-three"> |
|
|
|
<view v-for="(item, index) in americaIndexes" :key="index" class="card-item"> |
|
|
|
<IndexCard :flagIcon="item.flagIcon" :stockName="item.stockName" |
|
|
|
:currentPrice="item.currentPrice" :changeAmount="item.changeAmount" |
|
|
|
:changePercent="item.changePercent" :isRising="item.isRising" |
|
|
|
@click="viewIndexDetail(item)" /> |
|
|
|
<view v-for="iitem in item.list" :key="iitem" class="card-item"> |
|
|
|
<IndexCard |
|
|
|
:market="iitem.market" |
|
|
|
:stockName="iitem.name" |
|
|
|
:currentPrice="iitem.currentPrice" |
|
|
|
:changeAmount="iitem.changeAmount" |
|
|
|
:changePercent="iitem.changePercent" |
|
|
|
:isRising="iitem.isRising" |
|
|
|
@click="viewIndexDetail(iitem)" |
|
|
|
/> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
@ -99,201 +65,202 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
|
import { ref, onMounted, computed, nextTick, watch } from 'vue' |
|
|
|
import footerBar from '../../components/footerBar.vue' |
|
|
|
import IndexCard from '../../components/IndexCard.vue' |
|
|
|
import { ref, onMounted, computed, nextTick, watch } from "vue"; |
|
|
|
import footerBar from "../../components/footerBar.vue"; |
|
|
|
import IndexCard from "../../components/IndexCard.vue"; |
|
|
|
import { getRegionalGroupAPI } from "../../api/marketSituation/marketSituation.js"; |
|
|
|
|
|
|
|
// 响应式数据 |
|
|
|
const iSMT = ref(0) // 状态栏高度 |
|
|
|
const contentHeight = ref(0) |
|
|
|
const headerHeight = ref(0) // 头部高度 |
|
|
|
const searchValue = ref('') // 搜索值 |
|
|
|
const isWarnTextOverflow = ref(false) // warn文字是否溢出 |
|
|
|
const iSMT = ref(0); // 状态栏高度 |
|
|
|
const contentHeight = ref(0); |
|
|
|
const headerHeight = ref(0); // 头部高度 |
|
|
|
const searchValue = ref(""); // 搜索值 |
|
|
|
const isWarnTextOverflow = ref(false); // warn文字是否溢出 |
|
|
|
|
|
|
|
// warn文字的class计算属性 |
|
|
|
const warnTextClass = computed(() => { |
|
|
|
return isWarnTextOverflow.value ? 'warn_text scroll-active' : 'warn_text' |
|
|
|
}) |
|
|
|
return isWarnTextOverflow.value ? "warn_text scroll-active" : "warn_text"; |
|
|
|
}); |
|
|
|
|
|
|
|
// 检测warn文字是否溢出 |
|
|
|
const checkWarnTextOverflow = () => { |
|
|
|
nextTick(() => { |
|
|
|
setTimeout(() => { |
|
|
|
const query = uni.createSelectorQuery() |
|
|
|
const query = uni.createSelectorQuery(); |
|
|
|
|
|
|
|
// 同时查询容器和文字元素 |
|
|
|
query.select('.warn_text_container').boundingClientRect() |
|
|
|
query.select('.warn_text').boundingClientRect() |
|
|
|
query.select(".warn_text_container").boundingClientRect(); |
|
|
|
query.select(".warn_text").boundingClientRect(); |
|
|
|
query.exec((res) => { |
|
|
|
const containerRect = res[0] |
|
|
|
const textRect = res[1] |
|
|
|
const containerRect = res[0]; |
|
|
|
const textRect = res[1]; |
|
|
|
|
|
|
|
if (!containerRect || !textRect) { |
|
|
|
return |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 判断文字是否超出容器(留一些余量) |
|
|
|
const isOverflow = textRect.width > (containerRect.width - 10) |
|
|
|
|
|
|
|
isWarnTextOverflow.value = isOverflow |
|
|
|
}) |
|
|
|
}, 500) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const isOverflow = textRect.width > containerRect.width - 10; |
|
|
|
|
|
|
|
isWarnTextOverflow.value = isOverflow; |
|
|
|
}); |
|
|
|
}, 500); |
|
|
|
}); |
|
|
|
}; |
|
|
|
const globalIndexArray = ref([]); |
|
|
|
// 亚太-中华指数数据 |
|
|
|
const asiachinaIndexes = ref([ |
|
|
|
{ |
|
|
|
flagIcon: '/static/c1.png', |
|
|
|
stockName: '上证指数', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '3933.96', |
|
|
|
changeAmount: '+24.32', |
|
|
|
changePercent: '+0.62%', |
|
|
|
isRising: true |
|
|
|
flagIcon: "/static/c1.png", |
|
|
|
stockName: "上证指数", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "3933.96", |
|
|
|
changeAmount: "+24.32", |
|
|
|
changePercent: "+0.62%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c2.png', |
|
|
|
stockName: '深证成指', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '45757.90', |
|
|
|
changeAmount: '-123.45', |
|
|
|
changePercent: '-0.27%', |
|
|
|
isRising: false |
|
|
|
flagIcon: "/static/c2.png", |
|
|
|
stockName: "深证成指", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "45757.90", |
|
|
|
changeAmount: "-123.45", |
|
|
|
changePercent: "-0.27%", |
|
|
|
isRising: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c3.png', |
|
|
|
stockName: '创业板指', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '6606.08', |
|
|
|
changeAmount: '+89.76', |
|
|
|
changePercent: '+1.38%', |
|
|
|
isRising: true |
|
|
|
flagIcon: "/static/c3.png", |
|
|
|
stockName: "创业板指", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "6606.08", |
|
|
|
changeAmount: "+89.76", |
|
|
|
changePercent: "+1.38%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c4.png', |
|
|
|
stockName: 'HSI50', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '22333.96', |
|
|
|
changeAmount: '+156.78', |
|
|
|
changePercent: '+0.71%', |
|
|
|
isRising: true |
|
|
|
flagIcon: "/static/c4.png", |
|
|
|
stockName: "HSI50", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "22333.96", |
|
|
|
changeAmount: "+156.78", |
|
|
|
changePercent: "+0.71%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c5.png', |
|
|
|
stockName: '沪深300', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '45757.90', |
|
|
|
changeAmount: '-89.12', |
|
|
|
changePercent: '-0.19%', |
|
|
|
isRising: false |
|
|
|
flagIcon: "/static/c5.png", |
|
|
|
stockName: "沪深300", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "45757.90", |
|
|
|
changeAmount: "-89.12", |
|
|
|
changePercent: "-0.19%", |
|
|
|
isRising: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c6.png', |
|
|
|
stockName: '上证50', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '45757.90', |
|
|
|
changeAmount: '+234.56', |
|
|
|
changePercent: '+0.52%', |
|
|
|
isRising: true |
|
|
|
} |
|
|
|
]) |
|
|
|
flagIcon: "/static/c6.png", |
|
|
|
stockName: "上证50", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "45757.90", |
|
|
|
changeAmount: "+234.56", |
|
|
|
changePercent: "+0.52%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
]); |
|
|
|
|
|
|
|
// 亚太指数数据 |
|
|
|
const asiaIndexes = ref([ |
|
|
|
{ |
|
|
|
flagIcon: '/static/c7.png', |
|
|
|
stockName: '日经225', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '28456.78', |
|
|
|
changeAmount: '+234.56', |
|
|
|
changePercent: '+0.83%', |
|
|
|
isRising: true |
|
|
|
flagIcon: "/static/c7.png", |
|
|
|
stockName: "日经225", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "28456.78", |
|
|
|
changeAmount: "+234.56", |
|
|
|
changePercent: "+0.83%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c8.png', |
|
|
|
stockName: '韩国KOSPI', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '2567.89', |
|
|
|
changeAmount: '-12.34', |
|
|
|
changePercent: '-0.48%', |
|
|
|
isRising: false |
|
|
|
flagIcon: "/static/c8.png", |
|
|
|
stockName: "韩国KOSPI", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "2567.89", |
|
|
|
changeAmount: "-12.34", |
|
|
|
changePercent: "-0.48%", |
|
|
|
isRising: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c9.png', |
|
|
|
stockName: '印度孟买', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '65432.10', |
|
|
|
changeAmount: '+456.78', |
|
|
|
changePercent: '+0.70%', |
|
|
|
isRising: true |
|
|
|
} |
|
|
|
]) |
|
|
|
flagIcon: "/static/c9.png", |
|
|
|
stockName: "印度孟买", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "65432.10", |
|
|
|
changeAmount: "+456.78", |
|
|
|
changePercent: "+0.70%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
]); |
|
|
|
|
|
|
|
// 美洲指数数据 |
|
|
|
const americaIndexes = ref([ |
|
|
|
{ |
|
|
|
flagIcon: '/static/c7.png', |
|
|
|
stockName: '道琼斯指数', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '34567.89', |
|
|
|
changeAmount: '+123.45', |
|
|
|
changePercent: '+0.36%', |
|
|
|
isRising: true |
|
|
|
flagIcon: "/static/c7.png", |
|
|
|
stockName: "道琼斯指数", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "34567.89", |
|
|
|
changeAmount: "+123.45", |
|
|
|
changePercent: "+0.36%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c8.png', |
|
|
|
stockName: '纳斯达克', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '13456.78', |
|
|
|
changeAmount: '-67.89', |
|
|
|
changePercent: '-0.50%', |
|
|
|
isRising: false |
|
|
|
flagIcon: "/static/c8.png", |
|
|
|
stockName: "纳斯达克", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "13456.78", |
|
|
|
changeAmount: "-67.89", |
|
|
|
changePercent: "-0.50%", |
|
|
|
isRising: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
flagIcon: '/static/c9.png', |
|
|
|
stockName: '标普500', |
|
|
|
stockCode:'noCode', |
|
|
|
currentPrice: '4234.56', |
|
|
|
changeAmount: '+23.45', |
|
|
|
changePercent: '+0.56%', |
|
|
|
isRising: true |
|
|
|
} |
|
|
|
]) |
|
|
|
flagIcon: "/static/c9.png", |
|
|
|
stockName: "标普500", |
|
|
|
stockCode: "noCode", |
|
|
|
currentPrice: "4234.56", |
|
|
|
changeAmount: "+23.45", |
|
|
|
changePercent: "+0.56%", |
|
|
|
isRising: true, |
|
|
|
}, |
|
|
|
]); |
|
|
|
|
|
|
|
// 计算属性:内容区域顶部位置 |
|
|
|
const contentTopPosition = computed(() => { |
|
|
|
const statusBarHeight = iSMT.value || 0 |
|
|
|
const currentHeaderHeight = headerHeight.value > 0 ? headerHeight.value : 100 |
|
|
|
return statusBarHeight + currentHeaderHeight |
|
|
|
}) |
|
|
|
const statusBarHeight = iSMT.value || 0; |
|
|
|
const currentHeaderHeight = headerHeight.value > 0 ? headerHeight.value : 100; |
|
|
|
return statusBarHeight + currentHeaderHeight; |
|
|
|
}); |
|
|
|
|
|
|
|
// 方法:返回上一页 |
|
|
|
const goBack = () => { |
|
|
|
uni.navigateBack() |
|
|
|
} |
|
|
|
uni.navigateBack(); |
|
|
|
}; |
|
|
|
|
|
|
|
// 方法:搜索输入 |
|
|
|
const onSearchInput = (e) => { |
|
|
|
searchValue.value = e.detail.value |
|
|
|
} |
|
|
|
searchValue.value = e.detail.value; |
|
|
|
}; |
|
|
|
|
|
|
|
// 方法:清除搜索 |
|
|
|
const clearSearch = () => { |
|
|
|
searchValue.value = '' |
|
|
|
} |
|
|
|
searchValue.value = ""; |
|
|
|
}; |
|
|
|
|
|
|
|
// 方法:查看更多 |
|
|
|
const viewMore = (market) => { |
|
|
|
console.log('查看更多:', market) |
|
|
|
console.log("查看更多:", market); |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/marketSituation/marketDetail?market=${market}` |
|
|
|
}) |
|
|
|
} |
|
|
|
url: `/pages/marketSituation/marketDetail?market=${market}`, |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
// 方法:查看指数详情 |
|
|
|
const viewIndexDetail = (item) => { |
|
|
|
console.log('查看指数详情:', item.stockName) |
|
|
|
console.log("查看指数详情:", item.stockName); |
|
|
|
// uni.showToast({ |
|
|
|
// title: `查看 ${item.stockName} 详情`, |
|
|
|
// icon: 'none', |
|
|
|
@ -301,40 +268,54 @@ const viewIndexDetail = (item) => { |
|
|
|
// }) |
|
|
|
// 这里可以跳转到具体的指数详情页面 |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}` |
|
|
|
}) |
|
|
|
url: `/pages/marketSituation/marketCondition?stockInformation=${encodeURIComponent(JSON.stringify(item))}`, |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const getRegionalGroup = async () => { |
|
|
|
try { |
|
|
|
const result = await getRegionalGroupAPI(); |
|
|
|
globalIndexArray.value = result.data; |
|
|
|
} catch (e) { |
|
|
|
console.log("获取区域指数失败", e); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 生命周期:页面挂载 |
|
|
|
onMounted(() => { |
|
|
|
onMounted(async () => { |
|
|
|
await getRegionalGroup(); |
|
|
|
// 获取系统信息 |
|
|
|
const systemInfo = uni.getSystemInfoSync() |
|
|
|
iSMT.value = systemInfo.statusBarHeight || 0 |
|
|
|
const systemInfo = uni.getSystemInfoSync(); |
|
|
|
iSMT.value = systemInfo.statusBarHeight || 0; |
|
|
|
|
|
|
|
console.log('全球指数页面加载完成') |
|
|
|
console.log("全球指数页面加载完成"); |
|
|
|
// 动态计算header实际高度 |
|
|
|
uni.createSelectorQuery().select('.header_fixed').boundingClientRect((rect) => { |
|
|
|
uni |
|
|
|
.createSelectorQuery() |
|
|
|
.select(".header_fixed") |
|
|
|
.boundingClientRect((rect) => { |
|
|
|
if (rect) { |
|
|
|
headerHeight.value = rect.height |
|
|
|
console.log('Header实际高度:', headerHeight.value, 'px') |
|
|
|
headerHeight.value = rect.height; |
|
|
|
console.log("Header实际高度:", headerHeight.value, "px"); |
|
|
|
} |
|
|
|
}).exec() |
|
|
|
// 检测warn文字是否溢出 |
|
|
|
checkWarnTextOverflow() |
|
|
|
}) |
|
|
|
.exec(); |
|
|
|
// 检测warn文字是否溢出 |
|
|
|
checkWarnTextOverflow(); |
|
|
|
}); |
|
|
|
|
|
|
|
// 监听headerHeight变化,重新计算contentHeight |
|
|
|
watch(headerHeight, (newHeight) => { |
|
|
|
if (newHeight > 0) { |
|
|
|
const systemInfo = uni.getSystemInfoSync() |
|
|
|
const windowHeight = systemInfo.windowHeight |
|
|
|
const statusBarHeight = systemInfo.statusBarHeight || 0 |
|
|
|
const footerHeight = 100 |
|
|
|
const systemInfo = uni.getSystemInfoSync(); |
|
|
|
const windowHeight = systemInfo.windowHeight; |
|
|
|
const statusBarHeight = systemInfo.statusBarHeight || 0; |
|
|
|
const footerHeight = 100; |
|
|
|
|
|
|
|
contentHeight.value = windowHeight - statusBarHeight - newHeight - footerHeight |
|
|
|
console.log('重新计算contentHeight:', contentHeight.value) |
|
|
|
contentHeight.value = windowHeight - statusBarHeight - newHeight - footerHeight; |
|
|
|
console.log("重新计算contentHeight:", contentHeight.value); |
|
|
|
} |
|
|
|
}) |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
|
@ -430,7 +411,6 @@ watch(headerHeight, (newHeight) => { |
|
|
|
height: 40rpx; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.warn { |
|
|
|
display: flex; |
|
|
|
align-items: center; |
|
|
|
|