This commit is contained in:
yanran200730
2022-11-02 16:05:35 +08:00
parent a1ddb7ab60
commit 83e06be215
5 changed files with 347 additions and 174 deletions

View File

@@ -1,39 +1,37 @@
<template>
<div class="Activity">
<div class="Activity" v-if="pageShow">
<div class="section">
<h2>10.30线下公益宣传</h2>
<p>在今天4月28日下午的联防联控机制新闻发布会上有关负责人表示预计五一假期客流量较去年明显下降出游应严格做好疫情防控</p>
<h2>{{ info.title }}</h2>
<p>{{ info.detail }}</p>
</div>
<div class="section">
<h2>基础信息</h2>
<div class="info-wrapper">
<div class="info-item">
<h2>活动地点</h2>
<span class="omit">成都市金牛区xxxx大厦成都成都市金牛区xxxx大厦成都成都市金牛区xxxx大厦成都</span>
<div class="right">
<span class="omit">{{ info.address }}</span>
<div class="right" @click="toAddress">
<image src="https://cdn.cunwuyun.cn/wxmp/tianfuxing/dh.png" />
<i>导航</i>
</div>
</div>
<div class="info-item">
<h2>进场打卡</h2>
<span>2022-10-14 09:25:25
2022-10-28 12:00:00</span>
<span>{{ info.intoBegintime }} {{ info.intoEndtime }}</span>
</div>
<div class="info-item">
<h2>离场打卡</h2>
<span>2022-10-14 09:25:25
2022-10-28 12:00:00</span>
<span>{{ info.exitBegintime }} {{ info.exitEndtime }}</span>
</div>
</div>
</div>
<div class="signin">
<div class="top" @click="getLocation">
<div class="top" @click="toSign" :class="[isClock ? '' : 'disable']">
<h2>打卡签到</h2>
<span>积分+5</span>
<span v-if="isClock">积分+{{ intoIntegral }}</span>
</div>
<p>符合打卡条件</p>
<i>未到打卡时间/不在指定位置</i>
<p v-if="isClock">符合打卡条件</p>
<i v-else>未到打卡时间/不在指定位置</i>
</div>
</div>
</template>
@@ -46,18 +44,145 @@
data () {
return {
qqmapsdk: null
id: '',
info: {},
qqmapsdk: null,
pageShow: false,
latitude: '',
longitude: '',
address: '',
distance: 100000
}
},
onLoad () {
// this.getLocation()
computed: {
isClock () {
if (!this.info.id) {
return false
}
const times = new Date().getTime()
const inSTimes = new Date(this.info.intoBegintime.replaceAll('-', '/')).getTime()
const inETimes = new Date(this.info.intoEndtime.replaceAll('-', '/')).getTime()
const outSTimes = new Date(this.info.exitBegintime.replaceAll('-', '/')).getTime()
const outETimes = new Date(this.info.exitEndtime.replaceAll('-', '/')).getTime()
if (this.info.clockRange > this.distance && (!this.info.intoClock && (times > inSTimes && times < inETimes)) || this.info.exitClock && (times > outSTimes && times < outETimes)) {
return true
}
return false
},
intoIntegral () {
if (!this.info.id) {
return 0
}
const times = new Date().getTime()
const inSTimes = new Date(this.info.intoBegintime.replaceAll('-', '/')).getTime()
const inETimes = new Date(this.info.intoEndtime.replaceAll('-', '/')).getTime()
const outSTimes = new Date(this.info.exitBegintime.replaceAll('-', '/')).getTime()
const outETimes = new Date(this.info.exitEndtime.replaceAll('-', '/')).getTime()
if (!this.info.intoClock && (times > inSTimes && times < inETimes)) {
return this.info.intoIntegral
}
if (!this.info.exitClock && (times > outSTimes && times < outETimes)) {
return this.info.exitIntegral
}
return 0
}
},
onShow () {
this.getInfo()
},
onLoad (query) {
this.id = query.id
this.qqmapsdk = new QQMapWX({
key: '3RZBZ-LZUCF-CT6J5-NWKZH-FCWOQ-UUFKY'
})
this.$loading()
},
methods: {
getInfo () {
this.$instance.post(`/appactivityinfo/queryDetailById?id=${this.id}`).then(res => {
if (res.code === 0) {
this.info = res.data
this.$nextTick(() => {
this.getLocation()
this.pageShow = true
})
}
})
},
toSign () {
if (!this.latitude) {
this.$dialog.alert({
title: '温馨提示',
content: '您未授权定位,请先授权!'
}).then(() => {
this.getLocation()
}).catch(() => {
})
return false
}
if (!this.isClock) {
this.$dialog.alert({
title: '温馨提示',
content: '不满足打卡条件!'
}).then(() => {
this.getLocation()
}).catch(() => {
})
return false
}
this.$loading()
let type = 0
const times = new Date().getTime()
const inSTimes = new Date(this.info.intoBegintime.replaceAll('-', '/')).getTime()
const inETimes = new Date(this.info.intoEndtime.replaceAll('-', '/')).getTime()
const outSTimes = new Date(this.info.exitBegintime.replaceAll('-', '/')).getTime()
const outETimes = new Date(this.info.exitEndtime.replaceAll('-', '/')).getTime()
if (!this.info.intoClock && (times > inSTimes && times < inETimes)) {
type = 0
}
if (!this.info.exitClock && (times > outSTimes && times < outETimes)) {
type = 1
}
this.$instance.post(`/appactivityinfo/clock`, {
address: this.address,
activityId: this.id,
clockTime: this.$dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'),
lat: this.latitude,
lng: this.longitude,
type
}).then(res => {
if (res.code === 0) {
this.$toast('打卡成功')
this.getInfo()
}
this.$hideLoading()
}).catch(() => {
this.$hideLoading()
})
},
getLocation () {
wx.authorize({
scope: 'scope.userLocation',
@@ -65,14 +190,13 @@
uni.getLocation({
type: 'wgs84',
success: res => {
console.log('当前位置的经度:' + res.longitude)
console.log('当前位置的纬度:' + res.latitude)
this.latitude = res.latitude
this.longitude = res.longitude
this.qqmapsdk.reverseGeocoder({
location: `${res.latitude},${res.longitude}`,
success: data => {
console.log(data)
this.address = data.result.formatted_addresses.recommend
},
fail: function(info){
console.log(info)
@@ -85,11 +209,11 @@
latitude: res.latitude
},
to: [{
longitude: 114.342093,
latitude: 30.499959
longitude: this.info.lng,
latitude: this.info.lat
}],
success: res => {
console.log(res.result.elements[0].distance)
this.distance = res.result.elements[0].distance
},
fail: function(error) {
console.error(error)
@@ -121,6 +245,14 @@
}
})
},
toAddress () {
wx.openLocation({
latitude: this.info.lat,
longitude: this.info.lng,
scale: 18
})
}
}
}
</script>
@@ -232,13 +364,22 @@
box-shadow: 0 8px 12px -4px rgba(133,196,255,0.65);
border-radius: 50%;
&.disable {
border-color: #D5DCEA;
background-image: none;
h2 {
color: #ADB9D1;
}
}
h2 {
margin-bottom: 20px;
color: #fff;
font-size: 40px;
}
span {
margin-top: 20px;
color: rgba(255, 255, 255, 0.8);
font-size: 28px;
}