Browse Source

代码规范修改

master
zhangyongzhangyong 6 years ago
parent
commit
10fda6c50c
  1. 50
      src/views/modules/heart/actinfo-add-or-update.vue
  2. 7
      src/views/modules/heart/actinfo-list.vue
  3. 188
      src/views/modules/heart/map-select.vue

50
src/views/modules/heart/actinfo-add-or-update.vue

@ -289,7 +289,7 @@ export default {
return {
visible: false,
dataForm: {
id:"",
id: '',
title: '',
headPic: '',
signupStartTime: '',
@ -317,13 +317,13 @@ export default {
deptId: '',
punishmentPoints: '',
reward: '',
isBanner:"1",
isBanner: '1',
actUserDefaultState: '1',
bannerUrl:""
bannerUrl: ''
},
isSignupEndTime: {
disabledDate (time) {
return time < Date.now() - 8.64e7;//8.64e7=1000*60*60*24
return time < Date.now() - 8.64e7 // 8.64e7=1000*60*60*24
}
},
isImgRequired: true,
@ -355,7 +355,6 @@ export default {
if (beginDateVal) {
return time.getTime() > new Date(beginDateVal).getTime()
}
}
},
pickerBeginSignInDateAfter: {
@ -528,7 +527,6 @@ export default {
this.$emit('refreshDataList')
this.$parent.selectComponent = 'ActInfoList'
this.$router.push({ path: '/heart-actinfo'})
},
init () {
this.visible = true
@ -541,16 +539,16 @@ export default {
},
position(position){
if(position.type == 1 ){
this.dataForm.actAddress = position.address;
this.dataForm.actLatitude = position.latitude;
this.dataForm.actLongitude = position.longitude;
this.dataForm.signinAddress = position.address;
this.dataForm.signinLatitude = position.latitude;
this.dataForm.signinLongitude = position.longitude;
this.dataForm.actAddress = position.address
this.dataForm.actLatitude = position.latitude
this.dataForm.actLongitude = position.longitude
this.dataForm.signinAddress = position.address
this.dataForm.signinLatitude = position.latitude
this.dataForm.signinLongitude = position.longitude
} else {
this.dataForm.signinAddress = position.address;
this.dataForm.signinLatitude = position.latitude;
this.dataForm.signinLongitude = position.longitude;
this.dataForm.signinAddress = position.address
this.dataForm.signinLatitude = position.latitude
this.dataForm.signinLongitude = position.longitude
}
},
//
@ -614,23 +612,19 @@ export default {
if (!valid) {
return false
}
var signUpEndTime = new Date(Date.parse(this.dataForm.signupEndTime));
var actStarTime = new Date(Date.parse(this.dataForm.actStartTime));
var actEndTime = new Date(Date.parse(this.dataForm.actEndTime));
var signinEndTime = new Date(Date.parse(this.dataForm.signinEndTime));
var signUpEndTime = new Date(Date.parse(this.dataForm.signupEndTime))
var actStarTime = new Date(Date.parse(this.dataForm.actStartTime))
var actEndTime = new Date(Date.parse(this.dataForm.actEndTime))
var signinEndTime = new Date(Date.parse(this.dataForm.signinEndTime))
if (signUpEndTime > actStarTime) {
return this.$message.error('活动开始时间必须大于报名截止时间。');
return this.$message.error('活动开始时间必须大于报名截止时间.')
}
if (actEndTime < actStarTime) {
return this.$message.error('活动结束时间必须大于活动开始时间。');
return this.$message.error('活动结束时间必须大于活动开始时间.')
}
if (signinEndTime < actEndTime) {
return this.$message.error('签到结束时间必须大于活动结束时间。');
return this.$message.error('签到结束时间必须大于活动结束时间.')
}
this.isAble = true
this.$http[!this.dataForm.id ? 'post' : 'put']('/heart/actinfo/', this.dataForm).then(({ data: res }) => {
this.isAble = false
@ -647,7 +641,9 @@ export default {
}
})
this.$parent.selectComponent = 'ActInfoList'
this.$router.push({ path: '/heart-actinfo'})
this.$router.push({
path: '/heart-actinfo'
})
}).catch(() => {})
})
}, 1000, { 'leading': true, 'trailing': false }),

7
src/views/modules/heart/actinfo-list.vue

@ -134,7 +134,7 @@ export default {
ActUserClockLog
},
created: function () {
this.getDataList();
this.getDataList()
},
methods: {
detailAction (id) {
@ -143,7 +143,9 @@ export default {
},
addAction () {
this.$parent.selectComponent = 'ActInfoAdd'
this.$router.push({ path: '/heart-actinfo'})
this.$router.push(
{ path: '/heart-actinfo'}
)
},
joinManage (id) {
this.$parent.selectComponent = 'ActUserRelation'
@ -166,7 +168,6 @@ export default {
if (state === '1') {
this.actInfoCancelVisible = true
this.$nextTick(() => {
console.log(this.$refs.actinfoCancel.dataForm);
this.$refs.actinfoCancel.dataForm.id = row.id
this.$refs.actinfoCancel.init()
})

188
src/views/modules/heart/map-select.vue

@ -1,44 +1,38 @@
<template>
<el-dialog :visible.sync="visible" :close-on-click-modal="false" :close-on-press-escape="false">
<el-form :inline="true"
<el-form
:inline="true"
:model="dataForm"
:label-width="$i18n.locale === 'en-US' ? '120px' : '120px'">
:label-width="$i18n.locale === 'en-US' ? '120px' : '120px'"
>
<el-row>
<el-form-item label="活动地点:"
prop="address">
<el-input v-model="dataForm.address"
type="text"
clearable
style="width:400px">
</el-input>&emsp;
<el-button type="primary"
@click="searchKeyword()">搜索</el-button>
<el-form-item label="活动地点:" prop="address">
<el-input v-model="dataForm.address" type="text" clearable style="width:400px"></el-input>&emsp;
<el-button type="primary" @click="searchKeyword()">搜索</el-button>
</el-form-item>
</el-row>
<el-row>
<el-form-item label=" "
prop="map">
<el-form-item label=" " prop="map">
<div>
<div id="container" style="width:500px;height:400px;"></div>
</div>
</el-form-item>
</el-row>
</el-form>
<address-check v-if="addressCheckVisible" ref="addressCheck" v-on:checkOk="checkOk"></address-check>
</el-dialog>
</template>
<script>
var searchService;
import jsonp from 'jsonp'
import AddressCheck from './address-check'
var searchService
export default {
name: 'maps',
data () {
return {
dataForm: {
address: "",
address: '',
longitude: 0, //
latitude: 0, //
city: '',
@ -47,7 +41,6 @@ export default {
},
visible: false,
addressCheckVisible: false
}
},
methods: {
@ -56,14 +49,19 @@ export default {
this.dataForm.address = ''
this.dataForm.type = type
this.dataForm.radius = radius
this.getMyLocation();
this.getMyLocation()
},
getAddress (lat, lng) {
this.dataForm.longitude = lng;
this.dataForm.latitude = lat;
var url3 = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lng + "&key=MQFBZ-LTWW6-R7XSK-MFXUQ-DVSIE-BGB4M&output=jsonp";
jsonp(url3, null, (err, data) => {
if (err) {
this.dataForm.longitude = lng
this.dataForm.latitude = lat
var url3 =
'https://apis.map.qq.com/ws/geocoder/v1/?location=' +
lat +
',' +
lng +
'&key=MQFBZ-LTWW6-R7XSK-MFXUQ-DVSIE-BGB4M&output=jsonp'
jsonp(url3, null, (err, data) => {
if (err) {
console.log(err)
}
console.log(data)
@ -71,112 +69,122 @@ export default {
})
},
getMyLocation () {
var geolocation = new qq.maps.Geolocation("MQFBZ-LTWW6-R7XSK-MFXUQ-DVSIE-BGB4M", "e家党群-管理端");
geolocation.getIpLocation(this.showPosition, this.showErr);
var geolocation = new qq.maps.Geolocation(
'MQFBZ-LTWW6-R7XSK-MFXUQ-DVSIE-BGB4M',
'e家党群-管理端'
)
geolocation.getIpLocation(this.showPosition, this.showErr)
},
showPosition (position) {
console.log(position);
this.dataForm.latitude = position.lat;
this.dataForm.longitude = position.lng;
this.dataForm.city = position.city;
this.setMap();
console.log(position)
this.dataForm.latitude = position.lat
this.dataForm.longitude = position.lng
this.dataForm.city = position.city
this.setMap()
},
showErr () {
console.log("定位失败");
this.getMyLocation();//使
console.log('定位失败')
this.getMyLocation() // 使
},
setMap () {
const that = this
var markerList =[];
var radiusList =[];
var markerList = []
var radiusList = []
// map qq.maps.Map()
//
var myLatlng = new qq.maps.LatLng(this.dataForm.latitude,this.dataForm.longitude);
var myLatlng = new qq.maps.LatLng(
this.dataForm.latitude,
this.dataForm.longitude
)
//
var zoom = this.capacity();
var zoom = this.capacity()
var myOptions = {
zoom: zoom, //
center: myLatlng, //
mapTypeId: qq.maps.MapTypeId.ROADMAP // MapType
}
// //dom
var map = new qq.maps.Map(document.getElementById("container"), myOptions);
// dom
var map = new qq.maps.Map(
document.getElementById('container'),
myOptions
)
//
var radius = new qq.maps.Circle({
center:new qq.maps.LatLng(this.dataForm.latitude,this.dataForm.longitude),
center: new qq.maps.LatLng(
this.dataForm.latitude,
this.dataForm.longitude
),
radius: this.dataForm.radius,
map: map
});
radiusList.push(radius);
})
radiusList.push(radius)
var marker = new qq.maps.Marker({
position: myLatlng,
map: map
});
})
markerList.push(marker)
//
qq.maps.event.addListener(map, 'click', function (event) {
that.cleanMarkRadius(markerList,radiusList);
that.getAddress(event.latLng.lat,event.latLng.lng);
var myLatlng = new qq.maps.LatLng(event.latLng.lat,event.latLng.lng);
map.setCenter(myLatlng);
that.cleanMarkRadius(markerList, radiusList)
that.getAddress(event.latLng.lat, event.latLng.lng)
var myLatlng = new qq.maps.LatLng(event.latLng.lat, event.latLng.lng)
map.setCenter(myLatlng)
var marker = new qq.maps.Marker({
position: event.latLng,
map: map
});
})
//
var radius = new qq.maps.Circle({
center: new qq.maps.LatLng(event.latLng.lat, event.latLng.lng),
radius: that.dataForm.radius,
map: map
});
radiusList.push(radius);
})
radiusList.push(radius)
markerList.push(marker)
qq.maps.event.addListener(map, 'click', function (event) {
that.cleanMarkRadius(markerList,radiusList);
});
that.cleanMarkRadius(markerList, radiusList)
})
qq.maps.event.addListener(marker, 'click', function (event) {
that.addressCheckHandle();
});
});
that.addressCheckHandle()
})
})
//
searchService = new qq.maps.SearchService({
complete: function (result) {
var pois = result.detail.pois;
var pois = result.detail.pois
if (pois == null || pois.length <= 0) {
alert("未找到地址!");
that.getAddress(that.dataForm.latitude,that.dataForm.longitude);
alert('未找到地址!')
that.getAddress(that.dataForm.latitude, that.dataForm.longitude)
return
}
map.setCenter(pois[0].latLng);
that.getAddress(pois[0].latLng.lat,pois[0].latLng.lng);
map.setCenter(pois[0].latLng)
that.getAddress(pois[0].latLng.lat, pois[0].latLng.lng)
var marker = new qq.maps.Marker({
map: map,
position: pois[0].latLng
});
})
//
var radius = new qq.maps.Circle({
center: new qq.maps.LatLng(pois[0].latLng.lat, pois[0].latLng.lng),
radius: that.dataForm.radius,
map: map
});
radiusList.push(radius);
markerList.push(marker);
that.cleanMarkRadius(markerList,radiusList);
})
radiusList.push(radius)
markerList.push(marker)
that.cleanMarkRadius(markerList, radiusList)
qq.maps.event.addListener(marker, 'click', function (event) {
that.addressCheckHandle();
});
that.addressCheckHandle()
})
}
});
})
},
searchKeyword () {
searchService.setLocation(this.dataForm.city);
searchService.search(this.dataForm.address);
searchService.setLocation(this.dataForm.city)
searchService.search(this.dataForm.address)
},
addressCheckHandle () {
if (this.dataForm.address =='' || !(this.dataForm.latitude > 0)){
alert("请选择地址!");
if (this.dataForm.address === '' || !(this.dataForm.latitude > 0)) {
alert('请选择地址!')
return
}
this.addressCheckVisible = true
@ -193,45 +201,43 @@ export default {
cleanMarkRadius (markerList, radiusList) {
if (markerList) {
if (markerList.length > 1) {
for (var i = 0; i < markerList.length-1; i++) {
markerList[i].setMap(null);
for (var i4 = 0; i4 < markerList.length - 1; i4++) {
markerList[i4].setMap(null)
}
} else {
for (var i = 0; i < markerList.length; i++) {
markerList[i].setMap(null);
for (var i3 = 0; i3 < markerList.length; i3++) {
markerList[i3].setMap(null)
}
}
}
if (radiusList) {
if (radiusList.length > 1) {
for (var i = 0; i < radiusList.length-1; i++) {
radiusList[i].setMap(null);
for (var i2 = 0; i2 < radiusList.length - 1; i2++) {
radiusList[i2].setMap(null)
}
} else {
for (var i = 0; i < markerList.length; i++) {
radiusList[i].setMap(null);
for (var i1 = 0; i1 < markerList.length; i1++) {
radiusList[i1].setMap(null)
}
}
}
},
capacity () {
if(0 < this.dataForm.radius && this.dataForm.radius <= 25){
if (this.dataForm.radius > 0 && this.dataForm.radius <= 25) {
return 18
} else if (25 < this.dataForm.radius && this.dataForm.radius <= 50){
} else if (this.dataForm.radius > 25 && this.dataForm.radius <= 50) {
return 17
} else if (50 < this.dataForm.radius && this.dataForm.radius <= 100){
} else if (this.dataForm.radius > 50 && this.dataForm.radius <= 100) {
return 16
} else if (100 < this.dataForm.radius && this.dataForm.radius <= 200){
} else if (this.dataForm.radius > 100 && this.dataForm.radius <= 200) {
return 15
} else if (200 < this.dataForm.radius && this.dataForm.radius <= 500){
} else if (this.dataForm.radius > 200 && this.dataForm.radius <= 500) {
return 14
} else if (500 < this.dataForm.radius && this.dataForm.radius <= 1000){
} else if (this.dataForm.radius > 500 && this.dataForm.radius <= 1000) {
return 13
} else if (1000 < this.dataForm.radius && this.dataForm.radius <= 2000){
} else if (this.dataForm.radius > 1000 && this.dataForm.radius <= 2000) {
return 12
} else if (2000 < this.dataForm.radius && this.dataForm.radius <= 5000){
} else if (this.dataForm.radius > 2000 && this.dataForm.radius <= 5000) {
return 11
}
}

Loading…
Cancel
Save