130 lines
6.0 KiB
JavaScript
130 lines
6.0 KiB
JavaScript
const self_mixin = {
|
|
data() {
|
|
return {
|
|
//已报名人数
|
|
hasRegUserNum: 0,
|
|
unionId: null,
|
|
unionLimitNum: 0,
|
|
isRegisterFull: false
|
|
}
|
|
},
|
|
methods: {
|
|
async getActivityInfo() {
|
|
const resp = await $.get('/mobile/activity/unionActivity/findOne', {id: this.activityId})
|
|
if (resp.code === 0) {
|
|
resp.data.location = JSON.parse(resp.data.location)
|
|
resp.data.unionUserNumberLimit = JSON.parse(resp.data.unionUserNumberLimit)
|
|
this.o = resp.data
|
|
this.unionId = "${@shiro.getPrincipalProperty('unit').getUnionid()}"
|
|
if (!this.unionId) {
|
|
this.$toast.fail('您的所属工会信息缺失,请联系管理员')
|
|
return
|
|
}
|
|
if (this.o.userNumberLimit === 2) {
|
|
const unionLimit = resp.data.unionUserNumberLimit.find(v => v.id === this.unionId)
|
|
this.unionLimitNum = unionLimit.limitNum
|
|
}
|
|
await this.getHasRegUserNum()
|
|
this.$nextTick(() => {
|
|
// document.getElementsByClassName('activity_img_back')[0].style.backgroundImage = "url(" + FILE_DOMAIN + this.o.cover + ")"
|
|
if (this.o.needSign) {
|
|
this.initMap()
|
|
}
|
|
})
|
|
}
|
|
},
|
|
async getHasRegUserNum() {
|
|
const resp = await $.get('/mobile/activity/unionActivity/getHasRegUserNum', {activityId: this.activityId})
|
|
this.hasRegUserNum = resp.data
|
|
if (this.o.signUpMethod === 1) {
|
|
if (this.o.userNumberLimit === 1) {
|
|
if (this.hasRegUserNum === this.o.totalUserNumberLimit) {
|
|
this.isRegisterFull = true
|
|
}
|
|
}
|
|
}
|
|
},
|
|
initMap() {
|
|
let marker = null
|
|
let circle = null
|
|
this.$nextTick(() => {
|
|
let map = new AMap.Map("signMap", {
|
|
zoomEnable: true,
|
|
dragEnable: false,
|
|
resizeEnable: true,
|
|
center: [114.402582, 30.521378],
|
|
zoom: 16
|
|
});
|
|
|
|
if (this.o.location && Array.isArray(this.o.location)) {
|
|
const lng = parseFloat(this.o.location[0])
|
|
const lat = parseFloat(this.o.location[1])
|
|
marker = new AMap.Marker({
|
|
position: [lng, lat],
|
|
offset: new AMap.Pixel(-13, -30)
|
|
})
|
|
map.add(marker)
|
|
// marker.setMap(map);
|
|
// map.setZoomAndCenter(18, [lng, lat])
|
|
|
|
circle = new AMap.Circle({
|
|
center: new AMap.LngLat(lng, lat), // 圆心位置
|
|
radius: this.o.rangeMeter, //半径
|
|
strokeColor: "#F33", //线颜色
|
|
strokeOpacity: 1, //线透明度
|
|
strokeWeight: 1, //线粗细度
|
|
fillColor: "#ee2200", //填充颜色
|
|
fillOpacity: 0.35 //填充透明度
|
|
})
|
|
map.add(circle)
|
|
map.setFitView()
|
|
}
|
|
|
|
if (window.location.pathname === '/mobile/activity/myActivity/goSign' && !this.isSign) {
|
|
map.plugin('AMap.Geolocation', function () {
|
|
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(10, 20),//定位按钮与设置的停靠位置的偏移量,默认:Pixel(10, 20)
|
|
showMarker: true, //定位成功后在定位到的位置显示点标记,默认:true
|
|
showCircle: false, //定位成功后用圆圈表示定位精度范围,默认:true
|
|
panToLocation: true, //定位成功后将定位到的位置作为地图中心点,默认:true
|
|
zoomToAccuracy: true //定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false
|
|
});
|
|
map.addControl(geolocation)
|
|
|
|
geolocation.getCurrentPosition()
|
|
|
|
AMap.event.addListener(geolocation, 'error', (err) => {
|
|
alert(JSON.stringify(err))
|
|
}); //返回定位出错信息
|
|
});
|
|
}
|
|
|
|
|
|
})
|
|
},
|
|
getMapDistance(paramObj) {
|
|
let lng1 = paramObj.lng1
|
|
let lat1 = paramObj.lat1
|
|
|
|
let lng2 = paramObj.lng2
|
|
let lat2 = paramObj.lat2
|
|
|
|
let radLat1 = lat1 * Math.PI / 180.0;
|
|
let radLat2 = lat2 * Math.PI / 180.0;
|
|
let a = radLat1 - radLat2;
|
|
let b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
|
|
let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
|
|
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
|
|
s = s * 6378.137;// EARTH_RADIUS;
|
|
s = Math.round(s * 10000) / 10000;
|
|
s = s * 1000
|
|
return s.toFixed(2)
|
|
}
|
|
}
|
|
} |