Commit c25de083 by zeven

修复无码商品无法扫码支付

parent ed07bc6e
...@@ -125,23 +125,16 @@ const CounterMixins = ComposeComponent => { ...@@ -125,23 +125,16 @@ const CounterMixins = ComposeComponent => {
let totalCount = this.totalCount; let totalCount = this.totalCount;
if (type === 'waiting') { if (type === 'waiting') {
// 客户端等待,响应购物车列表 // 客户端等待,响应购物车列表
const {goodsArr} = this.state;
const goods = {};
this.token = token; this.token = token;
goodsArr.map(({barcode, num}) => { const {ids, noBarcode} = this.getGoods();
if (!goods[barcode]) {
goods[barcode] = num;
} else {
goods[barcode] += num;
}
});
window.socket.emit( window.socket.emit(
'counterGoods', 'counterGoods',
sid, sid,
JSON.stringify(goods), JSON.stringify(ids),
totalPrice, totalPrice,
totalCount, totalCount,
payType, payType,
JSON.stringify(noBarcode),
); );
} else if (type === 'fail') { } else if (type === 'fail') {
// 下单失败 // 下单失败
...@@ -474,18 +467,7 @@ const CounterMixins = ComposeComponent => { ...@@ -474,18 +467,7 @@ const CounterMixins = ComposeComponent => {
} }
}; };
// 付款码支付 getGoods = () => {
barcodepay = async (code, facepay) => {
if (this.barcodeBusy) {
return true;
}
const isWxpay = code.toString().match(/1[0-5]\d{16}/);
const isAlipay = code.toString().match(/^(2[5-9]|30)\d{14,22}$/);
if (!isWxpay && !isAlipay) {
return false;
}
this.barcodeBusy = true;
let successPay = false;
const {goodsArr} = this.state; const {goodsArr} = this.state;
const ids = {}; const ids = {};
const noBarcode = []; const noBarcode = [];
...@@ -508,6 +490,22 @@ const CounterMixins = ComposeComponent => { ...@@ -508,6 +490,22 @@ const CounterMixins = ComposeComponent => {
}); });
} }
}); });
return {ids, noBarcode};
};
// 付款码支付
barcodepay = async (code, facepay) => {
if (this.barcodeBusy) {
return true;
}
const isWxpay = code.toString().match(/1[0-5]\d{16}/);
const isAlipay = code.toString().match(/^(2[5-9]|30)\d{14,22}$/);
if (!isWxpay && !isAlipay) {
return false;
}
this.barcodeBusy = true;
let successPay = false;
const {ids, noBarcode} = this.getGoods();
const res = await this.props.dispatch({ const res = await this.props.dispatch({
type: 'goods/barcodepay', type: 'goods/barcodepay',
ids, ids,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment