index.vue
5.8 KB
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
<template>
<view>
<v-tabs class="tab_c" v-model="current" :tabs="tabs" @change="changeTab" fixed="true"
line-height="8rpx" line-color="#04764E"
color="#AAAAAA" activeColor="#04764E" height="88rpx"></v-tabs>
<z-swiper ref="zSwiper" v-model="tabs" @slideChange="onSwiperChange"
:options="options">
<z-swiper-item v-for="(item, index) in tabs" :key="item" style="min-height: 90vh;">
<view v-if="match_map.get(item) && match_map.get(item).length > 0 " style="width: 100vw;">
<MatchList :data_info="match_map.get(item)" ref="MatchListRef" :key="index" @updateItem ="updateItem"></MatchList>
</view>
<view style="width: 100vw; height: 80vh; align-items: center; display: flex; justify-content: center;"
v-else>
<image style="height: 460rpx; width: 460rpx;" src="../../static/pic_zanwushuju@2x.png"></image>
</view>
</z-swiper-item>
</z-swiper>
</view>
</template>
<script>
import MatchList from '../../components/MatchList.vue'
import {
default as http
} from "@/utils/http.js";
import common from '../../utils/common';
import followHelper from '../../utils/followHelper.js';
export default {
components: {
MatchList
},
data() {
return {
match_map: new Map(),
options: {
autoHeight: true,
centeredSlides: true,
centeredSlidesBounds: true,
initialSlide: 1
},
current: 1,
tabs: []
}
},
async onLoad() {
let infoRes = await http.gql({
"query": `{
liveScore(lotIds: "72,45",order:[["MatchTime","desc"]], limit:100) {
count
matchs {
Id
InfoId
LotteryId
IssueName
MatchTime
MatchNumber
HostName
HostRed
HostYellow
GuestName
GuestRed
GuestYellow
GameName
QcBf
BcBf
HostTeam {
LogoFullPath
}
GuestTeam {
LogoFullPath
}
MatchState
MatchRound
PreTotalScore
Temperature
SportsInjury
SportsInfoCount
Sportsdt {
SportsdtMatchId
}
}
}
} `
})
let matchs = infoRes.data.liveScore.matchs
if (this.match_map.size > 0) {
this.match_map.clear()
}
this.tabs.length = 0
var followList = await followHelper.getFollowList()
this.match_map.set("关注", followList)
let zhongyao = []
let wancheng = []
for (let m of matchs) {
if (m.MatchState === "完") {
wancheng.push(m)
} else if(m.MatchState === "未"){
zhongyao.push(m)
}
}
zhongyao.sort((item1, item2) => (new Date(item1.IssueName) - new Date(item2.IssueName)))
this.match_map.set("重要", zhongyao)
this.match_map.set("完赛", wancheng)
for (let m of matchs) {
if (m.GameName) {
var list = this.match_map.get(m.GameName)
if (!list) {
list = []
}
list.push(m)
this.match_map.set(m.GameName, list)
}
}
for (const [key, value] of this.match_map.entries()) {
console.log(key, value.length);
}
this.tabs.push(...this.match_map.keys())
},
methods: {
updateItem(id, index) {
console.log("id:" + id + "index:" + index)
var list = this.match_map.get(this.tabs[this.current])
var follow_list = followHelper.getFollowList()
var same = follow_list.some(function(item, index) {
return item.Id === id
})
if (same) {
list[index].isFollow = true
} else {
list[index].isFollow = false
}
console.log(list[index])
},
async startRealTime() {
let query_data = `query{
getlivedata
}`
let result = await http.gql({
query: query_data
})
console.log(result)
if (result && result.data && result.data.getlivedata) {
var liveData = result.data.getlivedata.LiveData
var zhongyao = this.match_map.get("重要")
for (let m of zhongyao) {
if (m && m.Sportsdt &&
m.Sportsdt.SportsdtMatchId
) {
var live = liveData[m.Sportsdt.SportsdtMatchId]
if (live) {
m.QcBf = live.ScoreAll[0] + "-" + live.ScoreAll[1]
m.BcBf = live.Score[0] + "-" + live.Score[1]
m.HostRed = live.RedCard[0]
m.HostYellow = live.YellowCard[0]
m.GuestRed = live.RedCard[1]
m.GuestYellow = live.YellowCard[1]
}
}
}
ref.onRefreshInfo(zhongyao)
console.log(zhongyao)
}
},
onSwiperChange(swiper) {
this.current = this.$refs.zSwiper.swiper.activeIndex
console.log("---》" + this.tabs[this.current] +"--"+ this.match_map.get(this.tabs[this.current]))
console.log('onSwiperChange:' + swiper.activeIndex)
var ref = this.$refs.MatchListRef[this.current]
console.log(this.$refs.MatchListRef)
if (this.current === 0) {
var followList = followHelper.getFollowList()
ref.onRefreshInfo(followList)
} else {
var data = this.match_map.get(this.tabs[this.current])
ref.onRefreshInfo(data)
}
},
changeTab(index) {
console.log('当前选中的项:' + index)
this.$refs.zSwiper.swiper.slideTo(index); //切换到第一个slide,速度为1秒
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #F5F5F5;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-top: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.tab_c {
/* position: fixed; */
z-index: 4;
}
</style>