应用开发

This commit is contained in:
devil_gong 2019-04-16 15:17:30 +08:00
parent 1d11f494df
commit fcc471619c
15 changed files with 708 additions and 76 deletions

View File

@ -42,7 +42,9 @@ function GetDocumentRoot()
return str_replace('\\', '/', substr(str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']), 0, 0 -strlen($_SERVER['PHP_SELF'])));
}
}
return '';
// 服务器root没有获取到默认使用系统root_path
return (substr(ROOT_PATH, -1) == '/') ? substr(ROOT_PATH, 0, -1) : ROOT_PATH;
}
/**
@ -740,7 +742,7 @@ function Fsockopen_Post($url, $data = '')
$post = substr( $post , 0 , -1 );
$len = strlen($post);
$fp = @fsockopen( $host ,$port, $errno, $errstr, 10);
if (!$fp) {
if(!$fp) {
return "$errstr ($errno)\n";
} else {
$receive = '';
@ -1214,14 +1216,14 @@ function DS($key)
*/
function ParamsChecked($data, $params)
{
if (empty($params) || !is_array($data) || !is_array($params))
if(empty($params) || !is_array($data) || !is_array($params))
{
return '内部调用参数配置有误';
}
foreach ($params as $v)
{
if (empty($v['key_name']) || empty($v['error_msg']))
if(empty($v['key_name']) || empty($v['error_msg']))
{
return '内部调用参数配置有误';
}
@ -1261,7 +1263,7 @@ function ParamsChecked($data, $params)
{
// 是否存在
case 'isset' :
if (!isset($data[$v['key_name']]))
if(!isset($data[$v['key_name']]))
{
return $v['error_msg'];
}
@ -1269,7 +1271,7 @@ function ParamsChecked($data, $params)
// 是否为空
case 'empty' :
if (empty($data[$v['key_name']]))
if(empty($data[$v['key_name']]))
{
return $v['error_msg'];
}
@ -1277,11 +1279,11 @@ function ParamsChecked($data, $params)
// 是否存在于验证数组中
case 'in' :
if (empty($v['checked_data']) || !is_array($v['checked_data']))
if(empty($v['checked_data']) || !is_array($v['checked_data']))
{
return '内部调用参数配置有误';
}
if (!isset($data[$v['key_name']]) || !in_array($data[$v['key_name']], $v['checked_data']))
if(!isset($data[$v['key_name']]) || !in_array($data[$v['key_name']], $v['checked_data']))
{
return $v['error_msg'];
}
@ -1289,7 +1291,7 @@ function ParamsChecked($data, $params)
// 是否为数组
case 'is_array' :
if (!isset($data[$v['key_name']]) || !is_array($data[$v['key_name']]))
if(!isset($data[$v['key_name']]) || !is_array($data[$v['key_name']]))
{
return $v['error_msg'];
}
@ -1327,12 +1329,12 @@ function ParamsChecked($data, $params)
// 自定义函数
case 'fun' :
if (empty($v['checked_data']) || !function_exists($v['checked_data']))
if(empty($v['checked_data']) || !function_exists($v['checked_data']))
{
return '验证函数为空或函数未定义';
}
$fun = $v['checked_data'];
if(!$fun($data[$v['key_name']]))
if(!isset($data[$v['key_name']]) || !$fun($data[$v['key_name']]))
{
return $v['error_msg'];
}
@ -1340,12 +1342,12 @@ function ParamsChecked($data, $params)
// 最小
case 'min' :
if (!isset($v['checked_data']))
if(!isset($v['checked_data']))
{
return '验证最小值未定义';
}
$fun = $v['checked_data'];
if($data[$v['key_name']] < $v['checked_data'])
if(!isset($data[$v['key_name']]) || $data[$v['key_name']] < $v['checked_data'])
{
return $v['error_msg'];
}
@ -1353,12 +1355,29 @@ function ParamsChecked($data, $params)
// 最大
case 'max' :
if (!isset($v['checked_data']))
if(!isset($v['checked_data']))
{
return '验证最大值未定义';
}
$fun = $v['checked_data'];
if($data[$v['key_name']] > $v['checked_data'])
if(!isset($data[$v['key_name']]) || $data[$v['key_name']] > $v['checked_data'])
{
return $v['error_msg'];
}
break;
// 数据库唯一
case 'unique' :
if(!isset($v['checked_data']))
{
return '验证唯一表参数未定义';
}
if(empty($data[$v['key_name']]))
{
return $v['error_msg'];
}
$temp = db($v['checked_data'])->where([$v['key_name']=>$data[$v['key_name']]])->find();
if(!empty($temp))
{
return $v['error_msg'];
}

View File

@ -67,7 +67,7 @@ class Hook extends Controller
[
'name' => '我的宠物',
'url' => PluginsHomeUrl('petscms', 'pets', 'index'),
'contains' => ['petsindex', 'petssaveinfo'],
'contains' => ['petsindex', 'petssaveinfo', 'petshelp'],
'is_show' => 1,
'icon' => 'am-icon-github-alt',
],

View File

@ -111,7 +111,11 @@ class Pets extends Controller
'where' => ['id' => intval($params['id'])],
);
$ret = Service::PetsList($data_params);
$data = empty($ret['data'][0]) ? [] : $ret['data'][0];
if(!empty($ret['data'][0]))
{
$ret['data'][0]['lose_features'] = str_replace('<br />', "\n", $ret['data'][0]['lose_features']);
$data = $ret['data'][0];
}
unset($params['id']);
}
$this->assign('data', $data);
@ -172,5 +176,97 @@ class Pets extends Controller
$params['user'] = $this->user;
return Service::PestSave($params);
}
/**
* 丢失提供信息添加/编辑
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-03-15T23:51:50+0800
* @param [array] $params [输入参数]
*/
public function helpsave($params = [])
{
// 是否ajax请求
if(!IS_AJAX)
{
return $this->error('非法访问');
}
// 用户
$params['user'] = $this->user;
return Service::HelpSave($params);
}
/**
* 宠物帮助数据列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-03-15T23:51:50+0800
* @param [array] $params [输入参数]
*/
public function help($params = [])
{
// 参数
$params = input();
if(empty($params['pets_id']))
{
$this->assign('msg', '参数有误');
return $this->fetch('public/tips_error');
}
// 分页
$number = 10;
// 条件
$where = [
'user_id' => $this->user['id'],
'pets_id' => intval($params['pets_id']),
];
// 获取总数
$total = Service::HelpTotal($where);
// 分页
$page_params = array(
'number' => $number,
'total' => $total,
'where' => $params,
'page' => isset($params['page']) ? intval($params['page']) : 1,
'url' => PluginsHomeUrl('petscms', 'pets', 'index'),
);
$page = new \base\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
// 获取列表
$data_params = array(
'm' => $page->GetPageStarNumber(),
'n' => $number,
'where' => $where,
);
$data = Service::HelpList($data_params);
$this->assign('data_list', $data['data']);
return $this->fetch('../../../plugins/view/petscms/pets/help');
}
/**
* 宠物帮助数据地图展示
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-03-15T23:51:50+0800
* @param [array] $params [输入参数]
*/
public function helpmap($params = [])
{
// 隐藏头尾
$this->assign('is_header', 0);
$this->assign('is_footer', 0);
// 参数
$this->assign('params', input());
return $this->fetch('../../../plugins/view/petscms/pets/helpmap');
}
}
?>

View File

@ -107,6 +107,9 @@ class Service
// 丢失时间
$v['lose_time_name'] = empty($v['lose_time']) ? '' : date('Y-m-d', $v['lose_time']);
// 丢失宠物特征
$v['lose_features'] = str_replace("\n", '<br />', $v['lose_features']);
// 二维码
$v['qrcode_url'] = MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$v['id']], true, true)))]);
@ -370,8 +373,8 @@ class Service
'lose_province' => isset($params['province']) ? intval($params['province']) : 0,
'lose_city' => isset($params['city']) ? intval($params['city']) : 0,
'lose_county' => isset($params['county']) ? intval($params['county']) : 0,
'lose_lng' => !empty($params['lng']) ? floatval($params['lng']) : 0.00,
'lose_lat' => !empty($params['lat']) ? floatval($params['lat']) : 0.00,
'lose_lng' => empty($params['lng']) ? 0.00 : floatval($params['lng']),
'lose_lat' => empty($params['lat']) ? 0.00 : floatval($params['lat']),
'lose_address' => isset($params['address']) ? $params['address'] : '',
'status' => isset($params['status']) ? intval($params['status']) : 0,
];
@ -439,5 +442,148 @@ class Service
}
return DataReturn('success', 0, $result);
}
/**
* 丢失提供信息保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-04-11
* @desc description
* @param [array] $params [输入参数]
*/
public static function HelpSave($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'pets_id',
'error_msg' => '宠物id有误',
],
[
'checked_type' => 'length',
'key_name' => 'contacts_name',
'checked_data' => '1,30',
'error_msg' => '联系人姓名格式 1~30 个字符之间',
],
[
'checked_type' => 'empty',
'key_name' => 'province',
'error_msg' => '请选择省份',
],
[
'checked_type' => 'empty',
'key_name' => 'city',
'error_msg' => '请选择城市',
],
[
'checked_type' => 'empty',
'key_name' => 'county',
'error_msg' => '请选择区/县',
],
[
'checked_type' => 'length',
'key_name' => 'address',
'checked_data' => '1,80',
'error_msg' => '详细地址格式 1~80 个字符之间',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 电话微信只至少填写一个
if(empty($params['contacts_tel']) && empty($params['contacts_weixin']))
{
return DataReturn('电话/微信只至少填写一个', -1);
}
// 宠物数据
$data = [
'user_id' => isset($params['user']['id']) ? intval($params['user']['id']) : 0,
'pets_id' => intval($params['pets_id']),
'contacts_name' => $params['contacts_name'],
'contacts_tel' => isset($params['contacts_tel']) ? $params['contacts_tel'] : '',
'contacts_weixin' => isset($params['contacts_weixin']) ? $params['contacts_weixin'] : '',
'province' => intval($params['province']),
'city' => intval($params['city']),
'county' => intval($params['county']),
'address' => $params['address'],
'lng' => empty($params['lng']) ? 0.00 : floatval($params['lng']),
'lat' => empty($params['lat']) ? 0.00 : floatval($params['lat']),
];
// 添加/编辑
if(empty($params['id']))
{
$data['add_time'] = time();
if(Db::name('PluginsPetscmsHelp')->insertGetId($data) > 0)
{
return DataReturn('添加成功', 0);
}
return DataReturn('添加失败', -100);
} else {
$data['upd_time'] = time();
if(Db::name('PluginsPetscmsHelp')->where(['id'=>intval($params['id'])])->update($data))
{
return DataReturn('编辑成功', 0);
}
return DataReturn('编辑失败', -100);
}
}
/**
* 宠物帮助数据列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function HelpList($params = [])
{
$where = empty($params['where']) ? [] : $params['where'];
$m = isset($params['m']) ? intval($params['m']) : 0;
$n = isset($params['n']) ? intval($params['n']) : 10;
$order_by = empty($params['order_by']) ? 'id desc' : $params['order_by'];
// 获取数据列表
$data = Db::name('PluginsPetscmsHelp')->where($where)->limit($m, $n)->order($order_by)->select();
if(!empty($data))
{
foreach($data as &$v)
{
// 地址
$v['province_name'] = RegionService::RegionName($v['province']);
$v['city_name'] = RegionService::RegionName($v['city']);
$v['county_name'] = RegionService::RegionName($v['county']);
// 时间
$v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']);
$v['add_time_date'] = date('Y-m-d', $v['add_time']);
$v['upd_time_time'] = empty($v['upd_time']) ? '' : date('Y-m-d H:i:s', $v['upd_time']);
$v['upd_time_date'] = empty($v['upd_time']) ? '' : date('Y-m-d', $v['upd_time']);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
* 宠物帮助数据总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
public static function HelpTotal($where = [])
{
return (int) Db::name('PluginsPetscmsHelp')->where($where)->count();
}
}
?>

View File

@ -1,5 +1,9 @@
# 宠物管理系统宠物
CREATE TABLE `s_plugins_petscms_pets` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`pest_no` char(60) NOT NULL DEFAULT '' COMMENT '宠物编号',
`status` tinyint(2) unsigned NOT NULL DEFAULT '0' COMMENT '状态0正常, 1丢失, 2去世, 3关闭',
`title` char(60) NOT NULL DEFAULT '' COMMENT '标题',
`name` char(30) NOT NULL DEFAULT '' COMMENT '名字',
`birthday` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '出生日期',
@ -13,9 +17,43 @@ CREATE TABLE `s_plugins_petscms_pets` (
`person_name` char(30) NOT NULL DEFAULT '' COMMENT '主人姓名',
`person_tel` char(30) NOT NULL DEFAULT '' COMMENT '主人电话',
`person_weixin` char(30) NOT NULL DEFAULT '' COMMENT '主人微信',
`lose_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '丢失-丢失时间',
`lose_reward_amount` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '丢失-悬赏金额',
`lose_features` char(255) NOT NULL DEFAULT '' COMMENT '丢失-宠物特征',
`lose_province` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '丢失-所在省',
`lose_city` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '丢失-所在市',
`lose_county` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '丢失-所在县/区',
`lose_address` char(80) NOT NULL DEFAULT '' COMMENT '丢失-详细地址',
`lose_lng` decimal(13,10) unsigned NOT NULL DEFAULT '0.0000000000' COMMENT '丢失-经度',
`lose_lat` decimal(13,10) unsigned NOT NULL DEFAULT '0.0000000000' COMMENT '丢失-纬度',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`upd_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `pest_no` (`pest_no`),
KEY `type` (`type`),
KEY `gender` (`gender`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='宠物管理系统宠物 - 应用';
KEY `gender` (`gender`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='宠物管理系统宠物 - 应用'
# 宠物管理系统宠物丢失帮助数据
CREATE TABLE `s_plugins_petscms_help` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
`pets_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '宠物id',
`contacts_name` char(30) NOT NULL DEFAULT '' COMMENT '联系人姓名',
`contacts_tel` char(30) NOT NULL DEFAULT '' COMMENT '联系人电话',
`contacts_weixin` char(30) NOT NULL DEFAULT '' COMMENT '联系人微信',
`province` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '所在省',
`city` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '所在市',
`county` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '所在县/区',
`address` char(80) NOT NULL DEFAULT '' COMMENT '详细地址',
`lng` decimal(13,10) unsigned NOT NULL DEFAULT '0.0000000000' COMMENT '经度',
`lat` decimal(13,10) unsigned NOT NULL DEFAULT '0.0000000000' COMMENT '纬度',
`add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`upd_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `pets_id` (`pets_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='宠物管理系统宠物丢失帮助数据 - 应用'

View File

@ -69,8 +69,68 @@
</ul>
{{if isset($data['status']) and in_array($data['status'], [0,1])}}
<div class="base-btn">
<!-- <button type="button" class="am-btn am-btn-primary am-radius am-icon-share-alt"> 分享</button> -->
{{if $data['status'] eq 1}}
<div class="base-btn" data-am-modal="{target: '#lose-provide-popup'}">
<button type="button" class="am-btn am-btn-primary am-radius am-icon-pencil"> 我要提供信息</button>
</div>
<!-- 提供信息窗口 -->
<div class="am-popup" id="lose-provide-popup">
<div class="am-popup-inner">
<div class="am-popup-hd">
<h4 class="am-popup-title">提供信息</h4>
<span data-am-modal-close class="am-close">&times;</span>
</div>
<div class="am-popup-bd">
<form class="am-form form-validation view-save" action="{{:PluginsHomeUrl('petscms', 'pets', 'helpsave')}}" method="POST" request-type="ajax-reload">
<div class="am-form-group">
<label>联系人<span class="am-form-group-label-tips-must">必填</span></label>
<input type="text" name="contacts_name" placeholder="联系人" maxlength="30" data-validation-message="联系人姓名格式 1~30 个字符之间" class="am-radius" required />
</div>
<div class="am-form-group">
<label>联系电话<span class="am-form-group-label-tips-must">电话/微信选填一个</span></label>
<input type="text" name="contacts_tel" placeholder="联系电话" maxlength="30" data-validation-message="联系人电话格式 1~30 个字符之间" class="am-radius js-choice-one" data-choice-one-to="input[name=contacts_weixin]" {{if !empty($user['mobile'])}}value="{{$user.mobile}}"{{/if}} required />
</div>
<div class="am-form-group">
<label>联系微信<span class="am-form-group-label-tips-must">电话/微信选填一个</span></label>
<input type="text" name="contacts_weixin" placeholder="联系微信" maxlength="30" data-validation-message="联系人微信格式 1~30 个字符之间" class="am-radius js-choice-one" data-choice-one-to="input[name=contacts_tel]" required />
</div>
<div class="am-form-group region-linkage" data-url="{{:MyUrl('index/region/index')}}">
<label class="block">省市区<span class="am-form-group-label-tips-must">必选</span></label>
<select name="province" data-next="city" class="am-radius chosen-select" data-placeholder="省份" data-validation-message="请选择省份" data-value="0" required />
<option value="">省份</option>
</select>
<select name="city" data-next="county" class="am-radius chosen-select" data-placeholder="城市" data-validation-message="请选择城市" data-value="0" required />
<option value="">城市</option>
</select>
<select name="county" class="am-radius chosen-select" data-placeholder="区/县" data-validation-message="请选择区/县" data-value="0" required />
<option value="">区/县</option>
</select>
</div>
<div class="am-form-group map-address">
<label>详细地址<span class="am-form-group-label-tips-must">必填</span></label>
<div class="am-input-group am-input-group-sm">
<input type="hidden" name="lng" id="form-lng" value="" />
<input type="hidden" name="lat" id="form-lat" value="" />
<input type="text" name="address" id="form-address" placeholder="详细地址" maxlength="80" data-validation-message="详细地址格式 1~80 个字符之间" class="am-radius" required />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="button" id="map-location-submit"><span class="am-icon-map-marker"></span> 定位</button>
</span>
</div>
</div>
<div id="map" data-level="17" class="am-form-group"></div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="pets_id" value="{{if !empty($data['id'])}}{{$data.id}}{{/if}}" />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">提交</button>
</div>
</form>
</div>
</div>
</div>
{{/if}}
<div class="base-share">
<div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a><a href="#" class="bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a></div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</div>
@ -81,7 +141,9 @@
{{if isset($data['status']) and $data['status'] eq 1}}
<div class="lose">
<div class="am-alert am-alert-warning" data-am-alert>
<p class="lose-title">该宠物已丢失,欢迎大家提供信息,重重有赏!</p>
{{if !empty($data['lose_features'])}}
<p class="lose-desc">{{$data.lose_features|raw}}</p>
{{/if}}
<ul class="person">
{{if !empty($data['person_name'])}}
<li>
@ -90,9 +152,9 @@
</li>
{{/if}}
{{if !empty($data['person_tel'])}}
<li>
<li class="tel">
<span>主人电话</span>
<span>{{$data.person_tel}}</span>
<a href="tel:{{$data.person_tel}}">{{$data.person_tel}}</a>
</li>
{{/if}}
{{if !empty($data['person_weixin'])}}
@ -109,9 +171,9 @@
</li>
{{/if}}
{{if !empty($data['lose_reward_amount']) and $data['lose_reward_amount'] gt 0}}
<li>
<li class="price">
<span>悬赏金额</span>
<span>{{$data.lose_reward_amount}}</span>
<strong>¥{{$data.lose_reward_amount}}</strong>
</li>
{{/if}}
{{if !empty($data['lose_address'])}}
@ -122,7 +184,9 @@
{{/if}}
</ul>
</div>
<div id="map" data-level="17" class="am-form-group"></div>
{{if !empty($data['lose_lng']) and !empty($data['lose_lat'])}}
<div id="map-view" data-level="17" class="am-form-group"></div>
{{/if}}
</div>
{{/if}}
@ -145,23 +209,59 @@
<script type="text/javascript">
$(function()
{
// 百度地图API功能
var map = new BMap.Map("map", {enableMapClick:false});
var level = $('#map').data('level') || 16;
var point = new BMap.Point({{if !empty($data['lose_lng'])}}{{$data['lose_lng']}}{{else /}}116.400244{{/if}},{{if !empty($data['lose_lat'])}}{{$data['lose_lat']}}{{else /}}39.92556{{/if}});
map.centerAndZoom(point, level);
// 丢失地址-地图展示
{{if !empty($data['lose_lng']) and !empty($data['lose_lat'])}}
var map = new BMap.Map("map-view", {enableMapClick:false});
var level = $('#map-view').data('level') || 16;
var point = new BMap.Point({{$data['lose_lng']}},{{$data['lose_lat']}});
map.centerAndZoom(point, level);
// 添加控件
var navigationControl = new BMap.NavigationControl({
// 靠左上角位置
anchor: BMAP_ANCHOR_TOP_LEFT,
// LARGE类型
type: BMAP_NAVIGATION_CONTROL_LARGE,
});
map.addControl(navigationControl);
// 添加控件
var navigationControl = new BMap.NavigationControl({
// 靠左上角位置
anchor: BMAP_ANCHOR_TOP_LEFT,
// LARGE类型
type: BMAP_NAVIGATION_CONTROL_LARGE,
});
map.addControl(navigationControl);
// 创建标注
var marker = new BMap.Marker(point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
// 创建标注
var marker = new BMap.Marker(point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
{{/if}}
// 丢失提供信息-地图
{{if isset($data['status']) and $data['status'] eq 1}}
var map = new BMap.Map("map", {enableMapClick:false});
var level = $('#map').data('level') || 16;
var point = new BMap.Point(116.400244,39.92556);
map.centerAndZoom(point, level);
// 添加控件
var navigationControl = new BMap.NavigationControl({
// 靠左上角位置
anchor: BMAP_ANCHOR_TOP_LEFT,
// LARGE类型
type: BMAP_NAVIGATION_CONTROL_LARGE,
});
map.addControl(navigationControl);
// 创建标注
var marker = new BMap.Marker(point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
marker.enableDragging(); // 可拖拽
marker.addEventListener("dragend", function(e) {
map.panTo(e.point);
$('#form-lng').val(e.point.lng);
$('#form-lat').val(e.point.lat);
});
// 设置版权控件位置
var cr = new BMap.CopyrightControl({anchor:BMAP_ANCHOR_BOTTOM_RIGHT});
map.addControl(cr); //添加版权控件
var bs = map.getBounds(); //返回地图可视区域
cr.addCopyright({id: 1, content: "<div class='map-copy'><span>拖动红色图标直接定位</span></div>", bounds:bs});
{{/if}}
});
</script>

View File

@ -0,0 +1,92 @@
{{include file="public/header" /}}
<!-- header top nav -->
{{include file="public/header_top_nav" /}}
<!-- search -->
{{include file="public/nav_search" /}}
<!-- header nav -->
{{include file="public/header_nav" /}}
<!-- goods category -->
{{include file="public/goods_category" /}}
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
{{include file="public/user_menu" /}}
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body pets-help" data-url="{{:PluginsHomeUrl('petscms', 'pets', 'helpmap')}}">
<!-- 列表 -->
<div class="data-list">
<table class="am-table">
<thead>
<tr>
<th>联系人信息</th>
<th>省市区/县</th>
<th>详细地址</th>
<th class="am-hide-sm-only">操作时间</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{if !empty($data_list)}}
{{foreach $data_list as $v}}
<tr>
<td>
姓名:{{if empty($v['contacts_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.contacts_name}}{{/if}}<br />
电话:{{if empty($v['contacts_tel'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.contacts_tel}}{{/if}}<br />
微信:{{if empty($v['contacts_weixin'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.contacts_weixin}}{{/if}}
</td>
<td>
所在省:{{if empty($v['province_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.province_name}}{{/if}}<br />
所在市:{{if empty($v['city_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.city_name}}{{/if}}<br />
所在区/县:{{if empty($v['county_name'])}}<span class="items-value-empty">未填写</span>{{else /}}{{$v.county_name}}{{/if}}<br />
</td>
<td>{{$v.address}}</td>
<td class="am-hide-sm-only">
添加:{{$v.add_time_time}}
{{if !empty($v['upd_time_time'])}}
<br />更新:{{$v.upd_time_time}}
{{/if}}
</td>
<td>
{{if !empty($v['lng']) and !empty($v['lat']) and $v['lng'] gt 0 and $v['lat'] gt 0}}
<button class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-map-marker am-btn-block map-submit" data-lng="{{$v.lng}}" data-lat="{{$v.lat}}"> 查看地图</button>
{{/if}}
</td>
</tr>
{{/foreach}}
{{/if}}
{{if empty($data_list)}}
<tr>
<td colspan="5">
<div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
</td>
</tr>
{{/if}}
</tbody>
</table>
</div>
<!-- 分页 -->
{{if !empty($data_list)}}
{{$page_html|raw}}
{{/if}}
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -0,0 +1,39 @@
{{include file="public/header" /}}
{{if !empty($params['lng']) and !empty($params['lat']) and $params['lng'] gt 0 and $params['lat'] gt 0}}
<div id="help-map" style="width: 100%; height: 100vh;"></div>
{{else /}}
<div class="table-no"><i class="am-icon-warning"></i> 参数有误</div>
{{/if}}
{{include file="public/footer" /}}
{{if !empty($params['lng']) and !empty($params['lat']) and $params['lng'] gt 0 and $params['lat'] gt 0}}
<!-- map -->
<script type="text/javascript" src="{{$Think.__MY_HTTP__}}://api.map.baidu.com/api?v=2.0&ak={{:MyC('common_baidu_map_ak')}}"></script>
<script type="text/javascript">
$(function()
{
// 丢失地址-地图展示
var map = new BMap.Map("help-map", {enableMapClick:false});
var level = $('#help-map').data('level') || 16;
var point = new BMap.Point({{$params['lng']}}, {{$params['lat']}});
map.centerAndZoom(point, level);
// 添加控件
var navigationControl = new BMap.NavigationControl({
// 靠左上角位置
anchor: BMAP_ANCHOR_TOP_LEFT,
// LARGE类型
type: BMAP_NAVIGATION_CONTROL_LARGE,
});
map.addControl(navigationControl);
// 创建标注
var marker = new BMap.Marker(point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
});
</script>
{{/if}}

View File

@ -176,6 +176,7 @@
<td>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'saveinfo',array_merge($params, ['id'=>$v['id']]))}}" class="am-btn am-btn-secondary am-btn-xs am-radius am-icon-edit am-btn-block"> 编辑</a>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'detail',array_merge($params, ['id'=>$v['id']]))}}" class="am-btn am-btn-success am-btn-xs am-radius am-icon-newspaper-o am-btn-block" target="_blank"> 详情</a>
<a href="{{:PluginsHomeUrl('petscms', 'pets', 'help',array_merge($params, ['pets_id'=>$v['id']]))}}" class="am-btn am-btn-default am-btn-xs am-radius am-icon-gg am-btn-block" target="_blank"> 帮助</a>
</td>
</tr>
{{/foreach}}

View File

@ -173,6 +173,12 @@ class AdminService
'checked_data' => 'CheckUserName',
'error_msg' => '用户名格式 5~18 个字符(可以是字母数字下划线)',
],
[
'checked_type' => 'unique',
'key_name' => 'username',
'checked_data' => 'Admin',
'error_msg' => '用户名已存在',
],
[
'checked_type' => 'fun',
'key_name' => 'login_pwd',

View File

@ -2085,26 +2085,37 @@ class GoodsService
return DataReturn('父级不能与当前相同', -10);
}
// 添加
// 添加/编辑
$msg = '操作失败';
$code = -100;
if(empty($params['id']))
{
$data['add_time'] = time();
if(Db::name('GoodsCategory')->insertGetId($data) > 0)
{
return DataReturn('添加成功', 0);
$code = 0;
$msg = '添加成功';
} else {
$msg = '添加失败';
}
return DataReturn('添加失败', -100);
} else {
$data['upd_time'] = time();
if(Db::name('GoodsCategory')->where(['id'=>intval($params['id'])])->update($data))
{
// 删除大分类缓存
cache(config('shopxo.cache_goods_category_key'), null);
return DataReturn('编辑成功', 0);
$code = 0;
$msg = '编辑成功';
} else {
$msg = '编辑失败';
}
return DataReturn('编辑失败', -100);
}
// 状态
if($code == 0)
{
// 删除大分类缓存
cache(config('shopxo.cache_goods_category_key'), null);
}
return DataReturn($msg, $code);
}
/**

File diff suppressed because one or more lines are too long

View File

@ -69,3 +69,10 @@ form.form-validation #map {
width: 100%;
height: 350px;
}
/**
* 帮助页面
*/
.pets-help #help-map {
height: 80vh;
}

View File

@ -29,7 +29,7 @@
.pets-detail {
margin-top: 10px;
}
.base-btn {
.base-btn, .base-share {
margin-top: 20px;
}
.pets-detail .am-btn-primary {
@ -74,7 +74,7 @@
background: #f8fdff;
padding: 0 10px;
overflow: hidden;
border: 1px solid #edf9ff;
border: 1px solid #ebf9ff;
}
.base ul.basic li {
padding: 10px 0;
@ -82,12 +82,12 @@
width: 50%;
}
.base ul.basic li:not(:last-child) {
border-bottom: 1px solid #edf9ff;
border-bottom: 1px solid #f0faff;
}
.base ul.basic li span:first-child {
font-weight: 500;
margin-right: 10px;
border-right: 1px solid #ebf6fc;
border-right: 1px solid #d7f1ff;
padding-right: 10px;
color: #666;
}
@ -96,13 +96,13 @@
* 丢失信息
*/
.lose .am-alert-warning {
background-color: #fff8ef;
border-color: #fff3ea;
background-color: #ffeee1;
border-color: #ffb682;
color: #888;
margin-top: 20px;
margin-bottom: 5px;
}
.lose .lose-title {
.lose .lose-desc {
font-size: 16px;
color: #f00;
}
@ -112,7 +112,7 @@
.lose ul.person li span:first-child {
font-weight: 500;
margin-right: 10px;
border-right: 1px solid #feebdd;
border-right: 1px solid #ffd5b5;
padding-right: 10px;
}
.lose ul.person {
@ -122,16 +122,39 @@
padding: 8px 0;
}
.lose ul.person li:not(:last-child) {
border-bottom: 1px solid #fff2e8;
border-bottom: 1px solid #ffe4d0;
}
.lose ul.person li:last-child {
padding-bottom: 0;
}
#map {
.lose ul.person li.tel a {
color: #70cfff;
}
#map-view {
width: 100%;
height: 350px;
}
/**
* 地图联动地址
*/
form.form-validation .map-address {
border-bottom: 0;
padding-bottom: 0;
margin-bottom: 10px;
}
form.form-validation .region-linkage .chosen-select {
display: -webkit-inline-box;
width: calc(33.3% - 3px) !important;
}
form.form-validation .region-linkage .chosen-select .chosen-single {
width: 100%;
}
form.form-validation #map {
width: 100%;
height: 300px;
}
@media only screen and (min-width: 641px) {
.pets-detail {
padding: 0 5px;
@ -170,5 +193,12 @@
.base h1 {
margin: 10px 0 5px 0;
}
.base ul.basic li span:first-child, .lose ul.person li span:first-child {
margin-right: 5px;
padding-right: 5px;
}
#map-view, form.form-validation #map {
height: 200px;
}
}

View File

@ -0,0 +1,14 @@
$(function()
{
// 帮助-地图查看
$('.pets-help .map-submit').on('click', function()
{
var lng = parseFloat($(this).data('lng'));
var lat = parseFloat($(this).data('lat'));
if(lng > 0 && lat > 0)
{
var url = UrlFieldReplace('lat', lat, UrlFieldReplace('lng', lng, $('.pets-help').data('url')));
ModalLoad(url, '地图', 'plugins-petscms-popup-modal-help');
}
});
});