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

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

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

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

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

Loading…
Cancel
Save