From 664df587e39460291499afd9c3ce9a9feb19e407 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 21 Sep 2018 18:35:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/Application/Common/Lang/zh-cn.php | 8 ++ .../Controller/RegionController.class.php | 54 +++++++++++++ .../UserAddressController.class.php | 79 +++++++++++++++++++ .../Home/Lang/zh-cn/useraddress.php | 12 +++ .../Home/View/Default/Buy/Index.html | 2 +- .../Home/View/Default/Lib/RegionLinkage.html | 12 +++ .../Home/View/Default/Public/Footer.html | 4 + .../Home/View/Default/Public/Header.html | 3 + .../View/Default/UserAddress/SaveInfo.html | 38 +++++++++ .../Service/ResourcesService.class.php | 18 +++++ service/Public/Admin/Default/Css/Common.css | 2 - service/Public/Common/Css/Common.css | 8 ++ service/Public/Common/Js/Common.js | 62 ++++++++++----- .../Public/Home/Default/Css/UserAddress.css | 3 + service/Public/Home/Default/Js/Buy.js | 31 ++------ 15 files changed, 286 insertions(+), 50 deletions(-) create mode 100644 service/Application/Home/Controller/RegionController.class.php create mode 100644 service/Application/Home/Controller/UserAddressController.class.php create mode 100644 service/Application/Home/Lang/zh-cn/useraddress.php create mode 100644 service/Application/Home/View/Default/Lib/RegionLinkage.html create mode 100644 service/Application/Home/View/Default/UserAddress/SaveInfo.html create mode 100644 service/Public/Home/Default/Css/UserAddress.css diff --git a/service/Application/Common/Lang/zh-cn.php b/service/Application/Common/Lang/zh-cn.php index 3a75f9f44..75d2828e6 100755 --- a/service/Application/Common/Lang/zh-cn.php +++ b/service/Application/Common/Lang/zh-cn.php @@ -300,6 +300,14 @@ return array( 'common_favor_not_text' => '收藏', 'common_not_install_text' => '未安装', + 'common_linkage_province_text' => '省份', + 'common_linkage_city_text' => '城市', + 'common_linkage_county_text' => '区/县', + + 'common_linkage_province_format' => '请选择省份', + 'common_linkage_city_format' => '请选择城市', + 'common_linkage_county_format' => '请选择区/县', + // 性别 'common_gender_list' => array( 0 => array('id' => 0, 'name' => '保密', 'checked' => true), diff --git a/service/Application/Home/Controller/RegionController.class.php b/service/Application/Home/Controller/RegionController.class.php new file mode 100644 index 000000000..2bf70f4a5 --- /dev/null +++ b/service/Application/Home/Controller/RegionController.class.php @@ -0,0 +1,54 @@ +error(L('common_unauthorized_access')); + } + } + + /** + * 获取地区 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-21 + * @desc description + */ + public function Index() + { + $params = [ + 'where' => [ + 'pid' => intval(I('pid', 0)), + ], + ]; + $data = ResourcesService::RegionNode($params); + $this->ajaxReturn(L('common_operation_success'), 0, $data); + } +} +?> \ No newline at end of file diff --git a/service/Application/Home/Controller/UserAddressController.class.php b/service/Application/Home/Controller/UserAddressController.class.php new file mode 100644 index 000000000..7529ade9e --- /dev/null +++ b/service/Application/Home/Controller/UserAddressController.class.php @@ -0,0 +1,79 @@ +Is_Login(); + } + + /** + * [Index 首页] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2017-02-22T16:50:32+0800 + */ + public function Index() + { + $cart_list = BuyService::CartList(['user'=>$this->user]); + $this->assign('cart_list', $cart_list['data']); + + $base = [ + 'total_price' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'total_price')), + 'total_stock' => empty($cart_list['data']) ? 0 : array_sum(array_column($cart_list['data'], 'stock')), + 'ids' => empty($cart_list['data']) ? '' : implode(',', array_column($cart_list['data'], 'id')), + ]; + $this->assign('base', $base); + $this->display('Index'); + } + + /** + * [SaveInfo 地址添加/编辑页面] + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-14T21:37:02+0800 + */ + public function SaveInfo() + { + $this->assign('is_header', 0); + $this->assign('is_footer', 0); + + // 文章信息 + if(empty($_REQUEST['id'])) + { + $data = array(); + } else { + $data = M('Article')->find(I('id')); + } + $this->assign('data', $data); + + // 地区 + + $this->display('SaveInfo'); + } +} +?> \ No newline at end of file diff --git a/service/Application/Home/Lang/zh-cn/useraddress.php b/service/Application/Home/Lang/zh-cn/useraddress.php new file mode 100644 index 000000000..0051c7d06 --- /dev/null +++ b/service/Application/Home/Lang/zh-cn/useraddress.php @@ -0,0 +1,12 @@ + \ No newline at end of file diff --git a/service/Application/Home/View/Default/Buy/Index.html b/service/Application/Home/View/Default/Buy/Index.html index 5712048e8..ad9073353 100644 --- a/service/Application/Home/View/Default/Buy/Index.html +++ b/service/Application/Home/View/Default/Buy/Index.html @@ -20,7 +20,7 @@

确认收货地址

- +
    diff --git a/service/Application/Home/View/Default/Lib/RegionLinkage.html b/service/Application/Home/View/Default/Lib/RegionLinkage.html new file mode 100644 index 000000000..b0f7ab68b --- /dev/null +++ b/service/Application/Home/View/Default/Lib/RegionLinkage.html @@ -0,0 +1,12 @@ +
    + + + + +
    \ No newline at end of file diff --git a/service/Application/Home/View/Default/Public/Footer.html b/service/Application/Home/View/Default/Public/Footer.html index be97ad26d..56c3c0c64 100755 --- a/service/Application/Home/View/Default/Public/Footer.html +++ b/service/Application/Home/View/Default/Public/Footer.html @@ -16,6 +16,10 @@ + + + + diff --git a/service/Application/Home/View/Default/Public/Header.html b/service/Application/Home/View/Default/Public/Header.html index 73a025f87..f79493cca 100755 --- a/service/Application/Home/View/Default/Public/Header.html +++ b/service/Application/Home/View/Default/Public/Header.html @@ -12,6 +12,9 @@ + + + diff --git a/service/Application/Home/View/Default/UserAddress/SaveInfo.html b/service/Application/Home/View/Default/UserAddress/SaveInfo.html new file mode 100644 index 000000000..e36236821 --- /dev/null +++ b/service/Application/Home/View/Default/UserAddress/SaveInfo.html @@ -0,0 +1,38 @@ + + + +
    + +
    + + + + + +
    + + + + + + + + \ No newline at end of file diff --git a/service/Application/Service/ResourcesService.class.php b/service/Application/Service/ResourcesService.class.php index d4b5af9cd..5f356dc70 100644 --- a/service/Application/Service/ResourcesService.class.php +++ b/service/Application/Service/ResourcesService.class.php @@ -72,5 +72,23 @@ class ResourcesService } return $data; } + + /** + * 获取地区节点数据 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-21 + * @desc description + * @param [array] $params [输入参数] + */ + public static function RegionNode($params = []) + { + $field = empty($params['field']) ? 'id,name,level,letters' : $params['field']; + $where = empty($params['where']) ? [] : $params['where']; + $where['is_enable'] = 1; + + return M('Region')->where($where)->field($field)->order('id asc, sort asc')->select(); + } } ?> \ No newline at end of file diff --git a/service/Public/Admin/Default/Css/Common.css b/service/Public/Admin/Default/Css/Common.css index bdb24aa7b..d9a03534d 100755 --- a/service/Public/Admin/Default/Css/Common.css +++ b/service/Public/Admin/Default/Css/Common.css @@ -22,8 +22,6 @@ .c-p {cursor:pointer;} .c-m {cursor: move !important;} legend {padding-bottom:0.2rem !important; margin-bottom: 1rem; } -.none {display:none !important;} -.block {display:block !important;} .am-popup-bd {background:#fff;} .cr-eee {color:#eee !important;} .cr-ccc {color:#ccc !important;} diff --git a/service/Public/Common/Css/Common.css b/service/Public/Common/Css/Common.css index ac959c0fc..96a8974ae 100755 --- a/service/Public/Common/Css/Common.css +++ b/service/Public/Common/Css/Common.css @@ -1,3 +1,9 @@ +/** + * 公共 + */ +.none {display:none !important;} +.block {display:block !important;} + /* 没数据 */ .table-no {text-align:center;padding:30px 0;background:#FFF !important; color: #888; } @@ -27,6 +33,8 @@ .chosen-choices { padding: 0px 3px !important; min-height: 32px; } .chosen-container-single .chosen-single { height: 32px; line-height: 32px; } .chosen-container-multi .chosen-choices li.search-field { padding-left: 3px; } +.chosen-container-single .chosen-single { color: #444 !important; } +.chosen-container-single .chosen-default { color: #999 !important; } /** * 公共提示信息 diff --git a/service/Public/Common/Js/Common.js b/service/Public/Common/Js/Common.js index 313d32697..90411ddd0 100755 --- a/service/Public/Common/Js/Common.js +++ b/service/Public/Common/Js/Common.js @@ -1071,21 +1071,14 @@ $(function() }); }); - // 地区联动 - $('.region-linkage select').on('change', function() + function RegionNodeData(value, name, next_name) { - var temp_name = $(this).attr('name'); - var find_all = (temp_name == 'province') ? ["city", "county"] : ((temp_name == 'city') ? ["county"] : 'no'); - - var name = (temp_name == 'province') ? 'city' : ((temp_name == 'city') ? 'county' : 'no'); - var v = $(this).val(); - var $this_next_obj = $('.region-linkage select[name='+name+']'); - if(name !== 'no') + if(value != null) { $.ajax({ - url:$(this).parent().data('url'), + url:$('.region-linkage').data('url'), type:'POST', - data:{"pid": v}, + data:{"pid": value}, dataType:'json', success:function(result) { @@ -1099,26 +1092,53 @@ $(function() } /* 下一级数据添加 */ - $this_next_obj.append(html); + $('.region-linkage select[name='+next_name+']').append(html).trigger('chosen:updated'); } else { Prompt(result.msg); } } }); + } - /* 子级元素数据清空 */ - if(find_all != 'no') + /* 子级元素数据清空 */ + var child = null; + switch(name) + { + case 'province' : + child = ['city', 'county']; + break; + + case 'city' : + child = ['county']; + break; + } + if(child != null) + { + for(var i in child) { - for(var i in find_all) - { - var $temp_obj = $('.region-linkage select[name='+find_all[i]+']'); - var temp_find = $temp_obj.find('option').first().text(); - var temp_html = ''; - $temp_obj.html(temp_html); - } + var $temp_obj = $('.region-linkage select[name='+child[i]+']'); + var temp_find = $temp_obj.find('option').first().text(); + var temp_html = ''; + $temp_obj.html(temp_html).trigger('chosen:updated'); } } + } + + // 地区联动 + $('.region-linkage select').on('change', function() + { + var name = $(this).attr('name') || null; + var next_name = (name == 'province') ? 'city' : ((name == 'city') ? 'county' : null); + var value = $(this).val() || null; + if(next_name != null) + { + RegionNodeData(value, name, next_name); + } }); + if($('.region-linkage select').length > 0) + { + RegionNodeData(0, 'province', 'province'); + } // 根据字符串地址获取坐标位置 $('#map-location-submit').on('click', function() diff --git a/service/Public/Home/Default/Css/UserAddress.css b/service/Public/Home/Default/Css/UserAddress.css new file mode 100644 index 000000000..d7e90e9a8 --- /dev/null +++ b/service/Public/Home/Default/Css/UserAddress.css @@ -0,0 +1,3 @@ +.my-content { padding: 15px 10px; } +.region-linkage .chosen-select { display: -webkit-inline-box; width: calc(33.3% - 3px) !important; } +.region-linkage .chosen-select .chosen-single { width: 100%; } \ No newline at end of file diff --git a/service/Public/Home/Default/Js/Buy.js b/service/Public/Home/Default/Js/Buy.js index 7716d409c..70b50c97d 100644 --- a/service/Public/Home/Default/Js/Buy.js +++ b/service/Public/Home/Default/Js/Buy.js @@ -15,33 +15,12 @@ $(function() { -// 弹出地址选择 - - - var $ww = $(window).width(); - - $('.address-submit').click(function() { -// 禁止遮罩层下面的内容滚动 - $(document.body).css("overflow","hidden"); - - $(this).addClass("selected"); - $(this).parent().addClass("selected"); - - - $('.theme-popover-mask').show(); - $('.theme-popover-mask').height($(window).height()); - $('.theme-popover').slideDown(200); - - }) - - $('.theme-poptit .close,.btn-op .close').click(function() { - - $(document.body).css("overflow","visible"); - $('.address-submit').removeClass("selected"); - $('.item-props-can').removeClass("selected"); - $('.theme-popover-mask').hide(); - $('.theme-popover').slideUp(200); + // 弹出地址选择 + $('.address-submit').on('click', function() + { + ModalLoad($(this).data('url'), '地址管理', 'popup-modal-address', 'common-address-modal'); }); + }); \ No newline at end of file