Authored by 郝肖肖

weixin openid

... ... @@ -11,6 +11,7 @@ var loading = require('../plugin/loading'),
// 点击微信显示加载
var $loadingToast = $(".loading-toast");
var theOrderCode = document.getElementById('ordercode').value;
var openId = document.getElementById('openId').value;
var wxPayEl = document.getElementById('weixin'),
wxHammer = wxPayEl && new Hammer(wxPayEl);
... ... @@ -54,15 +55,7 @@ function jsApiCall(orderCode, jsApiParameters) {
'getBrandWCPayRequest',
jsApiParameters,
function (res) {
//发送支付确认
$.ajax({
type: 'GET',
url: '/shopping/pay/wechatPayConfirm?order_code=' + orderCode,
dataType: 'json',
success: function (res) {
window.location.href = '/home/orders/detail?order_code=' + orderCode;
}
});
window.location.href = '/home/orders/detail?order_code=' + orderCode + '&openId=' + openId;
}
);
}
... ... @@ -82,7 +75,11 @@ function callpay(orderCode) {
} else {
$.ajax({
type: 'GET',
url: '/shopping/pay/wechatwapapi?order_code=' + orderCode,
url: '/shopping/pay/wechatwapapi',
data: {
'order_code': orderCode,
'openId': openId,
},
dataType: 'json',
success: function (res) {
if (res.code === 200) {
... ...
... ... @@ -2,12 +2,13 @@
<div class="pay-page yoho-page">
{{#if orderCode}}
<input id='ordercode' type="hidden" value="{{orderCode}}">
<input id='openId' type="hidden" value="{{openId}}">
{{/if}}
<div class="payapp-list">
{{# payAppInfo}}
{{#if payLink}}
<a href="{{payLink}}">
{{/if}}
{{#if payLink}}
<a href="{{payLink}}">
{{/if}}
<div class="box" id="{{appId}}">
<div class="icon">
{{#if appIcon}}
... ... @@ -26,9 +27,9 @@
</div>
<div class="iconfont">&#xe604</div>
</div>
{{#if payLink}}
</a>
{{/if}}
{{#if payLink}}
</a>
{{/if}}
{{/ payAppInfo}}
</div>
<div class="loading-toast hide"></div>
... ...
... ... @@ -979,7 +979,7 @@ class HomeController extends AbstractAction
if (!empty($orderDetail['isPay'])) {
$this->go(Helpers::url('/home/orderdetail', array('order_code' => $orderCode)));
}
$openId = '';
$hasWxShare = strpos($this->server('HTTP_USER_AGENT', ''), 'MicroMessenger') !== false;
if ($hasWxShare) {
$openId = $this->getSession('weixinOpenId' . $orderCode);
... ... @@ -1013,6 +1013,7 @@ class HomeController extends AbstractAction
),
),
'hasWxShare' => $hasWxShare,
'openId' => $openId,
'orderCode' => $orderCode,
'orderTotal' => isset($orderDetail['goodsAmount']) ? $orderDetail['goodsAmount'] : 0,
'orderTotalFormat' => isset($orderDetail['goodsAmount']) ? sprintf("%d", $orderDetail['goodsAmount']) : 0,
... ... @@ -1111,6 +1112,11 @@ class HomeController extends AbstractAction
$this->setTitle('订单详情');
$this->setNavHeader('订单详情', true, false);
$openId = $this->get('openId', '');
if (!empty($openId)) {
//微信支付成功,发送支付确认接口
OrderData::payConfirm($orderCode, 22, $this->_uid);
}
$this->_view->display('order-detail', array(
'orderDetailPage' => true,
... ...
... ... @@ -122,8 +122,14 @@ class PayController extends AbstractAction
$totalFee = strval($orderDetail['data']['payment_amount'] * 100);
$openId = $this->getSession('weixinOpenId' . $orderCode);
if (empty($openId)) {
$openId = $this->get('openId');
UdpLog::info('【wechat支付】通过get 获取openId: ', array('orderCode' => $orderCode, 'uid' => $uid, 'openId' => $openId);
}
if (empty($openId)) {
UdpLog::info('【wechat支付】获取wechat标识为空', 'orderCode:'.$orderCode.'uid:'.$uid.'返回openId:'.$openId);
UdpLog::info('【wechat支付】获取wechat标识为空', array('orderCode' => $orderCode, 'uid' => $uid, 'openId' => $openId);
break;
}
... ...