|
@@ -17,7 +17,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="详细地址:" prop="fullAddress">
|
|
|
- <el-input v-model="formData.fullAddress" placeholder="请输入详细地址" clearable />
|
|
|
+ <el-input v-model="formData.fullAddress" placeholder="请输入详细地址" clearable @blur="initGeocoder" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="经纬度:" prop="point">
|
|
|
<el-input
|
|
@@ -98,7 +98,10 @@
|
|
|
<el-input v-show="false" v-model="formData.authImage" />
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <preview-image v-if="formData.authImage" width="148px" height="148px" :src="formData.authImage" />
|
|
|
+ <template v-if="authTempFlag">
|
|
|
+ <preview-image v-if="formData.authImage" width="148px" height="148px" :src="formData.authImage" />
|
|
|
+ </template>
|
|
|
+ <template v-else>无</template>
|
|
|
</template>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
@@ -237,9 +240,10 @@ import { AssociatedClubList } from '@/views/components/index'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import { saveBrandAuth, getAuthFormData, fecthAuthList } from '@/api/auth'
|
|
|
import { getAddress } from '@/api/common'
|
|
|
-import { isPoint, isMobile, isNumber } from '@/utils/validate'
|
|
|
+import { isMobile, isNumber } from '@/utils/validate'
|
|
|
import { formatDate } from '@/utils'
|
|
|
import { authTempUsed } from '@/api/system'
|
|
|
+import { initGeocoder } from '@/components/SimpleAMap/common/utils'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
@@ -248,17 +252,17 @@ export default {
|
|
|
AssociatedClubList
|
|
|
},
|
|
|
data() {
|
|
|
- var validatePoint = (rule, value, callback) => {
|
|
|
- if (value === '') {
|
|
|
- callback(new Error('经纬度坐标不能为空'))
|
|
|
- } else {
|
|
|
- if (isPoint(value)) {
|
|
|
- callback()
|
|
|
- } else {
|
|
|
- callback(new Error('经纬度坐标格式不正确,(例如:114.095294,22.536004)'))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ // var validatePoint = (rule, value, callback) => {
|
|
|
+ // if (value === '') {
|
|
|
+ // callback(new Error('经纬度坐标不能为空'))
|
|
|
+ // } else {
|
|
|
+ // if (isPoint(value)) {
|
|
|
+ // callback()
|
|
|
+ // } else {
|
|
|
+ // callback(new Error('经纬度坐标格式不正确,(例如:114.095294,22.536004)'))
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
var validateMobile = (rule, value, callback) => {
|
|
|
if (value === '') {
|
|
@@ -324,7 +328,7 @@ export default {
|
|
|
authParty: [{ required: true, message: '机构名称不能为空', trigger: ['blur', 'change'] }],
|
|
|
address: [{ required: true, message: '地址不能为空', trigger: 'change', type: 'array' }],
|
|
|
fullAddress: [{ required: true, message: '详细不能为空', trigger: ['blur', 'change'] }],
|
|
|
- point: [{ required: true, validator: validatePoint, trigger: ['blur', 'change'] }],
|
|
|
+ // point: [{ required: true, validator: validatePoint, trigger: ['blur', 'change'] }],
|
|
|
mobile: [{ required: true, validator: validateMobile, trigger: ['blur', 'change'] }],
|
|
|
logo: [{ required: true, message: '请上传机构logo', trigger: 'change' }],
|
|
|
banner: [{ required: true, message: '请至少上传一张banner图片', trigger: 'change' }],
|
|
@@ -351,6 +355,8 @@ export default {
|
|
|
authImageLogoWidth: 100,
|
|
|
authImageLogoHeight: 100
|
|
|
},
|
|
|
+ // 授权牌模板标识
|
|
|
+ authTempFlag: false,
|
|
|
// 关联机构相关
|
|
|
assClubQuery: {
|
|
|
pageNum: 1,
|
|
@@ -463,6 +469,27 @@ export default {
|
|
|
this.filterSelectAssClubList = this.selectAssClubListAll
|
|
|
},
|
|
|
|
|
|
+ // 根据地址信息定位
|
|
|
+ async initGeocoder() {
|
|
|
+ try {
|
|
|
+ const geocoder = await initGeocoder()
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ geocoder.getLocation(this.locationAddress, (status, result) => {
|
|
|
+ if (status === 'complete' && result.info === 'OK') {
|
|
|
+ const position = result.geocodes[0].location
|
|
|
+ this.onPosition(position)
|
|
|
+ resolve()
|
|
|
+ } else {
|
|
|
+ console.log(result)
|
|
|
+ reject()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.log(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
// 地图定位
|
|
|
initMap() {
|
|
|
this.dialogMapVisible = true
|
|
@@ -555,13 +582,24 @@ export default {
|
|
|
this.selectAssClubListAll = res.data.releationClubList
|
|
|
this.filterSelectAssClubList = this.selectAssClubListAll
|
|
|
}
|
|
|
+
|
|
|
+ // 如果经纬度为空
|
|
|
+ if (!res.data.lngAndLat && this.locationAddress) {
|
|
|
+ this.initGeocoder()
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
|
|
|
// 表单提交保存
|
|
|
- submit() {
|
|
|
- this.$refs.submitForm.validate((valide) => {
|
|
|
+ async submit() {
|
|
|
+ this.$refs.submitForm.validate(async(valide) => {
|
|
|
if (!valide) return
|
|
|
+
|
|
|
+ // 如果经纬度为空
|
|
|
+ if (!this.formData.point && this.locationAddress) {
|
|
|
+ await this.initGeocoder()
|
|
|
+ }
|
|
|
+
|
|
|
const {
|
|
|
authParty,
|
|
|
address: [provinceId, cityId, townId],
|
|
@@ -623,6 +661,7 @@ export default {
|
|
|
// const lngAndLat = this.formData.point
|
|
|
|
|
|
console.log(data)
|
|
|
+
|
|
|
// return
|
|
|
saveBrandAuth(data)
|
|
|
.then((res) => {
|
|
@@ -645,6 +684,7 @@ export default {
|
|
|
const node = this.$refs.cascader.getCheckedNodes()
|
|
|
if (node.length <= 0) return
|
|
|
this.address = node[0].pathLabels.join()
|
|
|
+ this.initGeocoder()
|
|
|
},
|
|
|
|
|
|
// 获取当前机构可用授权牌模板
|
|
@@ -659,6 +699,9 @@ export default {
|
|
|
const [width, height] = res.data.logoSize.split(',')
|
|
|
this.validatorFields.authImageLogoWidth = width
|
|
|
this.validatorFields.authImageLogoHeight = height
|
|
|
+ this.authTempFlag = true
|
|
|
+ } else {
|
|
|
+ this.authTempFlag = false
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.log(error)
|