Skip to content

Commit f93c8d2

Browse files
committed
完成
1 parent 383dcb0 commit f93c8d2

25 files changed

+1357
-46
lines changed

src/assets/img/header_border_dark.png

7.65 KB
Loading
522 KB
Loading

src/assets/img/logo_dark.png

6.06 KB
Loading

src/assets/img/logo_light2.png

7.84 KB
Loading

src/assets/img/qiehuan_dark.png

1.28 KB
Loading

src/assets/img/qiehuan_light.png

1.62 KB
Loading

src/components/common/time.vue

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<template>
2+
<div>
3+
{{nowDate}}{{nowWeek}} {{nowTime}}
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: "time",
10+
data(){
11+
return {
12+
nowDate: "", // 当前日期
13+
nowTime: "", // 当前时间
14+
nowWeek: "" // 当前星期
15+
}
16+
},
17+
destroyed() {
18+
if (this.timer) { // 注意在vue实例销毁前,清除我们的定时器
19+
clearInterval(this.timer);
20+
}
21+
},
22+
methods:{
23+
dealWithTime(data) { // 获取当前时间
24+
let formatDateTime;
25+
let Y = data.getFullYear();
26+
let M = data.getMonth() + 1;
27+
let D = data.getDate();
28+
let H = data.getHours();
29+
let Min = data.getMinutes();
30+
let S = data.getSeconds();
31+
let W = data.getDay();
32+
H = H < 10 ? "0" + H : H;
33+
Min = Min < 10 ? "0" + Min : Min;
34+
S = S < 10 ? "0" + S : S;
35+
switch (W) {
36+
case 0:
37+
W = "";
38+
break;
39+
case 1:
40+
W = "";
41+
break;
42+
case 2:
43+
W = "";
44+
break;
45+
case 3:
46+
W = "";
47+
break;
48+
case 4:
49+
W = "";
50+
break;
51+
case 5:
52+
W = "";
53+
break;
54+
case 6:
55+
W = "";
56+
break;
57+
default:
58+
break;
59+
}
60+
this.nowDate = Y + "" + M + "" + D + "";
61+
this.nowWeek = "" + W ;
62+
this.nowTime = H + ":" + Min + ":" + S;
63+
},
64+
},
65+
mounted() {
66+
this.dealWithTime(new Date())
67+
this.timer = setInterval(()=> {
68+
this.dealWithTime(new Date()) // 修改数据date
69+
}, 500)
70+
}
71+
72+
}
73+
</script>
74+
75+
<style scoped>
76+
77+
</style>

src/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import router from './router'
44
import store from './store'
55
import axios from 'axios'
66
import echarts from 'echarts'
7+
import SocketService from './utils/socket_service'
78
import './assets/font/iconfont.css'
89
import './assets/css/jlobal.less'
10+
import 'assets/theme/vintage'
911

12+
SocketService.Instance.connect()
1013
axios.defaults.baseURL = 'http://localhost:8888/api/'
14+
Vue.prototype.$socket = SocketService.Instance
1115
Vue.prototype.$http = axios
1216
Vue.config.productionTip = false
1317
Vue.prototype.$echarts = echarts

src/network/request.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import axios from 'axios'
2+
3+
export function request(config) {
4+
const instance = axios.create({
5+
baseURL: 'http://haoyingwang.3vfree.net/',
6+
timeout:5000
7+
})
8+
instance.interceptors.request.use(config => {
9+
return config
10+
}, err => {
11+
console.log(err);
12+
})
13+
instance.interceptors.response.use(
14+
res => {
15+
return res.data
16+
}, err => {
17+
console.log(err);
18+
}
19+
)
20+
return instance(config)
21+
}

src/network/seller.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { request } from './request'
2+

src/router/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ const Home = () =>import('../views/Home/Home')
44
const SellerPage = () => import('../views/Seller/SellerPage')
55
const TrendPage = ()=> import('../views/Trend/TrendPage')
66
const MapPage = () => import('../views/Map/MapPage')
7+
const RankPage = () => import('../views/Rank/RankPage')
8+
const HotPage = () => import('../views/Hot/HotPage')
9+
const StockPage = () => import('../views/Stock/StockPage')
710

811
Vue.use(VueRouter)
912

@@ -32,6 +35,21 @@ const routes = [
3235
name: 'MapPage',
3336
component: MapPage
3437
},
38+
{
39+
path: '/RankPage',
40+
name: 'RankPage',
41+
component: RankPage
42+
},
43+
{
44+
path: '/HotPage',
45+
name: 'HotPage',
46+
component: HotPage
47+
},
48+
{
49+
path: '/StockPage',
50+
name: 'StockPage',
51+
component: StockPage
52+
},
3553

3654
]
3755

src/store/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,16 @@ Vue.use(Vuex)
55

66
export default new Vuex.Store({
77
state: {
8+
theme:'chalk'
89
},
910
mutations: {
11+
changeTheme(state){
12+
if(state.theme === 'chalk'){
13+
state.theme = 'vintage'
14+
}else{
15+
state.theme = 'chalk'
16+
}
17+
}
1018
},
1119
actions: {
1220
},

src/utils/map_utils.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const name2pinyin = {
2+
安徽: 'anhui',
3+
陕西: 'shanxi1',
4+
澳门: 'aomen',
5+
北京: 'beijing',
6+
重庆: 'chongqing',
7+
福建: 'fujian',
8+
甘肃: 'gansu',
9+
广东: 'guangdong',
10+
广西: 'guangxi',
11+
贵州: 'guizhou',
12+
海南: 'hainan',
13+
河北: 'hebei',
14+
黑龙江: 'heilongjiang',
15+
河南: 'henan',
16+
湖北: 'hubei',
17+
湖南: 'hunan',
18+
江苏: 'jiangsu',
19+
江西: 'jiangxi',
20+
吉林: 'jilin',
21+
辽宁: 'liaoning',
22+
内蒙古: 'neimenggu',
23+
宁夏: 'ningxia',
24+
青海: 'qinghai',
25+
山东: 'shandong',
26+
上海: 'shanghai',
27+
山西: 'shanxi',
28+
四川: 'sichuan',
29+
台湾: 'taiwan',
30+
天津: 'tianjin',
31+
香港: 'xianggang',
32+
新疆: 'xinjiang',
33+
西藏: 'xizang',
34+
云南: 'yunnan',
35+
浙江: 'zhejiang'
36+
}
37+
38+
export function getProvinceMapInfo (arg) {
39+
const path = `map/province/${name2pinyin[arg]}.json`
40+
return {
41+
key: name2pinyin[arg],
42+
path: path
43+
}
44+
}

src/utils/socket_service.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
export default class SocketService{
2+
3+
static instanct = null
4+
static get Instance(){
5+
if(!this.instanct){
6+
this.instanct = new SocketService()
7+
}
8+
return this.instanct
9+
}
10+
11+
ws = null
12+
callBackMapping = {}
13+
connected = false
14+
sendRetryCount = 0
15+
connectRetryCount = 0
16+
17+
connect(){
18+
if(!window.WebSocket){
19+
return console.log('您的浏览器不支持WebSocket')
20+
}
21+
this.ws = new WebSocket('ws://localhost:9998')
22+
23+
this.ws.onopen = () =>{
24+
this.connectRetryCount = 0
25+
console.log('连接服务器成功')
26+
this.connected = true
27+
}
28+
this.ws.onclose = () =>{
29+
this.connected = false
30+
console.log('连接服务器失败')
31+
this.connectRetryCount++
32+
setTimeout(()=>{
33+
this.connect()
34+
},this.connectRetryCount * 500)
35+
}
36+
this.ws.onmessage = msg =>{
37+
console.log('从服务器获得数据')
38+
const recvData = JSON.parse(msg.data)
39+
const socketType = recvData.socketType
40+
if(this.callBackMapping[socketType]){
41+
const action = recvData.action
42+
if(action === 'getData'){
43+
const realData = JSON.parse(recvData.data)
44+
this.callBackMapping[socketType].call(this, realData)
45+
}else if(action ==='fullScreen'){
46+
this.callBackMapping[socketType].call(this, recvData)
47+
}else if(action ==='themeChange'){
48+
49+
}
50+
}
51+
}
52+
}
53+
registerCallBack ( socketType,callBack ){
54+
this.callBackMapping[socketType] = callBack
55+
}
56+
unRegisterCallBack(socketType){
57+
this.callBackMapping[socketType] = null
58+
}
59+
send(data){
60+
this.sendRetryCount = 0
61+
if(this.connected){
62+
this.ws.send(JSON.stringify(data))
63+
}else{
64+
this.sendRetryCount++
65+
setTimeout(()=>{
66+
this.send(data)
67+
},this.sendRetryCount * 500)
68+
}
69+
}
70+
}

src/utils/theme_utils.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const theme = {
2+
chalk:{
3+
backgroundColor:'#161522',
4+
titleColor:'#ffffff',
5+
themeSrc:'qiehuan_dark.png',
6+
headerBorderSrc:'header_border_dark.png'
7+
},
8+
vintage:{
9+
backgroundColor: '#eeeeee',
10+
titleColor: '#000000',
11+
themeSrc:'qiehuan_light.png',
12+
headerBorderSrc:'header_border_light.png'
13+
14+
}
15+
16+
}
17+
18+
export function getThemeValue(themeName) {
19+
return theme[themeName]
20+
}

0 commit comments

Comments
 (0)