51
51
<el-row >
52
52
<el-col :span =" 12" >
53
53
<el-form-item label =" 门店所在地区" prop =" areaId" >
54
- <el-cascader v-model =" formData.areaId" :options =" areaList" :props =" areaTreeProps " />
54
+ <el-cascader v-model =" formData.areaId" :options =" areaList" :props =" defaultProps " />
55
55
</el-form-item >
56
56
</el-col >
57
57
<el-col :span =" 12" >
99
99
</el-col >
100
100
</el-row >
101
101
<el-form-item label =" 获取经纬度" >
102
- <el-button type =" primary" @click =" mapDialogVisible.value = true" >获取</el-button >
102
+ <el-button type =" primary" @click =" mapDialogVisible = true" >获取</el-button >
103
103
</el-form-item >
104
104
</el-form >
105
105
<template #footer >
121
121
import * as DeliveryPickUpStoreApi from ' @/api/mall/trade/delivery/pickUpStore'
122
122
import { DICT_TYPE , getIntDictOptions } from ' @/utils/dict'
123
123
import { CommonStatusEnum } from ' @/utils/constants'
124
+ import { defaultProps } from ' @/utils/tree'
124
125
import { getAreaTree } from ' @/api/system/area'
125
- import * as ConfigApi from ' @/api/infra /config'
126
+ import * as ConfigApi from ' @/api/mall/trade /config'
126
127
const { t } = useI18n () // 国际化
127
128
const message = useMessage () // 消息弹窗
128
129
@@ -161,12 +162,6 @@ const formRules = reactive({
161
162
status: [{ required: true , message: ' 开启状态不能为空' , trigger: ' blur' }]
162
163
})
163
164
const formRef = ref () // 表单 Ref
164
- const areaTreeProps = {
165
- children: ' children' ,
166
- label: ' name' ,
167
- value: ' id' ,
168
- emitPath: false
169
- }
170
165
const areaList = ref () // 区域树
171
166
const tencentLbsUrl = ref (' ' ) // 腾讯位置服务 url
172
167
@@ -244,16 +239,8 @@ const selectAddress = function (loc: any): void {
244
239
mapDialogVisible .value = false
245
240
}
246
241
247
- /** 初始化数据 */
248
- const initData = async () => {
249
- formLoading .value = true
250
- try {
251
- const data = await getAreaTree ()
252
- areaList .value = data
253
- } finally {
254
- formLoading .value = false
255
- }
256
- // TODO @jason:要不创建一个 initTencentLbsMap
242
+ /** 初始化腾讯地图 */
243
+ const initTencentLbsMap = async () => {
257
244
window .selectAddress = selectAddress
258
245
window .addEventListener (
259
246
' message' ,
@@ -267,17 +254,16 @@ const initData = async () => {
267
254
},
268
255
false
269
256
)
270
- const data = await ConfigApi .getConfigKey (' tencent.lbs.key' )
271
- let key = ' '
272
- if (data && data .length > 0 ) {
273
- key = data
274
- }
257
+ const data = await ConfigApi .getTradeConfig ()
258
+ const key = data .tencentLbsKey
275
259
tencentLbsUrl .value = ` https://apis.map.qq.com/tools/locpicker?type=1&key=${key }&referer=myapp `
276
260
}
277
261
278
262
/** 初始化 **/
279
- onMounted (() => {
280
- initData ()
263
+ onMounted (async () => {
264
+ areaList .value = await getAreaTree ()
265
+ // 加载地图
266
+ await initTencentLbsMap ()
281
267
})
282
268
</script >
283
269
<style lang="scss">
0 commit comments