MatchEventStatistics.vue
4.5 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
<template>
<view>
<view v-if="isLoading"
style="width: 50vw; height: 70vh; display: flex; justify-items: center; align-items: center;">
<view
style="width: 50vw; height: 100%; display: flex; justify-items: center; align-items: center; align-content: center; justify-content: center; ">
<image style="width: 63px; height: 34px;" src="../../static/loading_icon.gif"></image>
</view>
</view>
<view v-if="!isLoading">
<view style="display: flex; justify-content: space-between; padding-left: 14px; padding-right: 14px;">
<image style="width: 18px; height: 18px; border-radius: 18px;"
:src="data_info.HostTeam ? data_info.HostTeam.LogoFullPath : ''" />
<view class="title">事件统计</view>
<image style="width: 18px; height: 18px; border-radius: 18px;"
:src="data_info.GuestTeam ? data_info.GuestTeam.LogoFullPath : ''" />
</view>
<view v-if="!data_list"
style="width: 50vw; height: 70vh; display: flex; justify-items: center; align-items: center;">
<text style="width: 50vw; height: 100%; display: flex; justify-items: center; align-items: center; align-content: center; justify-content: center;">
数据更新中,敬请期待</text>
</view>
<view v-if="data_list" v-for="(item, index) in data_list" :key="index">
<view v-if="!isNaN(parseInt(item.Home))"
style="display: flex; justify-content: space-between; padding-left: 14px; padding-right: 14px; margin-top: 14px; margin-bottom: 14px; ">
<view class="text">{{item.Home}}</view>
<view style="display: flex; align-items: center; width: 98%; justify-content: center; tes ">
<view class="bar_bg" style="display: flex; flex: 1.5; flex-direction: row-reverse;">
<view class="bar" :style="'width:' + changeWitch(item,item.Home) ">
</view>
</view>
<view class="text1" style="align-self: center;">{{item.Name}}</view>
<view class="bar_bg" style="display: flex; flex: 1.5;">
<view class="bar" style="align-content: flex-start;"
:style="'width:' + changeWitch(item,item.Away)"></view>
</view>
</view>
<view class="text">{{item.Away}}</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
default as http
} from "@/utils/http.js";
export default {
props: {
data_info: [Object]
},
data() {
return {
select_data: this.data_info,
data_list: null,
isLoading: false
}
},
methods: {
changeWitch(item, value) {
var v = parseInt((parseInt(value) / (parseInt(item.Home) + parseInt(item.Away))) * 100) + "%"
return v
},
async load_data() {
console.log("load_data:" + JSON.stringify(this.select_data))
this.isLoading = true
var gameid = this.select_data.Sportsdt ? this.select_data.Sportsdt.SportsdtMatchId : undefined;
if (gameid) {
let result = await http.gql({
query: `query{
getgamegoaldata(gameid:${gameid})
}`
})
//处理返回请求
console.log(result)
if (result && result.data && result.data.getgamegoaldata) {
if (result.data.getgamegoaldata.Error) {
clearInterval(this.timer);
this_.disabled = false;
this.data_list = null;
uni.showToast({
icon: "none",
title: result.data.getgamegoaldata.Error,
});
} else {
this.data_list = result.data.getgamegoaldata.Stat
}
} else {
this.data_list = null;
}
}
this.isLoading = false
},
childmethods(item) {
console.log("childMethods:" + JSON.stringify(item))
this.select_data = item;
this.load_data()
}
},
async mounted() {
this.load_data()
},
}
</script>
<style>
.title {
color: #797979;
font-size: 12px;
text-align: center;
font-family: SourceHanSansSC-regular;
}
.text {
width: 27px;
color: #42464C;
font-size: 12px;
text-align: center;
font-family: SourceHanSansSC-regular;
}
.text1 {
color: #8F9197;
width: 48px;
min-width: 48px;
font-size: 12px;
text-align: center;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
display: block;
margin-left: 4px;
margin-right: 4px;
font-family: SourceHanSansSC-regular;
}
.bar {
height: 8px;
line-height: 17px;
border-radius: 18px;
background-color: rgba(40, 120, 255, 1);
color: rgba(255, 255, 255, 1);
font-size: 12px;
text-align: left;
font-family: Roboto;
}
.bar_bg {
height: 8px;
line-height: 17px;
border-radius: 18px;
background-color: rgba(246, 249, 255, 1);
color: rgba(255, 255, 255, 1);
font-size: 12px;
text-align: left;
font-family: Roboto;
}
</style>