feat:
1. 用户个人信息优化,增加不同类型的流水查询入口
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 243 KiB After Width: | Height: | Size: 48 KiB |
@@ -7,27 +7,43 @@
|
|||||||
|
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<basic-container>
|
<basic-container>
|
||||||
<p style="text-align: center">
|
<div class="dashboard-header">
|
||||||
<img src="https://img.shields.io/badge/Release-V4.8.0-green.svg" alt="Downloads" />
|
<!-- 品牌区 -->
|
||||||
<img src="https://img.shields.io/badge/JDK-17+-green.svg" alt="Build Status" />
|
<div class="brand-area">
|
||||||
<img
|
<img src="/img/logo.png" alt="亿茶一路" class="logo"/>
|
||||||
src="https://img.shields.io/badge/Spring%20Cloud-2025-blue.svg"
|
<div class="title-group">
|
||||||
alt="Coverage Status"
|
<h1 class="main-title">亿茶一路</h1>
|
||||||
/>
|
<p class="slogan">贡茶有硒 · 黑茶有亿</p>
|
||||||
<img src="https://img.shields.io/badge/Spring%20Boot-3.5-blue.svg" alt="Downloads" />
|
</div>
|
||||||
<a target="_blank" href="https://bladex.cn">
|
</div>
|
||||||
<img
|
|
||||||
src="https://img.shields.io/badge/Saber%20Author-Small%20Chill-ff69b4.svg"
|
<!-- 天气+日期信息 -->
|
||||||
alt="Downloads"
|
<div class="info-area" v-if="!loading">
|
||||||
/>
|
|
||||||
</a>
|
<div v-if="locationInfo" class="location-line">
|
||||||
<a target="_blank" href="https://bladex.cn">
|
{{ displayLocation }}
|
||||||
<img
|
</div>
|
||||||
src="https://img.shields.io/badge/Copyright%20-@BladeX-%23ff3f59.svg"
|
<div v-else class="location-line error">位置未知</div>
|
||||||
alt="Downloads"
|
<div class="weather-date-line">
|
||||||
/>
|
<span v-if="weatherData" class="weather-item">
|
||||||
</a>
|
{{ weatherData.temp }}°C · {{ weatherData.text }}
|
||||||
</p>
|
</span>
|
||||||
|
<span v-else class="weather-item error">天气加载失败</span>
|
||||||
|
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
icon="el-icon-refresh"
|
||||||
|
link
|
||||||
|
@click="refreshWeather"
|
||||||
|
style="margin-left: 6px; padding: 2px;"
|
||||||
|
></el-button>
|
||||||
|
|
||||||
|
<span class="divider">·</span>
|
||||||
|
<span class="date-item">{{ currentDate }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="loading">加载中...</div>
|
||||||
|
</div>
|
||||||
</basic-container>
|
</basic-container>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="15">
|
<el-col :span="15">
|
||||||
@@ -54,27 +70,285 @@
|
|||||||
<script>
|
<script>
|
||||||
import {mapGetters} from 'vuex';
|
import {mapGetters} from 'vuex';
|
||||||
|
|
||||||
|
const QWEATHER_KEY = '977c0d0cdeaf497196d834579a8eddee';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'wel',
|
name: 'wel',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
activeNames: ['1', '2', '3', '5'],
|
activeNames: ['1', '2', '3', '5'],
|
||||||
logActiveNames: ['44'],
|
logActiveNames: ['44'],
|
||||||
|
loading: true,
|
||||||
|
weatherData: {},
|
||||||
|
locationInfo: null,
|
||||||
|
currentDate: '',
|
||||||
|
weatherUpdateTimer: null,
|
||||||
|
cachedPosition: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters(['userInfo']),
|
...mapGetters(['userInfo']),
|
||||||
|
displayLocation() {
|
||||||
|
const loc = this.locationInfo;
|
||||||
|
if (!loc) return '位置未知';
|
||||||
|
const parts = [loc.adm1];
|
||||||
|
if (loc.adm2 !== loc.name) parts.push(loc.adm2);
|
||||||
|
parts.push(loc.name);
|
||||||
|
return parts.join(' · ');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
async mounted() {
|
||||||
|
this.updateDate();
|
||||||
|
await this.autoGetWeatherByCurrentLocation(); // 首次加载
|
||||||
|
// 启动定时刷新:每 10 分钟更新一次天气(可调整)
|
||||||
|
this.weatherUpdateTimer = setInterval(() => {
|
||||||
|
this.autoGetWeatherByCurrentLocation();
|
||||||
|
}, 120 * 60 * 1000); // 120分钟
|
||||||
|
},
|
||||||
|
beforeUnmount() {
|
||||||
|
if (this.weatherUpdateTimer) {
|
||||||
|
clearInterval(this.weatherUpdateTimer);
|
||||||
|
this.weatherUpdateTimer = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleChange(val) {
|
handleIconError() {
|
||||||
window.console.log(val);
|
console.warn('SVG 图标加载失败,可考虑切换 PNG');
|
||||||
|
// 可选:动态替换为 PNG
|
||||||
|
// this.$el.querySelector('.weather-icon').src = ...png...
|
||||||
|
},
|
||||||
|
refreshWeather() {
|
||||||
|
this.autoGetWeatherByCurrentLocation();
|
||||||
|
},
|
||||||
|
// 获取用户当前位置
|
||||||
|
async getCurrentLocation() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!navigator.geolocation) {
|
||||||
|
reject(new Error('浏览器不支持定位'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 启用高精度(可选)
|
||||||
|
const options = {
|
||||||
|
enableHighAccuracy: true, // 尝试使用 GPS(更精确但耗电)
|
||||||
|
timeout: 10000, // 10秒超时
|
||||||
|
maximumAge: 60000 // 接受1分钟内的缓存位置
|
||||||
|
};
|
||||||
|
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
(position) => {
|
||||||
|
const {latitude, longitude} = position.coords;
|
||||||
|
resolve({lat: latitude, lng: longitude});
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
let message = '无法获取位置';
|
||||||
|
switch (error.code) {
|
||||||
|
case error.PERMISSION_DENIED:
|
||||||
|
message = '用户拒绝了位置请求';
|
||||||
|
break;
|
||||||
|
case error.POSITION_UNAVAILABLE:
|
||||||
|
message = '位置信息不可用';
|
||||||
|
break;
|
||||||
|
case error.TIMEOUT:
|
||||||
|
message = '获取位置超时';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
reject(new Error(message));
|
||||||
|
},
|
||||||
|
options
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 调用示例:自动获取位置并查询天气
|
||||||
|
async autoGetWeatherByCurrentLocation() {
|
||||||
|
try {
|
||||||
|
this.loading = true;
|
||||||
|
|
||||||
|
let position;
|
||||||
|
if (this.cachedPosition) {
|
||||||
|
position = this.cachedPosition;
|
||||||
|
} else {
|
||||||
|
position = await this.getCurrentLocation();
|
||||||
|
this.cachedPosition = position; // 缓存
|
||||||
|
}
|
||||||
|
|
||||||
|
const {lat, lng} = position;
|
||||||
|
|
||||||
|
// 第一步:用经纬度查城市
|
||||||
|
const geoRes = await fetch(
|
||||||
|
`https://p25khwy3xa.re.qweatherapi.com/geo/v2/city/lookup?location=${lng},${lat}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'X-QW-Api-Key': QWEATHER_KEY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const geoData = await geoRes.json();
|
||||||
|
|
||||||
|
if (geoData.code !== '200' || !geoData.location?.[0]) {
|
||||||
|
throw new Error('未找到当前位置对应的城市');
|
||||||
|
}
|
||||||
|
|
||||||
|
const locationId = geoData.location[0].id;
|
||||||
|
|
||||||
|
this.locationInfo = geoData.location[0];
|
||||||
|
|
||||||
|
// 第二步:查天气
|
||||||
|
const weatherRes = await fetch(
|
||||||
|
`https://p25khwy3xa.re.qweatherapi.com/v7/weather/now?location=${locationId}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'X-QW-Api-Key': QWEATHER_KEY
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const weatherData = await weatherRes.json();
|
||||||
|
|
||||||
|
if (weatherData.code === '200') {
|
||||||
|
this.weatherData = weatherData.now;
|
||||||
|
} else {
|
||||||
|
throw new Error(weatherData.message || '天气数据异常');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('自动定位天气失败:', err);
|
||||||
|
this.weatherData = {temp: '--', icon: '100', text: '定位失败'};
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
updateDate() {
|
||||||
|
const now = new Date();
|
||||||
|
const week = ['日', '一', '二', '三', '四', '五', '六'][now.getDay()];
|
||||||
|
this.currentDate = `${now.getFullYear()}年${String(now.getMonth() + 1).padStart(2, '0')}月${String(now.getDate()).padStart(2, '0')}日 周${week}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped>
|
||||||
.el-font-size {
|
/* 主容器:弹性布局,左右分布 */
|
||||||
|
.dashboard-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start; /* 关键:顶部对齐,避免因高度不同而居中错位 */
|
||||||
|
padding: 16px 24px;
|
||||||
|
min-height: 72px; /* 保证最小高度,防止内容少时塌陷 */
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 品牌区 */
|
||||||
|
.brand-area {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start; /* 与 header 顶部对齐 */
|
||||||
|
gap: 12px;
|
||||||
|
flex-shrink: 0; /* 防止被压缩 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
|
||||||
|
flex-shrink: 0; /* 固定尺寸 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.title-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-title {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2d3d;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slogan {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #667a99;
|
||||||
|
margin: 4px 0 0 0;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 信息区:右对齐,固定文本方向 */
|
||||||
|
.info-area {
|
||||||
|
text-align: right;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.5;
|
||||||
|
min-width: 200px; /* 防止在窄屏下文字换行混乱 */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end; /* 确保内部元素右对齐 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-line,
|
||||||
|
.weather-date-line {
|
||||||
|
white-space: nowrap;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.location-line {
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 4px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.weather-date-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weather-icon {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.divider {
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-item {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 加载态占位,防止布局跳动 */
|
||||||
|
.loading {
|
||||||
|
height: 48px; /* 与 info-area 高度相近 */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.dashboard-header {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-area {
|
||||||
|
align-self: stretch;
|
||||||
|
text-align: left;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user