form.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. {extend name="default/base/base_seller" /}
  2. {block name="seller_main"}
  3. <div class="dssc-form-default">
  4. <form id="chain_form" enctype="multipart/form-data" method="post" >
  5. {if $Request.action=='add'}
  6. <dl>
  7. <dt><i class="required">*</i>{$Think.lang.chain_name}{$Think.lang.ds_colon}</dt>
  8. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_name}{/present}" name="chain_name" id="chain_name" class="w200 text"><span></span>
  9. <p class="hint"></p>
  10. </dd>
  11. </dl>
  12. {/if}
  13. <dl>
  14. <dt>{if $Request.action=='add'}<i class="required">*</i>{/if}{$Think.lang.chain_passwd}{$Think.lang.ds_colon}</dt>
  15. <dd><input type="password" value="" name="chain_passwd" id="chain_passwd" class="w200 text"><span></span>
  16. <p class="hint">{if $Request.action=='edit'}{$Think.lang.chain_passwd_tips}{/if}</p>
  17. </dd>
  18. </dl>
  19. <dl>
  20. <dt><i class="required">*</i>{$Think.lang.chain_addressname}{$Think.lang.ds_colon}</dt>
  21. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_addressname}{/present}" name="chain_addressname" id="chain_addressname" class="w200 text"><span></span>
  22. <p class="hint"></p></dd>
  23. </dl>
  24. <dl>
  25. <dt><i class="required">*</i>{$Think.lang.chain_truename}{$Think.lang.ds_colon}</dt>
  26. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_truename}{/present}" name="chain_truename" id="chain_truename" class="w200 text"><span></span>
  27. <p class="hint"></p></dd>
  28. </dl>
  29. <dl>
  30. <dt><i class="required">*</i>{$Think.lang.chain_mobile}{$Think.lang.ds_colon}</dt>
  31. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_mobile}{/present}" name="chain_mobile" id="chain_mobile" class="w200 text"><span></span>
  32. <p class="hint"></p></dd>
  33. </dl>
  34. <dl>
  35. <dt>{$Think.lang.chain_telephony}{$Think.lang.ds_colon}</dt>
  36. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_telephony}{/present}" name="chain_telephony" id="chain_telephony" class="w200 text"><span></span>
  37. <p class="hint"></p></dd>
  38. </dl>
  39. <dl>
  40. <dt><i class="required">*</i>{$Think.lang.chain_area_info}{$Think.lang.ds_colon}</dt>
  41. <dd>
  42. <div {if $Think.config.ds_config.mapak_type eq '2'}onclick="change_map()"{/if}>
  43. <input type="hidden" value="{$chain_array.chain_area_2|default=''}" name="chain_area_2" id="_area_2">
  44. <input type="hidden" value="{$chain_array.chain_area_3|default=''}" name="chain_area_3" id="_area">
  45. <input type="hidden" name="chain_area_info" id="region" value="{$chain_array.chain_area_info|default=''}"/>
  46. </div>
  47. <span></span>
  48. <p class="hint"></p></dd>
  49. </dl>
  50. <dl>
  51. <dt><i class="required">*</i>{$Think.lang.chain_address}{$Think.lang.ds_colon}</dt>
  52. <dd><input type="text" value="{present name='chain_array'}{$chain_array.chain_address}{/present}" name="chain_address" id="chain_address" {if $Think.config.ds_config.mapak_type eq '2'}onkeyup="local.search($(this).val());"{/if} class="w200 text">
  53. <input name="chain_longitude" id="longitude" value="{$chain_array.chain_longitude|default=''}" type="hidden" />
  54. <input name="chain_latitude" id="latitude" value="{$chain_array.chain_latitude|default=''}" type="hidden" />
  55. <div id="allmap" style="width:530px;height: 350px;margin-top: 20px"></div><span></span>
  56. <p class="hint"></p></dd>
  57. </dl>
  58. <dl>
  59. <dt><i class="required">*</i>{$Think.lang.chain_state}: </dt>
  60. <dd>
  61. <input id="chain_state1" name="chain_state" {if !isset($chain_array) || $chain_array.chain_state == '1'}checked="checked"{/if} value="1" type="radio">
  62. <label for="chain_state1" class="cb-enable {if !isset($chain_array) || $chain_array.chain_state == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>{$Think.lang.ds_yes}</span></label>
  63. <input id="chain_state0" name="chain_state" {if isset($chain_array) && $chain_array.chain_state == '0'}checked="checked"{/if} value="0" type="radio"></dt>
  64. <label for="chain_state0" class="cb-disable {if isset($chain_array) && $chain_array.chain_state == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>{$Think.lang.ds_no}</span></label>
  65. <p class="hint"></p></dd>
  66. </dl>
  67. <dl>
  68. <dt><i class="required">*</i>{$Think.lang.chain_if_pickup}: </dt>
  69. <dd>
  70. <input id="chain_if_pickup1" name="chain_if_pickup" {if !isset($chain_array) || $chain_array.chain_if_pickup == '1'}checked="checked"{/if} value="1" type="radio">
  71. <label for="chain_if_pickup1" class="cb-enable {if !isset($chain_array) || $chain_array.chain_if_pickup == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>{$Think.lang.ds_yes}</span></label>
  72. <input id="chain_if_pickup0" name="chain_if_pickup" {if isset($chain_array) && $chain_array.chain_if_pickup == '0'}checked="checked"{/if} value="0" type="radio"></dt>
  73. <label for="chain_if_pickup0" class="cb-disable {if isset($chain_array) && $chain_array.chain_if_pickup == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>{$Think.lang.ds_no}</span></label>
  74. <p class="hint"></p></dd>
  75. </dl>
  76. <dl>
  77. <dt><i class="required">*</i>{$Think.lang.chain_if_collect}: </dt>
  78. <dd>
  79. <input id="chain_if_collect1" name="chain_if_collect" {if !isset($chain_array) || $chain_array.chain_if_collect == '1'}checked="checked"{/if} value="1" type="radio">
  80. <label for="chain_if_collect1" class="cb-enable {if !isset($chain_array) || $chain_array.chain_if_collect == '1'}selected{/if}" title="{$Think.lang.ds_yes}"><span>{$Think.lang.ds_yes}</span></label>
  81. <input id="chain_if_collect0" name="chain_if_collect" {if isset($chain_array) && $chain_array.chain_if_collect == '0'}checked="checked"{/if} value="0" type="radio"></dt>
  82. <label for="chain_if_collect0" class="cb-disable {if isset($chain_array) && $chain_array.chain_if_collect == '0'}selected{/if}" title="{$Think.lang.ds_no}"><span>{$Think.lang.ds_no}</span></label>
  83. <p class="hint"></p></dd>
  84. </dl>
  85. <div class="bottom">
  86. <input type="submit" class="submit" value="{$Think.lang.ds_submit}">
  87. </div>
  88. </form>
  89. </div>
  90. <script src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js"></script>
  91. <!--{if $Think.config.ds_config.mapak_type eq '1'}-->
  92. <script type="text/javascript">
  93. window._AMapSecurityConfig = {
  94. securityJsCode:"{$Think.config.ds_config.gaode_jscode}",
  95. }
  96. </script>
  97. <script type="text/javascript" src="//webapi.amap.com/maps?v=2.0&key={$Think.config.ds_config.gaode_ak}"></script>
  98. <!--{else}-->
  99. <script type="text/javascript" src="{$Think.HTTP_TYPE}api.map.baidu.com/api?v=2.0&ak={$Think.config.ds_config.baidu_ak}"></script>
  100. <!--{/if}-->
  101. <script>
  102. var local;
  103. var map;
  104. var lst_name='';
  105. function change_map(){
  106. var name=$("#region").val();
  107. if(name!='' && lst_name!=name){
  108. lst_name=name;
  109. map.setCurrentCity(name);
  110. map.centerAndZoom(name,16);
  111. map.clearOverlays();
  112. local.search(name);
  113. }
  114. }
  115. //按钮先执行验证再提交表单
  116. $(function () {
  117. $("#region").ds_region();
  118. var lng = '{$chain_array.chain_longitude|default=""}';
  119. var lat = '{$chain_array.chain_latitude|default=""}';
  120. if ({$Think.config.ds_config.mapak_type} == '1'){
  121. var map = new AMap.Map("allmap", {
  122. resizeEnable: true,
  123. zoom:15
  124. });
  125. if(!lng && !lat){
  126. var map = new AMap.Map("allmap", {
  127. resizeEnable: true,
  128. zoom:15
  129. });
  130. //获取用户所在城市信息
  131. AMap.plugin("AMap.CitySearch", function () {
  132. var citySearch = new AMap.CitySearch();
  133. citySearch.getLocalCity(function (status, result) {
  134. if (status === "complete" && result.info === "OK") {
  135. // 查询成功,result即为当前所在城市信息
  136. AMap.plugin("AMap.Geocoder", function () {
  137. var geocoder = new AMap.Geocoder({
  138. // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode
  139. city: result.adcode,
  140. });
  141. geocoder.getLocation(result.city, function(status1, result1) {
  142. var location = result1.geocodes[0].location;
  143. var lng = location.lng;
  144. var lat = location.lat;
  145. //初始化定位
  146. var marker = new AMap.Marker({
  147. position: new AMap.LngLat(lng, lat),
  148. icon: '//api.map.baidu.com/images/marker_red_sprite.png',
  149. zoom: 15
  150. });
  151. map.add(marker);
  152. document.getElementById("longitude").value = lng;
  153. document.getElementById("latitude").value = lat;
  154. map.panTo([lng, lat]);
  155. //搜索定位
  156. AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){
  157. var auto = new AMap.AutoComplete({input:"chain_address"});
  158. var placeSearch = new AMap.PlaceSearch({
  159. map: map
  160. }); //构造地点查询类
  161. auto.on("select", select);//注册监听,当选中某条记录时会触发
  162. function select(e) {
  163. placeSearch.setCity(e.poi.adcode);
  164. placeSearch.search(e.poi.name); //关键字查询查询
  165. }
  166. });
  167. //点击定位
  168. map.on('click', function(e) {
  169. document.getElementById("longitude").value = e.lnglat.getLng();
  170. document.getElementById("latitude").value = e.lnglat.getLat();
  171. if(marker){
  172. map.remove(marker);
  173. }
  174. marker = new AMap.Marker({
  175. position: new AMap.LngLat(e.lnglat.getLng(), e.lnglat.getLat()),
  176. icon: '//api.map.baidu.com/images/marker_red_sprite.png',
  177. anchor: 'bottom-center',
  178. zoom: 15
  179. });
  180. map.add(marker);
  181. });
  182. });
  183. });
  184. }
  185. });
  186. });
  187. }else{
  188. map.panTo([lng, lat]);
  189. //初始化定位
  190. var marker = new AMap.Marker({
  191. position: new AMap.LngLat(lng, lat),
  192. icon: '//api.map.baidu.com/images/marker_red_sprite.png',
  193. zoom: 15
  194. });
  195. map.add(marker);
  196. document.getElementById("longitude").value = lng;
  197. document.getElementById("latitude").value = lat;
  198. //搜索定位
  199. AMap.plugin(['AMap.PlaceSearch','AMap.AutoComplete'], function(){
  200. var auto = new AMap.AutoComplete({input:"chain_address"});
  201. var placeSearch = new AMap.PlaceSearch({
  202. map: map
  203. }); //构造地点查询类
  204. auto.on("select", select);//注册监听,当选中某条记录时会触发
  205. function select(e) {
  206. placeSearch.setCity(e.poi.adcode);
  207. placeSearch.search(e.poi.name); //关键字查询查询
  208. }
  209. });
  210. //点击定位
  211. map.on('click', function(e) {
  212. document.getElementById("longitude").value = e.lnglat.getLng();
  213. document.getElementById("latitude").value = e.lnglat.getLat();
  214. if(marker){
  215. map.remove(marker);
  216. }
  217. marker = new AMap.Marker({
  218. position: new AMap.LngLat(e.lnglat.getLng(), e.lnglat.getLat()),
  219. icon: '//api.map.baidu.com/images/marker_red_sprite.png',
  220. anchor: 'bottom-center',
  221. zoom: 15
  222. });
  223. map.add(marker);
  224. });
  225. }
  226. }else{
  227. map = new BMap.Map("allmap");
  228. if(!lng && !lat){
  229. var geolocation = new BMap.Geolocation();
  230. geolocation.getCurrentPosition(function (r) {
  231. if (this.getStatus() == BMAP_STATUS_SUCCESS) {
  232. var lng = r.point.lng;
  233. var lat = r.point.lat;
  234. var point = new BMap.Point(lng, lat);
  235. map.centerAndZoom(point, 16);
  236. map.addControl(new BMap.NavigationControl());
  237. map.enableScrollWheelZoom();
  238. var marker = new BMap.Marker(point); // 创建标注
  239. map.addOverlay(marker); // 将标注添加到地图中
  240. marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
  241. document.getElementById("longitude").value = lng;
  242. document.getElementById("latitude").value = lat;
  243. } else {
  244. layer.msg('failed' + this.getStatus());
  245. }
  246. }, {enableHighAccuracy: true})
  247. }else{
  248. var point = new BMap.Point(lng, lat);
  249. map.centerAndZoom(point, 16);
  250. map.addControl(new BMap.NavigationControl());
  251. map.enableScrollWheelZoom();
  252. var marker = new BMap.Marker(point); // 创建标注
  253. map.addOverlay(marker); // 将标注添加到地图中
  254. marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
  255. }
  256. var options = {
  257. onSearchComplete: function(results){
  258. // 判断状态是否正确
  259. if (local.getStatus() == BMAP_STATUS_SUCCESS){
  260. if(results.getCurrentNumPois()>0){
  261. map.clearOverlays(); //清除标注 或者可以把market 放入数组
  262. var point = new BMap.Point(results.getPoi(0).point.lng , results.getPoi(0).point.lat);
  263. var marker = new BMap.Marker(point);
  264. map.centerAndZoom(point, 16);
  265. map.addOverlay(marker);
  266. marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
  267. document.getElementById("longitude").value = results.getPoi(0).point.lng;
  268. document.getElementById("latitude").value = results.getPoi(0).point.lat;
  269. }
  270. }
  271. }
  272. };
  273. local = new BMap.LocalSearch(map, options);
  274. map.addEventListener("click", function(e){
  275. // alert(e.point.lng + ", " + e.point.lat);
  276. map.clearOverlays(); //清除标注 或者可以把market 放入数组
  277. var point = new BMap.Point(e.point.lng , e.point.lat);
  278. var marker = new BMap.Marker(point);
  279. map.addOverlay(marker);
  280. marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
  281. document.getElementById("longitude").value = e.point.lng;
  282. document.getElementById("latitude").value = e.point.lat;
  283. });
  284. }
  285. $("#chain_form").validate({
  286. submitHandler: function (form) {
  287. ds_ajaxpost('chain_form', 'url', '{:url("seller_chain/index")}');
  288. },
  289. errorPlacement: function (error, element) {
  290. element.nextAll('span').first().after(error);
  291. },
  292. rules: {
  293. chain_name: {
  294. required: true,
  295. remote: {
  296. url: "{:url('seller_chain/ajax',['branch'=>'chain_name'])}",
  297. type: 'get',
  298. data: {
  299. chain_name: function () {
  300. return $('#chain_name').val();
  301. },
  302. id: '{$chain_array.chain_id|default=0}'
  303. }
  304. }
  305. },
  306. chain_mobile: {
  307. required: true,
  308. },
  309. chain_truename: {
  310. required: true,
  311. },
  312. chain_passwd: {
  313. required: {present name='chain_array'}false{else}true{/present}
  314. },
  315. },
  316. messages: {
  317. chain_name: {
  318. required: '{$Think.lang.chain_name_required}',
  319. remote: '{$Think.lang.chain_name_remote}'
  320. },
  321. chain_mobile: {
  322. required: '{$Think.lang.chain_phone_required}',
  323. },
  324. chain_truename: {
  325. required: '{$Think.lang.chain_realname_required}',
  326. },
  327. chain_passwd: {
  328. required: '{$Think.lang.chain_passwd_required}'
  329. },
  330. }
  331. });
  332. });
  333. </script>
  334. {/block}