Commit 284eddc7 by 修福龙

刷脸开通支付分

parent 52041612
...@@ -44,6 +44,7 @@ class FacePage extends Component { ...@@ -44,6 +44,7 @@ class FacePage extends Component {
qrCode: '', qrCode: '',
goTipsModal: false, goTipsModal: false,
type: '', type: '',
code: 1,
setting: false, setting: false,
}; };
...@@ -265,14 +266,16 @@ class FacePage extends Component { ...@@ -265,14 +266,16 @@ class FacePage extends Component {
handleDoorLogin = async ret => { handleDoorLogin = async ret => {
this.setState({ this.setState({
type: ret.type, type: ret.type,
code: ret.code,
}); });
if (ret) { if (ret) {
if (ret.code < 0 || ret.code === 401) { if (ret.code < 0 || ret.code === 401) {
// 未授权,提示用户扫码验证 // 未授权,提示用户扫码验证
let tipText = ret.msg; let tipText = ret.msg;
let payscoreEnable = ret.payscoreEnable; // 判断扣款方式使用支付分还是代扣
if (payscoreEnable) { this.payscoreEnable = !!ret.payscoreEnable;
Speech.speak('正在开通支付分,请看向屏幕,靠中间站稳'); if (this.payscoreEnable && ret.code === -10 && this.sense) {
Speech.speak('正在开通支付分,请看向屏幕');
} else { } else {
Speech.speak(tipText); Speech.speak(tipText);
} }
...@@ -285,32 +288,10 @@ class FacePage extends Component { ...@@ -285,32 +288,10 @@ class FacePage extends Component {
}); });
return; return;
} }
if (ret.code === -10) { if (ret.code === -10 && this.sense) {
if (this.sense && WxFacepay.getUserPayScoreStatus && payscoreEnable) { // 无感设备
let openPayScore = false; if (WxFacepay.getUserPayScoreStatus && this.payscoreEnable) {
const {orderId, code} = await this.getPayScoreStatus(); this.openPayScore(ret.action);
if (orderId && code) {
for (let i = 0; i < 10; i++) {
// 查询用户支付分状态与服务授权状态
await delay(1000);
const {data} = await this.props.dispatch({
type: 'goods/payscoreCheck',
userId: ret.userId,
orderId,
code,
});
if (data.code === 1 && data.data.payscoreState) {
openPayScore = true;
await this.wxdoor();
break;
}
}
}
if (!openPayScore) {
tipText = '请扫码开通支付分';
Speech.speak(tipText);
this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 扫码开通支付分
}
} else { } else {
this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 扫码开通免密支付 this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 扫码开通免密支付
} }
...@@ -444,6 +425,34 @@ class FacePage extends Component { ...@@ -444,6 +425,34 @@ class FacePage extends Component {
this.handleDoorLogin(ret); this.handleDoorLogin(ret);
}; };
// 刷脸开通支付分
openPayScore = async action => {
let openPayScore = false;
const {orderId, code} = await this.getPayScoreStatus();
if (orderId && code) {
for (let i = 0; i < 10; i++) {
// 查询用户支付分状态与服务授权状态
await delay(1000);
const {data} = await this.props.dispatch({
type: 'goods/payscoreCheck',
userId: this.userId,
orderId,
code,
});
if (data.code === 1 && data.data.payscoreState) {
openPayScore = true;
await this.wxdoor();
break;
}
}
}
if (!openPayScore) {
const tipText = '请扫码开通支付分';
Speech.speak(tipText);
this.setQrcode({action: action, tip: tipText, qrcode: true}); // 扫码开通支付分
}
};
// 刷脸查询用户支付分状态 // 刷脸查询用户支付分状态
getPayScoreStatus = async () => { getPayScoreStatus = async () => {
const {orderDetailsModal, tipsModal} = this.state; const {orderDetailsModal, tipsModal} = this.state;
...@@ -451,8 +460,6 @@ class FacePage extends Component { ...@@ -451,8 +460,6 @@ class FacePage extends Component {
// 出现订单弹窗,不做人脸识别 // 出现订单弹窗,不做人脸识别
return; return;
} }
// const tipText = '正在开通支付分,请看向屏幕,靠中间站稳';
// Speech.speak(tipText);
const data = await this.payscoreinfo(); const data = await this.payscoreinfo();
if (data.code === 1) { if (data.code === 1) {
const out_trade_no = data.data.orderId; const out_trade_no = data.data.orderId;
...@@ -615,8 +622,14 @@ class FacePage extends Component { ...@@ -615,8 +622,14 @@ class FacePage extends Component {
}; };
goTips = async () => { goTips = async () => {
Speech.speak('请扫码开门'); if (this.payscoreEnable) {
this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true}); await this.setState({tipsModal: false});
Speech.speak('正在开通支付分,请看向屏幕');
this.openPayScore(this.action);
} else {
Speech.speak('请扫码开门');
this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true});
}
}; };
goToo = async () => { goToo = async () => {
...@@ -643,11 +656,12 @@ class FacePage extends Component { ...@@ -643,11 +656,12 @@ class FacePage extends Component {
qrCode, qrCode,
goTipsModal, goTipsModal,
type, type,
code,
} = this.state; } = this.state;
let flag = ''; let flag = '';
if (type === 'over') { if (type === 'over' && (code === -9 || code === -10)) {
flag = '我已付款'; flag = '我已付款';
} else if (type === 'loss') { } else if (type === 'loss' && (code === -9 || code === -10)) {
flag = '确认出店'; flag = '确认出店';
} else { } else {
flag = ''; flag = '';
......
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