Commit f7b12965 by zeven

刷脸设备兼容即拿迷你店

parent 019a08ca
{ {
"name": "zm-face-counter", "name": "zm-face-counter",
"version": "1.1.8", "version": "1.2.0",
"private": true, "private": true,
"scripts": { "scripts": {
"android": "react-native run-android", "android": "react-native run-android",
......
...@@ -80,6 +80,10 @@ class FacePage extends Component { ...@@ -80,6 +80,10 @@ class FacePage extends Component {
this.phone = this.phone.substr(0, this.phone.length - 1); this.phone = this.phone.substr(0, this.phone.length - 1);
else if (/^\d$/.test(text)) this.phone += text; else if (/^\d$/.test(text)) this.phone += text;
if (this.phone.length > 11) this.phone = this.phone.substr(-11); if (this.phone.length > 11) this.phone = this.phone.substr(-11);
clearTimeout(this.clearPhoneTimeout); // 输入号码超过1分钟,自动清除号码,防止绑定错误号码
this.clearPhoneTimeout = setTimeout(() => {
this.phone = '';
}, 60000);
}); });
} }
...@@ -174,12 +178,14 @@ class FacePage extends Component { ...@@ -174,12 +178,14 @@ class FacePage extends Component {
} }
}; };
doorOpen = ({action}) => { doorOpen = ({action, sense}) => {
this.action = action; this.action = action;
this.sense = sense;
if (action === '进店') this.action = 'leave'; if (action === '进店') this.action = 'leave';
else if (action === '出店') this.action = 'enter'; else if (action === '出店') this.action = 'enter';
this.loading(false); this.loading(false);
this.wakeUp(); this.wakeUp();
if (this.sense && this.action === 'enter') this.face();
}; };
handleTalkCall = async () => { handleTalkCall = async () => {
...@@ -264,6 +270,10 @@ class FacePage extends Component { ...@@ -264,6 +270,10 @@ class FacePage extends Component {
}); });
return; return;
} }
if (ret.code === -10) {
this.setQrcode({action: ret.action, tip: tipText, qrcode: true}); // 开通免密支付
return;
}
// else if (ret.orders && ret.orders.length > 0) { // else if (ret.orders && ret.orders.length > 0) {
// // 有购物订单 // // 有购物订单
// let goodsArr = []; // let goodsArr = [];
...@@ -304,7 +314,9 @@ class FacePage extends Component { ...@@ -304,7 +314,9 @@ class FacePage extends Component {
setQrcode = ({action, tip, qrcode}) => { setQrcode = ({action, tip, qrcode}) => {
const state = { const state = {
qrCode: `${qrHost}/#/store-${action || 'leave'}-j${this.storeKey}`, qrCode: `${qrHost}/#/store-${action || 'leave'}-${
this.sense ? 's' : 'j'
}${this.storeKey}`,
}; };
if (tip) { if (tip) {
state.tip = tip; state.tip = tip;
...@@ -363,9 +375,7 @@ class FacePage extends Component { ...@@ -363,9 +375,7 @@ class FacePage extends Component {
} }
if (!res.openid) { if (!res.openid) {
// 返回错误出现二维码扫码 // 返回错误出现二维码扫码
this.phone = ''; this.goTips();
Speech.speak('请扫码开门');
this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true});
return; return;
} }
if (res.sub_openid) { if (res.sub_openid) {
...@@ -379,6 +389,7 @@ class FacePage extends Component { ...@@ -379,6 +389,7 @@ class FacePage extends Component {
nickname: res.nickname, nickname: res.nickname,
}; };
if (validity.phone.test(this.phone)) action.phone = this.phone; if (validity.phone.test(this.phone)) action.phone = this.phone;
if (this.sense) action.sense = true;
const ret = await this.props.dispatch(action); const ret = await this.props.dispatch(action);
this.phone = ''; this.phone = '';
this.loading(false); this.loading(false);
...@@ -412,15 +423,16 @@ class FacePage extends Component { ...@@ -412,15 +423,16 @@ class FacePage extends Component {
const res = await Smilepay.verify(JSON.parse(data.data)); const res = await Smilepay.verify(JSON.parse(data.data));
if (res.code !== '1000') { if (res.code !== '1000') {
Toast.show(res.msg); Toast.show(res.msg);
Speech.speak('请扫码开门'); this.goTips();
this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true});
return; return;
} }
this.loading(true); this.loading(true);
const ret = await this.props.dispatch({ const action = {
type: 'store/wxdoor', type: 'store/wxdoor',
alipayUid: res.uid, alipayUid: res.uid,
}); };
if (this.sense) action.sense = true;
const ret = await this.props.dispatch(action);
this.loading(false); this.loading(false);
this.handleDoorLogin(ret); this.handleDoorLogin(ret);
} }
...@@ -491,7 +503,7 @@ class FacePage extends Component { ...@@ -491,7 +503,7 @@ class FacePage extends Component {
}; };
goTips = async () => { goTips = async () => {
Speech.speak('请扫码确认'); Speech.speak('请扫码开门');
this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true}); this.setQrcode({action: this.action, tip: '请扫码开门', qrcode: true});
}; };
...@@ -586,9 +598,9 @@ class FacePage extends Component { ...@@ -586,9 +598,9 @@ class FacePage extends Component {
<TipsModal <TipsModal
visible={goTipsModal} visible={goTipsModal}
transparent transparent
title={'扫码开门'} title="温馨提示"
qrCode={qrCode} qrCode={qrCode}
tip="请扫码确认" tip={tip}
onMaskPress={() => this.setState({goTipsModal: false})} onMaskPress={() => this.setState({goTipsModal: false})}
faceType={faceType} faceType={faceType}
/> />
......
...@@ -43,10 +43,20 @@ export function wxdoor({ ...@@ -43,10 +43,20 @@ export function wxdoor({
alipayUid, alipayUid,
fToken, fToken,
phone, phone,
sense,
}) { }) {
return axios.post( return axios.post(
'/store/wxdoor', '/store/wxdoor',
qs.stringify({userId, openid, wxtoken, nickname, alipayUid, fToken, phone}), qs.stringify({
userId,
openid,
wxtoken,
nickname,
alipayUid,
fToken,
phone,
sense,
}),
); );
} }
......
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