Commit d3399471 by 黄日华

增加引导语音

parent b308e370
src/assets/Vertical/guide.jpg

39.9 KB | W: | H:

src/assets/Vertical/guide.jpg

32.1 KB | W: | H:

src/assets/Vertical/guide.jpg
src/assets/Vertical/guide.jpg
src/assets/Vertical/guide.jpg
src/assets/Vertical/guide.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -71,6 +71,7 @@ const CounterMixins = ComposeComponent => {
cloudFinishModal: false,
noBuyModal: false,
logoVisible: true,
nobodyVoice: true,
};
componentWillMount = async () => {
......@@ -124,6 +125,8 @@ const CounterMixins = ComposeComponent => {
this.barcode += keyCode - 7;
} else if (keyCode >= 29 && keyCode <= 54) {
this.barcode += pressedKey;
} else {
this.barcode += pressedKey;
}
});
EnterEvent.on('Trigger', async () => {
......@@ -132,6 +135,7 @@ const CounterMixins = ComposeComponent => {
});
this.printerConnect();
this.listen();
this.guideVoice();
};
initSetting = () => {
......@@ -256,6 +260,7 @@ const CounterMixins = ComposeComponent => {
window.socket.on(
'goodsOperate',
({type, number, row, barcode, price}) => {
console.warn('goodsOperate', barcode);
const index = row;
if (type === 'add') {
// 新增
......@@ -354,7 +359,7 @@ const CounterMixins = ComposeComponent => {
clearInterval(this.payInter);
this.setState({voiceModal: false});
}
}, 2000);
}, 3000);
this.setState({voiceModal: true, voiceTitle: msg});
Speech.speak(msg);
} else if (type === 'paid') {
......@@ -389,7 +394,7 @@ const CounterMixins = ComposeComponent => {
step: 1,
});
this.setState({voiceModal: false});
}, 1200);
}, 3000);
}
if (count >= 20) {
// 一分钟,超时关闭付款
......@@ -399,7 +404,9 @@ const CounterMixins = ComposeComponent => {
step: 1,
});
clearInterval(this.payInter);
setTimeout(() => {
this.setState({voiceModal: false});
}, 3000);
}
}, 3000);
} else {
......@@ -423,7 +430,7 @@ const CounterMixins = ComposeComponent => {
step: 1,
});
this.setState({voiceModal: false});
}, 1200);
}, 3000);
}
}
},
......@@ -456,9 +463,21 @@ const CounterMixins = ComposeComponent => {
successPay = async balance => {
Toast.hide();
const msg = balance
? '余额付款成功,祝您生活愉快~'
: '付款成功,祝您生活愉快~';
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 = balance
// ? '余额付款成功,祝您生活愉快~'
// : '付款成功,祝您生活愉快~';
const msg = '付款' + total + '元,共' + totalNum + '件商品,祝您生活愉快';
this.props.dispatch({
// 购物完成步骤
type: 'app/step',
......@@ -466,9 +485,11 @@ const CounterMixins = ComposeComponent => {
});
this.setState({voiceModal: true, voiceTitle: msg});
Speech.speak(msg);
this.storeSetting(this.state.goodsArr);
this.storeSetting(goodsArr);
setTimeout(() => {
this.clearList();
this.onLucky();
}, 3000);
};
storeSetting = async printer => {
......@@ -478,8 +499,11 @@ const CounterMixins = ComposeComponent => {
group,
});
if (data.code === 1) {
this.setState({receipt: data.data.receipt || {}, printer});
if (data.data.receipt && data.data.receipt.enable) {
this.setState({
receipt: (data.data && data.data.receipt) || {},
printer,
});
if (data.data && data.data.receipt && data.data.receipt.enable) {
if (data.data.receipt.confirm) {
await this.setState({
visible: true,
......@@ -527,6 +551,7 @@ const CounterMixins = ComposeComponent => {
showLeaveModal = () => {
if (this.state.stype === 'guard') {
Speech.speak('请点击开门离店或者再逛一逛继续购物');
this.setState({cloudFinishModal: true});
clearTimeout(this.leaveModalTimeout);
this.leaveModalTimeout = setTimeout(() => {
......@@ -599,6 +624,7 @@ const CounterMixins = ComposeComponent => {
this.setState({
goodsArr: gaArr,
});
this.goodsChangeSpeak(gaArr);
}
this.setState({
focus: true,
......@@ -626,6 +652,7 @@ const CounterMixins = ComposeComponent => {
this.setState({
goodsArr: gaArr,
});
this.goodsChangeSpeak(gaArr);
}
};
......@@ -636,6 +663,7 @@ const CounterMixins = ComposeComponent => {
this.setState({
goodsArr,
});
this.goodsChangeSpeak(goodsArr);
};
submitGoodNum = async num => {
......@@ -650,6 +678,7 @@ const CounterMixins = ComposeComponent => {
this.setState({
goodsArr: gaArr,
});
this.goodsChangeSpeak(gaArr);
}
};
......@@ -669,6 +698,15 @@ const CounterMixins = ComposeComponent => {
return;
}
barcode = barcode || this.barcode;
if (isNaN(barcode.substring(0, 4))) {
const msg = '请遮住条码旁边的二维码,再重新扫条码';
this.setState({voiceModal: true, voiceTitle: msg});
Speech.speak(msg);
setTimeout(() => {
this.setState({voiceModal: false});
}, 3500);
return;
}
if (await this.barcodepay(barcode)) {
return;
}
......@@ -711,22 +749,32 @@ const CounterMixins = ComposeComponent => {
this.goodsMap[barcode] = data.data;
let dataReal = data.data;
let t = 0;
let totalNum = 0;
for (let i = 0; i < goodsArr.length; i++) {
if (goodsArr[i].barcode === barcode) {
goodsArr[i].num += 1;
} else {
t++;
}
totalNum =
Number(NP.round(totalNum, 2).toFixed(2)) +
Number(NP.round(goodsArr[i].num, 2).toFixed(2));
}
if (t === goodsArr.length) {
dataReal.num = data.data.num || 1;
totalNum =
Number(NP.round(totalNum, 2).toFixed(2)) +
Number(NP.round(dataReal.num, 2).toFixed(2));
goodsArr.push({...dataReal});
}
const current = Math.ceil(goodsArr.length / window.pageSize);
Speech.speak('共' + totalNum + '件商品');
clearInterval(this.nobodyInter);
this.setState({
current,
goodsArr,
modalS: false,
nobodyInter: false,
});
Toast.hide();
} else if (data.code === 1 && price <= 0) {
......@@ -766,9 +814,20 @@ const CounterMixins = ComposeComponent => {
dot: false,
});
Toast.hide();
this.goodsChangeSpeak(goodsArr);
}
};
goodsChangeSpeak = goodsArr => {
let totalNum = 0;
goodsArr.map(v => {
totalNum =
Number(NP.round(totalNum, 2).toFixed(2)) +
Number(NP.round(v.num, 2).toFixed(2));
});
Speech.speak('共' + totalNum + '件商品');
};
getGoods = () => {
const {goodsArr} = this.state;
const ids = {};
......@@ -847,7 +906,7 @@ const CounterMixins = ComposeComponent => {
} else {
this.successPay();
successPay = true;
await wait(1200);
await wait(3000);
// await wait(res.data.timeout);
}
} else if (res.code === 2) {
......@@ -864,7 +923,7 @@ const CounterMixins = ComposeComponent => {
if (status.code === 1 && status.data === 1) {
this.successPay();
successPay = true;
await wait(1200);
await wait(3000);
break;
}
}
......@@ -872,9 +931,9 @@ const CounterMixins = ComposeComponent => {
// 付款失败
await wait(res.data.timeout);
} else {
await wait(1200);
await wait(3000);
}
await this.setState({voiceModal: false});
this.setState({voiceModal: false});
this.barcodeBusy = false;
if (successPay) {
return 'SUCCESS';
......@@ -900,7 +959,7 @@ const CounterMixins = ComposeComponent => {
this.orderId = data.data.orderId;
this.successPay(true);
await AutoClick.clickBackKey();
await wait(1200);
await wait(3000);
await this.setState({voiceModal: false});
this.barcodeBusy = false;
return data;
......@@ -962,6 +1021,24 @@ const CounterMixins = ComposeComponent => {
this.setState({
goodsArr: [],
});
this.guideVoice();
};
guideVoice = () => {
if (this.nobodyInter) clearInterval(this.nobodyInter);
const that = this;
this.nobodyInter = setInterval(async () => {
if (this.state.nobodyVoice) {
await Speech.speak('您好,选购完商品后请到收银机这边付款');
await wait(5000);
await Speech.speak('请先扫描商品条码,再出示付款码');
} else {
clearInterval(that.nobodyInter);
}
}, 30000);
this.setState({
nobodyVoice: true,
});
};
pushBag = index => {
......@@ -975,6 +1052,7 @@ const CounterMixins = ComposeComponent => {
});
const {stype} = this.state;
if (stype === 'guard') {
Speech.speak('请点击开门离店或者再逛一逛继续购物');
this.setState({
cloudFinishModal: true,
});
......@@ -1034,6 +1112,7 @@ const CounterMixins = ComposeComponent => {
noBuyModal,
logoVisible,
qrHost,
nobodyVoice,
} = this.state;
return (
<View style={{flex: 1}}>
......@@ -1229,6 +1308,30 @@ const CounterMixins = ComposeComponent => {
speak={this.speak}
balancePay={this.balancePay}
/>
<View
style={{
width: 100,
height: 100,
position: 'absolute',
top: 0,
left: 0,
zIndex: 999,
opacity: 0,
}}>
<Touch
style={{
width: '100%',
height: '100%',
}}
onPress={() => {
this.setState({nobodyVoice: !nobodyVoice});
if (!nobodyVoice) {
this.guideVoice();
}
}}>
<View />
</Touch>
</View>
</View>
);
};
......
......@@ -36,8 +36,6 @@ import {ossLink} from '../utils/config';
let pageSize = 8; // 分页大小
window.pageSize = pageSize;
// const wait = t => new Promise(resolve => setTimeout(resolve, t));
class VerticalPage extends Component {
state = {
contact: '',
......@@ -90,6 +88,10 @@ class VerticalPage extends Component {
await this.refreshLogo();
}
async componentDidMount() {
await this.listen();
}
initSetting = () => {
AutoClick.isSettingsOn().then(setting => {
if (!setting) this.setState({setting: true}); // 展示辅助按钮
......@@ -103,10 +105,6 @@ class VerticalPage extends Component {
await AutoClick.goSetting(); // 按钮跳转设置
};
async componentDidMount() {
this.listen();
}
listen = async () => {
try {
while (!window.socket) {
......@@ -1764,27 +1762,28 @@ const styles = {
zIndex: 999999999999999,
elevation: 6,
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
width: '100%',
height: '100%',
backgroundColor: '#0C0C0C',
},
guardModal_image: {
height: '65%',
width: '100%',
height: '60%',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
},
Imageee: {
minHeight: '60%',
height: '100%',
},
guardModal_button: {
height: '35%',
width: '100%',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
justifyContent: 'flex-start',
alignItems: 'center',
marginTop: '10%',
},
guardModal_button_call: {
backgroundColor: '#fc4000',
......
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