派单地图dome
This commit is contained in:
parent
98865bd1b6
commit
ebb015b51c
1
addons/address/bootstrap.js
vendored
1
addons/address/bootstrap.js
vendored
|
|
@ -21,7 +21,6 @@ require([], function () {
|
||||||
if (city_code){
|
if (city_code){
|
||||||
url += city_code ? "&city_code=" + city_code : "";
|
url += city_code ? "&city_code=" + city_code : "";
|
||||||
}
|
}
|
||||||
console.log(url);
|
|
||||||
Fast.api.open(url, '位置选择', {
|
Fast.api.open(url, '位置选择', {
|
||||||
callback: function (res) {
|
callback: function (res) {
|
||||||
input_id && $("#" + input_id).val(res.address).trigger("change");
|
input_id && $("#" + input_id).val(res.address).trigger("change");
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ class Index extends Controller
|
||||||
// 加载当前控制器语言包
|
// 加载当前控制器语言包
|
||||||
$this->view->assign('site', $site);
|
$this->view->assign('site', $site);
|
||||||
$this->view->assign('config', $config);
|
$this->view->assign('config', $config);
|
||||||
|
|
||||||
return $this->view->fetch();
|
return $this->view->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace app\admin\controller\orders;
|
||||||
use app\admin\model\Order;
|
use app\admin\model\Order;
|
||||||
use app\admin\model\OrderDispatch;
|
use app\admin\model\OrderDispatch;
|
||||||
use app\common\controller\Backend;
|
use app\common\controller\Backend;
|
||||||
|
use think\Config;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
|
@ -301,4 +302,11 @@ class Dispatch extends Backend
|
||||||
return $workers;
|
return $workers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function map(){
|
||||||
|
// 配置信息
|
||||||
|
$config = get_addon_config('address');
|
||||||
|
$this->view->assign('mapkey',$config);
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
79
application/admin/view/orders/dispatch/map.html
Normal file
79
application/admin/view/orders/dispatch/map.html
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>地图派单示例</title>
|
||||||
|
<!-- 使用高德测试 Key -->
|
||||||
|
<script src="https://webapi.amap.com/maps?v=2.0&key={$mapkey.amapkey|default=''}"></script>
|
||||||
|
<style>
|
||||||
|
#map { width: 100%; height: 600px; }
|
||||||
|
.info-window {
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="map"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window._AMapSecurityConfig = {
|
||||||
|
securityJsCode: "{$mapkey.amapsecurityjscode|default=''}",
|
||||||
|
}
|
||||||
|
|
||||||
|
const taskLocation = [104.065735, 30.657201]; // 天府广场
|
||||||
|
|
||||||
|
const workers = [
|
||||||
|
{ name: '张三', phone: '138****1234', position: [104.066, 30.658] },
|
||||||
|
{ name: '李四', phone: '139****5678', position: [104.064, 30.656] },
|
||||||
|
{ name: '王五', phone: '136****9876', position: [104.067, 30.659] },
|
||||||
|
];
|
||||||
|
|
||||||
|
const map = new AMap.Map('map', {
|
||||||
|
zoom: 16,
|
||||||
|
center: taskLocation,
|
||||||
|
});
|
||||||
|
|
||||||
|
// 添加任务地点标记(红色)
|
||||||
|
const taskMarker = new AMap.Marker({
|
||||||
|
position: taskLocation,
|
||||||
|
title: '任务地点',
|
||||||
|
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
|
||||||
|
label: {
|
||||||
|
content: '<span style="color: red; font-weight: bold;">任务点</span>',
|
||||||
|
offset: new AMap.Pixel(20, -10)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map.add(taskMarker);
|
||||||
|
|
||||||
|
// 添加工人标记(蓝色)
|
||||||
|
workers.forEach(worker => {
|
||||||
|
const marker = new AMap.Marker({
|
||||||
|
position: worker.position,
|
||||||
|
title: worker.name,
|
||||||
|
icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-blue.png',
|
||||||
|
label: {
|
||||||
|
content: `<span>${worker.name}</span>`,
|
||||||
|
offset: new AMap.Pixel(20, -10)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const infoWindow = new AMap.InfoWindow({
|
||||||
|
content: `
|
||||||
|
<div class="info-window">
|
||||||
|
<strong>${worker.name}</strong><br/>
|
||||||
|
电话:${worker.phone}<br/>
|
||||||
|
<button onclick="alert('已派单给 ${worker.name}')">派单</button>
|
||||||
|
</div>`,
|
||||||
|
offset: new AMap.Pixel(0, -30)
|
||||||
|
});
|
||||||
|
|
||||||
|
marker.on('click', () => {
|
||||||
|
infoWindow.open(map, marker.getPosition());
|
||||||
|
});
|
||||||
|
|
||||||
|
map.add(marker);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -230,6 +230,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
||||||
},
|
},
|
||||||
refresh: true,
|
refresh: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "mapdispatch",
|
||||||
|
text: "地图派单",
|
||||||
|
title: "派单",
|
||||||
|
extend: 'data-toggle="tooltip" data-container="body"',
|
||||||
|
classname: 'btn btn-xs btn-info btn-dialog',
|
||||||
|
icon: 'fa fa-add',
|
||||||
|
url: function (row) {
|
||||||
|
return 'orders/dispatch/map?order_id=' + row.id;
|
||||||
|
},
|
||||||
|
visible: function (row) {
|
||||||
|
if (row.status == 10) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
refresh: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "reminder",
|
name: "reminder",
|
||||||
text: "催单",
|
text: "催单",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user