add.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <?php $shoname_name = D('Home/Front')->get_config_by_name('shoname'); ?>
  6. <title><?php echo $shoname; ?></title>
  7. <link rel="shortcut icon" href="" />
  8. <meta name="renderer" content="webkit">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  11. <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
  12. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  13. <!--[if lt IE 9]>
  14. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  15. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  16. <![endif]-->
  17. <link href="./resource/css/bootstrap.min.css?v=201903260001" rel="stylesheet">
  18. <link href="./resource/css/common.css?v=201903260001" rel="stylesheet">
  19. <script type="text/javascript">
  20. window.sysinfo = {
  21. <?php if (!empty($_W['uniacid']) ){ ?>'uniacid': '{$_W['uniacid']}',<?php } ?>
  22. <?php if( !empty($_W['acid']) ){ ?>'acid': '{$_W['acid']}',<?php } ?>
  23. <?php if (!empty($_W['openid']) ) { ?>'openid': '{$_W['openid']}',<?php } ?>
  24. <?php if( !empty($_W['uid']) ) { ?>'uid': '{$_W['uid']}',<?php } ?>
  25. 'isfounder': <?php if (!empty($_W['isfounder']) ) { ?>1<?php }else{ ?>0<?php } ?>,
  26. 'siteroot': '{$_W['siteroot']}',
  27. 'siteurl': '{$_W['siteurl']}',
  28. 'attachurl': '{$_W['attachurl']}',
  29. 'attachurl_local': '{$_W['attachurl_local']}',
  30. 'attachurl_remote': '{$_W['attachurl_remote']}',
  31. 'module' : {'url' : '<?php if( defined('MODULE_URL') ) { ?>{MODULE_URL}<?php } ?>', 'name' : '<?php if (defined('IN_MODULE') ) { ?>{IN_MODULE}<?php } ?>'},
  32. 'cookie' : {'pre': ''},
  33. 'account' : {:json_encode($_W['account'])},
  34. };
  35. </script>
  36. <script type="text/javascript" src="./resource/js/lib/jquery-1.11.1.min.js"></script>
  37. <script type="text/javascript" src="./resource/js/lib/bootstrap.min.js"></script>
  38. <script type="text/javascript" src="./resource/js/app/util.js?v=201903260001"></script>
  39. <script type="text/javascript" src="./resource/js/app/common.min.js?v=201903260001"></script>
  40. <script type="text/javascript" src="./resource/js/require.js?v=201903260001"></script>
  41. <script type="text/javascript" src="./resource/js/lib/jquery.nice-select.js?v=201903260001"></script>
  42. <script type="text/javascript" src="/static/js/dist/area/cascade.js"></script>
  43. <script src="https://map.qq.com/api/js?v=2.exp&key=6R4BZ-WAB3W-JITRG-OE7GY-R2753-P3BZ2" type="text/javascript" charset="utf-8"></script>
  44. <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
  45. <link href="/static/css/snailfish.css" rel="stylesheet">
  46. <style>
  47. body.dragging, body.dragging * {
  48. cursor: move !important;
  49. }
  50. .dragged {
  51. position: absolute;
  52. opacity: 0.5;
  53. z-index: 2000;
  54. border: 1px solid #ccc;
  55. border-radius: 5px;
  56. background: #fff;
  57. }
  58. #sortable li {
  59. border-top: 1px solid #c5c5c5;
  60. padding-top: 20px;
  61. }
  62. #sortable li:first-child {
  63. border: 0;
  64. }
  65. #sortable li.placeholder {
  66. position: relative;
  67. }
  68. #sortable li.placeholder:before {
  69. position: absolute;
  70. }
  71. </style>
  72. </head>
  73. <body layadmin-themealias="default">
  74. <div class="layui-fluid">
  75. <div class="layui-card">
  76. <div class="layui-card-header layui-elem-quote">当前位置:<span class="line-text"><?php if( !empty($item['id'])){ ?>编辑<?php }else{ ?>新增<?php } ?>门店<?php if( !empty($item['id'])){ ?>({$item['title']})<?php } ?></span></div>
  77. <div class="layui-card-body" style="padding:15px;">
  78. <form action="" method="post" class="layui-form" lay-filter="component-layui-form-item" enctype="multipart/form-data" >
  79. <input type="hidden" name="data[id]" value="{$item['id']}"/>
  80. <div class="layui-form-item">
  81. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>门店名称</label>
  82. <div class="layui-input-block">
  83. <input type="text" id='room_name' name="data[room_name]" class="form-control" value="{$item['room_name']}" lay-verify="required">
  84. </div>
  85. </div>
  86. <?php if($supply_id == 0){ ?>
  87. <div class="layui-form-item">
  88. <label class="layui-form-label">选择供应商</label>
  89. <div class="layui-input-block">
  90. <div class="input-group " style="margin: 0;">
  91. <input type="text" disabled value="{$item['supply_id']}" class="form-control valid" name="data[supply_id]" placeholder="" id="member_id">
  92. <span class="input-group-btn">
  93. <span data-input="#member_id" id="chose_member_id" class="btn btn-default">选择供应商</span>
  94. </span>
  95. </div>
  96. <?php if( $item['supply_info']){ ?>
  97. <div class="input-group " style="margin: 0;">
  98. <div class="layadmin-text-center choose_user">
  99. <img style="" src="{:tomedia($item['supply_info']['logo'])}">
  100. <div class="layadmin-maillist-img" style="">{$item['supply_info']['shopname']}</div>
  101. <button type="button" class="layui-btn layui-btn-sm" onclick="cancle_bind(this)"><i class="layui-icon">&#xe640;</i></button>
  102. </div>
  103. </div>
  104. <?php } ?>
  105. </div>
  106. <div class="layui-input-block">
  107. <span class="layui-form-mid layui-word-aux image-block">备注:新增门店是平台使用的时候不需要选择供应商</span>
  108. </div>
  109. </div>
  110. <?php } ?>
  111. <div class="layui-form-item">
  112. <label class="layui-form-label">门店标志图片</label>
  113. <div class="layui-input-block">
  114. {:tpl_form_field_image2('data[room_logo]',$item['room_logo'])}
  115. <span class="layui-form-mid layui-word-aux image-block">门店标志图片,建议尺寸:1750*1500,数量:1张,支持gif、png、jpg、jpeg格式,大小不超过1M</span>
  116. </div>
  117. </div>
  118. <div class="layui-form-item">
  119. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>门店地址</label>
  120. <div class="layui-input-block">
  121. <select id="sel-provance" lay-ignore name="data[province_id]" onChange="selectCity();" style="width:130px;display:inline;" lay-verify="required">
  122. <option value="" selected="true">省/直辖市</option>
  123. </select>
  124. <select id="sel-city" lay-ignore name="data[city_id]" onChange="selectcounty(0)" style="width:135px;display:inline;" lay-verify="required">
  125. <option value="" selected="true">请选择</option>
  126. </select>
  127. <select id="sel-area" lay-ignore name="data[country_id]" style="width:130px;display:inline;" lay-verify="required">
  128. <option value="" selected="true">请选择</option>
  129. </select>
  130. </div>
  131. </div>
  132. <div class="layui-form-item">
  133. <label class="layui-form-label">门店精确位置</label>
  134. <div class="layui-input-block">
  135. <div class="dEdit_1">
  136. <div class="layui-inline">
  137. <div class="layui-input-inline" style="width: 200px;">
  138. <input type="text" style="width: 200px;" name="data[address]" id="address" data-val="true" data-val-required="请填写门店精确位置" class="form-control" value="{$item['address']}" data-rule-required="true" />
  139. </div>
  140. <div class="layui-input-inline" style="width: 100px;">
  141. <a class="btn btn-default" id="js_search_pos" onclick="getResult()">搜索地图</a>
  142. </div>
  143. <br />
  144. <div class="layui-form-mid layui-word-aux">地图搜索以后,请点击地图定位进行标记坐标,经纬度出来以后在进行保存,以防设置失效。</div>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="layui-form-item">
  150. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>门店经纬度</label>
  151. <div class="layui-input-block">
  152. <div class="dEdit_1">
  153. <div class="layui-inline">
  154. <div class="layui-input-inline" style="width: 100px;">
  155. <input class="form-control input-sm" data-val="true" id="lon" name="data[lon]" readonly="readonly" type="text" value="{$item['lon']}" lay-verify="required">
  156. </div>
  157. <div class="layui-input-inline" style="width: 100px;">
  158. <input class="form-control input-sm" data-val="true" id="lat" name="data[lat]" readonly="readonly" type="text" value="{$item['lat']}" lay-verify="required">
  159. </div>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. <div class="layui-form-item">
  165. <label class="layui-form-label">门店地图定位</label>
  166. <div class="layui-input-block">
  167. <div class="map-box" id="container" style="width: 603px; height: 300px; float: left;"></div>
  168. <div class="des" id="map_des" style="display: none; float: left;">请选择一个地址并点击地图中的“导入经纬度”</div>
  169. <div class="info-box" id="infoDiv" style="display: none"></div>
  170. </div>
  171. </div>
  172. <div class="layui-form-item">
  173. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>门店联系电话</label>
  174. <div class="layui-input-block">
  175. <input type="text" name="data[mobile]" class="form-control" value="{$item['mobile']}" lay-verify="required"/>
  176. </div>
  177. </div>
  178. <div class="layui-form-item">
  179. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>门店营业时间</label>
  180. <div class="layui-input-block">
  181. <div class="input-group fixsingle-input-group">
  182. <div class="layui-input-inline">
  183. <input type="text" class="layui-input" name='data[business_hours_begin]' value='<?php echo $item[business_hours_begin];?>' id="business_hour_1" placeholder="HH:mm" lay-key="5" lay-verify="required">
  184. </div>
  185. <div class="layui-input-inline" style="width: 20px;">
  186. </div>
  187. <div class="layui-input-inline">
  188. <input type="text" class="layui-input" name='data[business_hours_end]' value='<?php echo $item[business_hours_end];?>' id="business_hour_2" placeholder="HH:mm" lay-key="6" lay-verify="required">
  189. </div>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="layui-form-item">
  194. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>联系人</label>
  195. <div class="layui-input-block">
  196. <input type="text" name="data[contacts]" class="form-control" value="{$item['contacts']}" lay-verify="required"/>
  197. </div>
  198. </div>
  199. <div class="layui-form-item">
  200. <label class="layui-form-label">门店介绍</label>
  201. <div class="layui-input-block">
  202. <textarea rows="5" cols="50" class="form-control" name="data[introduction]">{$item['introduction']}</textarea>
  203. </div>
  204. </div>
  205. <div class="layui-form-item">
  206. <label class="layui-form-label"><span style="color:red;">*&nbsp;</span>排序</label>
  207. <div class="layui-input-block">
  208. <input type="text" name="data[displayorder]" class="form-control" value="{$item['displayorder']}" lay-verify="number"/>
  209. <span class='help-block'>数字越大,排名越靠前</span>
  210. </div>
  211. </div>
  212. <div class="layui-form-item">
  213. <label class="layui-form-label">状态</label>
  214. <div class="layui-input-block">
  215. <input type='radio' name='data[state]' title="启用" value=1 <?php if( $item['state']==1 || empty($item)){ ?>checked<?php } ?> />
  216. <input type='radio' name='data[state]' title="禁用" value=0 <?php if( $item['state']==0 && !empty($item) ){ ?>checked<?php } ?> />
  217. </div>
  218. </div>
  219. <div class="layui-form-item">
  220. <label class="layui-form-label"> </label>
  221. <div class="layui-input-block">
  222. <input type="submit" value="提交" lay-submit lay-filter="formDemo" class="btn btn-primary" />
  223. </div>
  224. </div>
  225. </form>
  226. </div>
  227. </div>
  228. </div>
  229. <script src="/layuiadmin/layui/layui.js"></script>
  230. <script src="/static/js/jquery-sortable.js"></script>
  231. <script>
  232. layui.config({
  233. base: '/layuiadmin/' //静态资源所在路径
  234. }).extend({
  235. index: 'lib/index' //主入口模块
  236. }).use('index');
  237. </script>
  238. <script>
  239. $(function () {
  240. initMap();//初始化门店地图
  241. cascdeInit("1","1","{$item['province_id']}","{$item['city_id']}","{$item['country_id']}","0");
  242. });
  243. var layer = layui.layer;
  244. var $;
  245. var cur_open_div;
  246. layui.use(['jquery', 'layer','form','laydate'], function(){
  247. $ = layui.$;
  248. var form = layui.form;
  249. var laydate = layui.laydate;
  250. //时间选择器
  251. laydate.render({
  252. elem: '#business_hour_1'
  253. ,type: 'time'
  254. ,format: 'HH:mm'
  255. });
  256. //时间选择器
  257. laydate.render({
  258. elem: '#business_hour_2'
  259. ,type: 'time'
  260. ,format: 'HH:mm'
  261. });
  262. form.on('radio(linktype)', function(data){
  263. if (data.value == 2) {
  264. $('#typeGroup').show();
  265. } else {
  266. $('#typeGroup').hide();
  267. }
  268. });
  269. $('#chose_link').click(function(){
  270. cur_open_div = $(this).attr('data-input');
  271. $.post("{:U('util.selecturl', array('ok' => 1))}", {}, function(shtml){
  272. layer.open({
  273. type: 1,
  274. area: '930px',
  275. content: shtml //注意,如果str是object,那么需要字符拼接。
  276. });
  277. });
  278. });
  279. $('#chose_member_id').click(function(){
  280. cur_open_div = $(this).attr('data-input');
  281. $.post("{:U('supply/zhenquery', array('ok' => 1))}", {}, function(shtml){
  282. layer.open({
  283. type: 1,
  284. area: '930px',
  285. content: shtml //注意,如果str是object,那么需要字符拼接。
  286. });
  287. });
  288. })
  289. var is_post = true;
  290. //监听提交
  291. form.on('submit(formDemo)', function(data){
  292. if(is_post){
  293. is_post = false;
  294. $.ajax({
  295. url: data.form.action,
  296. type: data.form.method,
  297. data: data.field,
  298. dataType:'json',
  299. success: function (info) {
  300. if(info.status == 0)
  301. {
  302. layer.msg(info.result.message,{icon: 1,time: 2000});
  303. }else if(info.status == 1){
  304. var go_url = location.href;
  305. if( info.result.hasOwnProperty("url") )
  306. {
  307. go_url = info.result.url;
  308. }
  309. layer.msg('操作成功',{time: 1000,
  310. end:function(){
  311. var backurl = "{:U('salesroom/index',array('ok'=>'1'))}";
  312. location.href = backurl;
  313. // location.href = info.result.url;
  314. }
  315. });
  316. }
  317. }
  318. });
  319. }
  320. return false;
  321. });
  322. })
  323. </script>
  324. <script>
  325. $(function () {
  326. var group = $("#sortable").sortable({
  327. group: 'limited_drop_targets',
  328. handle: 'i.fa-arrows-alt',
  329. onDrop: function ($item, container, _super) {
  330. console.log(group.sortable("serialize").get().join("\n"));
  331. $('#sortIpt').val(group.sortable("serialize").get().join("\n"));
  332. _super($item, container);
  333. },
  334. serialize: function (parent, children, isContainer) {
  335. return isContainer ? children.join() : $(parent).data('id');
  336. },
  337. tolerance: 6,
  338. distance: 10
  339. });
  340. });
  341. </script>
  342. <script>
  343. var map, searchService, marker, markers = [], infoWin = null;
  344. var initMap = function () {
  345. <?php if( !empty($item['lon']) ){ ?>
  346. var center = new qq.maps.LatLng({$item['lat']},{$item['lon']});
  347. <?php }else{?>
  348. var center = new qq.maps.LatLng(39.916527, 116.397128);
  349. <?php }?>
  350. map = new qq.maps.Map(document.getElementById('container'), {
  351. center: center,
  352. zoom: 13
  353. });
  354. var scaleControl = new qq.maps.ScaleControl({
  355. align: qq.maps.ALIGN.BOTTOM_LEFT,
  356. margin: qq.maps.Size(85, 15),
  357. map: map
  358. });
  359. //调用Poi检索类
  360. searchService = new qq.maps.SearchService({
  361. //检索成功的回调函数
  362. complete: function (results) {
  363. //设置回调函数参数
  364. var pois = results.detail.pois;
  365. infoWin = new qq.maps.InfoWindow({
  366. map: map
  367. });
  368. var latlngBounds = new qq.maps.LatLngBounds();
  369. for (var i = 0, l = pois.length; i < l; i++) {
  370. var poi = pois[i];
  371. //扩展边界范围,用来包含搜索到的Poi点
  372. latlngBounds.extend(poi.latLng);
  373. (function (n) {
  374. var marker = new qq.maps.Marker({
  375. map: map
  376. });
  377. marker.setPosition(pois[n].latLng);
  378. markers.push(marker);
  379. qq.maps.event.addListener(marker, 'click', function () {
  380. infoWin.open();
  381. infoWin.setContent('<div style = "width:200px;padding:10px 0;">' + pois[n].address + '<div class="map-import-btn"><input type="button" class="btn btn-xs btn-primary" value="导入经纬度" onclick="chooseShopLoc(this);" address=' + pois[n].address + ' lat =' + pois[n].latLng.getLat() + ' lng =' + pois[n].latLng.getLng() + ' /></div></div>');
  382. infoWin.setPosition(pois[n].latLng);
  383. });
  384. })(i);
  385. }
  386. //调整地图视野
  387. map.fitBounds(latlngBounds);
  388. },
  389. //若服务请求失败,则运行以下函数
  390. error: function () {
  391. alert("很抱歉,未搜索到此地址,请重新输入!");
  392. }
  393. });
  394. }
  395. function getSelectArea() {
  396. var storeArr = [];
  397. var s_province = $('#sel-provance').val();
  398. var s_city = $('#sel-city').val();
  399. var s_area = $('#sel-area').val();
  400. var s_street = $('#sel-street').val();
  401. if('请选择省份' != s_province)
  402. {
  403. storeArr.push(s_province);
  404. }
  405. if('请选择城市' != s_city)
  406. {
  407. storeArr.push(s_city);
  408. }
  409. if('请选择区域' != s_area)
  410. {
  411. storeArr.push(s_area);
  412. }
  413. if('请选择街道/镇' != s_street && '' != s_street)
  414. {
  415. storeArr.push(s_street);
  416. }
  417. $("#area-selector select").each(function (i) {
  418. if ($(this).find("option:selected").text() != '请选择') {
  419. storeArr.push($(this).find("option:selected").text());
  420. }
  421. });
  422. return storeArr;
  423. }
  424. //查询社区信息
  425. function chooseShopLoc(t) {
  426. var address = $(t).attr("address");
  427. var storeAreaArr = getSelectArea();
  428. for (var i = 3; i >= 0; i--) {
  429. if (i == 0)
  430. {
  431. address = address.replace(storeAreaArr[0] + "市", '');
  432. }
  433. address = address.replace(storeAreaArr[i], '');
  434. }
  435. var lat = $(t).attr("lat");
  436. var lng = $(t).attr("lng");
  437. this.clearMarkers();
  438. var position = new qq.maps.LatLng(lat, lng);
  439. marker = new qq.maps.Marker({
  440. map: map,
  441. position: position,
  442. draggable: true
  443. });
  444. map.panTo(position);
  445. map.zoomTo(18);
  446. $("#lon").val(lng);
  447. $("#lat").val(lat);
  448. qq.maps.event.addListener(marker, 'dragend', function () {
  449. if (marker.getPosition()) {
  450. $("#lon").val(marker.getPosition().getLng());
  451. $("#lat").val(marker.getPosition().getLat());
  452. }
  453. });
  454. if (infoWin) {
  455. infoWin.close();
  456. }
  457. $("#map_des").hide();
  458. }
  459. ////删除所有标记
  460. function clearMarkers() {
  461. if (markers) {
  462. for (i = 0; i < markers.length; i++) {
  463. markers[i].setMap(null);
  464. }
  465. markers.length = 0;
  466. }
  467. }
  468. //搜索地址,这里需要判断是否选择了省市区
  469. function getResult() {
  470. if ($("#AddressId").val() <= 0) {
  471. // $.dialog.tips("请先选择店铺地址");
  472. return;
  473. }
  474. if ($.trim($("#address").val()).length == 0) {
  475. //tip.msgbox.err('请先输入详细地址');
  476. layer.msg('请先输入详细地址',{icon: 1,time: 2000});
  477. return;
  478. }
  479. if (marker != null) marker.setMap(null);
  480. clearMarkers();
  481. if (infoWin) {
  482. infoWin.close();
  483. }
  484. var storeArr = getSelectArea();
  485. var regions = storeArr[0] + storeArr[1] + storeArr[2];
  486. var regionText = storeArr.join(',');
  487. var poiText = regions + $.trim($("#address").val());
  488. //searchService.setLocation(regionText);
  489. searchService.setLocation(storeArr[1]);
  490. searchService.search(poiText);
  491. $("#map_des").show();
  492. }
  493. require(['bootstrap'],function(){
  494. $('#myTab a').click(function (e) {
  495. e.preventDefault();
  496. $('#tab').val( $(this).attr('href'));
  497. $(this).tab('show');
  498. })
  499. });
  500. function showbacktype(type){
  501. $('.backtype').hide();
  502. $('.backtype' + type).show();
  503. }
  504. function cancle_bind(obj,id)
  505. {
  506. $('#member_id').val('');
  507. $(obj).parent().parent().remove();
  508. }
  509. </script>
  510. </body>
  511. </html>