Commit 52041612 by 修福龙

通过刷脸开通微信支付分

parent fd0c90a4
......@@ -90,5 +90,11 @@ export default {
delete action.type;
return yield call(api.wxauthinfo, action);
},
*payscoreinfo(action, {call}) {
return yield call(api.payscoreinfo, action);
},
*payscoreCheck(action, {call}) {
return yield call(api.payscoreCheck, action);
},
},
};
......@@ -270,7 +270,12 @@ class FacePage extends Component {
if (ret.code < 0 || ret.code === 401) {
// 未授权,提示用户扫码验证
let tipText = ret.msg;
let payscoreEnable = ret.payscoreEnable;
if (payscoreEnable) {
Speech.speak('正在开通支付分,请看向屏幕,靠中间站稳');
} else {
Speech.speak(tipText);
}
this.userId = ret.userId;
if (ret.code === 401) {
// 需要验证手机号
......@@ -281,7 +286,34 @@ class FacePage extends Component {
return;
}
if (ret.code === -10) {
this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 开通免密支付
if (this.sense && WxFacepay.getUserPayScoreStatus && payscoreEnable) {
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: 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 {
this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 扫码开通免密支付
}
return;
}
// else if (ret.orders && ret.orders.length > 0) {
......@@ -391,12 +423,18 @@ class FacePage extends Component {
if (res.sub_openid) {
res.openid = res.sub_openid;
}
this.faceinfo = {...res};
await this.wxdoor();
}
};
wxdoor = async () => {
this.loading(true);
const action = {
type: 'store/wxdoor',
openid: res.openid,
wxtoken: res.token,
nickname: res.nickname,
openid: this.faceinfo.openid,
wxtoken: this.faceinfo.token,
nickname: this.faceinfo.nickname,
};
if (validity.phone.test(this.phone)) action.phone = this.phone;
if (this.sense) action.sense = true;
......@@ -404,7 +442,61 @@ class FacePage extends Component {
this.phone = '';
this.loading(false);
this.handleDoorLogin(ret);
};
// 刷脸查询用户支付分状态
getPayScoreStatus = async () => {
const {orderDetailsModal, tipsModal} = this.state;
if (orderDetailsModal || tipsModal) {
// 出现订单弹窗,不做人脸识别
return;
}
// const tipText = '正在开通支付分,请看向屏幕,靠中间站稳';
// Speech.speak(tipText);
const data = await this.payscoreinfo();
if (data.code === 1) {
const out_trade_no = data.data.orderId;
const payscore_out_request_no = data.data.authorizationCode;
const payscore_service_id = data.data.payscoreId;
let auth = (await this.payscoreAuthinfo()) || {};
if (
auth.return_code === 'SUCCESS' ||
(auth.code === 1 && auth.data.bizCode === '0000')
) {
if (auth.data) {
auth = auth.data;
}
const params = {
appid: auth.appid || auth.subAppId,
mch_id: auth.mch_id || auth.subMchId,
out_trade_no,
authinfo: auth.authinfo || auth.authInfo,
payscore_out_request_no,
payscore_service_id,
// ask_unionid: 1,
};
WxFacepay.getUserPayScoreStatus(params);
return {orderId: out_trade_no, code: payscore_out_request_no};
}
}
};
// 获取用户支付分状态
payscoreinfo = async () => {
const {data} = await this.props.dispatch({
type: 'goods/payscoreinfo',
});
return data;
};
// 获取刷脸支付调用凭证
payscoreAuthinfo = async () => {
const rawdata = await WxFacepay.rawdata();
const {data} = await this.props.dispatch({
type: 'goods/wxauthinfo',
rawdata,
});
return data;
};
alipayinfo = async () => {
......
......@@ -63,6 +63,17 @@ export function smilepay({zimmetainfo, service_id, service_params}) {
);
}
export function wxauthinfo(action) {
return axios.post('/common/wxpay/faceAuth', action);
export function wxauthinfo({rawdata}) {
return axios.post('/common/wxpay/faceAuth', qs.stringify({rawdata}));
}
export function payscoreinfo() {
return axios.post('/store/goods/payscore/info');
}
export function payscoreCheck({userId, orderId, code}) {
return axios.post(
'/store/goods/payscore/check',
qs.stringify({userId, orderId, code}),
);
}
......@@ -44,6 +44,12 @@ if (!NativeModules.AutoClick) {
search: `${wxPkg}:id/container_register_allow_button`,
parent: false,
},
wxpayscoreRegister: {
pkgName: wxPkg,
method: 'clickByText',
search: '申请授权',
parent: true,
},
smileConfirm: {
pkgName: alPkg,
method: 'clickByExact',
......
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