This commit is contained in:
zmj 2024-06-05 00:14:06 +08:00
parent 5e2a76a98a
commit 1361b6e11e
7 changed files with 405 additions and 0 deletions

View File

@ -63,3 +63,4 @@
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>
<script charset="utf-8" src="https://map.qq.com/api/gljs?v=1.exp&key=V4LBZ-UKCHA-EUNK7-CUH4F-HOXVO-YTF56"></script>

12
package-lock.json generated
View File

@ -17,12 +17,14 @@
"css-color-function": "^1.3.3", "css-color-function": "^1.3.3",
"echarts": "^5.3.3", "echarts": "^5.3.3",
"element-plus": "2.2.27", "element-plus": "2.2.27",
"fetch-jsonp": "^1.3.0",
"highlight.js": "^11.6.0", "highlight.js": "^11.6.0",
"nprogress": "^0.2.0", "nprogress": "^0.2.0",
"pinia": "^2.0.14", "pinia": "^2.0.14",
"vue": "^3.2.37", "vue": "^3.2.37",
"vue-clipboard3": "^2.0.0", "vue-clipboard3": "^2.0.0",
"vue-echarts": "^6.2.3", "vue-echarts": "^6.2.3",
"vue-jsonp": "^2.0.0",
"vue-router": "^4.0.16", "vue-router": "^4.0.16",
"vue3-video-play": "1.3.1-beta.6", "vue3-video-play": "1.3.1-beta.6",
"vuedraggable": "^4.1.0" "vuedraggable": "^4.1.0"
@ -4070,6 +4072,11 @@
"reusify": "^1.0.4" "reusify": "^1.0.4"
} }
}, },
"node_modules/fetch-jsonp": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/fetch-jsonp/-/fetch-jsonp-1.3.0.tgz",
"integrity": "sha512-hxCYGvmANEmpkHpeWY8Kawfa5Z1t2csTpIClIDG/0S92eALWHRU1RnGaj86Tf5Cc0QF+afSa4SQ4pFB2rFM5QA=="
},
"node_modules/file-entry-cache": { "node_modules/file-entry-cache": {
"version": "6.0.1", "version": "6.0.1",
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
@ -8486,6 +8493,11 @@
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
"dev": true "dev": true
}, },
"node_modules/vue-jsonp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/vue-jsonp/-/vue-jsonp-2.0.0.tgz",
"integrity": "sha512-Mzd9GNeuKP5hHFDWZNMWOsCuMILSkA6jo2l4A02wheFz3qqBzH7aSEFTey1BRCZCLizlaf1EqJ5YUtF392KspA=="
},
"node_modules/vue-router": { "node_modules/vue-router": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.3.0.tgz", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.3.0.tgz",

20
src/api/address.ts Normal file
View File

@ -0,0 +1,20 @@
import request from '@/utils/request'
export function apigetProvinceLists() {
return request.get({ url: '/geo/province' })
}
export function apicityLists(params: any) {
return request.get({ url: '/geo/city', params })
}
export function apiAreaLists(params: any) {
return request.get({ url: '/geo/area', params })
}
export function apiStreetLists(params: any) {
return request.get({ url: '/geo/street', params })
}
export function apiVillageLists(params: any) {
return request.get({ url: '/geo/village', params })
}

View File

@ -0,0 +1,226 @@
<template>
<el-card>
<div class="w-[600px]">
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
<el-tabs v-model="activeName" class="demo-tabs">
<el-tab-pane label="基础设置" name="first">
<el-form-item label="门店名称" prop="title">
<el-input v-model="formData.title" clearable placeholder="请输入店员名称" />
</el-form-item>
<el-form-item label="门店手机号" prop="title">
<el-input v-model="formData.title" clearable placeholder="请输入店员名称" />
</el-form-item>
<el-form-item label="营业状态" prop="title">
<el-switch v-model="formData.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="营业时间" prop="title">
<el-time-picker v-model="formData.times" is-range range-separator="-"
start-placeholder="开始时间" end-placeholder="结束时间" value-format="HH:mm:ss" />
</el-form-item>
<el-form-item label="门店地址" prop="title">
<el-row>
<el-col :span="6">
<el-select class="flex-1" v-model="formData.city_id" clearable placeholder="请选择"
@change="getCityList(formData.province_id, false)">
<el-option v-for="(item, index) in address.provinceList" :key="index"
:label="item.province_name" :value="parseInt(item.province_code)" />
</el-select>
</el-col>
<el-col :span="6">
<el-select class="flex-1" v-model="formData.city_id" clearable placeholder="请选择"
@change="getAreaList(formData.city_id, false)">
<el-option v-for="(item, index) in address.cityList" :key="index"
:label="item.city_name" :value="parseInt(item.city_code)" />
</el-select>
</el-col>
<el-col :span="6">
<el-select class="flex-1" v-model="formData.area_id" clearable placeholder="请选择"
@change="getTownList(formData.area_id, false)">
<el-option v-for="(item, index) in address.areaList" :key="index"
:label="item.area_name" :value="parseInt(item.area_code)" />
</el-select>
</el-col>
<el-col :span="6">
<el-select class="flex-1" v-model="formData.street_id" clearable placeholder="请选择"
@change="getVilllageList(formData.street_id, false)">
<el-option v-for="(item, index) in address.townList" :key="index"
:label="item.street_name" :value="parseInt(item.street_code)" />
</el-select>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="配送范围(km)" prop="title">
<el-input-number v-model="formData.num" :step="1" />
</el-form-item>
<el-form-item label="门店详细地址" prop="title">
<!-- <el-input v-model="formData.title" clearable placeholder="请输入手机号码" /> -->
<!-- <myMap></myMap> -->
</el-form-item>
</el-tab-pane>
<el-tab-pane label="配送设置" name="second">
<el-form-item label="同城配送" prop="title">
<el-switch v-model="formData.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="到店自提" prop="title">
<el-switch v-model="formData.status" :active-value="1" :inactive-value="0"></el-switch>
</el-form-item>
<el-form-item label="默认配送方式" prop="title">
<el-radio-group v-model="formData.types" class="ml-4">
<el-radio label="1" size="large">配送</el-radio>
<el-radio label="2" size="large">自提</el-radio>
</el-radio-group>
</el-form-item>
</el-tab-pane>
</el-tabs>
</el-form>
</div>
</el-card>
</template>
<script lang="ts" setup name="oaPlanEdit">
import type { FormInstance } from 'element-plus'
import { timeFormat } from '@/utils/util'
import { apicityLists, apiAreaLists, apiStreetLists, apigetProvinceLists } from "@/api/address"
import myMap from "./myMap/index.vue"
import axios from 'axios';
axios.get(`https://apis.map.qq.com/ws/place/v1/search?boundary=nearby(40.040589,116.273543,1000)&keyword=公园&page_size=10&page_index=1&key=SMJBZ-WCHK4-ZPZUA-DSIXI-XDDVQ-XWFX7`)
.then(function (response) {
console.log(54545)
})
.catch(function (error) {
//
})
.finally(function () {
//
});
const formRef = shallowRef<FormInstance>()
const activeName = ref('first')
//
const address = reactive({
provinceList: [],
cityList: [],
areaList: [],
townList: [],
})
//
const formData = reactive({
id: '',
status: 0,
title: '',
province_id: '510000',
city_id: '',
area_id: '',
street_id: '',
types: '1',
times: '',
num: "",
start_time: '',
end_time: '',
remind_type: '',
remark: '',
})
const chekcDate = (rule: any, value: any, callback: any) => {
if (new Date(formData.end_time) < new Date(formData.start_time)) {
callback(new Error('结束时间不能早于开始时间'))
} else {
callback()
}
}
//
const formRules = reactive<any>({
end_time: [{
required: true,
message: '请输入结束时间',
trigger: ['blur']
},
{
validator: chekcDate,
trigger: ['blur']
}],
remind_type: [{
required: true,
message: '请输入提醒类型',
trigger: ['blur']
}],
})
//
const setFormData = async (data: Record<any, any>) => {
for (const key in formData) {
if (data[key] != null && data[key] != undefined) {
//@ts-ignore
formData[key] = data[key]
}
}
}
//
const handleSubmit = async () => {
await formRef.value?.validate()
const data = { ...formData, }
// mode.value == 'edit'
// ? await apiOaPlanEdit(data)
// : await apiOaPlanAdd(data)
}
const getProvinceList = async (isAsync: Boolean) => {
let res = await apigetProvinceLists()
address.provinceList = res
if (isAsync) {
return Promise.resolve({
msg: '获取成功'
});
}
}
const getCityList = async (province_code: number | String, isAsync: Boolean) => {
let res = await apicityLists({ province_code })
address.cityList = res
if (isAsync) {
return Promise.resolve({
msg: '获取成功'
});
}
}
const getAreaList = async (city_code: number | String, isAsync: Boolean) => {
let res = await apiAreaLists({ city_code })
address.areaList = res
if (isAsync) {
return Promise.resolve({
msg: '获取成功'
});
}
}
const getTownList = async (area_code: number | String, isAsync: Boolean) => {
let res = await apiStreetLists({ area_code })
address.townList = res
if (isAsync) {
return Promise.resolve({
msg: '获取成功'
});
}
}
// getProvinceList(false)
</script>

View File

@ -0,0 +1,141 @@
<template>
<div>
<div>
<el-autocomplete v-model="address" :fetch-suggestions="querySearch" placeholder="请输入详细地址"
:trigger-on-focus="false" />
<el-button type="primary" @click="getLocations">
搜索
</el-button>
</div>
<div id="amp-container" />
</div>
</template>
<script lang="ts" setup>
import { defineComponent, onMounted, reactive, ref, toRefs, inject } from 'vue';
import axios from 'axios';
const $api: any = inject("$api");
const dataMap = reactive({
map: '',
markerLayer: '',
latitude: '', //
lngitude: '', //
});
const TMap = (window as any).TMap;
onMounted(() => {
init();
getLocation();
});
const init = () => {
let center = new TMap.LatLng(dataMap.latitude, dataMap.lngitude);
dataMap.map = new TMap.Map(document.getElementById('amp-container'), {
center: center,//
zoom: 11, //
viewMode: '2D'
});
(dataMap.map as any).on('click', clickHandler); //
markerLayer(); //
};
//
const reloadMap = () => {
(document.getElementById('amp-container') as any).innerHTML = '';
dataMap.markerLayer = '';
let center = new TMap.LatLng(dataMap.latitude, dataMap.lngitude);
dataMap.map = new TMap.Map(document.getElementById('amp-container'), {
center: center,//
viewMode: '2D'
});
markerLayer();
};
const getLocation = async () => {
try {
let params = {
// ip:(window as any ).returnCitySN['cip'],
key: "V4LBZ-UKCHA-EUNK7-CUH4F-HOXVO-YTF56",
};
let { result } = await $api.cerStores.getLoaction(params);
// post
if (result) {
dataMap.latitude = result.location.lat;
dataMap.lngitude = result.location.lng;
(dataMap.map as any).setCenter(new TMap.LatLng(dataMap.latitude, dataMap.lngitude));
reloadMap();
}
} catch (e) {
console.log(e);
}
};
//
const clickHandler = (evt: any) => {
dataMap.latitude = evt.latLng.getLat().toFixed(6);
dataMap.lngitude = evt.latLng.getLng().toFixed(6);
(dataMap.map as any).setCenter(new TMap.LatLng(dataMap.latitude, dataMap.lngitude));
reloadMap();
};
//
const markerLayer = () => {
dataMap.markerLayer = new TMap.MultiMarker({
map: dataMap.map, //
//
styles: {
//styleId"myStyle"stylesstyleId
"myStyle": new TMap.MarkerStyle({
"width": 25, //
"height": 35, //
// "src": '../../assets/logo.png', //
'background': 'pink',
//
"anchor": { x: 16, y: 32 }
})
},
//
geometries: [
{
"id": "1", //id
"styleId": 'myStyle', //id
"position": new TMap.LatLng(dataMap.latitude, dataMap.lngitude), //
},
]
});
};
const address = ref('');
//
const getLocations = async () => {
try {
let params = {
key: "V4LBZ-UKCHA-EUNK7-CUH4F-HOXVO-YTF56", // key
address: address.value, //
};
let { result } = await $api.cerStores.getGeocoder(params);
dataMap.latitude = result.location.lat;
dataMap.lngitude = result.location.lng;
(dataMap.map as any).setCenter(new TMap.LatLng(dataMap.latitude, dataMap.lngitude));
reloadMap();
} catch (error) {
console.log(error);
}
};
const querySearch = async (queryString: string, cb: any) => {
try {
let params = {
keyword: queryString,
key: "V4LBZ-UKCHA-EUNK7-CUH4F-HOXVO-YTF56", // key
};
let { data } = await $api.cerStores.getSuggestion(params);
const results = data.map((item: any) => {
let obj = {
value: item.address,
address: item.address
};
return obj;
});
cb(results);
} catch (e) {
console.log(e);
}
};
</script>

View File

View File

@ -17,6 +17,11 @@ export default defineConfig({
host: '0.0.0.0', host: '0.0.0.0',
open: true, open: true,
port: 8787, port: 8787,
proxy: {
'/ws': {
target: 'https://apis.map.qq.com/',
}
}
}, },
plugins: [ plugins: [
vue(), vue(),