Commit f638d60e by 修福龙

增加了带字母的条码识别功能,刷脸支付余额抵扣功能

parent ca060e88
import React, {Component} from 'react'; import React, {Component} from 'react';
import {Modal, View, Text, Image} from 'react-native'; import {Modal, View, Text, Image} from 'react-native';
import Icon from 'react-native-vector-icons/Ionicons'; // import Icon from 'react-native-vector-icons/Ionicons';
import MIcon from 'react-native-vector-icons/MaterialCommunityIcons'; import MIcon from 'react-native-vector-icons/MaterialCommunityIcons';
import ModalStyles from './Modal/styles'; import ModalStyles from './Modal/styles';
import {colors, font} from '../utils/common'; import {colors, font} from '../utils/common';
......
...@@ -81,13 +81,15 @@ const CounterMixins = ComposeComponent => { ...@@ -81,13 +81,15 @@ const CounterMixins = ComposeComponent => {
const handleScan = this.submitBarcode; const handleScan = this.submitBarcode;
// if you want to react to keyUp // if you want to react to keyUp
KeyEvent.onKeyUpListener(async e => { KeyEvent.onKeyUpListener(async e => {
const {keyCode} = e; const {keyCode, pressedKey} = e;
if (keyCode === 66) { if (keyCode === 66) {
// 回车事件 // 回车事件
await handleScan(); await handleScan();
this.barcode = ''; this.barcode = '';
} else if (keyCode >= 7 && keyCode <= 16) { } else if (keyCode >= 7 && keyCode <= 16) {
this.barcode += keyCode - 7; this.barcode += keyCode - 7;
} else if (keyCode >= 29 && keyCode <= 54) {
this.barcode += pressedKey;
} }
}); });
this.listen(); this.listen();
...@@ -449,7 +451,7 @@ const CounterMixins = ComposeComponent => { ...@@ -449,7 +451,7 @@ const CounterMixins = ComposeComponent => {
const good = { const good = {
barcode: '000000', barcode: '000000',
name: '无码商品', name: '无码商品',
unit: 1, // unit: 1,
num: 1, num: 1,
// price: NP.round(price, 2).toFixed(2), // price: NP.round(price, 2).toFixed(2),
prePrice: NP.round(price, 2).toFixed(2), prePrice: NP.round(price, 2).toFixed(2),
...@@ -487,6 +489,7 @@ const CounterMixins = ComposeComponent => { ...@@ -487,6 +489,7 @@ const CounterMixins = ComposeComponent => {
purPrice: 0, purPrice: 0,
prePrice, prePrice,
num, num,
weight: 0,
}); });
} }
}); });
...@@ -494,7 +497,7 @@ const CounterMixins = ComposeComponent => { ...@@ -494,7 +497,7 @@ const CounterMixins = ComposeComponent => {
}; };
// 付款码支付 // 付款码支付
barcodepay = async (code, facepay) => { barcodepay = async (code, facepay, openid) => {
if (this.barcodeBusy) { if (this.barcodeBusy) {
return true; return true;
} }
...@@ -512,6 +515,7 @@ const CounterMixins = ComposeComponent => { ...@@ -512,6 +515,7 @@ const CounterMixins = ComposeComponent => {
code, code,
facepay, facepay,
noBarcode, noBarcode,
openid,
}); });
if (res.code !== 1) { if (res.code !== 1) {
await this.setState({voiceModal: true, voiceTitle: res.msg}); await this.setState({voiceModal: true, voiceTitle: res.msg});
......
...@@ -194,7 +194,8 @@ class VerticalPage extends Component { ...@@ -194,7 +194,8 @@ class VerticalPage extends Component {
res = await WxFacepay.facepay(params); res = await WxFacepay.facepay(params);
} }
if (res.face_code) { if (res.face_code) {
await this.props.barcodepay(res.face_code, true); await this.props.barcodepay(res.face_code, true, res.sub_openid);
// const ret = await this.props.barcodepay(res.face_code, true); // const ret = await this.props.barcodepay(res.face_code, true);
// const result = { ...params, payresult: ret }; // const result = { ...params, payresult: ret };
// if (ret !== 'SUCCESS') result.payresult = 'ERROR'; // if (ret !== 'SUCCESS') result.payresult = 'ERROR';
...@@ -287,16 +288,34 @@ class VerticalPage extends Component { ...@@ -287,16 +288,34 @@ class VerticalPage extends Component {
}}> }}>
{NP.round(item.prePrice, 2).toFixed(2)} {NP.round(item.prePrice, 2).toFixed(2)}
</Text> </Text>
<Text style={{fontSize: 25, color: colors.textXSActive}}> {item.unit ? (
{NP.round(item.price, 2).toFixed(2)}/ <Text style={{fontSize: 25, color: colors.textXSActive}}>
<Text style={styles.TdText}>{item.unit}</Text> {NP.round(item.price, 2).toFixed(2)}/
</Text> <Text style={styles.TdText}>{item.unit}</Text>
</Text>
) : (
<Text style={{fontSize: 25, color: colors.textXSActive}}>
{NP.round(item.price, 2).toFixed(2)}
</Text>
)}
</View> </View>
) : ( ) : (
<Text style={styles.TdText}> <View
{' '} style={{
{NP.round(item.prePrice, 2).toFixed(2)}/{item.unit}{' '} justifyContent: 'center',
</Text> alignItems: 'center',
flexDirection: 'row',
}}>
{item.unit ? (
<Text style={styles.TdText}>
{NP.round(item.prePrice, 2).toFixed(2)}/{item.unit}
</Text>
) : (
<Text style={styles.TdText}>
{NP.round(item.prePrice, 2).toFixed(2)}
</Text>
)}
</View>
)} )}
</View> </View>
<View style={styles.TdStyle}> <View style={styles.TdStyle}>
......
...@@ -9,10 +9,10 @@ export function getBags() { ...@@ -9,10 +9,10 @@ export function getBags() {
return axios.get('/store/goods/bags'); return axios.get('/store/goods/bags');
} }
export function barcodepay({ids, code, facepay, noBarcode}) { export function barcodepay({ids, code, facepay, noBarcode, openid}) {
return axios.post( return axios.post(
'/store/goods/barcodepay', '/store/goods/barcodepay',
qs.stringify({ids, code, facepay, noBarcode}), qs.stringify({ids, code, facepay, noBarcode, openid}),
); );
} }
......
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