Commit c8da3eb8 by 修福龙

收银系统刷脸支付兼容余额支付

parent 46a1ef94
......@@ -93,5 +93,8 @@ export default {
*payscoreinfo(action, {call}) {
return yield call(api.payscoreinfo, action);
},
*balancePay(action, {call}) {
return yield call(api.balancePay, action);
},
},
};
......@@ -18,6 +18,7 @@ import RedPacketModal from '../components/RedPacketModal';
import {width, height, scaleSize} from '../utils/screen';
import EnterEvent from '../utils/EnterEvent';
import Printer from '../utils/Printer';
import AutoClick from '../utils/AutoClick';
window.RN = RN;
window.Toast = Toast;
......@@ -365,9 +366,11 @@ const CounterMixins = ComposeComponent => {
return '门店设置已解锁';
};
successPay = async () => {
successPay = async balance => {
Toast.hide();
const msg = '付款成功,祝您生活愉快~';
const msg = balance
? '余额付款成功,祝您生活愉快~'
: '付款成功,祝您生活愉快~';
this.props.dispatch({
// 购物完成步骤
type: 'app/step',
......@@ -771,6 +774,33 @@ const CounterMixins = ComposeComponent => {
return true;
};
balancePay = async openid => {
if (this.barcodeBusy) {
return true;
}
Toast.loading('正在付款,请稍后~');
this.barcodeBusy = true;
const {ids, noBarcode} = this.getGoods();
const {data} = await this.props.dispatch({
type: 'goods/balancePay',
ids,
noBarcode,
openid,
});
if (data.code === 1) {
// 付款成功
this.orderId = data.data.orderId;
this.successPay(true);
await AutoClick.clickBackKey();
await wait(1200);
await this.setState({voiceModal: false});
this.barcodeBusy = false;
return data;
}
this.barcodeBusy = false;
return data;
};
selectUserModal = () =>
new Promise(async resolve => {
this.barcodeResolve = resolve;
......@@ -955,6 +985,7 @@ const CounterMixins = ComposeComponent => {
dropUp={this.dropUp}
dropDown={this.dropDown}
speak={this.speak}
balancePay={this.balancePay}
/>
</View>
);
......
......@@ -236,11 +236,10 @@ class VerticalPage extends Component {
res = await WxFacepay.facepay(params);
}
if (res.face_code) {
await this.props.barcodepay(res.face_code, true, res.sub_openid);
// const ret = await this.props.barcodepay(res.face_code, true);
// const result = { ...params, payresult: ret };
// if (ret !== 'SUCCESS') result.payresult = 'ERROR';
// WxFacepay.update(result);
const data = await this.props.balancePay(res.sub_openid);
if (data.code !== 1) {
await this.props.barcodepay(res.face_code, true, res.sub_openid);
}
this.faceRetry = false;
}
};
......@@ -266,7 +265,17 @@ class VerticalPage extends Component {
Toast.show(res.msg);
return;
}
await this.props.barcodepay(res.fToken, true, null, res.fToken, res.uid);
const balanceData = await this.props.balancePay(res.uid);
if (balanceData.code !== 1) {
await this.props.barcodepay(
res.fToken,
true,
null,
res.fToken,
res.uid,
);
}
// await this.props.barcodepay(res.fToken, true, null, res.fToken, res.uid);
}
};
......
......@@ -70,3 +70,7 @@ export function wxauthinfo({rawdata}) {
export function payscoreinfo() {
return axios.post('/store/goods/payscore/info');
}
export function balancePay(action) {
return axios.post('/store/goods/balancePay', qs.stringify(action));
}
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