Commit ef1350d4 by 黄日华

收银机优化付款开门流程

有人模式付款不进行开门
parent 5daf525a
......@@ -63,6 +63,16 @@ export default {
if (data.data && data.data.name) {
yield call(AsyncStorage.setItem, 'NAME', data.data.name);
}
if (data.data && data.data.human) {
yield call(AsyncStorage.setItem, 'HUMAN', '1');
} else {
yield call(AsyncStorage.setItem, 'HUMAN', '0');
}
if (data.data && data.data.isInduction) {
yield call(AsyncStorage.setItem, 'isInduction', '1');
} else {
yield call(AsyncStorage.setItem, 'isInduction', '0');
}
if (action.key) {
yield call(AsyncStorage.setItem, 'KEY', action.key);
}
......
......@@ -51,6 +51,7 @@ const CounterMixins = ComposeComponent => {
state = {
stype: 'guard',
isInduction: false,
goodsArr: [],
preventRevert: false,
modalS: false,
......@@ -73,6 +74,7 @@ const CounterMixins = ComposeComponent => {
logoVisible: true,
nobodyVoice: false,
numberValue: '',
human: false,
};
componentWillMount = async () => {
......@@ -89,9 +91,17 @@ const CounterMixins = ComposeComponent => {
}
this.initSetting();
await this.refreshLogo();
const human = await AsyncStorage.getItem('HUMAN');
const stype = await AsyncStorage.getItem('STYPE');
const qrHost = await AsyncStorage.getItem('QRHOST');
await this.setState({qrHost, stype});
const isInduction = await AsyncStorage.getItem('isInduction');
await this.setState({
qrHost,
stype,
isInduction: isInduction === '1',
human: human === '1',
});
};
componentDidMount = async () => {
......@@ -252,6 +262,9 @@ const CounterMixins = ComposeComponent => {
if (window.socket.hasListeners('goodsOperate')) {
window.socket.removeAllListeners('goodsOperate');
}
if (window.socket.hasListeners('humanSwitch')) {
window.socket.removeAllListeners('humanSwitch');
}
window.socket.on('cmdOperate', this.command.bind(this));
window.socket.on('adsOperate', ({adsData}) => {
this.setState({
......@@ -438,6 +451,9 @@ const CounterMixins = ComposeComponent => {
}
},
);
window.socket.on('humanSwitch', ({human}) => {
this.setState({human});
});
};
// 运营端远程命令
......@@ -466,28 +482,28 @@ const CounterMixins = ComposeComponent => {
successPay = async facepay => {
Toast.hide();
const {goodsArr} = this.state;
// let total = 0;
// let totalNum = 0;
// goodsArr.map(item => {
// totalNum += Number(item.num);
// if (item.price) {
// total += Number(item.price) * Number(item.num);
// } else {
// total += Number(item.prePrice) * Number(item.num);
// }
// });
// const msg = '付款' + total + '元,共' + totalNum + '件商品,祝您生活愉快';
const {goodsArr, human} = this.state;
let total = 0;
let totalNum = 0;
goodsArr.map(item => {
totalNum += Number(item.num);
if (item.price) {
total += Number(item.price) * Number(item.num);
} else {
total += Number(item.prePrice) * Number(item.num);
}
});
let msg = '付款' + total + '元,共' + totalNum + '件商品';
this.props.dispatch({
// 购物完成步骤
type: 'app/step',
step: 3,
});
// this.setState({voiceModal: true, voiceTitle: msg});
if (!facepay) {
await Speech.speak('付款成功');
}
if (this.state.stype === 'guard') {
// if (!facepay) {
// await Speech.speak('付款成功');
// }
if (this.state.stype === 'guard' && !human) {
let group = await AsyncStorage.getItem('KEY');
let {data} = await this.props.dispatch({
type: 'store/getStore',
......@@ -495,14 +511,20 @@ const CounterMixins = ComposeComponent => {
});
if (data.code === 1) {
if (data.data && data.data.payLeave) {
await this.onOpen();
await Speech.speak(msg);
setTimeout(() => {
this.onOpen();
}, 1000);
} else {
await Speech.speak('付款成功');
this.showLeaveModal();
}
} else {
this.showLeaveModal();
}
} else {
msg += ',祝您生活愉快';
await Speech.speak(msg);
await this.storeSetting(goodsArr);
await this.onLucky();
}
......@@ -567,7 +589,8 @@ const CounterMixins = ComposeComponent => {
};
showLeaveModal = () => {
if (this.state.stype === 'guard') {
const {stype, human} = this.state;
if (stype === 'guard' && !human) {
Speech.speak('请点击收银界面开门离店按钮,离开门店');
this.setState({cloudFinishModal: true});
clearTimeout(this.leaveModalTimeout);
......@@ -1129,6 +1152,7 @@ const CounterMixins = ComposeComponent => {
const {data} = await this.props.dispatch({
type: 'store/open',
orderId: this.orderId,
isScan: !this.state.isInduction,
});
if (data.code === 1) {
Speech.speak(data.msg || '门已经打开,谢谢惠顾');
......
......@@ -354,7 +354,6 @@ class VerticalPage extends Component {
onCall = async () => {
const {talkCall} = this.state;
console.warn(talkCall, Date.now());
if (talkCall === 2) {
this.setState({
talkCall: 0,
......
......@@ -35,8 +35,8 @@ export function door({userId}) {
return axios.post('/store/door', qs.stringify({userId}));
}
export function open({orderId}) {
return axios.post('/store/openDoor', qs.stringify({orderId}));
export function open({orderId, isScan}) {
return axios.post('/store/openDoor', qs.stringify({orderId, isScan}));
}
export function wxdoor({
......
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