From b18dadfd623cf993bc86281db0f7680dcd7e9123 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Fri, 23 Nov 2018 02:20:28 +0800 Subject: [PATCH] pay --- alipay/app.acss | 18 +++---- alipay/pages/buy/buy.acss | 4 ++ alipay/pages/buy/buy.axml | 2 +- alipay/pages/buy/buy.js | 13 ++++- alipay/pages/goods-detail/goods-detail.js | 10 ++-- .../user-order-detail/user-order-detail.acss | 3 ++ .../user-order-detail/user-order-detail.axml | 10 ++-- .../user-order-detail/user-order-detail.js | 1 + alipay/pages/user-order/user-order.acss | 27 ++++++++-- alipay/pages/user-order/user-order.axml | 37 ++++++++++---- alipay/pages/user-order/user-order.js | 49 ++++++++++++++----- alipay/pages/user-order/user-order.json | 5 +- .../Api/Controller/BuyController.class.php | 4 +- .../Api/Controller/OrderController.class.php | 4 ++ .../Application/Service/BuyService.class.php | 4 -- .../Service/OrderService.class.php | 6 +-- .../Service/ResourcesService.class.php | 14 ++++++ 17 files changed, 155 insertions(+), 56 deletions(-) diff --git a/alipay/app.acss b/alipay/app.acss index 69ca242ed..051dae4e0 100755 --- a/alipay/app.acss +++ b/alipay/app.acss @@ -78,17 +78,17 @@ textarea { /* 边框 */ -.br { border: solid 1rpx #efefef; } -.br-b { border-bottom: solid 1rpx #efefef; } -.br-t { border-top: solid 1rpx #efefef; } -.br-l { border-left: solid 1rpx #efefef; } -.br-r { border-right: solid 1rpx #efefef; } +.br { border: solid 1px #efefef; } +.br-b { border-bottom: solid 1px #efefef; } +.br-t { border-top: solid 1px #efefef; } +.br-l { border-left: solid 1px #efefef; } +.br-r { border-right: solid 1px #efefef; } /* 虚线边框 */ -.br-b-dashed { border-bottom: dashed 1rpx #efefef; } -.br-t-dashed { border-top: dashed 1rpx #efefef; } -.br-l-dashed { border-left: dashed 1rpx #efefef; } -.br-r-dashed { border-right: dashed 1rpx #efefef; } +.br-b-dashed { border-bottom: dashed 1px #efefef; } +.br-t-dashed { border-top: dashed 1px #efefef; } +.br-l-dashed { border-left: dashed 1px #efefef; } +.br-r-dashed { border-right: dashed 1px #efefef; } /* 箭头符号 */ .arrow-right { background-image: url('data:image/svg+xml;charset=utf-8,'); background-size: 15px 10px; background-repeat: no-repeat; background-position: center right; } diff --git a/alipay/pages/buy/buy.acss b/alipay/pages/buy/buy.acss index 8f6efe3e4..82f365cc3 100755 --- a/alipay/pages/buy/buy.acss +++ b/alipay/pages/buy/buy.acss @@ -101,6 +101,10 @@ vertical-align: middle; margin-right: 10rpx; } +.payment-list .selected { + border: 1px solid #d2364c; + color: #d2364c; +} /** * 扩展数据 diff --git a/alipay/pages/buy/buy.axml b/alipay/pages/buy/buy.axml index 5ddd42038..9f220d85f 100755 --- a/alipay/pages/buy/buy.axml +++ b/alipay/pages/buy/buy.axml @@ -57,7 +57,7 @@ - + {{item.name}} diff --git a/alipay/pages/buy/buy.js b/alipay/pages/buy/buy.js index 60ee8c929..bc2820063 100755 --- a/alipay/pages/buy/buy.js +++ b/alipay/pages/buy/buy.js @@ -172,7 +172,18 @@ Page({ // 支付方式选择 payment_event(e) { var payment_id = e.currentTarget.dataset.value || 0; - this.setData({ payment_id: payment_id}); + var temp_payment_list = this.data.payment_list; + for(var i in temp_payment_list) { + if(temp_payment_list[i]['id'] == payment_id) { + temp_payment_list[i]['selected'] = 'selected'; + } else { + temp_payment_list[i]['selected'] = ''; + } + } + this.setData({ + payment_id: payment_id, + payment_list: temp_payment_list + }); } }); diff --git a/alipay/pages/goods-detail/goods-detail.js b/alipay/pages/goods-detail/goods-detail.js index b948193b5..4ce2dff32 100755 --- a/alipay/pages/goods-detail/goods-detail.js +++ b/alipay/pages/goods-detail/goods-detail.js @@ -331,7 +331,7 @@ Page({ var goods_attribute_choose = this.data.goods_attribute_choose; var temp_attribute_active = this.data.temp_attribute_active; var attr_count = goods_attribute_choose.length; - var attribute_all = []; + var attribute_all = {}; if(attr_count > 0) { var attr_active_count = app.get_length(temp_attribute_active); @@ -345,7 +345,7 @@ Page({ } else { for(var i in temp_attribute_active) { - attribute_all.push(goods_attribute_choose[i]['id']+':'+goods_attribute_choose[i]['find'][temp_attribute_active[i]]['id']); + attribute_all[goods_attribute_choose[i]['id']] = goods_attribute_choose[i]['find'][temp_attribute_active[i]]['id']; } } } @@ -354,12 +354,12 @@ Page({ switch (this.data.buy_event_type) { case 'buy' : // 进入订单确认页面 - var data = [{ + var data = { "buy_type": "goods", "goods_id": this.data.goods.id, "stock": this.data.temp_buy_number, - "attr": attribute_all.join(',') - }]; + "attr": JSON.stringify(attribute_all) + }; my.navigateTo({ url: '/pages/buy/buy?data=' + JSON.stringify(data) }); diff --git a/alipay/pages/user-order-detail/user-order-detail.acss b/alipay/pages/user-order-detail/user-order-detail.acss index 9d204e7d2..8b8fb452a 100755 --- a/alipay/pages/user-order-detail/user-order-detail.acss +++ b/alipay/pages/user-order-detail/user-order-detail.acss @@ -24,6 +24,9 @@ line-height: 85rpx; } +.goods-base { + min-height: 160rpx; +} .goods .goods-item:not(:last-child) { border-bottom: 1px dashed #efefef; } diff --git a/alipay/pages/user-order-detail/user-order-detail.axml b/alipay/pages/user-order-detail/user-order-detail.axml index 3b4930944..a30bce7b8 100755 --- a/alipay/pages/user-order-detail/user-order-detail.axml +++ b/alipay/pages/user-order-detail/user-order-detail.axml @@ -21,11 +21,11 @@ {{attr.attr_type_name}}:{{attr.attr_name}} - - ¥{{item.price}} - ¥{{item.original_price}} - x{{item.buy_number}} - + + + ¥{{item.price}} + ¥{{item.original_price}} + x{{item.buy_number}} diff --git a/alipay/pages/user-order-detail/user-order-detail.js b/alipay/pages/user-order-detail/user-order-detail.js index 8f4e7b417..905e0b933 100755 --- a/alipay/pages/user-order-detail/user-order-detail.js +++ b/alipay/pages/user-order-detail/user-order-detail.js @@ -47,6 +47,7 @@ Page({ {name: "总价", value: data.total_price}, {name: "优惠", value: data.preferential_price}, {name: "支付金额", value: data.pay_price}, + {name: "支付方式", value: data.payment_name}, {name: "快递公司", value: data.express_name}, {name: "快递单号", value: data.expres_number}, {name: "用户留言", value: data.user_note}, diff --git a/alipay/pages/user-order/user-order.acss b/alipay/pages/user-order/user-order.acss index 88bbf0701..0b9465197 100755 --- a/alipay/pages/user-order/user-order.acss +++ b/alipay/pages/user-order/user-order.acss @@ -29,9 +29,6 @@ .search-btn .search-icon{ margin: 8rpx 0; } -/* - end 头部搜索框 -*/ /* 主体 @@ -39,7 +36,9 @@ .scroll-box{ height: calc(100vh - 120rpx); } - +.goods-base { + min-height: 160rpx; +} .goods-title { line-height: 36rpx; } @@ -77,4 +76,24 @@ } .item-operation button { padding: 0 35rpx; +} + +/** + * 支付方式 + */ +.payment-list { + padding: 40rpx 0; +} +.payment-list .item { + width: 50%; +} +.payment-list .item-content { + margin: 20rpx; + padding: 20rpx 10rpx; +} +.payment-list .item-content image { + width: 50rpx; + height: 50rpx !important; + vertical-align: middle; + margin-right: 10rpx; } \ No newline at end of file diff --git a/alipay/pages/user-order/user-order.axml b/alipay/pages/user-order/user-order.axml index c3b720d3b..fe671a29e 100755 --- a/alipay/pages/user-order/user-order.axml +++ b/alipay/pages/user-order/user-order.axml @@ -1,3 +1,4 @@ + @@ -6,6 +7,8 @@ + + @@ -23,11 +26,11 @@ {{attr.attr_type_name}}:{{attr.attr_name}} - - ¥{{detail.price}} - ¥{{detail.original_price}} - x{{detail.buy_number}} - + + + ¥{{detail.price}} + ¥{{detail.original_price}} + x{{detail.buy_number}} {{item.describe}} @@ -48,8 +51,22 @@ - - - - \ No newline at end of file + + + + + + + + + + + + {{item.name}} + + + + + 没有支付方式 + \ No newline at end of file diff --git a/alipay/pages/user-order/user-order.js b/alipay/pages/user-order/user-order.js index 5473ec727..1bff97e2b 100755 --- a/alipay/pages/user-order/user-order.js +++ b/alipay/pages/user-order/user-order.js @@ -9,6 +9,11 @@ Page({ params: null, input_keyword_value: '', load_status: 0, + is_show_payment_popup: false, + payment_list: [], + payment_id: 0, + temp_pay_value: 0, + temp_pay_index: 0, }, onLoad(params) { @@ -110,6 +115,7 @@ Page({ data_list_loding_status: 3, data_page: this.data.data_page + 1, load_status: 1, + payment_list: res.data.data.payment_list || [], }); // 是否还有数据 @@ -167,10 +173,25 @@ Page({ }, // 支付 - pay_event(e, order_id, index) { - var id = e.target.dataset.value; - var index = e.target.dataset.index; - this.pay_handle(id, index); + pay_event(e) { + this.setData({ + is_show_payment_popup: true, + temp_pay_value: e.target.dataset.value, + temp_pay_index: e.target.dataset.index, + }); + }, + + // 支付弹窗关闭 + payment_popup_event_close(e) { + this.setData({ is_show_payment_popup: false }); + }, + + // 支付弹窗发起支付 + popup_payment_event(e) { + var payment_id = e.target.dataset.value || 0; + this.setData({payment_id: payment_id}); + this.payment_popup_event_close(); + this.pay_handle(this.data.temp_pay_value, this.data.temp_pay_index); }, // 支付方法 @@ -182,7 +203,8 @@ Page({ url: app.get_request_url("Pay", "Order"), method: "POST", data: { - id: order_id + id: order_id, + payment_id: this.data.payment_id, }, dataType: "json", success: res => { @@ -191,18 +213,23 @@ Page({ // 线下支付成功 if (res.data.data.is_under_line == 1) { var temp_data_list = this.data.data_list; - temp_data_list[index]["status"] = 2; + temp_data_list[index]['status'] = 2; temp_data_list[index]['status_name'] = '待发货'; this.setData({ data_list: temp_data_list }); + + my.showToast({ + type: "success", + content: '支付成功' + }); } else { my.tradePay({ - orderStr: res.data.data.data, + tradeNO: res.data.data.data, success: res => { // 数据设置 - if (res.resultCode == "9000") { + if (res.resultCode == 9000) { var temp_data_list = this.data.data_list; - temp_data_list[index]["status"] = 2; - temp_data_list[index]['status_text'] = '待发货'; + temp_data_list[index]['status'] = 2; + temp_data_list[index]['status_name'] = '待发货'; this.setData({ data_list: temp_data_list }); } @@ -212,7 +239,7 @@ Page({ "/pages/paytips/paytips?code=" + res.resultCode + "&total_price=" + - temp_data_list[index]['total_price'] + this.data.data_list[index]['total_price'] }); }, fail: res => { diff --git a/alipay/pages/user-order/user-order.json b/alipay/pages/user-order/user-order.json index c96031fd7..55e2d05af 100755 --- a/alipay/pages/user-order/user-order.json +++ b/alipay/pages/user-order/user-order.json @@ -1,3 +1,6 @@ { - "pullRefresh": true + "pullRefresh": true, + "usingComponents": { + "popup": "mini-antui/es/popup/index" + } } \ No newline at end of file diff --git a/service/Application/Api/Controller/BuyController.class.php b/service/Application/Api/Controller/BuyController.class.php index 2b9eea2fe..ec6f2121e 100755 --- a/service/Application/Api/Controller/BuyController.class.php +++ b/service/Application/Api/Controller/BuyController.class.php @@ -48,7 +48,7 @@ class BuyController extends CommonController public function Index() { // 获取商品列表 - $params = $this->data_post; + $params = $_POST; $params['user'] = $this->user; $ret = BuyService::BuyTypeGoodsList($params); @@ -94,7 +94,7 @@ class BuyController extends CommonController */ public function Add() { - $params = $this->data_post; + $params = $_POST; $params['user'] = $this->user; $ret = BuyService::OrderAdd($params); $this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']); diff --git a/service/Application/Api/Controller/OrderController.class.php b/service/Application/Api/Controller/OrderController.class.php index 8fbf56a60..27749582d 100755 --- a/service/Application/Api/Controller/OrderController.class.php +++ b/service/Application/Api/Controller/OrderController.class.php @@ -65,11 +65,15 @@ class OrderController extends CommonController ); $data = OrderService::OrderList($data_params); + // 支付方式 + $payment_list = ResourcesService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1]); + // 返回数据 $result = [ 'total' => $total, 'page_total' => $page_total, 'data' => $data['data'], + 'payment_list' => $payment_list, ]; $this->ajaxReturn(L('common_operation_success'), 0, $result); } diff --git a/service/Application/Service/BuyService.class.php b/service/Application/Service/BuyService.class.php index 00598f008..b89d8a6d3 100755 --- a/service/Application/Service/BuyService.class.php +++ b/service/Application/Service/BuyService.class.php @@ -344,10 +344,6 @@ class BuyService $goods[0]['total_price'] = $params['stock']*$goods[0]['price']; // 属性 - if(!empty($params['attr'])) - { - $params['attr'] = json_decode($params['attr'], true); - } $goods[0]['attribute'] = self::GoodsAttrParsing($params); return DataReturn(L('common_operation_success'), 0, $goods); diff --git a/service/Application/Service/OrderService.class.php b/service/Application/Service/OrderService.class.php index 510ce349e..43993bee9 100755 --- a/service/Application/Service/OrderService.class.php +++ b/service/Application/Service/OrderService.class.php @@ -560,9 +560,6 @@ class OrderService $order_pay_status = L('common_order_pay_status'); foreach($data as &$v) { - // 订单基础 - $v['payment_name'] = ''; - // 状态 $v['status_name'] = $order_status_list[$v['status']]['name']; @@ -572,6 +569,9 @@ class OrderService // 快递公司 $v['express_name'] = ResourcesService::ExpressName($v['express_id']); + // 支付方式 + $v['payment_name'] = ($v['status'] <= 1) ? null : ResourcesService::OrderPaymentName($v['id']); + // 收件人地址 $v['receive_province_name'] = ResourcesService::RegionName($v['receive_province']); $v['receive_city_name'] = ResourcesService::RegionName($v['receive_city']); diff --git a/service/Application/Service/ResourcesService.class.php b/service/Application/Service/ResourcesService.class.php index 30ed5c020..6290c694f 100755 --- a/service/Application/Service/ResourcesService.class.php +++ b/service/Application/Service/ResourcesService.class.php @@ -39,6 +39,20 @@ class ResourcesService return empty($express_id) ? null : M('Express')->where(['id'=>intval($express_id)])->getField('name'); } + /** + * 获取订单支付名称 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-19 + * @desc description + * @param [int] $order_id [订单id] + */ + public static function OrderPaymentName($order_id = 0) + { + return empty($order_id) ? null : M('PayLog')->where(['order_id'=>intval($order_id)])->getField('payment_name'); + } + /** * 快递列表 * @author Devil -- GitLab