Authored by 陈峰

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

... ... @@ -186,7 +186,7 @@ exports.selectAddress = (req, res, next) => {
/**
* 发票信息
*/
exports.invoiceInfo = (req, res, next) => {
exports.invoiceInfo = (req, res) => {
let uid = req.user.uid;
let cookieData = req.cookies['order-info'];
let orderInfo = JSON.parse(cookieData);
... ... @@ -205,6 +205,6 @@ exports.invoiceInfo = (req, res, next) => {
pageHeader: headerData,
module: 'cart',
page: 'select-invoice'
})).catch(next);
}));
})();
};
... ...
/**
/*
* 支付
* @author: jing.li<jing.li@yoho.cn>
* @date: 2016/10/25
* @Author: Targaryen
* @Date: 2017-01-04 15:17:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-01-10 16:43:54
*/
'use strict';
const mRoot = '../models';
const payModel = require(`${mRoot}/pay`);
const payTool = payModel.payTool;
const headerModel = require('../../../doraemon/models/header'); // 头部model
const co = require('bluebird').coroutine;
const helpers = global.yoho.helpers;
const Payment = require('../helpers/payment');
const WxPay = require('../helpers/pay/wechat');
const common = require('../helpers/pay/common');
/**
* 支付中心
... ... @@ -19,10 +24,12 @@ const Payment = require('../helpers/payment');
* @param res
* @param next
*/
const payCenter = (req, res, next) => {
const payCenter = (req, res) => {
let orderCode = req.query.order_code;
let uid = req.user.uid;
let sessionKey = req.session.TOKEN;
let userAgent = req.get('User-Agent');
let hasWxShare = Boolean(userAgent.match(/MicroMessenger/i) && userAgent.match(/MicroMessenger/i).length > 0);
if (!orderCode || !uid) {
res.redirect('/');
... ... @@ -32,47 +39,75 @@ const payCenter = (req, res, next) => {
sessionKey = sessionKey.substr(0, sessionKey.length - 8);
}
let headerData = headerModel.setNav({
navTitle: '支付中心'
});
co(function* () {
let orderDetail = yield payModel.payCenter({
orderCode: orderCode,
uid: uid
});
let responseData = {
pageHeader: headerData,
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停'
};
if (hasWxShare) {
let openId = req.cookies['weixinOpenId' + orderCode];
payModel.payCenter({
orderCode: orderCode,
uid: uid,
sessionKey: sessionKey
}).then(result => {
res.render('pay/pay-center', Object.assign(responseData, result, {
isOldUser: Boolean(req.cookies._isOldUser && req.cookies._isOldUser === '4'),
}));
}).catch(next);
if (!openId) {
let getOpenidResult = yield WxPay.getOpenid(req.query.code, req.originalUrl);
if (getOpenidResult.openid) {
openId = getOpenidResult.openid;
}
if (getOpenidResult.redirectUrl) {
return res.redirect(getOpenidResult.redirectUrl);
}
if (openId) {
res.cookie('weixinOpenId' + orderCode, openId, {
domain: 'yohobuy.com',
expires: new Date(Date.now() + 24 * 60 * 60 * 1000)
});
}
}
}
let responseData = {
pageHeader: headerModel.setNav({
navTitle: '支付中心'
}),
module: 'cart',
page: 'pay',
title: '支付中心 | Yoho!Buy有货 | 潮流购物逛不停',
payAppInfo: payTool.payAppInfo(orderCode),
orderCode: orderCode,
hasWxShare: hasWxShare,
orderTotal: orderDetail.payment_amount || 0,
orderTotalFormat: parseInt(orderDetail.payment_amount, 10),
orderCount: payTool.calBuyNumCount(orderDetail.order_goods),
uid: uid,
isOldUser: Boolean(req.cookies._isOldUser && req.cookies._isOldUser === '4')
};
res.render('pay/pay-center', responseData);
})();
};
/**
* 支付宝跳转页
* 统一支付入口
* @param req
* @param res
*/
const goAlipay = (req, res, next) => {
const pay = (req, res, next) => {
let orderCode = req.query.order_code;
let user = req.user;
let uid = req.user.uid;
let sessionKey = req.session.TOKEN;
let payment = req.query.payment;
let paymentCode = common.getPaymentCode(payment);
let openId = req.cookies['weixinOpenId' + orderCode];
if (!orderCode || !uid || !sessionKey) {
res.redirect('/');
return res.redirect('/');
}
co(function*() {
co(function* () {
let orderDetail = yield payModel.getOtherDetail({
uid: uid,
orderCode: orderCode,
... ... @@ -95,11 +130,17 @@ const goAlipay = (req, res, next) => {
}).redirect(url);
}
Payment.pay(user, orderDetail.data, payment, req.protocol).then(result => {
if (result && result.data && result.data.href) {
res.redirect(result.data.href);
Payment.pay(user, orderDetail.data, payment, {
protocol: req.protocol,
openId: openId
}).then(result => {
if (result && paymentCode === payModel.payments.wechat) {
return res.json(result);
}
if (result && result.data && result.data.href && paymentCode === payModel.payments.alipay) {
return res.redirect(result.data.href);
} else {
res.redirect('/');
return res.redirect('/');
}
}).catch(next);
})();
... ... @@ -184,7 +225,7 @@ const payAli = (req, res, next) => {
module.exports = {
payCenter,
goAlipay,
pay,
payCod,
payAli
};
... ...
... ... @@ -69,6 +69,15 @@ const common = {
}
});
});
},
getPaymentCode(payment) {
let paymentPars = payment.split('_');
if (paymentPars.length !== 2) {
return false;
} else {
return paymentPars[0] * 1;
}
}
};
... ...
/**
*
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/9/8
/*
* @Author: Targaryen
* @Date: 2017-01-03 17:42:41
* @Last Modified by: Targaryen
* @Last Modified time: 2017-01-09 17:53:16
*/
'use strict';
const config = global.yoho.config;
const WxPayConfig = config.WxPayConfig;
const _ = require('lodash');
const logger = global.yoho.logger;
const rp = require('request-promise');
const Promise = require('bluebird');
const co = Promise.coroutine;
const sign = require('./sign');
const md5 = require('md5');
const common = require('./common');
/**
* 微信支付相关工具类
*/
const tools = {
/**
* 拼接签名字符串
*/
toUrlParams(urlObj) {
let buff = '';
_.forEach(urlObj, (value, key) => {
if (key !== 'sign') {
buff += key + '=' + value + '&';
}
});
buff = _.trimEnd(buff, '&');
const ServiceAPI = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
return buff;
},
/**
* 构造获取code的url连接
*/
createOauthUrlForCode(redirectUrl) {
let urlObj = {
appid: WxPayConfig.appId,
redirect_uri: redirectUrl,
response_type: 'code',
scope: 'snsapi_base',
state: 'STATE#wechat_redirect',
};
let bizString = tools.toUrlParams(urlObj);
return 'https://open.weixin.qq.com/connect/oauth2/authorize?' + bizString;
},
/**
* 构造获取open和access_toke的url地址
*/
createOauthUrlForOpenid(code) {
let urlObj = {
appid: WxPayConfig.appId,
secret: WxPayConfig.appSecret,
code: code,
grant_type: 'authorization_code'
};
let bizString = tools.toUrlParams(urlObj);
return 'https://api.weixin.qq.com/sns/oauth2/access_token?' + bizString;
},
/**
* 通过code从工作平台获取openid机器access_token
*/
getOpenidFromMp(code) {
let uri = tools.createOauthUrlForOpenid(code);
let rpOption = {
method: 'POST',
uri: uri,
body: {
some: 'payload'
},
json: true
};
return rp(rpOption).then(resultFromWx => {
return resultFromWx && resultFromWx.openid;
}).catch(err => {
logger.error(err);
});
},
/**
* 微信统一下单接口
*/
unifiedOrder(params) {
let unifiedParams = {
appid: WxPayConfig.appId,
mch_id: WxPayConfig.mchId,
notify_url: WxPayConfig.notifyUrl,
device_info: 'WEB',
nonce_str: common.nonceStr(),
body: '有货订单号:' + params.orderCode,
out_trade_no: 'YOHOBuy_' + params.orderCode,
total_fee: params.totalFee * 100,
trade_type: 'JSAPI',
openid: params.openId,
sign_type: 'MD5'
};
let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase();
_.assign(unifiedParams, { sign: signStr });
let xml = common.toXml(unifiedParams);
let xmlParams = {
method: 'POST',
uri: 'https://api.mch.weixin.qq.com/pay/unifiedorder',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: xml,
timeout: 1000
};
return co(function* () {
let xmlResult = yield rp(xmlParams);
let jsonResult = yield common.xml2Obj(xmlResult);
return jsonResult && jsonResult.xml;
})();
}
};
// TODO 微信支付
const Wechat = {
pay(user, order, info) {
return ServiceAPI.get('payment/weixin_data', {
order_code: order.order_code,
payment_code: info.id,
app_key: 'blkpc'
}).then(result => {
if (result && result.code === 200 && result.data) {
let url = `/shopping/pay/online/weixin?url=${result.data.codeUrl}&code=${order.order_code}`;
/**
* 支付中心微信支付相关处理
*/
getOpenid(code, originalUrl) {
if (!code) {
let baseUrl = 'http://m.yohobuy.com' + originalUrl;
let redirectUrl = tools.createOauthUrlForCode(baseUrl);
return Promise.resolve({ redirectUrl: redirectUrl });
} else {
return tools.getOpenidFromMp(code).then(openid => {
return { openid: openid };
});
}
},
/**
* 异步拉起微信支付相关处理
*/
pay(user, order, openId) {
return co(function* () {
let unifiedOrderResult = yield tools.unifiedOrder({
orderCode: order.order_code,
totalFee: parseFloat(order.payment_amount),
openId: openId
});
if (unifiedOrderResult) {
let nonceStr = common.nonceStr();
let resParams = {
appId: unifiedOrderResult.appid,
timeStamp: parseInt(Date.parse(new Date()) / 1000, 10),
nonceStr: nonceStr,
package: 'prepay_id=' + unifiedOrderResult.prepay_id,
signType: 'MD5',
};
let paySign = md5(sign.raw(resParams) + '&key=' + WxPayConfig.key).toUpperCase();
_.assign(resParams, { paySign: paySign });
return {
code: 200,
data: {
href: helpers.urlFormat(url)
jsApiParameters: resParams
}
};
} else {
return {
code: 400,
message: result.message
};
return {};
}
});
})();
}
};
... ...
/**
* 各种支付的入口
* TAR NOTE: 本项目中仅支持支付宝微信支付,其他支付方式需调试
* TAR NOTE: 本项目中仅支持支付宝支付,微信支付,其他支付方式需调试
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/7/22
*/
... ... @@ -14,22 +14,23 @@ const Wechat = require('./pay/wechat');
const Promise = require('bluebird');
const co = Promise.coroutine;
const logger = global.yoho.logger;
const common = require('./pay/common');
const Payment = {
pay(user, order, payType, protocol) {
/**
* 统一支付入口
* reqParams: 需要从 controller 传递的参数,支付宝需要 req.protocol,微信需要 openId
*/
pay(user, order, payType, reqParams) {
return co(function*() {
let result = {
code: 400,
message: '获取支付方式信息失败'
};
let paymentPars = payType.split('_');
let payInfo;
let bankCode = '';
if (paymentPars.length !== 2) {
return result;
}
if (!order.order_code) {
result.message = '没有找到该订单';
return result;
... ... @@ -45,11 +46,14 @@ const Payment = {
// return result;
// }
let method = paymentPars[0] * 1;
let method = common.getPaymentCode(payType);
if (!method) {
return result;
}
if (method === PayModel.payments.wechat) {
// 如果是微信支付,不需要调用获取支付方式详情接口
result = yield Wechat.pay(user, order, { id: PayModel.payments.wechat });
result = yield Wechat.pay(user, order, reqParams.openId);
} else {
payInfo = yield PayModel.getPaymentInfo(method);
... ... @@ -59,12 +63,7 @@ const Payment = {
switch (payInfo.id) {
case PayModel.payments.alipay:
result = Alipay.pay(user, order, payInfo, protocol);
break;
case PayModel.payments.alibank:
bankCode = paymentPars[1];
payInfo.bankCode = bankCode; // 设置默认银行
result = Alibank.pay(user, order, payInfo, protocol);
result = Alipay.pay(user, order, payInfo, reqParams.protocol);
break;
default:
break;
... ...
... ... @@ -73,11 +73,13 @@ const processInvoiceData = (orderInfo, mobile, addresslist) => {
id: 11,
text: '日用品'
},
{
choosed: invoiceType === 3,
id: 3,
text: '办公用品'
},
// 暂停办公用品开票
// {
// choosed: invoiceType === 3,
// id: 3,
// text: '办公用品'
// },
{
choosed: invoiceType === 6,
id: 6,
... ...
... ... @@ -19,7 +19,7 @@ const logger = global.yoho.logger;
// 支付方式
const payments = {
alipay: 33,
wechat: 36,
wechat: 22,
alibank: 42
};
... ... @@ -27,10 +27,7 @@ const payments = {
const _getBanner = (param) => {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: param.contentCode
}, {
code: 200
}).then((result) => {
}, { code: 200 }).then((result) => {
result = result.data;
return result;
... ... @@ -46,10 +43,7 @@ const _getOthersBuy2 = (param) => {
rec_pos: '100005',
limit: 2,
client_id: param.client_id
}, {
code: 200
}).then((result) => {
}, { code: 200 }).then((result) => {
if (result && result.data && result.data.product_list) {
return productProcess.processProductList(result.data.product_list);
}
... ... @@ -64,12 +58,8 @@ const _getOtherDetail = (param) => {
uid: param.uid,
order_code: param.orderCode,
session_key: param.sessionKey
}, {
code: 200
}).then((result) => {
}, { code: 200 }).then(result => {
return result;
});
};
... ... @@ -98,7 +88,7 @@ const _getOthersBuy = (param) => {
* @param id
*/
const getBankByOrder = (id) => {
return co(function*() {
return co(function* () {
let result = yield payApi.getBankByOrder(id);
if (result && result.code === 200 && result.data) {
... ... @@ -115,7 +105,7 @@ const getBankByOrder = (id) => {
* @param bankCode
*/
const setOrderPayBank = (code, payment, bankCode) => {
return co(function*() {
return co(function* () {
let data = yield payApi.setOrderPayBank(code, payment, bankCode);
return data;
... ... @@ -127,7 +117,7 @@ const setOrderPayBank = (code, payment, bankCode) => {
* @param id
*/
const getPaymentInfo = (id) => {
return co(function*() {
return co(function* () {
let result = yield payApi.getPaymentInfo(id);
if (result && result.code === 200 && result.data) {
... ... @@ -144,7 +134,7 @@ const getPaymentInfo = (id) => {
* @param uid
*/
const sendPayConfirm = (code, payment, uid) => {
return co(function*() {
return co(function* () {
let data = yield payApi.sendPayConfirm(code, payment, uid);
return data;
... ... @@ -174,7 +164,7 @@ const updateOrderPayment = (code, payment, uid) => {
* @param bankCode
*/
const updateOrderPayBank = (code, payment, bankCode) => {
return co(function*() {
return co(function* () {
let data = yield payApi.updateOrderPayBank(code, payment, bankCode);
return data;
... ... @@ -188,7 +178,7 @@ const updateOrderPayBank = (code, payment, bankCode) => {
* @param sessionKey
*/
const procOrderData = (payResult, uid, sessionKey) => {
return co(function*() {
return co(function* () {
let orderCode = payResult.orderCode;
let result = { code: 400, message: '' };
... ... @@ -254,7 +244,7 @@ const payTool = {
payAppInfo(orderCode) {
return [{
appIcon: '',
payLink: helpers.urlFormat('/cart/index/new/pay/goalipay', {
payLink: helpers.urlFormat('/cart/index/new/pay', {
payment: payments.alipay + '_platform',
order_code: orderCode
}),
... ... @@ -301,17 +291,7 @@ const payCenter = (params) => {
uid: params.uid,
orderCode: params.orderCode
}).then(result => {
let resultData = _.get(result, 'data', {});
return {
payAppInfo: payTool.payAppInfo(params.orderCode),
orderCode: params.orderCode,
hasWxShare: true,
orderTotal: resultData.payment_amount || 0,
orderTotalFormat: parseInt(resultData.payment_amount, 10),
orderCount: payTool.calBuyNumCount(resultData.order_goods),
uid: params.uid
};
return _.get(result, 'data', {});
});
};
... ... @@ -398,6 +378,7 @@ module.exports = {
sendPayConfirm,
procOrderData,
payCenter,
payTool,
getPayCod,
getPayAli
};
... ...
... ... @@ -26,9 +26,8 @@ router.post('/index/seckill/submit', seckill.submit);
router.get('/index/count', countController.cartCount);
router.get('/paySuccess/payCod', payController.payCod);// 支付成功,货到付款
router.get('/index/new/pay', authMW, payController.payCenter);// 支付中心
router.get('/index/new/pay/goalipay', authMW, payController.goAlipay);// 跳支付宝支付
router.get('/index/new/pay/aliwapreturn', authMW, payController.payAli);// 支付宝付款支付成功
router.get('/index/new/pay', authMW, payController.pay);// 统一支付 URL,支持微信,支付宝
router.get('/index/new/pay/alipayresult', authMW, payController.payAli);// 支付宝付款支付成功
router.get('/index/new/orderEnsure', authMW, order.orderEnsure); // 订单结算
router.get('/index/new/selectCoupon', authMW, order.selectCoupon); // 选择优惠券 页面
... ...
... ... @@ -6,15 +6,15 @@
<div class="info">
<span class="info-name">{{name}}</span>
<span class="info-phone">{{phoneNum}}</span>
<a href="/cart/index/selectAddress"><span class="info-address">{{addressInfo}}</span></a>
<a href="/cart/index/new/selectAddress"><span class="info-address">{{addressInfo}}</span></a>
<i class="iconfont">&#xe637;</i>
</div>
<a class="rest" href="/cart/index/selectAddress">其他地址<span class="iconfont">&#xe614;</span></a>
<a class="rest" href="/cart/index/new/selectAddress">其他地址<span class="iconfont">&#xe614;</span></a>
</div>
{{else}}
<div class="address block address-wrap not-address">
<i class="iconfont">&#xe637;</i>
<a class="choose" href="/cart/index/selectAddress">请选择收货地址<span class="iconfont">&#xe614;</span></a>
<a class="choose" href="/cart/index/new/selectAddress">请选择收货地址<span class="iconfont">&#xe614;</span></a>
</div>
{{/if}}
<section class="dispatch block">
... ...
... ... @@ -142,7 +142,7 @@ const _getOrderStatus = (order, showLogistics) => {
/* 待付款 */
Object.assign(result, {
unpaid: true,
payUrl: helpers.urlFormat('/home/orders/pay', {order_code: order.order_code})
payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.order_code})
});
break;
case 1:
... ...
... ... @@ -70,7 +70,7 @@ const _getOrderStatus = (order, showLogistics) => {
/* 待付款 */
Object.assign(result, {
unpaid: true,
payUrl: helpers.urlFormat('/home/orders/pay', {order_code: order.orderCode})
payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.orderCode})
});
break;
case 1:
... ... @@ -216,7 +216,7 @@ const orderDetailData = (uid, orderCode) => {
obj = _.assign(obj, {
thumb: data.goodsImage,
name: data.productName,
color: data.factoryColorName? data.factoryColorName : data.colorName,
color: data.factoryColorName ? data.factoryColorName : data.colorName,
size: data.sizeName,
price: data.goodsPrice,
count: count
... ... @@ -313,8 +313,6 @@ const orderDetailData = (uid, orderCode) => {
cancelReason: resons
});
//console.log(orderDetail)
return orderDetail;
});
... ...
... ... @@ -29,6 +29,8 @@ const suggest = require(`${cRoot}/suggest`);
const message = require(`${cRoot}/message`);
const onlineService = require(`${cRoot}/onlineService`);
const payController = require('../cart/controllers/pay');
// const myDetail = require(`${cRoot}/myDetail);
... ... @@ -132,4 +134,7 @@ router.get('/installment/card-detail', installment.cardDetail); // 银行å¡è¯¦æ
router.get('/installment/delBankCard', installment.delBankCard); // 删除绑定
router.get('/installment/setMasterCard', installment.setMasterCard); // 切换主卡
// 支付中心 URL,由于微信安全限制,在现有 URL 后追加 new
router.get('/orders/paynew', auth, payController.payCenter);
module.exports = router;
... ...
... ... @@ -98,6 +98,13 @@ module.exports = {
alipayKey: 'kcxawi9bb07mzh0aq2wcirsf9znusobw',
sellerMail: 'zfb@yoho.cn',
merchantUrl: 'http://m.yohobuy.com/home/orders/detail?order_code='
},
WxPayConfig: {
appId: 'wx75e5a7c0c88e45c2',
mchId: '1227694201',
key: '7e6f3307b64cc87c79c472814b88f7fb',
appSecret: 'ce21ae4a3f93852279175a167e54509b',
notifyUrl: 'payment/alipay_notify',
}
};
... ...
... ... @@ -19,6 +19,9 @@ module.exports = app => {
app.use('/activity', require('./apps/activity'));
app.use('/cart', require('./apps/cart'));
// 微信支付的 URL 处理
app.use('/shopping', require('./apps/cart'));
// 分期付款
app.use('/home', require('./apps/home'));
... ...
... ... @@ -26,9 +26,9 @@ var $invoice = $('.invoice'),
isTickets = $('#ticketsPage').val(),
productSku = $('#productSku').val(),
buyNumber = $('#buyNumber').val(),
headerTop = $("#yoho-header").outerHeight(),
isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, //判断有货币是否可以单击
addressTop = $(".address-wrap").outerHeight();
headerTop = $('#yoho-header').outerHeight(),
isYohoCoinClick = $coinLi.data('yoho-coin-click') * 1, // 判断有货币是否可以单击
addressTop = $('.address-wrap').outerHeight();
var orderCont = window.cookie('order-info') && JSON.parse(window.cookie('order-info'));
var invoiceCont = {
... ... @@ -55,7 +55,8 @@ function invoiceInit() {
$('.invoice-type').text(invoiceCont[orderCont.invoiceType] + '(' + invoicesType[orderCont.invoicesType] + ')');
} else {
$('.invoice-type').text('服装(电子)');
//$('.invoice-type').text('服装(纸质)');
// $('.invoice-type').text('服装(纸质)');
}
}
... ... @@ -193,15 +194,15 @@ function orderCompute() {
skuList: isLimitGood() ? orderInfo('skuList') : undefined
};
//门票
// 门票
if (isTickets) {
data = {
type: 'tickets',
productSku: productSku,
buyNumber: buyNumber,
yohoCoin: yohoCoin
}
};
};
}
loading.showLoadingMask();
$.ajax({
... ... @@ -306,7 +307,7 @@ function submitOrder() {
// 货到付款的进入订单页面
url = '/home/orderDetail?order_code=' + res.data.order_code;
} else {
url = '/home/orders/pay?order_code=' + res.data.order_code;
url = '/cart/index/new/pay?order_code=' + res.data.order_code;
}
/* tar add 161116 */
... ... @@ -314,7 +315,7 @@ function submitOrder() {
window._yas.sendCustomInfo({
op: 'YB_SC_TOPAY_CLICK',
param: JSON.stringify({
C_ID: window._ChannelVary[cookie('_Channel')],
C_ID: window._ChannelVary[window.cookie('_Channel')],
ORDER_CODE: res.data.order_code,
PRD_NUM: $('#goods-num').val(),
ORDER_AMOUNT: res.data.order_amount,
... ... @@ -528,7 +529,7 @@ function ticketsConfirm() {
}
// 校验手机号
$ticketsMobile.blur(function(e) {
$ticketsMobile.blur(function() {
var reg = /^[0123456789]{1,30}$/;
var mobile = $ticketsMobile.val();
... ...
... ... @@ -7,10 +7,10 @@ var loading = require('../plugin/loading'),
// 点击微信显示加载
var $loadingToast = $(".loading-toast");
var $loadingToast = $('.loading-toast');
/* TODO 影响加载此段 JS */
// var theOrderCode = document.getElementById('ordercode').value;
var theOrderCode = document.getElementById('ordercode').value;
var wxPayEl = document.getElementById('weixin'),
wxHammer = wxPayEl && new Hammer(wxPayEl);
... ... @@ -36,9 +36,9 @@ if ($('#goods-list').length === 0) {
$('.maybe-like').hide();
}
//隐藏微信分享选项
// 隐藏微信分享选项
if (window.wx) {
wx.hideOptionMenu();
window.wx.hideOptionMenu();
}
function onBridgeReady() {
... ... @@ -61,14 +61,13 @@ if (typeof WeixinJSBridge === undefined) {
// 调用微信JS api 支付
function jsApiCall(orderCode, jsApiParameters) {
$loadingToast.addClass("hide");
$loadingToast.addClass('hide');
// 防止重复操作弹框
window.WeixinJSBridge && window.WeixinJSBridge.invoke(
'getBrandWCPayRequest',
jsApiParameters,
function(res) {
function() {
window.location.href = '/home/orders/detail?order_code=' + orderCode + '&openId=true';
}
);
... ... @@ -78,7 +77,7 @@ function jsApiCall(orderCode, jsApiParameters) {
function callpay(orderCode) {
var jsApiParameters;
$loadingToast.removeClass("hide");
$loadingToast.removeClass('hide');
if (typeof WeixinJSBridge === undefined) {
if (document.addEventListener) {
document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
... ... @@ -89,9 +88,10 @@ function callpay(orderCode) {
} else {
$.ajax({
type: 'GET',
url: '/shopping/pay/wechatwapapi',
url: '/cart/index/new/pay',
data: {
'order_code': orderCode
order_code: orderCode,
payment: '22_platform',
},
dataType: 'json',
success: function(res) {
... ... @@ -106,7 +106,7 @@ function callpay(orderCode) {
tip.show('请刷新本页面,完成微信支付');
},
complete: function() {
$loadingToast.addClass("hide");
$loadingToast.addClass('hide');
}
});
}
... ... @@ -177,7 +177,7 @@ function showPage() {
function bindTouchedEvent() {
var $boxs = $('.box');
$boxs.on('touchstart', function(e) {
$boxs.on('touchstart', function() {
$(this).addClass('bytouch');
}).on('touchend touchcancel', function() {
$boxs.removeClass('bytouch');
... ...
... ... @@ -23,7 +23,7 @@ var $invoiceNotice = $('.invoice-notice'),
isModifyTel = false;
var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/,
linkUrl = $('.address-more').val() || '/cart/index/orderEnsure?cartType=ordinary';
linkUrl = $('.address-more').val() || '/cart/index/new/orderEnsure?cartType=ordinary';
var C_ID = window._ChannelVary[window.cookie('_Channel')] || 1;
... ...