Commit ef1350d4 by 黄日华

收银机优化付款开门流程

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