From 85dab636bdebe712646aba47fc317bfa2cfffc7b Mon Sep 17 00:00:00 2001 From: devil_gong Date: Fri, 22 Mar 2019 11:37:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E8=B4=B9=E8=AE=BE=E7=BD=AE=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E5=A2=9E=E6=94=AF=E4=BB=98=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=85=8D=E8=BF=90=E8=B4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/view/default/buy/index.html | 4 +- application/plugins/freightfee/Admin.php | 54 ++++++++++++------- application/plugins/freightfee/Hook.php | 52 ++++++++++++------ .../plugins/view/freightfee/admin/index.html | 11 ++++ .../view/freightfee/admin/saveinfo.html | 12 ++++- public/static/index/default/css/buy.css | 23 +++++--- public/static/index/default/js/buy.js | 31 ++--------- 7 files changed, 115 insertions(+), 72 deletions(-) diff --git a/application/index/view/default/buy/index.html b/application/index/view/default/buy/index.html index f5d8f2048..e083e30db 100755 --- a/application/index/view/default/buy/index.html +++ b/application/index/view/default/buy/index.html @@ -70,12 +70,12 @@ -
+

选择支付

{{if !empty($payment_list)}}
    {{foreach $payment_list as $payment}} -
  • +
  • {{if !empty($payment.logo)}} {{/if}} diff --git a/application/plugins/freightfee/Admin.php b/application/plugins/freightfee/Admin.php index f86af745f..312216619 100644 --- a/application/plugins/freightfee/Admin.php +++ b/application/plugins/freightfee/Admin.php @@ -14,6 +14,7 @@ use think\Db; use think\Controller; use app\service\PluginsService; use app\service\RegionService; +use app\service\PaymentService; /** * 运费设置 - 管理 @@ -37,16 +38,7 @@ class Admin extends Controller $ret = PluginsService::PluginsData('freightfee'); if($ret['code'] == 0) { - // 数据处理 - if(!empty($ret['data']['data'])) - { - foreach($ret['data']['data'] as &$v) - { - $v['region_names'] = empty($v['region_show']) ? '' : implode('、', Db::name('Region')->where('id', 'in', explode('-', $v['region_show']))->column('name')); - } - } - - $this->assign('data', $ret['data']); + $this->assign('data', $this->DataHandle($ret['data'])); return $this->fetch('../../../plugins/view/freightfee/admin/index'); } else { return $ret['msg']; @@ -83,24 +75,48 @@ class Admin extends Controller }, $region); } - // 数据处理 - if(!empty($ret['data']['data'])) - { - foreach($ret['data']['data'] as &$v) - { - $v['region_names'] = empty($v['region_show']) ? '' : implode('、', Db::name('Region')->where('id', 'in', explode('-', $v['region_show']))->column('name')); - } - } + // 支付方式 + $this->assign('payment_list', PaymentService::PaymentList(['is_enable'=>1, 'is_open_user'=>1])); $this->assign('region_list', $region); $this->assign('is_whether_list', $is_whether_list); - $this->assign('data', $ret['data']); + $this->assign('data', $this->DataHandle($ret['data'])); return $this->fetch('../../../plugins/view/freightfee/admin/saveinfo'); } else { return $ret['msg']; } } + /** + * 数据处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-22 + * @desc description + * @param [array] $data [应用数据] + */ + private function DataHandle($data) + { + if(!empty($data['data'])) + { + if(empty($data['payment'])) + { + $data['payment'] = []; + $data['payment_names'] = ''; + } else { + $data['payment'] = explode(',', $data['payment']); + $data['payment_names'] = implode('、', array_map(function($v){return mb_substr($v, strrpos($v, '-')+1, null, 'utf-8');}, $data['payment'])); + } + + foreach($data['data'] as &$v) + { + $v['region_names'] = empty($v['region_show']) ? '' : implode('、', Db::name('Region')->where('id', 'in', explode('-', $v['region_show']))->column('name')); + } + } + return $data; + } + /** * 数据保存 * @author Devil diff --git a/application/plugins/freightfee/Hook.php b/application/plugins/freightfee/Hook.php index 4c0b3cb76..7ec097b72 100644 --- a/application/plugins/freightfee/Hook.php +++ b/application/plugins/freightfee/Hook.php @@ -61,8 +61,29 @@ class Hook $ret = PluginsService::PluginsData('freightfee'); if($ret['code'] == 0) { + // 默认运费 + $price = 0; + + // 支付方式免运费 + $is_payment = true; + if(!empty($ret['data']['payment']) && !empty($params['params']['payment_id'])) + { + $payment = array_map(function($v){return explode('-', $v);}, explode(',', $ret['data']['payment'])); + if(!empty($payment) && is_array($payment)) + { + foreach($payment as $v) + { + if(isset($v[0]) && $v[0] == $params['params']['payment_id']) + { + $is_payment = false; + break; + } + } + } + } + // 是否设置运费数据 - if(!empty($ret['data']['data'][0])) + if($is_payment === true && !empty($ret['data']['data'][0])) { // 规则 $rules = $this->RulesHandle($ret['data']['data'], $params['data']['base']['address']); @@ -70,7 +91,6 @@ class Hook // 计费方式 if(!empty($rules)) { - $price = 0; switch($ret['data']['valuation']) { // 按件 @@ -83,22 +103,22 @@ class Hook $price = $this->QuantityCalculate($rules, $params['data']); break; } - - // 扩展展示数据 - $show_name = empty($ret['data']['show_name']) ? '运费' : $ret['data']['show_name']; - $params['data']['extension_data'][] = [ - 'name' => $show_name, - 'price' => $price, - 'type' => 0, - 'tips' => '+¥'.$price.'元', - ]; - - // 金额 - $params['data']['base']['increase_price'] += $price; - $params['data']['base']['actual_price'] += $price; } - return DataReturn('处理成功', 0); } + + // 扩展展示数据 + $show_name = empty($ret['data']['show_name']) ? '运费' : $ret['data']['show_name']; + $params['data']['extension_data'][] = [ + 'name' => $show_name, + 'price' => $price, + 'type' => 0, + 'tips' => '+¥'.$price.'元', + ]; + + // 金额 + $params['data']['base']['increase_price'] += $price; + $params['data']['base']['actual_price'] += $price; + return DataReturn('无需处理', 0); } else { return $ret['msg']; diff --git a/application/plugins/view/freightfee/admin/index.html b/application/plugins/view/freightfee/admin/index.html index 1097200c3..236036c53 100644 --- a/application/plugins/view/freightfee/admin/index.html +++ b/application/plugins/view/freightfee/admin/index.html @@ -20,6 +20,17 @@
+
+ +
+ {{if empty($data['payment_names'])}} + 未设置 + {{else /}} + {{$data.payment_names}} + {{/if}} +
+
+
diff --git a/application/plugins/view/freightfee/admin/saveinfo.html b/application/plugins/view/freightfee/admin/saveinfo.html index 877240907..f7d5f8835 100644 --- a/application/plugins/view/freightfee/admin/saveinfo.html +++ b/application/plugins/view/freightfee/admin/saveinfo.html @@ -10,11 +10,20 @@ 返回 -
+
+
+ + +
+
@@ -27,6 +36,7 @@
+ {{if empty($data['data'])}} diff --git a/public/static/index/default/css/buy.css b/public/static/index/default/css/buy.css index 9ba6f3b79..82af5eae6 100755 --- a/public/static/index/default/css/buy.css +++ b/public/static/index/default/css/buy.css @@ -13,8 +13,8 @@ ul.address-list li .user-base {font-size: 14px; font-weight: 700; margin-bottom: .address-default { display:block !important;} /* 物流/支付 */ -.business-item ul li { border:1px solid transparent ;overflow: hidden; float: left; cursor: pointer; padding: 5px; border: 1px solid #eee; margin: 0 10px 10px 0; } -ul.logistics-list li.selected, ul.payment-list li.selected {border-color:#d2364c ;position:relative ;} +.business-item ul li { border:1px solid transparent ;overflow: hidden; float: left; cursor: pointer; padding: 5px; border: 1px solid #e5e5e5; margin: 0 10px 10px 0; } +ul.logistics-list li.selected, ul.payment-list li.selected {border-color:#d2364c ;position:relative;box-shadow: 0px 0 0px 1px #d2364c;} ul.logistics-list li.selected i.icon-active, ul.payment-list li.selected i.icon-active { position: absolute; width: 10px; @@ -28,6 +28,14 @@ ul.logistics-list li.selected i.icon-active, ul.payment-list li.selected i.icon- .business-item ul { padding: 10px 3px 5px 5px;} ul.logistics-list li img, ul.payment-list li img { width: 36px; height: 36px; } +.business-item ul li, ul.address-list li { + -webkit-transition: border-color .2s ease-in; + -moz-transition: border-color .2s ease-in; + -ms-transition: border-color .2s ease-in; + -o-transition: border-color .2s ease-in; + transition: border-color .2s ease-in; +} + /*运费、留言、扩展数据*/ .buy-message {padding:0px 5px} .td.td-oplist .pay-logis,.td.td-bonus select{position:absolute;top:6px;right:0;} @@ -75,9 +83,10 @@ ul.address-list, .business-item ul { overflow: hidden; } .link-list{ margin:10px; } .link-list h3 {padding-bottom:5px;} - /*物流*/ + /*业务*/ .business-item ul li {width:calc(25% - 8px); } .business-item ul li:nth-child(4n) { margin-right: 0; } + .business-item ul li:hover, ul.address-list li:hover { border:1px solid #d2364c; box-shadow: 0px 0 0px 1px #d2364c; } /*留言*/ .buy-message{border:1px solid #eee; overflow: hidden;padding: 10px; margin: 0 5px;} @@ -100,9 +109,9 @@ ul.address-list, .business-item ul { overflow: hidden; } .order-nav .buy-footer-address .buy-line-title {color: #404040;font-weight: 700;} .link-list{margin:0px auto;} /*地址管理*/ - .address ul{margin-top:10px ;} - ul.address-list li{display:block; width: calc(33% - 5px);height: 130px;float: left;background-image: url(../images/peraddbg.png); background-repeat: no-repeat; background-size: 100% 100%; margin:0 10px 10px 0 ;padding:10px;} - ul.address-list li.address-default{background-image: url(../images/peraddressbg.png);} + .address ul{margin-top: 10px; padding: 1px;} + ul.address-list li{display:block; width: calc(33% - 5px);height: 130px;float: left;margin:0 10px 10px 0 ;padding:10px;border: 1px solid #e5e5e5;} + ul.address-list li.address-default{background-image: url(../images/peraddressbg.png);background-repeat: no-repeat; background-size: 100% 100%;border: 0;box-shadow: none;} ul.address-list li:nth-child(3n) { margin-right: 0; } .address-left{ width:100%;position: relative;} .th .td-inner{padding-left:0 ;} @@ -122,7 +131,7 @@ ul.address-list, .business-item ul { overflow: hidden; } .business-item ul li { width: calc(20% - 8px); } .business-item ul li:nth-child(5n) { margin-right: 0; } .business-item ul li:nth-child(4n) { margin-right: 10px; } - .business-item ul { padding: 10px 0 0 0; } + .business-item ul { padding: 10px 1px 0 1px; } .link-list h3 { padding: 0 0 5px 0; } .buy-message { margin: 0; } .buy-point-discharge { padding: 10px 0px; } diff --git a/public/static/index/default/js/buy.js b/public/static/index/default/js/buy.js index 0cf91b27f..220c4328f 100755 --- a/public/static/index/default/js/buy.js +++ b/public/static/index/default/js/buy.js @@ -2,7 +2,6 @@ if(store.enabled) { // 选择缓存key var store_use_new_address_status_key = 'store-buy-use-new-address-status-count'; - var store_payment_key = 'store-buy-payment-selected-index'; } $(function() @@ -21,13 +20,6 @@ $(function() window.location.href = UrlFieldReplace('address_id', $('ul.address-list li:first').data('value')); } } - - // 支付方式 - var store_payment_value = store.get(store_payment_key); - if(store_payment_value !== undefined) - { - $('ul.payment-list li').eq(store_payment_value).addClass('selected'); - } } // 地址选择 @@ -63,26 +55,11 @@ $(function() // 混合列表选择 $('.business-item ul li').on('click', function() { - var type = $(this).parents('.business-item').data('type') || null; - var temp_store_key = null; - switch(type) + var field = $(this).parents('.business-item').data('field') || null; + var value = $(this).data('value') || null; + if(field != null && value != null) { - case 'payment' : - temp_store_key = store_payment_key; - break; - } - if ($(this).hasClass('selected')) { - $(this).removeClass('selected'); - if(temp_store_key != null) - { - store.remove(temp_store_key); - } - } else { - $(this).addClass('selected').siblings('li').removeClass('selected'); - if(temp_store_key != null) - { - store.set(temp_store_key, $(this).index()); - } + window.location.href = UrlFieldReplace(field, value); } });