注:除了根据下面更改外一定要替换map文件
注意⚠️:需要安装:npm install vue-jsonp --save
平台端与门店端后台:
文件是:view/admin源码目录
1、链接:/src/main.js
添加如图所示:
方便复制:
import { VueJsonp } from 'vue-jsonp'
Vue.use(VueJsonp);
2、链接:/src/components/map/map.vue
下载附件 注:没有改过代码的直接覆盖,改过代码的对照一下
注:1和2平台端和门店端都需要更改
3、平台端修改:
a、链接:/src/api/store.js
添加接口如图所示:
方便复制:
/**
* @description 门店-添加门店
* data--地址转id
*/
export function getResolveCity (data) {
return request({
url: `resolve/city`,
method: 'get',
params: data
})
}
b、链接:/src/pages/store/addStore/index.vue(3.0.1之前链接:src/pages/store/components/addStore.vue)
方便复制:
提示:为减少误差,建议门店地址与定位地区保持一致
.tip{
color: #ed4014;
}
方便复制:
getResolveCity
方便复制:
resolveCity(address){
let data = {
address:address
}
getResolveCity(data).then(res=>{
let array = []
res.data.forEach(item=>{
array.push(item.id)
})
this.formItem.addressSelect = array
}).catch(err=>{
this.$Message.error(res.msg)
})
},
// 地图信息获取
getCoordinates(data) {
this.formItem.latitude = data.location.lat || 34.34127
this.formItem.longitude = data.location.lng || 108.93984
if(data.address_reference){
let landmark = data.address_reference.landmark_l2;
this.formItem.detailed_address = landmark.title;
this.formItem.latitude = landmark.location.lat || 34.34127;
this.formItem.longitude = landmark.location.lng || 108.93984;
let component = data.address_component;
let town = data.address_reference.town.title;
town = town == '丈八街道'?'丈八沟街道':town;
let address = [component.province,component.city,component.district,town];
this.storeAddress = address.join('');
this.formItem.address = address.join('');
this.resolveCity(address.join('/'));
}
},
查找函数getInfo();删除里面的onSearch()
查找函数 addchack()里面添加如图:
方便复制:this.formItem.addressSelect = e;
4、门店端修改:
文件是:view/store源码目录
a、链接:/src/api/setting.js
方便复制:
/**
* @description 门店-添加门店
* data--地址转id
*/
export function getResolveCity (data) {
return request({
url: `resolve/city`,
method: 'get',
params: data
})
}
b、链接:/src/pages/setting/index.vue
方便复制:
提示:为减少误差,建议门店地址与定位地区保持一致
v-if="isApi && currentTab == 1"
.tip{
color: #ed4014;
}
方便复制:getResolveCity
方便复制:
resolveCity(address){
let data = {
address:address
}
getResolveCity(data).then(res=>{
let array = []
res.data.forEach(item=>{
array.push(item.id)
})
this.formItem.addressSelect = array
}).catch(err=>{
this.$Message.error(res.msg)
})
},
// 地图信息获取
getCoordinates(data) {
this.formItem.latitude = data.location.lat || 34.34127
this.formItem.longitude = data.location.lng || 108.93984
if(data.address_reference){
let landmark = data.address_reference.landmark_l2;
this.formItem.detailed_address = landmark.title;
this.formItem.latitude = landmark.location.lat || 34.34127;
this.formItem.longitude = landmark.location.lng || 108.93984;
let component = data.address_component;
let town = data.address_reference.town.title;
town = town == '丈八街道'?'丈八沟街道':town;
let address = [component.province,component.city,component.district,town];
this.formItem.address = address.join('');
this.resolveCity(address.join('/'));
}
},
查找函数getInfo();删除里面的onSearch()
查找函数 addchack()里面添加如图:
方便复制:this.formItem.addressSelect = e;
需要安装:npm install vue-jsonp --save
5、需要重新打包 (平台后台、门店后台)
打包文档: https://doc.crmeb.com/pro/crmebprov2/2354
php代码修改:
6、文件:route/admin.php
增加如下接口:
//解析(导入地图城市地址)
Route::get('resolve/city', 'Common/resolveCityList')->option(['real_name' => '解析导入地图城市地址']);
放在下图所在位置:
7、文件:app/controller/admin/Common.php
增加如下方法:
/**
* 解析(获取导入地图城市地址)
* @param CityAreaServices $services
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function resolveCityList(CityAreaServices $services)
{
$address = $this->request->param('address', '');
if (!$address)
return app('json')->fail('地址不存在');
if (strpos($address, '/') === false) {
$address = implode('/', array_values($services->addressHandle($address)));
}
$city = $services->searchCity(compact('address'));
if (!$city) return app('json')->fail('地址暂未录入,请联系管理员');
$where = [['id', 'in', array_merge([$city['id']], explode('/', trim($city->path, '/')))]];
return app('json')->success($services->getCityList($where, 'id as value,id,name as label,parent_id as pid', ['children']));
}
可以放在,下图所示位置:
8、文件:route/store.php
增加如下接口:
//解析(导入地图城市地址)
Route::get('resolve/city', 'Common/resolveCityList')->option(['real_name' => '解析导入地图城市地址']);
放在下图所在位置:
9、文件:app/controller/store/Common.php
增加如下代码:
/**
* 解析(获取导入地图城市地址)
* @param CityAreaServices $services
* @param Request $request
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function resolveCityList(CityAreaServices $services, Request $request)
{
$address = $request->param('address', '');
if (!$address)
return app('json')->fail('地址不存在');
if (strpos($address, '/') === false) {
$address = implode('/', array_values($services->addressHandle($address)));
}
$city = $services->searchCity(compact('address'));
if (!$city) return app('json')->fail('地址暂未录入,请联系管理员');
$where = [['id', 'in', array_merge([$city['id']], explode('/', trim($city->path, '/')))]];
return app('json')->success($services->getCityList($where, 'id as value,id,name as label,parent_id as pid', ['children']));
}
可以放在,下图所示位置:
10、文件:app/controller/admin/v1/store/SystemStore.php
方法:save,增加如下两部分代码:
11、文件:app/controller/store/system/Store.php
方法:update, 增加如下代码
12、文件:app/services/store/SystemStoreServices.php
增加代码:
$storeInfo['addressSelect'] = [$storeInfo['province'], $storeInfo['city'], $storeInfo['area'], $storeInfo['street']];
14、重启swoole
注意⚠️:
附件中有完整修改打包后文件,
可以下载:地图修改.zip,
在项目站点根目录解压(针对技术小白)
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}