|
@@ -115,6 +115,7 @@ import { onLoad } from '@dcloudio/uni-app'
|
|
|
import { ref } from 'vue'
|
|
import { ref } from 'vue'
|
|
|
import { getDetailInfoById, getReportById, getSigninById } from '@/api/index.js'
|
|
import { getDetailInfoById, getReportById, getSigninById } from '@/api/index.js'
|
|
|
import dayjs from 'dayjs'
|
|
import dayjs from 'dayjs'
|
|
|
|
|
+import { calculateDistance } from '@/utils/calculateDistance.js'
|
|
|
|
|
|
|
|
// 富文本样式
|
|
// 富文本样式
|
|
|
let tagStyle = {
|
|
let tagStyle = {
|
|
@@ -126,11 +127,16 @@ const info = ref({})
|
|
|
// 活动ID
|
|
// 活动ID
|
|
|
const currentId = ref()
|
|
const currentId = ref()
|
|
|
|
|
|
|
|
|
|
+const lat = ref('')
|
|
|
|
|
+const lng = ref('')
|
|
|
|
|
+
|
|
|
onLoad((options) => {
|
|
onLoad((options) => {
|
|
|
if (options.id) {
|
|
if (options.id) {
|
|
|
currentId.value = options.id
|
|
currentId.value = options.id
|
|
|
// 根据ID获取活动数据详情
|
|
// 根据ID获取活动数据详情
|
|
|
getData(options.id)
|
|
getData(options.id)
|
|
|
|
|
+ // 获取当前用户经纬度
|
|
|
|
|
+ getAddress()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -144,6 +150,17 @@ const getData = async (id) => {
|
|
|
info.value = res.data
|
|
info.value = res.data
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 获取当前用户经纬度
|
|
|
|
|
+const getAddress = () => {
|
|
|
|
|
+ uni.getLocation({
|
|
|
|
|
+ // type: 'wgs84',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ lng.value = res.longitude
|
|
|
|
|
+ lat.value = res.latitude
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 点击查看更多回调
|
|
// 点击查看更多回调
|
|
|
const goDetail = (e) => {
|
|
const goDetail = (e) => {
|
|
|
// 1为已报名,2为签到人员,3为活动相册
|
|
// 1为已报名,2为签到人员,3为活动相册
|
|
@@ -190,29 +207,43 @@ const handleApply = (id) => {
|
|
|
|
|
|
|
|
// 我要签到按钮回调
|
|
// 我要签到按钮回调
|
|
|
const handleSign = (id) => {
|
|
const handleSign = (id) => {
|
|
|
- uni.showModal({
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- content: '确定签到吗?',
|
|
|
|
|
- success: async (res) => {
|
|
|
|
|
- if (res.confirm) {
|
|
|
|
|
- let data = {
|
|
|
|
|
- id
|
|
|
|
|
- }
|
|
|
|
|
- const res = await getSigninById(data)
|
|
|
|
|
- // console.log(res)
|
|
|
|
|
- if (res.code == 200) {
|
|
|
|
|
- uni.showToast({
|
|
|
|
|
- title: res.message,
|
|
|
|
|
- icon: 'success',
|
|
|
|
|
- mask: true
|
|
|
|
|
- })
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- getData(info.id)
|
|
|
|
|
- }, 1500)
|
|
|
|
|
|
|
+ let rangValue = 500
|
|
|
|
|
+
|
|
|
|
|
+ // 计算出距离
|
|
|
|
|
+ let distance = calculateDistance(info.value.lat, info.value.lng, lat.value, lng.value)
|
|
|
|
|
+ // console.log(distance)
|
|
|
|
|
+
|
|
|
|
|
+ if (rangValue > distance) {
|
|
|
|
|
+ uni.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: '确定签到吗?',
|
|
|
|
|
+ success: async (res) => {
|
|
|
|
|
+ if (res.confirm) {
|
|
|
|
|
+ let data = {
|
|
|
|
|
+ id
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = await getSigninById(data)
|
|
|
|
|
+ // console.log(res)
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res.message,
|
|
|
|
|
+ icon: 'success',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ })
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ getData(info.id)
|
|
|
|
|
+ }, 1500)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '超出签到范围,无法签到',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ mask: true
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|