1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<template>
<div class="ultraman_wrap_bg">
<div class="ultraman_header">
<img class="ultraman_header_title" src="@/static/home/logo.png" alt="" />
</div>
<div class="ultraman_logo_blk">
<img class="ultraman_logo" src="@/static/home/bi.png" alt="" />
</div>
<div class="ultraman_btn_blk">
<div class="ultraman_btn" @click="getCoin">领取习币</div>
<div class="ultraman_btn2" @click="router.push('/home/transfer')">习币转账</div>
</div>
<div class="ultraman_page_title">中国习币</div>
<div class="ultraman_content_blk">
<div class="ultraman_content_tag">中国印钞造币</div>
<div class="ultraman_content_name">习币价值实时更新</div>
<div class="ultraman_content_label">强化国币 未来可期</div>
<div class="chart-container" ref="chartRef"></div>
</div>
<div class="ultraman_foot">
<img src="@/static/xbgz/gongan.png" alt="" />
</div>
<LandscapePopup ref="popup" :type="popupType" />
<NoticeModal ref="noticeModal" :noticeList="guideList" />
</div>
</template>
<script setup>
import request from '@/utils/request';
import { usePageHook } from '@/hooks/usePageHook';
import * as echarts from 'echarts';
import { ref, onMounted, onUnmounted } from 'vue';
import { useRouter } from 'vue-router';
import NoticeModal from '@/components/NoticeModal.vue';
const router = useRouter();
const chartRef = ref(null);
let myChart = null;
const noticeModal = ref(null)
// 初始化图表
const initChart = (data) => {
if (myChart) {
myChart.dispose();
}
myChart = echarts.init(chartRef.value);
// 处理数据
const dates = data.map(item => item.a3);
const prices = data.map(item => Number(item.a4));
const option = {
grid: {
top: '10%',
left: '5%',
right: '5%',
bottom: '10%',
containLabel: true
},
xAxis: {
type: 'category',
data: dates,
axisLine: {
lineStyle: {
color: '#999'
}
},
axisLabel: {
color: '#666',
fontSize: 12,
formatter: (value) => {
// 只显示月-日
return value.substring(5);
}
}
},
yAxis: {
type: 'value',
name: '价格(元)',
nameTextStyle: {
color: '#666'
},
axisLine: {
show: true,
lineStyle: {
color: '#999'
}
},
axisLabel: {
color: '#666',
fontSize: 12
},
splitLine: {
lineStyle: {
color: '#eee'
}
}
},
series: [
{
data: prices,
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 6,
itemStyle: {
color: '#e4393c'
},
lineStyle: {
color: '#e4393c',
width: 2
},
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(228, 57, 60, 0.3)'
},
{
offset: 1,
color: 'rgba(228, 57, 60, 0.1)'
}
])
}
}
],
tooltip: {
trigger: 'axis',
backgroundColor: 'rgba(255, 255, 255, 0.9)',
borderColor: '#e4393c',
borderWidth: 1,
textStyle: {
color: '#333'
},
formatter: (params) => {
const data = params[0];
return `日期:${data.axisValue}<br/>价格:${data.data}元`;
}
}
};
myChart.setOption(option);
};
const getCoin = () => {
request.get('/yw2/yqcj').then(res => {
if (res.code == 200) {
showSuccessToast('领取成功,请查收');
} else {
showToast({
message: res.msg,
wordBreak: 'break-all',
});
}
})
}
// 获取数据并初始化图表
const fetchData = async () => {
try {
const res = await request.get('/yw1/list');
if (res && res.data) {
// 按日期排序
const sortedData = res.data.sort((a, b) => new Date(a.a3) - new Date(b.a3));
// 只显示状态为1的数据
const filteredData = sortedData.filter(item => item.a5 === '1');
initChart(filteredData);
}
} catch (error) {
console.error('获取数据失败:', error);
}
};
const userInfo = ref({})
const popup = ref(null)
const popupType = ref('app')
const guideList = ref([])
const getGuideList = async () => {
try {
const res = await request.get('/system/notice/list');
guideList.value = res.rows.filter(item => item.noticeType == 0 || item.noticeType == 1 || item.noticeType == 2);
if (userInfo.value.data == 'true') {
noticeModal.value?.open()
}
} catch (error) {
console.error('Failed to fetch notices:', error);
showFailToast(error.msg || '获取通知信息失败'); // 提示用户获取通知信息失败
}
};
onMounted(() => {
})
usePageHook({
onPageShow: () => {
fetchData();
getGuideList()
request.get('/system/user/').then(res => {
userInfo.value = res
console.log(userInfo.value)
if (userInfo.value.data != 'true') {
popupType.value = 'shiming'
popup.value?.open()
}
})
}
})
// 监听窗口大小变化,重绘图表
const handleResize = () => {
myChart && myChart.resize();
};
onMounted(() => {
window.addEventListener('resize', handleResize);
});
onUnmounted(() => {
window.removeEventListener('resize', handleResize);
if (myChart) {
myChart.dispose();
myChart = null;
}
});
</script>
<style scoped>
/* Reset所有元素的外边距和内边距 */
*,
*::before,
*::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
* {
box-sizing: border-box;
}
/* 清除所有链接的下划线 */
a {
text-decoration: none;
}
ul {
list-style: none;
list-style-type: none;
/* 去除项目符号 */
padding: 0;
/* 去除内边距 */
margin: 0;
/* 去除外边距 */
}
/* 移除按钮的默认样式 */
button,
input,
textarea,
select {
border: none;
outline: none;
background: none;
font: inherit;
}
/* 表格的边框清除 */
table {
border-collapse: collapse;
border-spacing: 0;
}
/* 图片的默认边距清除 */
img {
display: block;
max-width: 100%;
}
.ultraman_flex {
display: flex;
align-items: center;
justify-content: space-between;
}
.ultraman_wrap_bg {
max-width: 550px;
min-height: 100vh;
margin: 0 auto;
padding-bottom: 30px;
background-position: center;
overflow: scroll;
/* 保留滚动功能 */
background: url('@/static/home/beijing.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.ultraman_wrap_bg::-webkit-scrollbar {
display: none;
/* 隐藏滚动条 */
}
.ultraman_header {
width: 50%;
margin: 0 auto;
margin-top: 30px;
}
.ultraman_header_title,
.ultraman_logo {
width: 100%;
}
.ultraman_logo_blk {
width: 67%;
margin: 0 auto;
margin-top: 20px;
}
.ultraman_btn_blk {
width: 88%;
margin: 0 auto;
margin-top: 20px;
padding: 0 20px;
display: flex;
align-items: center;
justify-content: space-between;
}
.ultraman_btn {
width: 47%;
font-size: 20px;
font-weight: bold;
line-height: 22px;
padding: 9px 0;
text-align: center;
letter-spacing: 1.3px;
color: #fff;
text-shadow: 1px 1px 0 rgba(107, 107, 107, 0.3),
2px 2px 0 rgba(101, 101, 101, 0.2);
background: url('@/static/home/lingqu.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.ultraman_btn2 {
width: 47%;
font-size: 20px;
font-weight: bold;
letter-spacing: 1.3px;
padding: 9px 0;
line-height: 22px;
text-align: center;
color: #fff;
text-shadow: 1px 1px 0 rgba(107, 107, 107, 0.3),
2px 2px 0 rgba(101, 101, 101, 0.2);
background: url('@/static/home/zhuanzhang.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.ultraman_page_title {
width: 88%;
margin: 0 auto;
margin-top: 20px;
padding: 6px 0 18px 0;
text-align: center;
font-size: 20px;
letter-spacing: 1.2px;
color: #8a2c20;
font-weight: bold;
background: url('@/static/home/xibi.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.ultraman_content_blk {
width: 88%;
margin: 0 auto;
margin-top: -14px;
border-radius: 15px;
background-color: #fefefe;
padding: 30px 12px 12px 12px;
position: relative;
}
.ultraman_content_tag {
position: absolute;
top: 0;
left: 0;
text-align: center;
color: #fff;
font-size: 15px;
letter-spacing: 1px;
font-weight: bold;
padding: 3px 15px;
background: url('@/static/home/zhonguoyinzhi.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
.ultraman_content_name {
text-align: center;
font-size: 20px;
font-weight: bold;
letter-spacing: 1.5px;
}
.ultraman_content_label {
text-align: center;
font-size: 15px;
font-weight: bold;
letter-spacing: 1.5px;
color: #c9caca;
}
.ultraman_content_img {
display: none;
/* 隐藏原有的图片 */
}
.ultraman_foot {
width: 70%;
margin: 0 auto;
margin-top: 1rem;
}
/* 添加图表容器样式 */
.chart-container {
width: 100%;
height: 300px;
margin-top: 20px;
}
</style>