MyClassList.vue
8.42 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
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
<template>
<div class="sign_in">
<div class="header">
<van-swipe class="my-swipe" indicator-color="white" v-if="baseInfo.coverList && baseInfo.coverList.length > 0">
<van-swipe-item v-for="n in baseInfo.coverList" :key="n.id">
<video
v-if="n.cover_url.indexOf('.mp4') > -1"
id="video"
:src="n.cover_url"
poster=""
controls="controls"
windowlessvideo="true"
playsinline="true"
webkit-playsinline="true"
x5-playsinline="true"
x-webkit-airplay="allow"
width="100%"
height="260px"
type="video/mp4"
></video>
<img v-if="n.cover_url.indexOf('.mp4') == -1" :src="n.cover_url" />
</van-swipe-item>
</van-swipe>
<img v-else src="@/assets/home/defCoure.jpg" alt="" />
</div>
<div class="base_info">
<p class="base_title">{{ baseInfo.baseName }}</p>
<div class="rate">
<van-rate v-model="baseInfo.baseScore" color="#FFCC00" :size="16" readonly />
<span>{{ baseInfo.baseScore }}</span>
</div>
<p class="address">
<van-icon name="location" class="icon" />
{{ baseInfo.address }}
</p>
<p class="phone">
<van-icon name="phone" class="icon" />
{{ baseInfo.phone }}
</p>
</div>
<div class="select_student" @click="selectStudent">
<p class="select_tip">请选择需要打卡的孩子</p>
<div class="student" v-if="selectedContact.travelerName">
<span>{{ selectedContact.travelerName }}</span>
<van-icon name="close" class="icon" />
</div>
<div class="student" v-else>
<span>点击选择</span>
</div>
</div>
<div class="btns" @click="getPosition">立即打卡</div>
<van-popup v-model="failShow" round closeable :style="{ width: '80%' }">
<div class="success">
<img src="@/assets/tip1.png" alt="" />
<h3>打卡失败!</h3>
<p>您当前所在的地理位置不在课程的打卡范围内!</p>
</div>
</van-popup>
</div>
</template>
<script>
export default {
data() {
return {
baseInfo: '',
list: [],
baseId: '',
userInfo: '',
failShow: false,
selectedContact: '', //选择的出行人
}
},
mounted() {
var userInfo = localStorage.getItem('userInfo')
if (userInfo) {
this.userInfo = JSON.parse(userInfo)
}
// 选择的出行人
let selectedContactArr = localStorage.getItem('selectedContactArr')
if (selectedContactArr) {
selectedContactArr = JSON.parse(selectedContactArr)
this.selectedContact = selectedContactArr[0]
}
this.baseId = this.$route.query.qrresult
this.GetStudyBaseDetail(this.baseId)
},
methods: {
AddSign() {
this.$toast.loading({
message: '请求中...',
})
this.yxAxios
.get(`${this.yanxueUrl}/api/BaseManage/AddSign?userId=${this.selectedContact.travelerNum}&baseId=${this.baseId}`)
.then((res) => {
this.$toast.success('打卡签到成功')
console.log(res.data)
// alert('打卡签到成功:',JSON.stringify(res))
setTimeout(() => {
this.$router.push({ name: 'Home' })
}, 1000)
})
},
GetStudyBaseDetail(baseId) {
this.$toast.loading({
message: '请求中...',
})
this.yxAxios.get(`${this.yanxueUrl}/api/StudiesWap/GetStudyBaseDetail?userId=0&cs=绍兴市&id=${baseId}`).then((res) => {
console.log(res.data)
if (res.data.data) {
this.$toast.clear()
this.baseInfo = res.data.data
} else {
this.$toast.fail(res.data.message)
}
})
},
getPosition() {
if (!this.selectedContact.travelerNum) {
this.$toast('请选择需要打卡的孩子')
return false
}
if (this.baseInfo.signLong == 0 && this.baseInfo.signLat == 0) {
//基地没数坐标
this.AddSign()
return false
}
var basePosition = [this.baseInfo.signLong, this.baseInfo.signLat]
AMap.convertFrom(basePosition, 'baidu', function (status, result) {
console.log(result)
if (result.info === 'ok') {
basePosition = [result.locations[0].lng, result.locations[0].lat] // Array.<LngLat>
}
})
this.$toast.loading({
message: '请求中...',
})
this.getNowPosition((posi) => {
//获取当前位置坐标
this.$toast.clear()
if (posi) {
var nowPosition = [posi.position.lng, posi.position.lat]
var distance = AMap.GeometryUtil.distance(nowPosition, basePosition)
console.log(parseInt(distance), nowPosition, basePosition)
if (parseInt(distance) > 500) {
this.failShow = true
} else {
// alert('定位小于500m')
this.AddSign()
}
} else {
// alert('getNowPosition没有返回')
}
})
},
getNowPosition: function (callback) {
let mapObj = new AMap.Map('iCenter')
mapObj.plugin('AMap.Geolocation', function () {
let geolocation = new AMap.Geolocation({
enableHighAccuracy: true, //是否使用高精度定位,默认:true
timeout: 10000, //超过10秒后停止定位,默认:无穷大
maximumAge: 0, //定位结果缓存0毫秒,默认:0
convert: true, //自动偏移坐标,偏移后的坐标为高德坐标,默认:true
showButton: true, //显示定位按钮,默认:true
buttonPosition: 'LB', //定位按钮停靠位置,默认:'LB',左下角
buttonOffset: new AMap.Pixel(0, 0), //定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
showCircle: true, //定位成功后用圆圈表示定位精度范围,默认:true
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
zoomToAccuracy: true, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
})
mapObj.addControl(geolocation)
geolocation.getCurrentPosition()
AMap.event.addListener(geolocation, 'complete', function (res) {
// alert('返回定位信息:' + JSON.stringify(res))
console.log('返回定位信息:', res)
callback(res)
}) //返回定位信息
AMap.event.addListener(geolocation, 'error', function (res) {
// alert('返回定位出错信息:' + JSON.stringify(res))
console.log('返回定位出错信息:', res)
callback()
}) //返回定位出错信息
})
},
// 选择孩子
selectStudent() {
this.$router.push({ name: 'SelectContact', query: { limit: 1, hideParent: 1 } })
},
},
}
</script>
<style lang="scss" scoped>
.sign_in {
padding-bottom: 100px;
.header {
img {
width: 100%;
}
}
.base_info {
width: 702px;
margin: 0 auto;
padding-top: 20px;
.base_title {
font-size: 34px;
font-weight: bold;
}
.rate {
margin-top: 20px;
span {
font-size: 30px;
color: #ffcc00;
margin-left: 30px;
}
}
.address,
.phone {
font-size: 24px;
color: #999;
margin-top: 16px;
.icon {
color: #000;
}
}
}
.select_student {
width: 702px;
margin: 0 auto;
margin-top: 30px;
padding-top: 30px;
border-top: 2px solid #d8d8d8;
.select_tip {
font-size: 30px;
color: #999;
}
.student {
position: relative;
width: 532px;
line-height: 78px;
margin: 0 auto;
margin-top: 24px;
background: #f5f6fa;
border-radius: 8px;
font-size: 28px;
text-align: center;
.icon {
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}
}
}
.btns {
width: 702px;
margin: 0 auto;
margin-top: 100px;
text-align: center;
line-height: 90px;
border-radius: 100px;
font-size: 30px;
background: #4092ff;
color: #fff;
}
.success {
padding: 40px 0;
text-align: center;
img {
width: 30%;
}
h3 {
font-size: 36px;
}
p {
font-size: 30px;
color: #999999;
}
}
}
</style>