Authored by 郭成尧

Merge branch 'feature/cart' of git.yoho.cn:fe/yohobuywap-node into feature/cart

@@ -269,6 +269,14 @@ const payZero = (req, res, next) => { @@ -269,6 +269,14 @@ const payZero = (req, res, next) => {
269 title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停' 269 title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
270 }; 270 };
271 271
  272 + let responseFailure = {
  273 + pageHeader: headerModel.setNav({
  274 + navTitle: '支付中心',
  275 + navBtn: false
  276 + }),
  277 + title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
  278 + };
  279 +
272 let param = { 280 let param = {
273 uid: req.user.uid, 281 uid: req.user.uid,
274 udid: req.sessionID || require('md5')(req.ip) || 'yoho', 282 udid: req.sessionID || require('md5')(req.ip) || 'yoho',
@@ -284,8 +292,13 @@ const payZero = (req, res, next) => { @@ -284,8 +292,13 @@ const payZero = (req, res, next) => {
284 } 292 }
285 293
286 payModel.getPayAli(param).then(result => { 294 payModel.getPayAli(param).then(result => {
  295 +
287 if (result.match === true) { 296 if (result.match === true) {
288 - res.render('pay/pay-ali', Object.assign(responseData, result)); 297 + if (result.isCancel && result.isCancel === true) {
  298 + return res.render('pay/pay-failure', responseFailure);
  299 + } else {
  300 + res.render('pay/pay-ali', Object.assign(responseData, result));
  301 + }
289 } else { 302 } else {
290 res.redirect('/'); 303 res.redirect('/');
291 } 304 }
@@ -439,12 +439,17 @@ const getPayAli = (param) => { @@ -439,12 +439,17 @@ const getPayAli = (param) => {
439 439
440 if (result && result[2] && result[2].data && result[2].data.payment_amount) { 440 if (result && result[2] && result[2].data && result[2].data.payment_amount) {
441 resu.packageTitle = _.get(result[2], 'data.package_title', ''); 441 resu.packageTitle = _.get(result[2], 'data.package_title', '');
  442 +
  443 + resu.payment = result[2].data.payment_amount;
  444 +
442 if (param.isPay && param.isPay === true) { 445 if (param.isPay && param.isPay === true) {
443 - resu.payment = '0.00';  
444 - resu.payWay = false; 446 + if (result[2].data.payment_status && result[2].data.payment_status === 'Y') {
  447 + resu.payWay = false;
  448 + } else {
  449 + resu.isCancel = true;
  450 + }
445 } else { 451 } else {
446 resu.payWay = true; 452 resu.payWay = true;
447 - resu.payment = result[2].data.payment_amount;  
448 } 453 }
449 454
450 } else { 455 } else {
@@ -24,7 +24,7 @@ var richTip = require('../plugin/rich-tip'); @@ -24,7 +24,7 @@ var richTip = require('../plugin/rich-tip');
24 var $loadingToast = $('.loading-toast'); 24 var $loadingToast = $('.loading-toast');
25 25
26 /* TODO 影响加载此段 JS */ 26 /* TODO 影响加载此段 JS */
27 -var theOrderCode = document.getElementById('ordercode').value; 27 +var theOrderCode = document.getElementById('ordercode') ? document.getElementById('ordercode').value : '';
28 28
29 var wxPayEl = document.getElementById('weixin'), 29 var wxPayEl = document.getElementById('weixin'),
30 wxHammer = wxPayEl && new Hammer(wxPayEl); 30 wxHammer = wxPayEl && new Hammer(wxPayEl);