feat(admin): 重构服务管理模块新增增值服务功能
- 新增增值服务管理模块,支持按类目筛选绑定 - 新增工项服务定价和规格独立定价功能 - 优化前端订单页增值服务展示逻辑 - 升级版本号至1.0.19
这个提交包含在:
@@ -0,0 +1 @@
|
||||
{"files":["public\\assets\\addons\\address\\js\\gcoord.min.js","public\\assets\\addons\\address\\js\\jquery.autocomplete.js"],"license":"regular","licenseto":"26425","licensekey":"3DruY9BJMFlc5v7U qTT2DqvsmTkJ8a4TGK6OUA==","domains":[],"licensecodes":[],"validations":[]}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace addons\address;
|
||||
|
||||
use think\Addons;
|
||||
|
||||
/**
|
||||
* 地址选择
|
||||
* @author [MiniLing] <[laozheyouxiang@163.com]>
|
||||
*/
|
||||
class Address extends Addons
|
||||
{
|
||||
|
||||
/**
|
||||
* 插件安装方法
|
||||
* @return bool
|
||||
*/
|
||||
public function install()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件卸载方法
|
||||
* @return bool
|
||||
*/
|
||||
public function uninstall()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
34
server/addons/address/bootstrap.js
vendored
普通文件
34
server/addons/address/bootstrap.js
vendored
普通文件
@@ -0,0 +1,34 @@
|
||||
require([], function () {
|
||||
//绑定data-toggle=addresspicker属性点击事件
|
||||
|
||||
$(document).on('click', "[data-toggle='addresspicker']", function () {
|
||||
var that = this;
|
||||
var callback = $(that).data('callback');
|
||||
var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
|
||||
var lat_id = $(that).data("lat-id") ? $(that).data("lat-id") : "";
|
||||
var lng_id = $(that).data("lng-id") ? $(that).data("lng-id") : "";
|
||||
var zoom_id = $(that).data("zoom-id") ? $(that).data("zoom-id") : "";
|
||||
var lat = lat_id ? $("#" + lat_id).val() : '';
|
||||
var lng = lng_id ? $("#" + lng_id).val() : '';
|
||||
var zoom = zoom_id ? $("#" + zoom_id).val() : '';
|
||||
var url = "/addons/address/index/select";
|
||||
url += (lat && lng) ? '?lat=' + lat + '&lng=' + lng + (input_id ? "&address=" + $("#" + input_id).val() : "") + (zoom ? "&zoom=" + zoom : "") : '';
|
||||
Fast.api.open(url, '位置选择', {
|
||||
callback: function (res) {
|
||||
input_id && $("#" + input_id).val(res.address).trigger("change");
|
||||
lat_id && $("#" + lat_id).val(res.lat).trigger("change");
|
||||
lng_id && $("#" + lng_id).val(res.lng).trigger("change");
|
||||
zoom_id && $("#" + zoom_id).val(res.zoom).trigger("change");
|
||||
|
||||
try {
|
||||
//执行回调函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(that, res);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
146
server/addons/address/config.php
普通文件
146
server/addons/address/config.php
普通文件
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
[
|
||||
'name' => 'maptype',
|
||||
'title' => '默认地图类型',
|
||||
'type' => 'radio',
|
||||
'content' => [
|
||||
'tianditu' => '天地图',
|
||||
'baidu' => '百度地图',
|
||||
'amap' => '高德地图',
|
||||
'tencent' => '腾讯地图',
|
||||
],
|
||||
'value' => 'tianditu',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'zoom',
|
||||
'title' => '默认缩放级别',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '11',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'lat',
|
||||
'title' => '默认Lat',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '39.919990',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'lng',
|
||||
'title' => '默认Lng',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '116.456270',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'baidukey',
|
||||
'title' => '百度地图KEY',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'amapkey',
|
||||
'title' => '高德地图KEY',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'amapsecurityjscode',
|
||||
'title' => '高德地图安全密钥',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'tencentkey',
|
||||
'title' => '腾讯地图KEY',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'tianditukey',
|
||||
'title' => '天地图KEY',
|
||||
'type' => 'string',
|
||||
'content' => [],
|
||||
'value' => '369ea1edc677b9e3746093f8d9dc4465',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '天地图开发密钥TK',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => 'coordtype',
|
||||
'title' => '坐标系类型',
|
||||
'type' => 'select',
|
||||
'content' => [
|
||||
'DEFAULT' => '默认(使用所选地图默认坐标系)',
|
||||
'WGS84' => 'WGS-84 / CGCS2000 (天地图原生)',
|
||||
'GCJ02' => 'GCJ-02 (高德/腾讯)',
|
||||
'BD09' => 'BD-09 (百度)',
|
||||
],
|
||||
'value' => 'DEFAULT',
|
||||
'rule' => 'required',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => '',
|
||||
],
|
||||
[
|
||||
'name' => '__tips__',
|
||||
'title' => '温馨提示',
|
||||
'type' => '',
|
||||
'content' => [],
|
||||
'value' => '请先申请对应地图的Key,配置后再使用',
|
||||
'rule' => '',
|
||||
'msg' => '',
|
||||
'tip' => '',
|
||||
'ok' => '',
|
||||
'extend' => 'alert-danger-light',
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace addons\address\controller;
|
||||
|
||||
use think\addons\Controller;
|
||||
use think\Config;
|
||||
use think\Hook;
|
||||
|
||||
class Index extends Controller
|
||||
{
|
||||
|
||||
// 首页
|
||||
public function index()
|
||||
{
|
||||
// 语言检测
|
||||
$lang = $this->request->langset();
|
||||
$lang = preg_match("/^([a-zA-Z\-_]{2,10})\$/i", $lang) ? $lang : 'zh-cn';
|
||||
|
||||
$site = Config::get("site");
|
||||
|
||||
// 配置信息
|
||||
$config = [
|
||||
'site' => array_intersect_key($site, array_flip(['name', 'cdnurl', 'version', 'timezone', 'languages'])),
|
||||
'upload' => null,
|
||||
'modulename' => 'addons',
|
||||
'controllername' => 'index',
|
||||
'actionname' => 'index',
|
||||
'jsname' => 'addons/address',
|
||||
'moduleurl' => '',
|
||||
'language' => $lang
|
||||
];
|
||||
$config = array_merge($config, Config::get("view_replace_str"));
|
||||
|
||||
// 配置信息后
|
||||
Hook::listen("config_init", $config);
|
||||
// 加载当前控制器语言包
|
||||
$this->view->assign('site', $site);
|
||||
$this->view->assign('config', $config);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
// 选择地址
|
||||
public function select()
|
||||
{
|
||||
$config = get_addon_config('address');
|
||||
$zoom = (int)$this->request->get('zoom', $config['zoom']);
|
||||
$lng = (float)$this->request->get('lng');
|
||||
$lat = (float)$this->request->get('lat');
|
||||
$address = $this->request->get('address');
|
||||
$lng = $lng ?: $config['lng'];
|
||||
$lat = $lat ?: $config['lat'];
|
||||
$this->view->assign('zoom', $zoom);
|
||||
$this->view->assign('lng', $lng);
|
||||
$this->view->assign('lat', $lat);
|
||||
$this->view->assign('address', $address);
|
||||
$maptype = $config['maptype'];
|
||||
if (!isset($config[$maptype . 'key']) || !$config[$maptype . 'key']) {
|
||||
$this->error("请在配置中配置对应类型地图的密钥");
|
||||
}
|
||||
return $this->view->fetch('index/' . $maptype);
|
||||
}
|
||||
|
||||
}
|
||||
10
server/addons/address/info.ini
普通文件
10
server/addons/address/info.ini
普通文件
@@ -0,0 +1,10 @@
|
||||
name = address
|
||||
title = 地址位置选择插件
|
||||
intro = 地图位置选择插件,可返回地址和经纬度
|
||||
author = FastAdmin
|
||||
website =
|
||||
version = 1.1.8
|
||||
state = 1
|
||||
url = /addons/address.html
|
||||
license = regular
|
||||
licenseto = 26425
|
||||
@@ -0,0 +1,258 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>地址选择器</title>
|
||||
<link rel="stylesheet" href="__CDN__/assets/css/frontend.min.css"/>
|
||||
<link rel="stylesheet" href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css"/>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
right: 4%;
|
||||
z-index: 99;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
background: #1ABC9C;
|
||||
color: white;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.search {
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
padding: 5px;
|
||||
margin-left: -200px;
|
||||
}
|
||||
|
||||
.amap-marker-label {
|
||||
border: 0;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.info {
|
||||
padding: .75rem 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
border-radius: .25rem;
|
||||
position: fixed;
|
||||
top: 2rem;
|
||||
background-color: white;
|
||||
width: auto;
|
||||
min-width: 22rem;
|
||||
border-width: 0;
|
||||
left: 1.8rem;
|
||||
box-shadow: 0 2px 6px 0 rgba(114, 124, 245, .5);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="search">
|
||||
<div class="input-group">
|
||||
<input type="text" id="place" name="q" class="form-control" placeholder="输入地点"/>
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" name="search" id="search-btn" class="btn btn-success">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="confirm">确定</div>
|
||||
<div id="container"></div>
|
||||
<script type="text/javascript">
|
||||
window._AMapSecurityConfig = {
|
||||
securityJsCode: "{$config.amapsecurityjscode|default=''}",
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="//webapi.amap.com/maps?v=1.4.11&key={$config.amapkey|default=''}&plugin=AMap.ToolBar,AMap.Autocomplete,AMap.PlaceSearch,AMap.Geocoder"></script>
|
||||
<!-- UI组件库 1.0 -->
|
||||
<script src="//webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
|
||||
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
|
||||
<script src="__CDN__/assets/addons/address/js/gcoord.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var as, map, geocoder, address, fromtype, totype;
|
||||
address = "{$address|htmlentities}";
|
||||
var lng = Number("{$lng}");
|
||||
var lat = Number("{$lat}");
|
||||
fromtype = "GCJ02";
|
||||
totype = "{$config.coordtype|default='DEFAULT'}"
|
||||
totype = totype === 'DEFAULT' ? "GCJ02" : totype;
|
||||
|
||||
if (lng && lat && fromtype !== totype) {
|
||||
var result = gcoord.transform([lng, lat], gcoord[totype], gcoord[fromtype]);
|
||||
lng = result[0] || lng;
|
||||
lat = result[1] || lat;
|
||||
}
|
||||
|
||||
var init = function () {
|
||||
AMapUI.loadUI(['misc/PositionPicker', 'misc/PoiPicker'], function (PositionPicker, PoiPicker) {
|
||||
//加载PositionPicker,loadUI的路径参数为模块名中 'ui/' 之后的部分
|
||||
map = new AMap.Map('container', {
|
||||
zoom: parseInt('{$zoom}'),
|
||||
center: [lng, lat]
|
||||
});
|
||||
geocoder = new AMap.Geocoder({
|
||||
radius: 1000 //范围,默认:500
|
||||
});
|
||||
var positionPicker = new PositionPicker({
|
||||
mode: 'dragMarker',//设定为拖拽地图模式,可选'dragMap'、'dragMarker',默认为'dragMap'
|
||||
map: map//依赖地图对象
|
||||
});
|
||||
//输入提示
|
||||
var autoOptions = {
|
||||
input: "place"
|
||||
};
|
||||
|
||||
var relocation = function (lnglat, addr) {
|
||||
lng = lnglat.lng;
|
||||
lat = lnglat.lat;
|
||||
map.panTo([lng, lat]);
|
||||
positionPicker.start(lnglat);
|
||||
if (addr) {
|
||||
// var label = '<div class="info">地址:' + addr + '<br>经度:' + lng + '<br>纬度:' + lat + '</div>';
|
||||
var label = '<div class="info">地址:' + addr + '</div>';
|
||||
positionPicker.marker.setLabel({
|
||||
content: label //显示内容
|
||||
});
|
||||
} else {
|
||||
geocoder.getAddress(lng + ',' + lat, function (status, result) {
|
||||
if (status === 'complete' && result.regeocode) {
|
||||
var address = result.regeocode.formattedAddress;
|
||||
// var label = '<div class="info">地址:' + address + '<br>经度:' + lng + '<br>纬度:' + lat + '</div>';
|
||||
var label = '<div class="info">地址:' + address + '</div>';
|
||||
positionPicker.marker.setLabel({
|
||||
content: label //显示内容
|
||||
});
|
||||
} else {
|
||||
console.log(JSON.stringify(result));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
var auto = new AMap.Autocomplete(autoOptions);
|
||||
|
||||
//构造地点查询类
|
||||
var placeSearch = new AMap.PlaceSearch({
|
||||
map: map
|
||||
});
|
||||
//注册监听,当选中某条记录时会触发
|
||||
AMap.event.addListener(auto, "select", function (e) {
|
||||
placeSearch.setCity(e.poi.adcode);
|
||||
placeSearch.search(e.poi.name, function (status, result) {
|
||||
$(map.getAllOverlays("marker")).each(function (i, j) {
|
||||
j.on("click", function () {
|
||||
relocation(j.De.position);
|
||||
});
|
||||
});
|
||||
}); //关键字查询查询
|
||||
});
|
||||
AMap.event.addListener(map, 'click', function (e) {
|
||||
relocation(e.lnglat);
|
||||
});
|
||||
|
||||
//加载工具条
|
||||
var tool = new AMap.ToolBar();
|
||||
map.addControl(tool);
|
||||
|
||||
var poiPicker = new PoiPicker({
|
||||
input: 'place',
|
||||
placeSearchOptions: {
|
||||
map: map,
|
||||
pageSize: 6 //关联搜索分页
|
||||
}
|
||||
});
|
||||
poiPicker.on('poiPicked', function (poiResult) {
|
||||
poiPicker.hideSearchResults();
|
||||
$('.poi .nearpoi').text(poiResult.item.name);
|
||||
$('.address .info').text(poiResult.item.address);
|
||||
$('#address').val(poiResult.item.address);
|
||||
$("#place").val(poiResult.item.name);
|
||||
|
||||
relocation(poiResult.item.location);
|
||||
});
|
||||
|
||||
positionPicker.on('success', function (positionResult) {
|
||||
console.log(positionResult);
|
||||
as = positionResult.position;
|
||||
address = positionResult.address;
|
||||
lat = as.lat;
|
||||
lng = as.lng;
|
||||
});
|
||||
positionPicker.on('fail', function (positionResult) {
|
||||
address = '';
|
||||
});
|
||||
positionPicker.start();
|
||||
|
||||
if (address) {
|
||||
// 添加label
|
||||
var label = '<div class="info">地址:' + address + '</div>';
|
||||
positionPicker.marker.setLabel({
|
||||
content: label //显示内容
|
||||
});
|
||||
}
|
||||
|
||||
//点击搜索按钮
|
||||
$(document).on('click', '#search-btn', function () {
|
||||
if ($("#place").val() == '')
|
||||
return;
|
||||
placeSearch.search($("#place").val(), function (status, result) {
|
||||
$(map.getAllOverlays("marker")).each(function (i, j) {
|
||||
j.on("click", function () {
|
||||
relocation(j.De.position);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
//点击确定后执行回调赋值
|
||||
var close = function (data) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||
//再执行关闭
|
||||
parent.Layer.close(index);
|
||||
//再调用回传函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(undefined, data);
|
||||
}
|
||||
};
|
||||
|
||||
//点击搜索按钮
|
||||
$(document).on('click', '.confirm', function () {
|
||||
var zoom = map.getZoom();
|
||||
var data = {lat: lat, lng: lng, zoom: zoom, address: address};
|
||||
if (fromtype !== totype) {
|
||||
var result = gcoord.transform([data.lng, data.lat], gcoord[fromtype], gcoord[totype]);
|
||||
data.lng = (result[0] || data.lng).toFixed(5);
|
||||
data.lat = (result[1] || data.lat).toFixed(5);
|
||||
console.log(data, result, fromtype, totype);
|
||||
}
|
||||
close(data);
|
||||
});
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,243 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>地址选择器</title>
|
||||
<link rel="stylesheet" href="__CDN__/assets/css/frontend.min.css"/>
|
||||
<link rel="stylesheet" href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css"/>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
right: 4%;
|
||||
z-index: 99;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
background: #1ABC9C;
|
||||
color: white;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.search {
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
padding: 5px;
|
||||
margin-left: -200px;
|
||||
}
|
||||
|
||||
label.BMapLabel {
|
||||
max-width: inherit;
|
||||
padding: .75rem 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
background-color: white;
|
||||
width: auto;
|
||||
min-width: 22rem;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px 0 rgba(114, 124, 245, .5);
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="search">
|
||||
<div class="input-group">
|
||||
<input type="text" id="place" name="q" class="form-control" placeholder="输入地点"/>
|
||||
<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" name="search" id="search-btn" class="btn btn-success">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="confirm">确定</div>
|
||||
<div id="container"></div>
|
||||
<script type="text/javascript" src="//api.map.baidu.com/api?v=2.0&ak={$config.baidukey|default=''}"></script>
|
||||
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
|
||||
<script src="__CDN__/assets/addons/address/js/gcoord.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var map, marker, point, fromtype, totype;
|
||||
var zoom = parseInt("{$zoom}");
|
||||
var address = "{$address|htmlentities}";
|
||||
var lng = Number("{$lng}");
|
||||
var lat = Number("{$lat}");
|
||||
fromtype = "BD09";
|
||||
totype = "{$config.coordtype|default='DEFAULT'}"
|
||||
totype = totype === 'DEFAULT' ? "BD09" : totype;
|
||||
|
||||
if (lng && lat && fromtype !== totype) {
|
||||
var result = gcoord.transform([lng, lat], gcoord[totype], gcoord[fromtype]);
|
||||
lng = result[0] || lng;
|
||||
lat = result[1] || lat;
|
||||
}
|
||||
|
||||
var geocoder = new BMap.Geocoder();
|
||||
|
||||
var addPointMarker = function (point, addr) {
|
||||
deletePoint();
|
||||
addPoint(point);
|
||||
|
||||
if (addr) {
|
||||
addMarker(point, addr);
|
||||
} else {
|
||||
geocoder.getLocation(point, function (rs) {
|
||||
addMarker(point, rs.address);
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var addPoint = function (point) {
|
||||
lng = point.lng;
|
||||
lat = point.lat;
|
||||
marker = new BMap.Marker(point);
|
||||
map.addOverlay(marker);
|
||||
map.panTo(point);
|
||||
};
|
||||
|
||||
var addMarker = function (point, addr) {
|
||||
address = addr;
|
||||
// var labelhtml = '<div class="info">地址:' + address + '<br>经度:' + point.lng + '<br>纬度:' + point.lat + '</div>';
|
||||
var labelhtml = '<div class="info">地址:' + address + '</div>';
|
||||
var label = new BMap.Label(labelhtml, {offset: new BMap.Size(16, 20)});
|
||||
label.setStyle({
|
||||
border: 'none',
|
||||
padding: '.75rem 1.25rem'
|
||||
});
|
||||
marker.setLabel(label);
|
||||
};
|
||||
|
||||
var deletePoint = function () {
|
||||
var allOverlay = map.getOverlays();
|
||||
for (var i = 0; i < allOverlay.length; i++) {
|
||||
map.removeOverlay(allOverlay[i]);
|
||||
}
|
||||
};
|
||||
|
||||
var init = function () {
|
||||
map = new BMap.Map("container"); // 创建地图实例
|
||||
var point = new BMap.Point(lng, lat); // 创建点坐标
|
||||
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
||||
map.centerAndZoom(point, zoom); // 初始化地图,设置中心点坐标和地图级别
|
||||
|
||||
var size = new BMap.Size(10, 20);
|
||||
map.addControl(new BMap.CityListControl({
|
||||
anchor: BMAP_ANCHOR_TOP_LEFT,
|
||||
offset: size,
|
||||
}));
|
||||
|
||||
if ("{$lng}" != '' && "{$lat}" != '') {
|
||||
addPointMarker(point, address);
|
||||
}
|
||||
|
||||
ac = new BMap.Autocomplete({"input": "place", "location": map}); //建立一个自动完成的对象
|
||||
ac.addEventListener("onhighlight", function (e) { //鼠标放在下拉列表上的事件
|
||||
var str = "";
|
||||
var _value = e.fromitem.value;
|
||||
var value = "";
|
||||
if (e.fromitem.index > -1) {
|
||||
value = _value.province + _value.city + _value.district + _value.street + _value.business;
|
||||
}
|
||||
str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
|
||||
|
||||
value = "";
|
||||
if (e.toitem.index > -1) {
|
||||
_value = e.toitem.value;
|
||||
value = _value.province + _value.city + _value.district + _value.street + _value.business;
|
||||
}
|
||||
str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
|
||||
$("#searchResultPanel").html(str);
|
||||
});
|
||||
ac.addEventListener("onconfirm", function (e) { //鼠标点击下拉列表后的事件
|
||||
var _value = e.item.value;
|
||||
myValue = _value.province + _value.city + _value.district + _value.street + _value.business;
|
||||
$("#searchResultPanel").html("onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue);
|
||||
setPlace();
|
||||
});
|
||||
|
||||
function setPlace(text) {
|
||||
map.clearOverlays(); //清除地图上所有覆盖物
|
||||
function myFun() {
|
||||
var results = local.getResults();
|
||||
var result = local.getResults().getPoi(0);
|
||||
var point = result.point; //获取第一个智能搜索的结果
|
||||
map.centerAndZoom(point, 18);
|
||||
// map.addOverlay(new BMap.Marker(point)); //添加标注
|
||||
if (result.type != 0) {
|
||||
address = results.province + results.city + result.address;
|
||||
} else {
|
||||
address = result.address;
|
||||
}
|
||||
addPointMarker(point, address);
|
||||
}
|
||||
|
||||
var local = new BMap.LocalSearch(map, { //智能搜索
|
||||
onSearchComplete: myFun
|
||||
});
|
||||
local.search(text || myValue);
|
||||
}
|
||||
|
||||
map.addEventListener("click", function (e) {
|
||||
//通过点击百度地图,可以获取到对应的point, 由point的lng、lat属性就可以获取对应的经度纬度
|
||||
addPointMarker(e.point);
|
||||
});
|
||||
|
||||
//点击搜索按钮
|
||||
$(document).on('click', '#search-btn', function () {
|
||||
if ($("#place").val() == '')
|
||||
return;
|
||||
setPlace($("#place").val());
|
||||
});
|
||||
};
|
||||
|
||||
var close = function (data) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||
//再执行关闭
|
||||
parent.Layer.close(index);
|
||||
//再调用回传函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(undefined, data);
|
||||
}
|
||||
};
|
||||
|
||||
//点击确定后执行回调赋值
|
||||
$(document).on('click', '.confirm', function () {
|
||||
var zoom = map.getZoom();
|
||||
var data = {lat: lat, lng: lng, zoom: zoom, address: address};
|
||||
if (fromtype !== totype) {
|
||||
var result = gcoord.transform([data.lng, data.lat], gcoord[fromtype], gcoord[totype]);
|
||||
data.lng = (result[0] || data.lng).toFixed(5);
|
||||
data.lat = (result[1] || data.lat).toFixed(5);
|
||||
console.log(data, result, fromtype, totype);
|
||||
}
|
||||
close(data);
|
||||
});
|
||||
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,132 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
|
||||
<title>地图位置(经纬度)选择插件</title>
|
||||
<link rel="stylesheet" href="__CDN__/assets/css/frontend.min.css"/>
|
||||
<link rel="stylesheet" href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
|
||||
<div class="bs-docs-section clearfix">
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="page-header">
|
||||
<h2>地图位置(经纬度)选择示例</h2>
|
||||
</div>
|
||||
|
||||
<div class="bs-component">
|
||||
<form action="" method="post" role="form">
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="address" placeholder="地址">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="lng" placeholder="经度">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="lat" placeholder="纬度">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="zoom" placeholder="缩放">
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary" data-toggle='addresspicker' data-input-id="address" data-lng-id="lng" data-lat-id="lat" data-zoom-id="zoom">点击选择</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="page-header">
|
||||
<h2 id="code">调用代码</h2>
|
||||
</div>
|
||||
<div class="bs-component">
|
||||
<textarea class="form-control" rows="17">
|
||||
<form action="" method="post" role="form">
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="address" placeholder="地址">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="lng" placeholder="经度">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="lat" placeholder="纬度">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for=""></label>
|
||||
<input type="text" class="form-control" name="" id="zoom" placeholder="缩放">
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-primary" data-toggle='addresspicker' data-input-id="address" data-lng-id="lng" data-lat-id="lat" data-zoom-id="zoom">点击选择</button>
|
||||
</form>
|
||||
</textarea>
|
||||
</div>
|
||||
<div class="page-header">
|
||||
<h2>参数说明</h2>
|
||||
</div>
|
||||
|
||||
<div class="bs-component" style="background:#fff;">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>参数</th>
|
||||
<th>释义</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>data-input-id</td>
|
||||
<td>填充地址的文本框ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data-lng-id</td>
|
||||
<td>填充经度的文本框ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data-lat-id</td>
|
||||
<td>填充纬度的文本框ID</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>data-zoom-id</td>
|
||||
<td>填充缩放的文本框ID</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!--@formatter:off-->
|
||||
<script type="text/javascript">
|
||||
var require = {
|
||||
config: {$config|json_encode}
|
||||
};
|
||||
</script>
|
||||
<!--@formatter:on-->
|
||||
|
||||
<script>
|
||||
require.callback = function () {
|
||||
define('addons/address', ['jquery', 'bootstrap', 'frontend', 'template'], function ($, undefined, Frontend, Template) {
|
||||
var Controller = {
|
||||
index: function () {
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
define('lang', function () {
|
||||
return [];
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="__CDN__/assets/js/require.min.js" data-main="__CDN__/assets/js/require-frontend.min.js?v={$site.version}"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,291 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>地址选择器</title>
|
||||
<link rel="stylesheet" href="__CDN__/assets/css/frontend.min.css"/>
|
||||
<link rel="stylesheet" href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css"/>
|
||||
<style type="text/css">
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
right: 4%;
|
||||
z-index: 99;
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
line-height: 50px;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
background-color: white;
|
||||
background: #1ABC9C;
|
||||
color: white;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.search {
|
||||
position: absolute;
|
||||
width: 400px;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
padding: 5px;
|
||||
margin-left: -200px;
|
||||
}
|
||||
|
||||
.autocomplete-search {
|
||||
text-align: left;
|
||||
cursor: default;
|
||||
background: #fff;
|
||||
border-radius: 2px;
|
||||
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
-moz-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
background-clip: padding-box;
|
||||
position: absolute;
|
||||
display: none;
|
||||
z-index: 1036;
|
||||
max-height: 254px;
|
||||
overflow: hidden;
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.autocomplete-search .autocomplete-suggestion {
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.autocomplete-search .autocomplete-suggestion:hover {
|
||||
background: #f0f0f0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="search">
|
||||
<div class="input-group">
|
||||
<input type="text" id="place" name="q" class="form-control" placeholder="输入地点"/>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" name="search" id="search-btn" class="btn btn-success">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="confirm">确定</div>
|
||||
<div id="container"></div>
|
||||
|
||||
<script charset="utf-8" src="//map.qq.com/api/js?v=2.exp&libraries=place&key={$config.tencentkey|default=''}"></script>
|
||||
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
|
||||
<script src="__CDN__/assets/addons/address/js/gcoord.min.js"></script>
|
||||
<script src="__CDN__/assets/addons/address/js/jquery.autocomplete.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var map, marker, geocoder, infoWin, searchService, keyword, address, fromtype, totype;
|
||||
address = "{$address|htmlentities}";
|
||||
var lng = Number("{$lng}");
|
||||
var lat = Number("{$lat}");
|
||||
fromtype = "GCJ02";
|
||||
totype = "{$config.coordtype|default='DEFAULT'}"
|
||||
totype = totype === 'DEFAULT' ? "GCJ02" : totype;
|
||||
|
||||
if (lng && lat && fromtype !== totype) {
|
||||
var result = gcoord.transform([lng, lat], gcoord[totype], gcoord[fromtype]);
|
||||
lng = result[0] || lng;
|
||||
lat = result[1] || lat;
|
||||
}
|
||||
|
||||
var init = function () {
|
||||
var center = new qq.maps.LatLng(lat, lng);
|
||||
map = new qq.maps.Map(document.getElementById('container'), {
|
||||
center: center,
|
||||
zoom: parseInt("{$config.zoom}")
|
||||
});
|
||||
|
||||
//实例化信息窗口
|
||||
infoWin = new qq.maps.InfoWindow({
|
||||
map: map
|
||||
});
|
||||
|
||||
geocoder = {
|
||||
getAddress: function (latLng) {
|
||||
$.ajax({
|
||||
url: "https://apis.map.qq.com/ws/geocoder/v1/?location=" + latLng.lat + "," + latLng.lng + "&key={$config.tencentkey|default=''}&output=jsonp",
|
||||
dataType: "jsonp",
|
||||
type: 'GET',
|
||||
cache: true,
|
||||
crossDomain: true,
|
||||
success: function (ret) {
|
||||
console.log("getAddress:", ret)
|
||||
if (ret.status === 0) {
|
||||
var component = ret.result.address_component;
|
||||
if (ret.result.formatted_addresses && ret.result.formatted_addresses.recommend) {
|
||||
var recommend = ret.result.formatted_addresses.recommend;
|
||||
var standard_address = ret.result.formatted_addresses.standard_address;
|
||||
var address = component.province !== component.city ? component.province + component.city : component.province;
|
||||
|
||||
address = address + (recommend.indexOf(component.district) === 0 ? '' : component.district) + recommend;
|
||||
} else {
|
||||
address = ret.result.address;
|
||||
}
|
||||
showMarker(ret.result.location, address);
|
||||
showInfoWin(ret.result.location, address);
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e, 'error')
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//初始化marker
|
||||
showMarker(center);
|
||||
if (address) {
|
||||
showInfoWin(center, address);
|
||||
} else {
|
||||
geocoder.getAddress(center);
|
||||
}
|
||||
|
||||
var place = $("#place");
|
||||
place.autoComplete({
|
||||
minChars: 1,
|
||||
cache: 0,
|
||||
menuClass: 'autocomplete-search',
|
||||
source: function (term, response) {
|
||||
try {
|
||||
xhr.abort();
|
||||
} catch (e) {
|
||||
}
|
||||
xhr = $.ajax({
|
||||
url: "https://apis.map.qq.com/ws/place/v1/suggestion?keyword=" + term + "&key={$config.tencentkey|default=''}&output=jsonp",
|
||||
dataType: "jsonp",
|
||||
type: 'GET',
|
||||
cache: true,
|
||||
success: function (ret) {
|
||||
if (ret.status === 0) {
|
||||
if(ret.data.length === 0){
|
||||
$(".autocomplete-suggestions.autocomplete-search").html('');
|
||||
}
|
||||
response(ret.data);
|
||||
} else {
|
||||
console.log(ret);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
renderItem: function (item, search) {
|
||||
search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
var regexp = new RegExp("(" + search.replace(/[\,|\u3000|\uff0c]/, ' ').split(' ').join('|') + ")", "gi");
|
||||
return "<div class='autocomplete-suggestion' data-item='" + JSON.stringify(item) + "' data-title='" + item.title + "' data-val='" + item.title + "'>" + item.title.replace(regexp, "<b>$1</b>") + "</div>";
|
||||
},
|
||||
onSelect: function (e, term, sel) {
|
||||
e.preventDefault();
|
||||
var item = $(sel).data("item");
|
||||
//调用获取位置方法
|
||||
geocoder.getAddress(item.location);
|
||||
|
||||
var position = new qq.maps.LatLng(item.location.lat, item.location.lng);
|
||||
map.setCenter(position);
|
||||
}
|
||||
});
|
||||
|
||||
//地图点击
|
||||
qq.maps.event.addListener(map, 'click', function (event) {
|
||||
try {
|
||||
//调用获取位置方法
|
||||
geocoder.getAddress(event.latLng);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
//显示info窗口
|
||||
var showInfoWin = function (latLng, title) {
|
||||
var position = new qq.maps.LatLng(latLng.lat, latLng.lng);
|
||||
infoWin.open();
|
||||
infoWin.setContent(title);
|
||||
infoWin.setPosition(position);
|
||||
};
|
||||
|
||||
//实例化marker和监听拖拽结束事件
|
||||
var showMarker = function (latLng, title) {
|
||||
console.log("showMarker", latLng, title)
|
||||
var position = new qq.maps.LatLng(latLng.lat, latLng.lng);
|
||||
marker && marker.setMap(null);
|
||||
marker = new qq.maps.Marker({
|
||||
map: map,
|
||||
position: position,
|
||||
draggable: true,
|
||||
title: title || '拖动图标选择位置'
|
||||
});
|
||||
|
||||
//监听拖拽结束
|
||||
qq.maps.event.addListener(marker, 'dragend', function (event) {
|
||||
//调用获取位置方法
|
||||
geocoder.getAddress(event.latLng);
|
||||
});
|
||||
};
|
||||
|
||||
var close = function (data) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||
//再执行关闭
|
||||
parent.Layer.close(index);
|
||||
//再调用回传函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(undefined, data);
|
||||
}
|
||||
};
|
||||
|
||||
//点击确定后执行回调赋值
|
||||
$(document).on('click', '.confirm', function () {
|
||||
var zoom = map.getZoom();
|
||||
var data = {lat: infoWin.position.lat.toFixed(5), lng: infoWin.position.lng.toFixed(5), zoom: zoom, address: infoWin.content};
|
||||
if (fromtype !== totype) {
|
||||
var result = gcoord.transform([data.lng, data.lat], gcoord[fromtype], gcoord[totype]);
|
||||
data.lng = (result[0] || data.lng).toFixed(5);
|
||||
data.lat = (result[1] || data.lat).toFixed(5);
|
||||
console.log(data, result, fromtype, totype);
|
||||
}
|
||||
|
||||
close(data);
|
||||
});
|
||||
|
||||
//点击搜索按钮
|
||||
$(document).on('click', '#search-btn', function () {
|
||||
if ($("#place").val() === '')
|
||||
return;
|
||||
var first = $(".autocomplete-search > .autocomplete-suggestion:first");
|
||||
if (!first.length) {
|
||||
return;
|
||||
}
|
||||
var item = first.data("item");
|
||||
|
||||
//调用获取位置方法
|
||||
geocoder.getAddress(item.location);
|
||||
|
||||
var position = new qq.maps.LatLng(item.location.lat, item.location.lng);
|
||||
map.setCenter(position);
|
||||
});
|
||||
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,404 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
||||
<title>地址选择器 - 天地图</title>
|
||||
<link rel="stylesheet" href="__CDN__/assets/css/frontend.min.css"/>
|
||||
<link rel="stylesheet" href="__CDN__/assets/libs/font-awesome/css/font-awesome.min.css"/>
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
}
|
||||
|
||||
#container {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.search {
|
||||
position: absolute;
|
||||
width: 420px;
|
||||
top: 15px;
|
||||
left: 50%;
|
||||
margin-left: -210px;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.search .input-group {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
border-radius: 4px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.search input.form-control {
|
||||
height: 42px;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-right: none;
|
||||
border-radius: 4px 0 0 4px;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.search .btn-success {
|
||||
height: 42px;
|
||||
padding: 0 18px;
|
||||
border-radius: 0 4px 4px 0;
|
||||
background-color: #18bc9c;
|
||||
border-color: #18bc9c;
|
||||
}
|
||||
|
||||
.search-panel {
|
||||
position: absolute;
|
||||
top: 46px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
|
||||
max-height: 280px;
|
||||
overflow-y: auto;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.search-panel.hide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.search-item {
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.search-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.search-item:hover {
|
||||
background-color: #f7f9fa;
|
||||
}
|
||||
|
||||
.search-item .item-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.search-item .item-addr {
|
||||
font-size: 12px;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 15px;
|
||||
z-index: 999;
|
||||
background: #fff;
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
||||
max-width: 320px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.info-card .address-line {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #2c3e50;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.info-card .lnglat-line {
|
||||
font-size: 12px;
|
||||
color: #7f8c8d;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
position: absolute;
|
||||
bottom: 30px;
|
||||
right: 30px;
|
||||
z-index: 999;
|
||||
height: 52px;
|
||||
width: 52px;
|
||||
line-height: 52px;
|
||||
font-size: 15px;
|
||||
text-align: center;
|
||||
background: #18bc9c;
|
||||
color: #fff;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 4px 12px rgba(24, 188, 156, 0.45);
|
||||
transition: all 0.2s ease-in-out;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.confirm:hover {
|
||||
transform: scale(1.06);
|
||||
background: #15a589;
|
||||
box-shadow: 0 6px 16px rgba(24, 188, 156, 0.55);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="search">
|
||||
<div class="input-group">
|
||||
<input type="text" id="place" name="q" class="form-control" placeholder="输入地点检索或直接点击/拖动标注" autocomplete="off"/>
|
||||
<span class="input-group-btn">
|
||||
<button type="button" name="search" id="search-btn" class="btn btn-success">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<div id="searchResultPanel" class="search-panel hide"></div>
|
||||
</div>
|
||||
|
||||
<div class="info-card">
|
||||
<div class="address-line">
|
||||
<i class="fa fa-map-marker text-danger"></i> <span id="current-address">{$address|htmlentities|default='点击或拖动标注选点'}</span>
|
||||
</div>
|
||||
<div class="lnglat-line">
|
||||
<span>坐标:</span><span id="current-lnglat">{$lng}, {$lat}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="confirm">确定</div>
|
||||
<div id="container"></div>
|
||||
|
||||
<script type="text/javascript" src="https://api.tianditu.gov.cn/api?v=4.0&tk={$config.tianditukey|default=''}"></script>
|
||||
<script src="__CDN__/assets/libs/jquery/dist/jquery.min.js"></script>
|
||||
<script src="__CDN__/assets/addons/address/js/gcoord.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var map, marker, geocoder, localSearch, fromtype, totype;
|
||||
var zoom = parseInt("{$zoom}") || 12;
|
||||
var address = "{$address|htmlentities}";
|
||||
var lng = Number("{$lng}") || 116.40969;
|
||||
var lat = Number("{$lat}") || 39.89945;
|
||||
|
||||
fromtype = "WGS84";
|
||||
totype = "{$config.coordtype|default='DEFAULT'}";
|
||||
totype = totype === 'DEFAULT' ? "WGS84" : totype;
|
||||
|
||||
// 如果配置不是 WGS84 且传入了有效坐标,先将其转换为天地图能识别的 WGS84
|
||||
if (lng && lat && fromtype !== totype) {
|
||||
try {
|
||||
var transResult = gcoord.transform([lng, lat], gcoord[totype], gcoord[fromtype]);
|
||||
lng = transResult[0] || lng;
|
||||
lat = transResult[1] || lat;
|
||||
} catch (e) {
|
||||
console.error("坐标转换失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
var updateUI = function (point, addr) {
|
||||
lng = point.getLng();
|
||||
lat = point.getLat();
|
||||
if (addr) {
|
||||
address = addr;
|
||||
}
|
||||
$("#current-address").text(address || "正在解析地址...");
|
||||
$("#current-lnglat").text(lng.toFixed(6) + ", " + lat.toFixed(6));
|
||||
};
|
||||
|
||||
var queryAddress = function (point) {
|
||||
updateUI(point, "正在获取详细地址...");
|
||||
geocoder.getLocation(point, function (result) {
|
||||
if (result && result.getStatus() === 0) {
|
||||
var addr = result.getAddress() || "";
|
||||
updateUI(point, addr);
|
||||
} else {
|
||||
updateUI(point, "未知具体位置");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var addPointMarker = function (point, addr) {
|
||||
map.clearOverLays();
|
||||
lng = point.getLng();
|
||||
lat = point.getLat();
|
||||
|
||||
marker = new T.Marker(point);
|
||||
marker.enableDrag();
|
||||
marker.addEventListener("dragend", function () {
|
||||
var targetPoint = marker.getLngLat();
|
||||
queryAddress(targetPoint);
|
||||
});
|
||||
|
||||
map.addOverLay(marker);
|
||||
map.panTo(point);
|
||||
|
||||
if (addr) {
|
||||
updateUI(point, addr);
|
||||
} else {
|
||||
queryAddress(point);
|
||||
}
|
||||
};
|
||||
|
||||
var init = function () {
|
||||
if (typeof T === 'undefined') {
|
||||
alert("天地图 API 加载失败,请检查天地图密钥配置或网络连接!");
|
||||
return;
|
||||
}
|
||||
|
||||
map = new T.Map("container");
|
||||
var point = new T.LngLat(lng, lat);
|
||||
map.centerAndZoom(point, zoom);
|
||||
map.enableScrollWheelZoom();
|
||||
|
||||
// 缩放控件与比例尺
|
||||
var zoomControl = new T.Control.Zoom();
|
||||
map.addControl(zoomControl);
|
||||
var scaleControl = new T.Control.Scale();
|
||||
map.addControl(scaleControl);
|
||||
|
||||
geocoder = new T.Geocoder();
|
||||
|
||||
// 初始标点
|
||||
if ("{$lng}" !== '' && "{$lat}" !== '') {
|
||||
addPointMarker(point, address);
|
||||
} else {
|
||||
addPointMarker(point);
|
||||
}
|
||||
|
||||
// 地图点击事件
|
||||
map.addEventListener("click", function (e) {
|
||||
if (e.lnglat) {
|
||||
addPointMarker(e.lnglat);
|
||||
}
|
||||
});
|
||||
|
||||
// 搜索服务配置
|
||||
var searchConfig = {
|
||||
pageCapacity: 10,
|
||||
onSearchComplete: function (result) {
|
||||
var $panel = $("#searchResultPanel");
|
||||
$panel.empty().removeClass("hide");
|
||||
|
||||
if (!result) {
|
||||
$panel.html('<div class="search-item text-muted">未找到相关地点</div>');
|
||||
return;
|
||||
}
|
||||
|
||||
var resultType = parseInt(result.getResultType());
|
||||
if (resultType === 1) {
|
||||
var pois = result.getPois();
|
||||
if (pois && pois.length > 0) {
|
||||
var html = '';
|
||||
for (var i = 0; i < pois.length; i++) {
|
||||
var poi = pois[i];
|
||||
var poiLng = poi.lonlat.getLng ? poi.lonlat.getLng() : poi.lonlat.lng;
|
||||
var poiLat = poi.lonlat.getLat ? poi.lonlat.getLat() : poi.lonlat.lat;
|
||||
var poiAddr = poi.address || poi.name;
|
||||
html += '<div class="search-item" data-lng="' + poiLng + '" data-lat="' + poiLat + '" data-name="' + poi.name + '" data-address="' + poiAddr + '">';
|
||||
html += '<div class="item-title"><i class="fa fa-map-marker text-success"></i> ' + poi.name + '</div>';
|
||||
html += '<div class="item-addr">' + poiAddr + '</div>';
|
||||
html += '</div>';
|
||||
}
|
||||
$panel.html(html);
|
||||
} else {
|
||||
$panel.html('<div class="search-item text-muted">未找到相关地点</div>');
|
||||
}
|
||||
} else if (resultType === 2) {
|
||||
$panel.html('<div class="search-item text-muted">输入范围较广,请补充详细区域</div>');
|
||||
} else if (resultType === 3) {
|
||||
var area = result.getArea();
|
||||
if (area && area.lonlat) {
|
||||
var pt = new T.LngLat(area.lonlat.lng, area.lonlat.lat);
|
||||
addPointMarker(pt, area.name);
|
||||
$panel.addClass("hide");
|
||||
}
|
||||
} else {
|
||||
$panel.html('<div class="search-item text-muted">未找到相关地点</div>');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
localSearch = new T.LocalSearch(map, searchConfig);
|
||||
|
||||
var doSearch = function () {
|
||||
var kw = $.trim($("#place").val());
|
||||
if (!kw) return;
|
||||
localSearch.search(kw);
|
||||
};
|
||||
|
||||
$("#search-btn").on("click", doSearch);
|
||||
$("#place").on("keydown", function (e) {
|
||||
if (e.keyCode === 13) {
|
||||
e.preventDefault();
|
||||
doSearch();
|
||||
}
|
||||
});
|
||||
|
||||
// 点击搜索结果项
|
||||
$(document).on("click", ".search-item", function () {
|
||||
var $this = $(this);
|
||||
var targetLng = Number($this.data("lng"));
|
||||
var targetLat = Number($this.data("lat"));
|
||||
var targetAddr = $this.data("address");
|
||||
if (targetLng && targetLat) {
|
||||
var pt = new T.LngLat(targetLng, targetLat);
|
||||
addPointMarker(pt, targetAddr);
|
||||
map.centerAndZoom(pt, 16);
|
||||
$("#place").val($this.data("name"));
|
||||
$("#searchResultPanel").addClass("hide");
|
||||
}
|
||||
});
|
||||
|
||||
// 点击外部关闭搜索下拉面板
|
||||
$(document).on("click", function (e) {
|
||||
if (!$(e.target).closest(".search").length) {
|
||||
$("#searchResultPanel").addClass("hide");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var close = function (data) {
|
||||
var index = parent.Layer.getFrameIndex(window.name);
|
||||
var callback = parent.$("#layui-layer" + index).data("callback");
|
||||
parent.Layer.close(index);
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(undefined, data);
|
||||
}
|
||||
};
|
||||
|
||||
// 点击确定按钮回传
|
||||
$(document).on('click', '.confirm', function () {
|
||||
var currentZoom = map.getZoom();
|
||||
var data = {lat: lat, lng: lng, zoom: currentZoom, address: address};
|
||||
if (fromtype !== totype) {
|
||||
try {
|
||||
var result = gcoord.transform([data.lng, data.lat], gcoord[fromtype], gcoord[totype]);
|
||||
data.lng = Number((result[0] || data.lng).toFixed(6));
|
||||
data.lat = Number((result[1] || data.lat).toFixed(6));
|
||||
} catch (e) {
|
||||
console.error("坐标转换失败", e);
|
||||
}
|
||||
} else {
|
||||
data.lng = Number(data.lng.toFixed(6));
|
||||
data.lat = Number(data.lat.toFixed(6));
|
||||
}
|
||||
close(data);
|
||||
});
|
||||
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -43,10 +43,153 @@ class Master extends Backend
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
|
||||
// 合并查出当前页每个师傅拥有的技能
|
||||
$items = $list->items();
|
||||
$masterIds = array_column($items, 'id');
|
||||
$skillsGroup = [];
|
||||
if (!empty($masterIds)) {
|
||||
$allSkills = \think\Db::name('master_skill')
|
||||
->where('master_id', 'in', $masterIds)
|
||||
->where('status', 'normal')
|
||||
->select();
|
||||
foreach ($allSkills as $sk) {
|
||||
$name = !empty($sk['skill_name']) ? $sk['skill_name'] : '';
|
||||
if ($name) {
|
||||
$skillsGroup[$sk['master_id']][] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($items as &$it) {
|
||||
$it['skills_list'] = $skillsGroup[$it['id']] ?? [];
|
||||
}
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $items];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 师傅服务技能管理(内置于师傅列表)
|
||||
*/
|
||||
public function skills($ids = null)
|
||||
{
|
||||
$row = $this->model->find($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$selectedSkills = (array)$this->request->post('skills/a', []);
|
||||
$customText = trim((string)$this->request->post('custom_text', ''));
|
||||
|
||||
// 1. 处理自定义输入的技能
|
||||
$customNames = [];
|
||||
if (!empty($customText)) {
|
||||
$parts = preg_split('/[,,\s]+/u', $customText);
|
||||
foreach ($parts as $p) {
|
||||
$p = trim($p);
|
||||
if (!empty($p) && !in_array($p, $customNames) && !in_array($p, $selectedSkills)) {
|
||||
$customNames[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 清理当前师傅原有的技能
|
||||
\think\Db::name('master_skill')->where('master_id', $row['id'])->delete();
|
||||
|
||||
// 3. 写入选中的技能
|
||||
$dictRows = \think\Db::name('skill_dict')->where('name', 'in', $selectedSkills)->select();
|
||||
$dictMap = [];
|
||||
foreach ($dictRows as $dr) {
|
||||
$dictMap[$dr['name']] = $dr;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
foreach ($selectedSkills as $sName) {
|
||||
$dict = $dictMap[$sName] ?? null;
|
||||
\think\Db::name('master_skill')->insert([
|
||||
'master_id' => $row['id'],
|
||||
'cat_id' => 0,
|
||||
'skill_id' => $dict ? $dict['id'] : 0,
|
||||
'skill_name' => $sName,
|
||||
'category' => $dict ? $dict['category'] : '服务技能',
|
||||
'is_custom' => 0,
|
||||
'cert_image' => '',
|
||||
'status' => 'normal',
|
||||
'createtime' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
// 4. 处理自定义输入的技能(沉淀入库)
|
||||
foreach ($customNames as $cName) {
|
||||
$exist = \think\Db::name('skill_dict')->where('name', $cName)->find();
|
||||
if (!$exist) {
|
||||
$skillDictId = \think\Db::name('skill_dict')->insertGetId([
|
||||
'category_id'=> 0,
|
||||
'category' => '其他技能',
|
||||
'name' => $cName,
|
||||
'source' => 'custom',
|
||||
'master_id' => $row['id'],
|
||||
'weigh' => 0,
|
||||
'status' => 'normal',
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now
|
||||
]);
|
||||
} else {
|
||||
$skillDictId = $exist['id'];
|
||||
}
|
||||
|
||||
\think\Db::name('master_skill')->insert([
|
||||
'master_id' => $row['id'],
|
||||
'cat_id' => 0,
|
||||
'skill_id' => $skillDictId,
|
||||
'skill_name' => $cName,
|
||||
'category' => '其他技能',
|
||||
'is_custom' => 1,
|
||||
'cert_image' => '',
|
||||
'status' => 'normal',
|
||||
'createtime' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
$this->success('技能配置更新成功');
|
||||
}
|
||||
|
||||
// 读取技能字典全部分类与技能
|
||||
$categories = \think\Db::name('skill_category')->where('status', 'normal')->order('weigh desc')->select();
|
||||
$allDictSkills = \think\Db::name('skill_dict')->where('status', 'normal')->order('weigh desc')->select();
|
||||
|
||||
$catTree = [];
|
||||
foreach ($categories as $cat) {
|
||||
$catTree[$cat['name']] = [];
|
||||
}
|
||||
foreach ($allDictSkills as $item) {
|
||||
$cName = $item['category'];
|
||||
if (!isset($catTree[$cName])) {
|
||||
$catTree[$cName] = [];
|
||||
}
|
||||
$catTree[$cName][] = $item;
|
||||
}
|
||||
|
||||
// 读取当前师傅已拥有的技能
|
||||
$mySkills = \think\Db::name('master_skill')->where('master_id', $row['id'])->select();
|
||||
$selectedSkills = [];
|
||||
$customArr = [];
|
||||
foreach ($mySkills as $ms) {
|
||||
if ($ms['is_custom'] == 1) {
|
||||
$customArr[] = $ms['skill_name'];
|
||||
} else {
|
||||
$selectedSkills[] = $ms['skill_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->assign('row', $row);
|
||||
$this->view->assign('catTree', $catTree);
|
||||
$this->view->assign('selectedSkills', $selectedSkills);
|
||||
$this->view->assign('customText', implode(' ', $customArr));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 师傅全景档案画像
|
||||
*/
|
||||
@@ -78,10 +221,19 @@ class Master extends Backend
|
||||
->limit(5)
|
||||
->select();
|
||||
|
||||
// 4. 服务技能与认证证书
|
||||
$skills = \think\Db::name('master_skill')
|
||||
->alias('s')
|
||||
->join('service_cat c', 'c.id = s.cat_id', 'LEFT')
|
||||
->where('s.master_id', $row['id'])
|
||||
->field('s.*, c.name as cat_name')
|
||||
->select();
|
||||
|
||||
$this->view->assign('row', $row);
|
||||
$this->view->assign('recentOrders', $recentOrders);
|
||||
$this->view->assign('recentWithdraws', $recentWithdraws);
|
||||
$this->view->assign('recentReviews', $recentReviews);
|
||||
$this->view->assign('skills', $skills);
|
||||
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 师傅服务技能管理
|
||||
*
|
||||
* @icon fa fa-certificate
|
||||
*/
|
||||
class MasterSkill extends Backend
|
||||
{
|
||||
/**
|
||||
* MasterSkill模型对象
|
||||
* @var \app\admin\model\MasterSkill
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $relationSearch = true;
|
||||
protected $searchFields = 'id,master.realname,master.mobile,cat.name';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\MasterSkill;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with(['master', 'cat'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,13 @@ class Service extends Backend
|
||||
$this->view->assign("priceTypeList", $this->model->getPriceTypeList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
|
||||
// 获取全部可用的公共增项服务列表
|
||||
// 获取全部可用的公共增项服务列表并关联所属品类
|
||||
$addonsPool = Db::name('service_addon')
|
||||
->where('status', 'normal')
|
||||
->order('weigh desc, id asc')
|
||||
->alias('a')
|
||||
->leftJoin('service_cat c', 'a.cat_id = c.id')
|
||||
->field('a.*, COALESCE(c.name, "全平台通用") as cat_name')
|
||||
->where('a.status', 'normal')
|
||||
->order('a.cat_id asc, a.weigh desc, a.id asc')
|
||||
->select();
|
||||
$this->view->assign("addonsPool", $addonsPool);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
|
||||
/**
|
||||
* 技能分类管理
|
||||
*
|
||||
* @icon fa fa-th-large
|
||||
*/
|
||||
class SkillCategory extends Backend
|
||||
{
|
||||
/**
|
||||
* SkillCategory模型对象
|
||||
* @var \app\admin\model\SkillCategory
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $searchFields = 'id,name';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\SkillCategory;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看分类列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->withCount('skills')
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 技能列表管理
|
||||
*
|
||||
* @icon fa fa-tags
|
||||
*/
|
||||
class SkillDict extends Backend
|
||||
{
|
||||
/**
|
||||
* SkillDict模型对象
|
||||
* @var \app\admin\model\SkillDict
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $searchFields = 'id,name,category';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\SkillDict;
|
||||
|
||||
// 从真实技能分类表中拉取分类列表
|
||||
$categoryList = Db::name('skill_category')
|
||||
->where('status', 'normal')
|
||||
->order('weigh desc, id asc')
|
||||
->column('name', 'id');
|
||||
|
||||
$this->view->assign("categoryList", $categoryList);
|
||||
$this->view->assign("sourceList", $this->model->getSourceList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看技能列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with(['master'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加技能
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if (!empty($params['category_id'])) {
|
||||
$cat = Db::name('skill_category')->where('id', $params['category_id'])->find();
|
||||
if ($cat) {
|
||||
$params['category'] = $cat['name'];
|
||||
}
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($this->model->getError());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑技能
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if (!empty($params['category_id'])) {
|
||||
$cat = Db::name('skill_category')->where('id', $params['category_id'])->find();
|
||||
if ($cat) {
|
||||
$params['category'] = $cat['name'];
|
||||
}
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($row->getError());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Id' => 'ID',
|
||||
'Master_id' => '师傅ID',
|
||||
'Cat_id' => '服务技能/类目ID',
|
||||
'Cert_image' => '资质证书',
|
||||
'Status' => '状态',
|
||||
'Normal' => '正常',
|
||||
'Hidden' => '隐藏',
|
||||
'Createtime' => '认证时间',
|
||||
'Master.realname'=> '师傅姓名',
|
||||
'Master.mobile' => '师傅电话',
|
||||
'Cat.name' => '服务类目'
|
||||
];
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
return [
|
||||
'Cat_id' => '所属服务类目',
|
||||
'Name' => '服务项目名称',
|
||||
'Name' => '服务商品名称',
|
||||
'Image' => '服务展示主图',
|
||||
'Price_type' => '计价方式',
|
||||
'Base_price' => '基础基准价(元)',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Cat_id' => '所属服务类目',
|
||||
'Name' => '增值服务名称',
|
||||
'Unit' => '计价单位',
|
||||
'Default_price' => '平台指导价(元)',
|
||||
'Weigh' => '排序权重',
|
||||
'Status' => '服务状态',
|
||||
'Normal' => '正常启用',
|
||||
'Hidden' => '隐藏下架',
|
||||
];
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Id' => 'ID',
|
||||
'Name' => '分类名称',
|
||||
'Icon' => '图标',
|
||||
'Weigh' => '权重',
|
||||
'Status' => '状态',
|
||||
'Normal' => '正常启用',
|
||||
'Hidden' => '隐藏停用',
|
||||
'Createtime' => '创建时间',
|
||||
'Updatetime' => '更新时间'
|
||||
];
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'Id' => 'ID',
|
||||
'Category' => '技能大类',
|
||||
'Name' => '技能名称',
|
||||
'Source' => '字典来源',
|
||||
'Master_id' => '师傅ID',
|
||||
'Weigh' => '权重',
|
||||
'Status' => '状态',
|
||||
'Normal' => '正常启用',
|
||||
'Hidden' => '隐藏停用',
|
||||
'Createtime' => '创建时间',
|
||||
'Updatetime' => '更新时间',
|
||||
'Master.realname'=> '提交师傅'
|
||||
];
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class MasterSkill extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'master_skill';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['normal' => __('Normal'), 'hidden' => __('Hidden')];
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
public function master()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\Master', 'master_id', 'id')->setEagerlyType(0);
|
||||
}
|
||||
|
||||
public function cat()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\service\Cat', 'cat_id', 'id')->setEagerlyType(0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class SkillCategory extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'skill_category';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return [
|
||||
'normal' => '正常启用',
|
||||
'hidden' => '隐藏停用'
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联技能列表
|
||||
*/
|
||||
public function skills()
|
||||
{
|
||||
return $this->hasMany('app\admin\model\SkillDict', 'category_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class SkillDict extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'skill_dict';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = 'integer';
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = 'createtime';
|
||||
protected $updateTime = 'updatetime';
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'source_text',
|
||||
'status_text'
|
||||
];
|
||||
|
||||
public function getCategoryList()
|
||||
{
|
||||
return [
|
||||
'安装维修' => '安装维修',
|
||||
'建筑装修' => '建筑装修',
|
||||
'物流运输' => '物流运输',
|
||||
'汽车服务' => '汽车服务',
|
||||
'家政服务' => '家政服务',
|
||||
'便民服务' => '便民服务',
|
||||
'其他技能' => '其他技能'
|
||||
];
|
||||
}
|
||||
|
||||
public function getSourceList()
|
||||
{
|
||||
return [
|
||||
'system' => '系统预置',
|
||||
'custom' => '师傅自定义'
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return [
|
||||
'normal' => '正常启用',
|
||||
'hidden' => '隐藏停用'
|
||||
];
|
||||
}
|
||||
|
||||
public function getSourceTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['source'] ?? '');
|
||||
$list = $this->getSourceList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
public function master()
|
||||
{
|
||||
return $this->belongsTo('app\admin\model\Master', 'master_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -175,6 +175,29 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片 A2: 师傅已获服务技能 -->
|
||||
<div class="md-card">
|
||||
<div class="md-card-header">
|
||||
<h4 class="md-card-title"><i class="fa fa-certificate"></i> 已认证服务技能 ({:count($skills)})</h4>
|
||||
</div>
|
||||
<div class="md-card-body">
|
||||
{if !empty($skills)}
|
||||
<div style="display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px;">
|
||||
{foreach name="skills" item="sk"}
|
||||
<span class="label {if $sk.status == 'normal'}label-success{else}label-default{/if}" style="font-size: 13px; padding: 6px 12px; border-radius: 4px; display: inline-flex; align-items: center; gap: 5px;">
|
||||
<i class="fa fa-check-circle"></i> {$sk.cat_name|default='未归类技能'}
|
||||
{if !empty($sk.cert_image)}
|
||||
<a href="{$sk.cert_image}" target="_blank" style="color: #fff; margin-left: 4px;" title="查看证书"><i class="fa fa-picture-o"></i></a>
|
||||
{/if}
|
||||
</span>
|
||||
{/foreach}
|
||||
</div>
|
||||
{else}
|
||||
<div style="text-align: center; color: #94a3b8; padding: 15px 0;">暂未认证任何服务技能</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片 B: 钱包与资金账户 -->
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<style>
|
||||
.skill-config-box { padding: 10px 5px; }
|
||||
.skill-cat-block { margin-bottom: 18px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
|
||||
.skill-cat-title { background: #f8fafc; padding: 10px 14px; font-weight: 700; font-size: 13px; color: #1e293b; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; }
|
||||
.skill-cat-body { padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.skill-checkbox-label { margin: 0; font-weight: 400; font-size: 12px; cursor: pointer; }
|
||||
.skill-checkbox-label input[type="checkbox"] { margin-right: 4px; vertical-align: middle; }
|
||||
.skill-tag-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 4px; background: #f1f5f9; border: 1px solid #cbd5e1; user-select: none; }
|
||||
.skill-checkbox-label input[type="checkbox"]:checked + .skill-tag-pill { background: #ffedd5; border-color: #ea580c; color: #ea580c; font-weight: 600; }
|
||||
</style>
|
||||
|
||||
<form id="skills-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
<div class="skill-config-box">
|
||||
<div class="alert alert-info" style="font-size: 12px; margin-bottom: 15px;">
|
||||
<i class="fa fa-info-circle"></i> 当前正在为师傅 <strong>{$row.realname}</strong> ({$row.mobile}) 配置已认证服务技能。
|
||||
</div>
|
||||
|
||||
{foreach name="catTree" key="catName" item="items"}
|
||||
<div class="skill-cat-block">
|
||||
<div class="skill-cat-title">
|
||||
<span><i class="fa fa-tag text-primary"></i> {$catName}</span>
|
||||
<span class="text-muted" style="font-size: 11px;">{:count($items)} 项技能</span>
|
||||
</div>
|
||||
<div class="skill-cat-body">
|
||||
{if !empty($items)}
|
||||
{foreach name="items" item="it"}
|
||||
<label class="skill-checkbox-label">
|
||||
<input type="checkbox" name="skills[]" value="{$it.name}" {if in_array($it.name, $selectedSkills)}checked{/if} style="display:none;" />
|
||||
<span class="skill-tag-pill">{$it.name}</span>
|
||||
</label>
|
||||
{/foreach}
|
||||
{else}
|
||||
<span class="text-muted" style="font-size: 12px;">该分类下暂无技能字典项</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
|
||||
<!-- 自定义其他技能输入 -->
|
||||
<div class="skill-cat-block">
|
||||
<div class="skill-cat-title">
|
||||
<span><i class="fa fa-pencil text-warning"></i> 其他自定义技能</span>
|
||||
</div>
|
||||
<div class="skill-cat-body" style="display: block;">
|
||||
<textarea class="form-control" name="custom_text" rows="3" placeholder="请输入自定义技能项,用空格或逗号分隔。如:修手机 修柴油机">{$customText}</textarea>
|
||||
<div class="help-block" style="font-size: 11px; margin-bottom: 0;">保存后将自动归入师傅名下并沉淀进全平台技能列表库中。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,54 @@
|
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-certificate"></i> 师傅服务技能认证信息</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">选择师傅:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-master_id" data-rule="required" data-source="master/index" data-field="realname" class="form-control selectpage" name="row[master_id]" type="text" value="" placeholder="输入师傅姓名或手机号搜索">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务技能/类目:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-cat_id" data-rule="required" data-source="service/cat/index" data-field="name" class="form-control selectpage" name="row[cat_id]" type="text" value="" placeholder="选择所获技能分类(如家具、卫浴、灯具等)">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">技能证书/凭证:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-cert_image" class="form-control" size="50" name="row[cert_image]" type="text" value="" placeholder="上传技能资格证书、特种作业证或培训凭证照片">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-cert_image" class="btn btn-danger faupload" data-input-id="c-cert_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-cert_image"><i class="fa fa-upload"></i> 上传</button></span>
|
||||
<span><button type="button" id="fachoose-cert_image" class="btn btn-primary fachoose" data-input-id="c-cert_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-cert_image"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-cert_image"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">生效状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,54 @@
|
||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-pencil"></i> 修改师傅技能与资质</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">选择师傅:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-master_id" data-rule="required" data-source="master/index" data-field="realname" class="form-control selectpage" name="row[master_id]" type="text" value="{$row.master_id|htmlentities}" placeholder="输入师傅姓名或手机号搜索">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务技能/类目:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-cat_id" data-rule="required" data-source="service/cat/index" data-field="name" class="form-control selectpage" name="row[cat_id]" type="text" value="{$row.cat_id|htmlentities}" placeholder="选择所获技能分类">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">技能证书/凭证:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-cert_image" class="form-control" size="50" name="row[cert_image]" type="text" value="{$row.cert_image|htmlentities}" placeholder="上传技能资格证书、特种作业证或培训凭证照片">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-cert_image" class="btn btn-danger faupload" data-input-id="c-cert_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-cert_image"><i class="fa fa-upload"></i> 上传</button></span>
|
||||
<span><button type="button" id="fachoose-cert_image" class="btn btn-primary fachoose" data-input-id="c-cert_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-cert_image"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-cert_image"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">生效状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,23 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('master_skill/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('master_skill/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('master_skill/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('master_skill/edit')}"
|
||||
data-operate-del="{:$auth->check('master_skill/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,154 +1,284 @@
|
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<!-- 1. 基础信息 -->
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-info-circle"></i> 服务项目基础资料</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Cat_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-cat_id" data-rule="required" min="0" data-source="service/cat/index" class="form-control selectpage" name="row[cat_id]" type="text" value="" placeholder="请选择或搜索所属服务类目">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="" placeholder="如: 智能门锁安装/无缝墙布施工">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-image" data-rule="required" class="form-control" size="50" name="row[image]" type="text" value="" placeholder="请上传服务展示缩略图">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-image"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-image"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-description" class="form-control" rows="3" name="row[description]" placeholder="服务施工范围、注意事项及验收标准"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nav-tabs-custom" style="box-shadow: none;">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#tab-basic" data-toggle="tab"><i class="fa fa-info-circle text-primary"></i> 基础信息</a></li>
|
||||
<li><a href="#tab-service-types" data-toggle="tab"><i class="fa fa-wrench text-warning"></i> 工项服务定价</a></li>
|
||||
<li><a href="#tab-specs" data-toggle="tab"><i class="fa fa-cubes text-success"></i> 规格独立一口价</a></li>
|
||||
<li><a href="#tab-addons" data-toggle="tab"><i class="fa fa-plus-square text-danger"></i> 增值服务绑定</a></li>
|
||||
</ul>
|
||||
|
||||
<!-- 2. 定价与计价规则 -->
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-cny"></i> 定价与计价规则</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Price_type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-price_type" data-rule="required" class="form-control selectpicker" name="row[price_type]">
|
||||
{foreach name="priceTypeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="fixed"}selected{/in}>{$vo}</option>
|
||||
<div class="tab-content" style="padding: 15px 0;">
|
||||
<!-- Tab 1: 基础信息 -->
|
||||
<div class="tab-pane active" id="tab-basic">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">所属类目:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-cat_id" data-rule="required" min="0" data-source="service/cat/index" class="form-control selectpage" name="row[cat_id]" type="text" value="" placeholder="请选择所属服务类目">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">服务商品名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="" placeholder="如:智能门锁 / 现代吸顶灯 / 座便器">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">主图缩略图:</label>
|
||||
<div class="col-xs-12 col-sm-10">
|
||||
<div class="input-group">
|
||||
<input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-image" class="btn btn-danger plupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> 上传</button></span>
|
||||
<span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-image"></span>
|
||||
</div>
|
||||
<ul class="row list-inline plupload-preview" id="p-image"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">计价模式:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-price_type" data-rule="required" class="form-control selectpicker" name="row[price_type]">
|
||||
{foreach name="priceTypeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="fixed"}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">计价单位:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-unit" data-rule="required" class="form-control" name="row[unit]" type="text" value="件" placeholder="如:件、台、套、次">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">基准参考价(元):</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">¥</span>
|
||||
<input id="c-base_price" data-rule="required" class="form-control" step="0.01" name="row[base_price]" type="number" value="80.00">
|
||||
</div>
|
||||
<span class="help-block text-muted" style="margin-bottom:0; font-size:12px;"><i class="fa fa-info-circle"></i> 各工项未单独定价时默认采用此价</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">楼层步梯费:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">¥</span>
|
||||
<input id="c-floor_fee" data-rule="required" class="form-control" step="0.01" name="row[floor_fee]" type="number" value="10.00">
|
||||
<span class="input-group-addon">/层</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">免</span>
|
||||
<input id="c-free_floor" data-rule="required" class="form-control" name="row[free_floor]" type="number" value="2">
|
||||
<span class="input-group-addon">层</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务简介说明:</label>
|
||||
<div class="col-xs-12 col-sm-10">
|
||||
<textarea id="c-description" class="form-control" rows="2" name="row[description]" placeholder="服务施工范围、注意事项及验收标准"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">排序权重:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-4">状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tab 2: 工项服务定价 -->
|
||||
<div class="tab-pane" id="tab-service-types">
|
||||
<div class="alert alert-warning-light">
|
||||
<i class="fa fa-info-circle"></i> 勾选该商品所支持的具体施工工项并分别设定基准价。用户下单时可按需在这些工项间切换。
|
||||
</div>
|
||||
<table class="table table-bordered table-striped" id="service-types-table">
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th style="width: 60px; text-align: center;">启用</th>
|
||||
<th style="width: 120px;">工项标识</th>
|
||||
<th style="width: 180px;">前端显示名称</th>
|
||||
<th style="width: 180px;">一口基准工价(元)</th>
|
||||
<th style="width: 80px; text-align: center;">设为默认</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$defaultTypes = [
|
||||
'install' => ['name' => '安装', 'price' => 80.00, 'enabled' => true, 'is_default' => true],
|
||||
'repair' => ['name' => '维修', 'price' => 60.00, 'enabled' => true, 'is_default' => false],
|
||||
'remove' => ['name' => '拆旧', 'price' => 40.00, 'enabled' => true, 'is_default' => false],
|
||||
'deliver' => ['name' => '送货到家', 'price' => 50.00, 'enabled' => false, 'is_default' => false],
|
||||
'deliver_install' => ['name' => '送货到家并安装', 'price' => 120.00, 'enabled' => false, 'is_default' => false],
|
||||
'measure' => ['name' => '上门测量', 'price' => 30.00, 'enabled' => false, 'is_default' => false],
|
||||
];
|
||||
?>
|
||||
{foreach name="defaultTypes" item="st" key="code"}
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<input type="checkbox" class="st-enable" data-code="{$code}" {if $st.enabled}checked{/if}>
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<code>{$code}</code>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="form-control input-sm st-name" data-code="{$code}" value="{$st.name}">
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon">¥</span>
|
||||
<input type="number" step="0.01" class="form-control st-price" data-code="{$code}" value="{$st.price}">
|
||||
</div>
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<input type="radio" name="st_default_radio" class="st-default" data-code="{$code}" {if $st.is_default}checked{/if}>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" name="row[service_types_raw]" id="service_types_raw" value="">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务基准费:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">基础 ¥</span>
|
||||
<input id="c-base_price" data-rule="required" class="form-control" step="0.01" name="row[base_price]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">上限 ¥</span>
|
||||
<input id="c-max_price" data-rule="required" class="form-control" step="0.01" name="row[max_price]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">计价单位</span>
|
||||
<input id="c-unit" data-rule="required" class="form-control" name="row[unit]" type="text" value="次" placeholder="如: 件/台/㎡">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">步梯楼层费:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">单价 ¥</span>
|
||||
<input id="c-floor_fee" data-rule="required" class="form-control" step="0.01" name="row[floor_fee]" type="number" value="0.00">
|
||||
<span class="input-group-addon">/层</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">免楼层数</span>
|
||||
<input id="c-free_floor" data-rule="required" class="form-control" name="row[free_floor]" type="number" value="0">
|
||||
<span class="input-group-addon">层起算</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Need_model')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
<label for="row[need_model]-1"><input id="row[need_model]-1" name="row[need_model]" type="radio" value="1" checked /> 必须填写商品型号/规格</label>
|
||||
<label for="row[need_model]-0" style="margin-left: 20px;"><input id="row[need_model]-0" name="row[need_model]" type="radio" value="0" /> 无需填写</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 3. 上架与运营权重 -->
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-sliders"></i> 上架与运营权重</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">运营指标:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">初始销量</span>
|
||||
<input id="c-sales" data-rule="required" class="form-control" name="row[sales]" type="number" value="0">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">排序权重</span>
|
||||
<input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0" placeholder="数字越大越靠前">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tab 3: 规格独立定价 -->
|
||||
<div class="tab-pane" id="tab-specs">
|
||||
<div class="alert alert-success-light">
|
||||
<i class="fa fa-info-circle"></i> 为该商品增设不同规格(如:智能一体机 / 普通坐便器),并分别设置规格基准一口价。
|
||||
</div>
|
||||
<table class="table table-bordered table-striped" id="specs-table">
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th style="width: 200px;">规格名称</th>
|
||||
<th style="width: 150px;">规格独立一口价(元)</th>
|
||||
<th>规格施工描述</th>
|
||||
<th style="width: 80px; text-align: center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="specs-tbody">
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="button" class="btn btn-sm btn-success" id="btn-add-spec"><i class="fa fa-plus"></i> 添加新规格</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
|
||||
<!-- Tab 4: 增值服务绑定 -->
|
||||
<div class="tab-pane" id="tab-addons">
|
||||
<div class="alert alert-info" style="margin-bottom: 12px; padding: 10px 15px; border-radius: 4px;">
|
||||
<i class="fa fa-info-circle"></i> <strong>增值服务按类目精准隔离与绑定:</strong>
|
||||
系统根据上方所选的服务类目动态过滤可用增值服务。不同品类拥有独立的工法增项标准,支持在此单独设置专属单价。
|
||||
</div>
|
||||
|
||||
<div class="well well-sm" style="background: #fafafa; border: 1px solid #e7eaec; margin-bottom: 12px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span class="text-muted" style="font-size: 13px;"><i class="fa fa-filter"></i> 视图筛选:</span>
|
||||
<div class="btn-group btn-group-sm" id="addon-filter-group">
|
||||
<button type="button" class="btn btn-primary active" id="btn-filter-category"><i class="fa fa-check-circle"></i> 仅显示本类目与通用增项</button>
|
||||
<button type="button" class="btn btn-default" id="btn-filter-all"><i class="fa fa-th-list"></i> 显示全部增值服务库</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 6px;">
|
||||
<button type="button" class="btn btn-xs btn-success" id="btn-check-cat-addons"><i class="fa fa-check-square-o"></i> 一键勾选本类目专属增项</button>
|
||||
<button type="button" class="btn btn-xs btn-info" id="btn-check-common-addons"><i class="fa fa-check-square"></i> 一键勾选通用增项</button>
|
||||
<button type="button" class="btn btn-xs btn-default" id="btn-uncheck-all-addons"><i class="fa fa-square-o"></i> 全部取消勾选</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered table-striped table-hover" id="addons-table">
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th style="width: 50px; text-align: center;">绑定</th>
|
||||
<th style="width: 130px; text-align: center;">所属品类</th>
|
||||
<th style="min-width: 180px;">增值服务名称</th>
|
||||
<th style="width: 80px; text-align: center;">单位</th>
|
||||
<th style="width: 130px;">平台指导价</th>
|
||||
<th style="width: 180px;">针对本商品专属单价(元)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach name="addonsPool" item="ad"}
|
||||
<?php
|
||||
$isCommon = ($ad['cat_id'] == 0);
|
||||
?>
|
||||
<tr class="addon-row" data-cat-id="{$ad.cat_id}">
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<input type="checkbox" class="ad-bind" data-id="{$ad.id}" data-name="{$ad.name}" data-unit="{$ad.unit}" data-cat-id="{$ad.cat_id}">
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
{if $isCommon}
|
||||
<span class="label label-default" style="font-weight: normal; font-size: 11px;"><i class="fa fa-globe"></i> 全平台通用</span>
|
||||
{else}
|
||||
<span class="label label-primary" style="font-weight: normal; font-size: 11px;"><i class="fa fa-tag"></i> {$ad.cat_name}</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<strong>{$ad.name}</strong>
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<span class="badge" style="background-color: #f3f3f4; color: #555; border: 1px solid #e0e0e0;">{$ad.unit}</span>
|
||||
</td>
|
||||
<td style="vertical-align: middle; color: #888;">
|
||||
¥{$ad.default_price}
|
||||
</td>
|
||||
<td>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon">¥</span>
|
||||
<input type="number" step="0.01" class="form-control ad-price" data-id="{$ad.id}" value="{$ad.default_price}" placeholder="覆盖单价">
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" name="row[addons_raw]" id="addons_raw" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -156,8 +286,133 @@
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled" id="btn-submit-service">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function collectServiceConfig() {
|
||||
var serviceTypes = [];
|
||||
$('#service-types-table tbody tr').each(function () {
|
||||
var $row = $(this);
|
||||
var $enable = $row.find('.st-enable');
|
||||
if ($enable.is(':checked')) {
|
||||
var code = $enable.data('code');
|
||||
var name = $row.find('.st-name').val();
|
||||
var price = parseFloat($row.find('.st-price').val()) || 0;
|
||||
var isDef = $row.find('.st-default').is(':checked') ? 1 : 0;
|
||||
serviceTypes.push({
|
||||
code: code,
|
||||
name: name,
|
||||
price: price,
|
||||
is_default: isDef
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#service_types_raw').val(JSON.stringify(serviceTypes));
|
||||
|
||||
var addons = [];
|
||||
$('#addons-table tbody tr').each(function () {
|
||||
var $row = $(this);
|
||||
var $bind = $row.find('.ad-bind');
|
||||
if ($bind.is(':checked')) {
|
||||
var id = parseInt($bind.data('id'), 10);
|
||||
var name = $bind.data('name');
|
||||
var unit = $bind.data('unit');
|
||||
var price = parseFloat($row.find('.ad-price').val()) || 0;
|
||||
addons.push({
|
||||
id: id,
|
||||
name: name,
|
||||
unit: unit,
|
||||
price: price
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#addons_raw').val(JSON.stringify(addons));
|
||||
}
|
||||
|
||||
function applyAddonsFilter(onlyCategory) {
|
||||
var currentCatId = parseInt($('#c-cat_id').val(), 10) || 0;
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (onlyCategory) {
|
||||
if (rowCatId === 0 || (currentCatId > 0 && rowCatId === currentCatId)) {
|
||||
$(this).show();
|
||||
} else if (currentCatId === 0) {
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(function () {
|
||||
applyAddonsFilter(true);
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-filter-category', function () {
|
||||
$('#btn-filter-group .btn').removeClass('active btn-primary').addClass('btn-default');
|
||||
$(this).removeClass('btn-default').addClass('active btn-primary');
|
||||
applyAddonsFilter(true);
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-filter-all', function () {
|
||||
$('#btn-filter-group .btn').removeClass('active btn-primary').addClass('btn-default');
|
||||
$(this).removeClass('btn-default').addClass('active btn-primary');
|
||||
applyAddonsFilter(false);
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-check-cat-addons', function () {
|
||||
var currentCatId = parseInt($('#c-cat_id').val(), 10) || 0;
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (rowCatId > 0 && rowCatId === currentCatId) {
|
||||
$(this).find('.ad-bind').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-check-common-addons', function () {
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (rowCatId === 0) {
|
||||
$(this).find('.ad-bind').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-uncheck-all-addons', function () {
|
||||
$('#addons-table tbody tr.addon-row .ad-bind').prop('checked', false);
|
||||
});
|
||||
|
||||
$(document).on('change', '#c-cat_id', function () {
|
||||
if ($('#btn-filter-category').hasClass('active')) {
|
||||
applyAddonsFilter(true);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('submit', '#add-form', function () {
|
||||
collectServiceConfig();
|
||||
});
|
||||
|
||||
var specIndex = 1000;
|
||||
$(document).on('click', '#btn-add-spec', function () {
|
||||
specIndex++;
|
||||
var html = '<tr>' +
|
||||
'<td><input type="text" name="specs[' + specIndex + '][name]" class="form-control input-sm" placeholder="规格名称(如:四眼炒灶)"></td>' +
|
||||
'<td><div class="input-group input-group-sm"><span class="input-group-addon">¥</span><input type="number" step="0.01" name="specs[' + specIndex + '][base_price]" class="form-control" value="0.00"></div></td>' +
|
||||
'<td><input type="text" name="specs[' + specIndex + '][description]" class="form-control input-sm" placeholder="施工说明"></td>' +
|
||||
'<td style="text-align:center;"><button type="button" class="btn btn-xs btn-danger btn-del-spec"><i class="fa fa-trash"></i></button></td>' +
|
||||
'</tr>';
|
||||
$('#specs-tbody').append(html);
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-del-spec', function () {
|
||||
$(this).closest('tr').remove();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -241,18 +241,37 @@
|
||||
<button type="button" class="btn btn-sm btn-success" id="btn-add-spec"><i class="fa fa-plus"></i> 添加新规格</button>
|
||||
</div>
|
||||
|
||||
<!-- Tab 4: 增项服务绑定 -->
|
||||
<!-- Tab 4: 增值服务绑定 -->
|
||||
<div class="tab-pane" id="tab-addons">
|
||||
<div class="alert alert-danger-light">
|
||||
<i class="fa fa-info-circle"></i> 从系统增项库中勾选该商品允许加选的增项服务(如马桶勾选拆旧/改坑距,油烟机勾选打孔),并可为该商品定制专属单价(留空则默认按全局价)。
|
||||
<div class="alert alert-info" style="margin-bottom: 12px; padding: 10px 15px; border-radius: 4px;">
|
||||
<i class="fa fa-info-circle"></i> <strong>增值服务按类目精准隔离与绑定:</strong>
|
||||
系统已自动为您匹配该商品所属类目的专属增项池。不同品类拥有独立的工法与增项标准,支持为本商品单独设置专属覆写单价(留空则采用平台指导价)。
|
||||
</div>
|
||||
<table class="table table-bordered table-striped" id="addons-table">
|
||||
|
||||
<!-- 增值服务工具栏与品类联动过滤 -->
|
||||
<div class="well well-sm" style="background: #fafafa; border: 1px solid #e7eaec; margin-bottom: 12px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;">
|
||||
<div style="display: flex; align-items: center; gap: 8px;">
|
||||
<span class="text-muted" style="font-size: 13px;"><i class="fa fa-filter"></i> 视图筛选:</span>
|
||||
<div class="btn-group btn-group-sm" id="addon-filter-group">
|
||||
<button type="button" class="btn btn-primary active" id="btn-filter-category"><i class="fa fa-check-circle"></i> 仅显示本类目与通用增项</button>
|
||||
<button type="button" class="btn btn-default" id="btn-filter-all"><i class="fa fa-th-list"></i> 显示全部增值服务库</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="display: flex; align-items: center; gap: 6px;">
|
||||
<button type="button" class="btn btn-xs btn-success" id="btn-check-cat-addons"><i class="fa fa-check-square-o"></i> 一键勾选本类目专属增项</button>
|
||||
<button type="button" class="btn btn-xs btn-info" id="btn-check-common-addons"><i class="fa fa-check-square"></i> 一键勾选通用增项</button>
|
||||
<button type="button" class="btn btn-xs btn-default" id="btn-uncheck-all-addons"><i class="fa fa-square-o"></i> 全部取消勾选</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table table-bordered table-striped table-hover" id="addons-table">
|
||||
<thead>
|
||||
<tr class="active">
|
||||
<th style="width: 60px; text-align: center;">绑定</th>
|
||||
<th style="width: 180px;">增项名称</th>
|
||||
<th style="width: 90px; text-align: center;">单位</th>
|
||||
<th style="width: 140px;">平台全局指导价</th>
|
||||
<th style="width: 50px; text-align: center;">绑定</th>
|
||||
<th style="width: 130px; text-align: center;">所属品类</th>
|
||||
<th style="min-width: 180px;">增值服务名称</th>
|
||||
<th style="width: 80px; text-align: center;">单位</th>
|
||||
<th style="width: 130px;">平台指导价</th>
|
||||
<th style="width: 180px;">针对本商品专属单价(元)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -269,16 +288,24 @@
|
||||
<?php
|
||||
$isBind = isset($assignedMap[$ad['id']]);
|
||||
$customPrice = $isBind && isset($assignedMap[$ad['id']]['price']) ? $assignedMap[$ad['id']]['price'] : $ad['default_price'];
|
||||
$isCommon = ($ad['cat_id'] == 0);
|
||||
?>
|
||||
<tr>
|
||||
<tr class="addon-row" data-cat-id="{$ad.cat_id}">
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<input type="checkbox" class="ad-bind" data-id="{$ad.id}" data-name="{$ad.name}" data-unit="{$ad.unit}" {if $isBind}checked{/if}>
|
||||
<input type="checkbox" class="ad-bind" data-id="{$ad.id}" data-name="{$ad.name}" data-unit="{$ad.unit}" data-cat-id="{$ad.cat_id}" {if $isBind}checked{/if}>
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
{if $isCommon}
|
||||
<span class="label label-default" style="font-weight: normal; font-size: 11px;"><i class="fa fa-globe"></i> 全平台通用</span>
|
||||
{else}
|
||||
<span class="label label-primary" style="font-weight: normal; font-size: 11px;"><i class="fa fa-tag"></i> {$ad.cat_name}</span>
|
||||
{/if}
|
||||
</td>
|
||||
<td style="vertical-align: middle;">
|
||||
<strong>{$ad.name}</strong>
|
||||
</td>
|
||||
<td style="text-align: center; vertical-align: middle;">
|
||||
<span class="badge">{$ad.unit}</span>
|
||||
<span class="badge" style="background-color: #f3f3f4; color: #555; border: 1px solid #e0e0e0;">{$ad.unit}</span>
|
||||
</td>
|
||||
<td style="vertical-align: middle; color: #888;">
|
||||
¥{$ad.default_price}
|
||||
@@ -351,6 +378,75 @@
|
||||
$('#addons_raw').val(JSON.stringify(addons));
|
||||
}
|
||||
|
||||
// 增值服务按所属类目筛选
|
||||
function applyAddonsFilter(onlyCategory) {
|
||||
var currentCatId = parseInt($('#c-cat_id').val(), 10) || 0;
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (onlyCategory) {
|
||||
// 仅显示属于当前商品类目或者通用的增值服务
|
||||
if (rowCatId === 0 || rowCatId === currentCatId) {
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
} else {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 初始化时仅显示本类目与通用增项
|
||||
$(function () {
|
||||
applyAddonsFilter(true);
|
||||
});
|
||||
|
||||
// 切换筛选视图
|
||||
$(document).on('click', '#btn-filter-category', function () {
|
||||
$('#btn-filter-group .btn').removeClass('active btn-primary').addClass('btn-default');
|
||||
$(this).removeClass('btn-default').addClass('active btn-primary');
|
||||
applyAddonsFilter(true);
|
||||
});
|
||||
|
||||
$(document).on('click', '#btn-filter-all', function () {
|
||||
$('#btn-filter-group .btn').removeClass('active btn-primary').addClass('btn-default');
|
||||
$(this).removeClass('btn-default').addClass('active btn-primary');
|
||||
applyAddonsFilter(false);
|
||||
});
|
||||
|
||||
// 一键勾选本类目专属增项
|
||||
$(document).on('click', '#btn-check-cat-addons', function () {
|
||||
var currentCatId = parseInt($('#c-cat_id').val(), 10) || 0;
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (rowCatId > 0 && rowCatId === currentCatId) {
|
||||
$(this).find('.ad-bind').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 一键勾选全平台通用增项
|
||||
$(document).on('click', '#btn-check-common-addons', function () {
|
||||
$('#addons-table tbody tr.addon-row').each(function () {
|
||||
var rowCatId = parseInt($(this).data('cat-id'), 10) || 0;
|
||||
if (rowCatId === 0) {
|
||||
$(this).find('.ad-bind').prop('checked', true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 全部取消勾选
|
||||
$(document).on('click', '#btn-uncheck-all-addons', function () {
|
||||
$('#addons-table tbody tr.addon-row .ad-bind').prop('checked', false);
|
||||
});
|
||||
|
||||
// 当所属类目变更时动态联动过滤
|
||||
$(document).on('change', '#c-cat_id', function () {
|
||||
if ($('#btn-filter-category').hasClass('active')) {
|
||||
applyAddonsFilter(true);
|
||||
}
|
||||
});
|
||||
|
||||
// 监听表单提交事件,在提交前组装 JSON
|
||||
$(document).on('submit', '#edit-form', function () {
|
||||
collectServiceConfig();
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-th-large"></i> 技能分类定义</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">分类名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="" placeholder="如: 安装维修、建筑装修、物流运输">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">分类图标:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-icon" class="form-control" size="50" name="row[icon]" type="text" value="" placeholder="可上传分类图标图片或输入CSS类名">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-icon" class="btn btn-danger faupload" data-input-id="c-icon" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp,image/svg+xml" data-multiple="false" data-preview-id="p-icon"><i class="fa fa-upload"></i> 上传</button></span>
|
||||
<span><button type="button" id="fachoose-icon" class="btn btn-primary fachoose" data-input-id="c-icon" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-icon"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-icon"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">排序权重:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-weigh" data-rule="required;integer" class="form-control" name="row[weigh]" type="number" value="100" placeholder="数值越大排序越靠前">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">启用状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,54 @@
|
||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-pencil"></i> 修改技能分类</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">分类名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">分类图标:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-icon" class="form-control" size="50" name="row[icon]" type="text" value="{$row.icon|htmlentities}" placeholder="可上传分类图标图片或输入CSS类名">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-icon" class="btn btn-danger faupload" data-input-id="c-icon" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp,image/svg+xml" data-multiple="false" data-preview-id="p-icon"><i class="fa fa-upload"></i> 上传</button></span>
|
||||
<span><button type="button" id="fachoose-icon" class="btn btn-primary fachoose" data-input-id="c-icon" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> 选择</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-icon"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-icon"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">排序权重:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-weigh" data-rule="required;integer" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">启用状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,23 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('skill_category/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('skill_category/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('skill_category/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('skill_category/edit')}"
|
||||
data-operate-del="{:$auth->check('skill_category/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,56 @@
|
||||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-tags"></i> 技能信息定义</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">所属分类:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{:build_select('row[category_id]', $categoryList, '', ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">技能名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="" placeholder="如: 水电工、家具组装、应急补胎">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">字典来源:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="sourceList" item="vo"}
|
||||
<label for="row[source]-{$key}"><input id="row[source]-{$key}" name="row[source]" type="radio" value="{$key}" {in name="key" value="system"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">排序权重:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-weigh" data-rule="required;integer" class="form-control" name="row[weigh]" type="number" value="100" placeholder="数值越大排序越靠前">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">启用状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="normal"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,59 @@
|
||||
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
<div class="panel panel-default panel-form-section">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-pencil"></i> 修改技能标签</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">所属分类:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{:build_select('row[category_id]', $categoryList, $row.category_id, ['class'=>'form-control selectpicker', 'data-rule'=>'required'])}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">技能名称:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">字典来源:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="sourceList" item="vo"}
|
||||
<label for="row[source]-{$key}"><input id="row[source]-{$key}" name="row[source]" type="radio" value="{$key}" {in name="key" value="$row.source"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
{if $row.source == 'custom'}
|
||||
<span class="help-block"><i class="fa fa-info-circle text-warning"></i> 该技能由师傅自定义输入提交,改为【系统预置】即可纳入平台标准公共字典供所有师傅勾选。</span>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">排序权重:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-weigh" data-rule="required;integer" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">启用状态:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="$row.status"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
<button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -0,0 +1,23 @@
|
||||
<div class="panel panel-default panel-intro">
|
||||
{:build_heading()}
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('skill_dict/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('skill_dict/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('skill_dict/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('skill_dict/edit')}"
|
||||
data-operate-del="{:$auth->check('skill_dict/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -92,11 +92,25 @@ class Master extends Base
|
||||
if (!$master) {
|
||||
$this->success('未入驻', ['applied' => false]);
|
||||
}
|
||||
$skills = Db::name('master_skill')->alias('s')
|
||||
$skillsRaw = Db::name('master_skill')->alias('s')
|
||||
->join('service_cat c', 'c.id = s.cat_id', 'LEFT')
|
||||
->field('s.cat_id,c.name,c.icon')
|
||||
->field('s.cat_id,s.skill_id,s.skill_name,s.category,s.is_custom,c.name as cat_name,c.icon')
|
||||
->where('s.master_id', $master['id'])
|
||||
->select();
|
||||
$skills = [];
|
||||
foreach ($skillsRaw as $sr) {
|
||||
$name = !empty($sr['skill_name']) ? $sr['skill_name'] : ($sr['cat_name'] ?? '');
|
||||
if ($name) {
|
||||
$skills[] = [
|
||||
'cat_id' => (int)$sr['cat_id'],
|
||||
'skill_id' => (int)$sr['skill_id'],
|
||||
'name' => $name,
|
||||
'category' => $sr['category'] ?: '服务技能',
|
||||
'is_custom' => (int)$sr['is_custom'],
|
||||
'icon' => $sr['icon'] ?? ''
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$todo = Db::name('order')->where('master_id', $master['id'])
|
||||
->where('status', 'in', [OrderStatus::ACCEPTED, OrderStatus::SCHEDULED, OrderStatus::ARRIVED, OrderStatus::WORKING])
|
||||
@@ -915,4 +929,160 @@ class Master extends Base
|
||||
|
||||
$this->success('', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取技能字典树与师傅当前选定状态
|
||||
* @ApiMethod (GET)
|
||||
*/
|
||||
public function skillDict()
|
||||
{
|
||||
$master = $this->masterInfo();
|
||||
$masterId = $master ? (int)$master['id'] : 0;
|
||||
|
||||
// 1. 获取所有正常启用的字典项
|
||||
$dictList = Db::name('skill_dict')
|
||||
->where('status', 'normal')
|
||||
->order('weigh desc, id asc')
|
||||
->select();
|
||||
|
||||
// 2. 按大类分组
|
||||
$groups = [];
|
||||
$categoryOrder = ['安装维修', '建筑装修', '物流运输', '汽车服务', '家政服务', '便民服务'];
|
||||
foreach ($categoryOrder as $cat) {
|
||||
$groups[$cat] = [];
|
||||
}
|
||||
|
||||
foreach ($dictList as $item) {
|
||||
$cat = $item['category'];
|
||||
if (!isset($groups[$cat])) {
|
||||
$groups[$cat] = [];
|
||||
}
|
||||
$groups[$cat][] = [
|
||||
'id' => (int)$item['id'],
|
||||
'name' => $item['name'],
|
||||
'category' => $item['category'],
|
||||
'source' => $item['source'],
|
||||
];
|
||||
}
|
||||
|
||||
$tree = [];
|
||||
foreach ($groups as $catName => $items) {
|
||||
if (!empty($items)) {
|
||||
$tree[] = [
|
||||
'category' => $catName,
|
||||
'items' => $items
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 当前师傅已勾选的技能
|
||||
$selectedNames = [];
|
||||
$customText = '';
|
||||
if ($masterId > 0) {
|
||||
$mySkills = Db::name('master_skill')->where('master_id', $masterId)->select();
|
||||
$customArr = [];
|
||||
foreach ($mySkills as $ms) {
|
||||
$sName = !empty($ms['skill_name']) ? $ms['skill_name'] : '';
|
||||
if ($ms['is_custom'] == 1) {
|
||||
$customArr[] = $sName;
|
||||
} else if ($sName) {
|
||||
$selectedNames[] = $sName;
|
||||
}
|
||||
}
|
||||
$customText = implode(' ', $customArr);
|
||||
}
|
||||
|
||||
$this->success('ok', [
|
||||
'tree' => $tree,
|
||||
'selected_skills' => $selectedNames,
|
||||
'custom_text' => $customText,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存师傅服务技能与自定义输入技能
|
||||
* @ApiMethod (POST)
|
||||
*/
|
||||
public function saveSkills()
|
||||
{
|
||||
$master = $this->requireMaster();
|
||||
$selectedSkills = (array)$this->request->post('selected_skills/a', []);
|
||||
$customText = trim((string)$this->request->post('custom_text', ''));
|
||||
|
||||
// 1. 处理自定义输入的技能
|
||||
$customNames = [];
|
||||
if (!empty($customText)) {
|
||||
$parts = preg_split('/[,,\s]+/u', $customText);
|
||||
foreach ($parts as $p) {
|
||||
$p = trim($p);
|
||||
if (!empty($p) && !in_array($p, $customNames) && !in_array($p, $selectedSkills)) {
|
||||
$customNames[] = $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($selectedSkills) && empty($customNames)) {
|
||||
$this->error('请至少选择或输入一项服务技能');
|
||||
}
|
||||
|
||||
// 2. 清理当前师傅原有的技能
|
||||
Db::name('master_skill')->where('master_id', $master['id'])->delete();
|
||||
|
||||
// 3. 写入字典勾选的技能
|
||||
$dictRows = Db::name('skill_dict')->where('name', 'in', $selectedSkills)->select();
|
||||
$dictMap = [];
|
||||
foreach ($dictRows as $dr) {
|
||||
$dictMap[$dr['name']] = $dr;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
foreach ($selectedSkills as $sName) {
|
||||
$dict = $dictMap[$sName] ?? null;
|
||||
Db::name('master_skill')->insert([
|
||||
'master_id' => $master['id'],
|
||||
'cat_id' => 0,
|
||||
'skill_id' => $dict ? $dict['id'] : 0,
|
||||
'skill_name' => $sName,
|
||||
'category' => $dict ? $dict['category'] : '服务技能',
|
||||
'is_custom' => 0,
|
||||
'cert_image' => '',
|
||||
'status' => 'normal',
|
||||
'createtime' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
// 4. 处理自定义输入的技能(沉淀入库到 skill_dict 且归属当前师傅)
|
||||
foreach ($customNames as $cName) {
|
||||
$exist = Db::name('skill_dict')->where('name', $cName)->find();
|
||||
if (!$exist) {
|
||||
$skillDictId = Db::name('skill_dict')->insertGetId([
|
||||
'category' => '其他技能',
|
||||
'name' => $cName,
|
||||
'source' => 'custom',
|
||||
'master_id' => $master['id'],
|
||||
'weigh' => 0,
|
||||
'status' => 'normal',
|
||||
'createtime' => $now,
|
||||
'updatetime' => $now
|
||||
]);
|
||||
} else {
|
||||
$skillDictId = $exist['id'];
|
||||
}
|
||||
|
||||
Db::name('master_skill')->insert([
|
||||
'master_id' => $master['id'],
|
||||
'cat_id' => 0,
|
||||
'skill_id' => $skillDictId,
|
||||
'skill_name' => $cName,
|
||||
'category' => '其他技能',
|
||||
'is_custom' => 1,
|
||||
'cert_image' => '',
|
||||
'status' => 'normal',
|
||||
'createtime' => $now
|
||||
]);
|
||||
}
|
||||
|
||||
$this->success('服务技能保存成功');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ return array (
|
||||
'name' => '优匠优服',
|
||||
'beian' => '',
|
||||
'cdnurl' => '',
|
||||
'version' => '1.0.18',
|
||||
'version' => '1.0.21',
|
||||
'timezone' => 'Asia/Shanghai',
|
||||
'forbiddenip' => '',
|
||||
'languages' =>
|
||||
|
||||
在新工单中引用
屏蔽一个用户