Commit caa79788 by zeven

Merge remote-tracking branch 'origin/hzp'

parents 812f54db 7b025397
export default {
namespace: 'card',
state: false,
reducers: {
change(bool) {
return !bool;
},
},
};
...@@ -99,5 +99,8 @@ export default { ...@@ -99,5 +99,8 @@ export default {
*getOrderCounter(action, {call}) { *getOrderCounter(action, {call}) {
return yield call(api.getOrderCounter, action); return yield call(api.getOrderCounter, action);
}, },
*cardPay(action, {call}) {
return yield call(api.cardPay, action);
},
}, },
}; };
...@@ -11,6 +11,7 @@ import store from './store'; ...@@ -11,6 +11,7 @@ import store from './store';
import agora from './agora'; import agora from './agora';
import lucky from './lucky'; import lucky from './lucky';
import searchGoods from './searchGoods'; import searchGoods from './searchGoods';
import card from './card';
const {width: _width, height: _height} = Dimensions.get('window'); const {width: _width, height: _height} = Dimensions.get('window');
...@@ -79,4 +80,5 @@ export default [ ...@@ -79,4 +80,5 @@ export default [
agora, agora,
lucky, lucky,
searchGoods, searchGoods,
card,
]; ];
...@@ -125,6 +125,32 @@ const CounterMixins = ComposeComponent => { ...@@ -125,6 +125,32 @@ const CounterMixins = ComposeComponent => {
this.listen(); this.listen();
}; };
handleCard = async cardId => {
Toast.hide();
Toast.loading('正在付款,请稍后~');
const {ids, noBarcode} = this.getGoods();
this.props
.dispatch({
type: 'goods/cardPay',
ids,
noBarcode,
cardId,
})
.then(async ({data}) => {
console.log(data);
if (data.code === 1) {
this.orderId = data.data.orderId;
await this.successPay(true);
} else {
Toast.hide();
Speech.speak(data.msg);
}
});
setTimeout(() => {
this.setState({voiceModal: false});
}, 2000);
};
componentWillUnmount = () => { componentWillUnmount = () => {
clearInterval(this.clearListInter); clearInterval(this.clearListInter);
clearInterval(this.payInter); clearInterval(this.payInter);
...@@ -555,6 +581,9 @@ const CounterMixins = ComposeComponent => { ...@@ -555,6 +581,9 @@ const CounterMixins = ComposeComponent => {
}; };
submitBarcode = async barcode => { submitBarcode = async barcode => {
if (this.props.card) {
return await this.handleCard(barcode || this.barcode);
}
this.errGood = null; this.errGood = null;
if (!window.auth) { if (!window.auth) {
const msg = '系统未授权,无法查询商品'; const msg = '系统未授权,无法查询商品';
...@@ -994,7 +1023,12 @@ const CounterMixins = ComposeComponent => { ...@@ -994,7 +1023,12 @@ const CounterMixins = ComposeComponent => {
}; };
} }
return connect(({goods, admin, store}) => ({goods, admin, store}))(Mixins); return connect(({goods, admin, store, card}) => ({
goods,
admin,
store,
card,
}))(Mixins);
}; };
const CloseButton = ({onClose, style}) => { const CloseButton = ({onClose, style}) => {
......
...@@ -5,7 +5,6 @@ import Swiper from 'react-native-swiper'; ...@@ -5,7 +5,6 @@ import Swiper from 'react-native-swiper';
import QRCode from 'react-native-qrcode-svg'; import QRCode from 'react-native-qrcode-svg';
import Icon from 'react-native-vector-icons/Ionicons'; import Icon from 'react-native-vector-icons/Ionicons';
import Icons from 'react-native-vector-icons/MaterialIcons'; import Icons from 'react-native-vector-icons/MaterialIcons';
// import { connect } from 'react-redux';
import CounterMixins from './CounterMixins'; import CounterMixins from './CounterMixins';
import NP from '../utils/np'; import NP from '../utils/np';
import AutoClick from '../utils/AutoClick'; import AutoClick from '../utils/AutoClick';
...@@ -38,7 +37,6 @@ window.pageSize = pageSize; ...@@ -38,7 +37,6 @@ window.pageSize = pageSize;
// const wait = t => new Promise(resolve => setTimeout(resolve, t)); // const wait = t => new Promise(resolve => setTimeout(resolve, t));
// @connect(({ app }) => ({ app }))
class VerticalPage extends Component { class VerticalPage extends Component {
state = { state = {
contact: '', contact: '',
...@@ -51,6 +49,7 @@ class VerticalPage extends Component { ...@@ -51,6 +49,7 @@ class VerticalPage extends Component {
logoVisible: true, logoVisible: true,
logo: '', logo: '',
priceVisible: true, priceVisible: true,
isCard: false,
}; };
async componentWillMount() { async componentWillMount() {
...@@ -139,6 +138,12 @@ class VerticalPage extends Component { ...@@ -139,6 +138,12 @@ class VerticalPage extends Component {
group, group,
}); });
if (data.code === 1 && data.data) { if (data.code === 1 && data.data) {
if (data.data.cardCounter) {
// 是否支持刷卡
this.setState({
isCard: true,
});
}
await this.setState({ await this.setState({
logo: `${ossLink}/${data.data.logo}`, logo: `${ossLink}/${data.data.logo}`,
priceVisible: data.data.priceVisible, priceVisible: data.data.priceVisible,
...@@ -540,6 +545,14 @@ class VerticalPage extends Component { ...@@ -540,6 +545,14 @@ class VerticalPage extends Component {
} }
}; };
cardPayPay = async () => {
Speech.speak('请刷卡');
Toast.loading('请刷卡', 2000, () => {
this.props.dispatch({type: 'card/change'});
});
this.props.dispatch({type: 'card/change'});
};
render() { render() {
let { let {
admin, admin,
...@@ -557,6 +570,7 @@ class VerticalPage extends Component { ...@@ -557,6 +570,7 @@ class VerticalPage extends Component {
logo, logo,
priceVisible, priceVisible,
stype, stype,
isCard,
} = this.state; } = this.state;
pageSize = pageSize =
goods && goods.bags.length > 0 goods && goods.bags.length > 0
...@@ -897,14 +911,16 @@ class VerticalPage extends Component { ...@@ -897,14 +911,16 @@ class VerticalPage extends Component {
{/* })}*/} {/* })}*/}
{/*</View>*/} {/*</View>*/}
<View style={styles.shadow} /> <View style={styles.shadow} />
<Touch onPress={facepay}> <Touch onPress={isCard ? this.cardPayPay : facepay}>
<View style={styles.guide}> <View style={styles.guide}>
<Text style={styles.guideText}>点击进入</Text> <Text style={styles.guideText}>点击进入</Text>
<Image <Image
source={require('../assets/down.png')} source={require('../assets/down.png')}
style={styles.down} style={styles.down}
/> />
<Text style={styles.guideText}>人脸支付</Text> <Text style={styles.guideText}>
{isCard ? '刷卡支付' : '人脸支付'}
</Text>
</View> </View>
</Touch> </Touch>
<View style={styles.payment}> <View style={styles.payment}>
...@@ -935,24 +951,35 @@ class VerticalPage extends Component { ...@@ -935,24 +951,35 @@ class VerticalPage extends Component {
</View> </View>
</View> </View>
<View style={styles.faceScan}> <View style={styles.faceScan}>
<Touch onPress={facepay}> <Touch onPress={isCard ? this.cardPayPay : facepay}>
<View> <View>
<Image {isCard ? (
source={require('../assets/Vertical/face.gif')} <Image
style={styles.faceGif} source={require('../assets/Vertical/card.png')}
alt="" alt=""
/> />
<View style={styles.facePay}> ) : (
<Image <Image
source={ source={require('../assets/Vertical/face.gif')}
this.state.faceType === 'wxpay' style={styles.faceGif}
? require('../assets/Vertical/wxpay.png')
: require('../assets/Vertical/alipay01.png')
}
style={styles.payImage}
alt="" alt=""
/> />
<Text style={styles.payText}>点击刷脸支付</Text> )}
<View style={styles.facePay}>
{!isCard && (
<Image
source={
this.state.faceType === 'wxpay'
? require('../assets/Vertical/wxpay.png')
: require('../assets/Vertical/alipay01.png')
}
style={styles.payImage}
alt=""
/>
)}
<Text style={styles.payText}>
{isCard ? '点击刷卡支付' : '点击刷脸支付'}
</Text>
</View> </View>
</View> </View>
</Touch> </Touch>
...@@ -995,7 +1022,7 @@ class VerticalPage extends Component { ...@@ -995,7 +1022,7 @@ class VerticalPage extends Component {
<Text style={styles.explainText2}>2</Text> <Text style={styles.explainText2}>2</Text>
</View> </View>
<Text style={styles.explainText1}> <Text style={styles.explainText1}>
微信/支付宝扫二维码或付款码付款 {isCard ? '刷卡付款' : '微信/支付宝扫二维码或付款码付款'}
</Text> </Text>
</View> </View>
</View> </View>
......
...@@ -78,3 +78,7 @@ export function balancePay(action) { ...@@ -78,3 +78,7 @@ export function balancePay(action) {
export function getOrderCounter() { export function getOrderCounter() {
return axios.get('/store/goods/counter'); return axios.get('/store/goods/counter');
} }
export function cardPay(action) {
return axios.post('/store/goods/cardPay', qs.stringify(action));
}
...@@ -5891,6 +5891,18 @@ react-native-qrcode-svg@6.0.6: ...@@ -5891,6 +5891,18 @@ react-native-qrcode-svg@6.0.6:
prop-types "^15.5.10" prop-types "^15.5.10"
qrcode "^1.3.2" qrcode "^1.3.2"
react-native-root-modal@^5.0.1:
version "5.0.1"
resolved "https://registry.npm.taobao.org/react-native-root-modal/download/react-native-root-modal-5.0.1.tgz#8b49f523f70732f1697961edc42174f81259e6c1"
integrity sha1-i0n1I/cHMvFpeWHtxCF0+BJZ5sE=
dependencies:
react-native-root-siblings "^4.0.0"
react-native-root-siblings@^4.0.0:
version "4.1.1"
resolved "https://registry.nlark.com/react-native-root-siblings/download/react-native-root-siblings-4.1.1.tgz#b7742db7634a87f507eb99a5fd699c4f10c46ab0"
integrity sha1-t3Qtt2NKh/UH65ml/WmcTxDEarA=
react-native-svg@12.1.0: react-native-svg@12.1.0:
version "12.1.0" version "12.1.0"
resolved "https://registry.npm.taobao.org/react-native-svg/download/react-native-svg-12.1.0.tgz#acfe48c35cd5fca3d5fd767abae0560c36cfc03d" resolved "https://registry.npm.taobao.org/react-native-svg/download/react-native-svg-12.1.0.tgz#acfe48c35cd5fca3d5fd767abae0560c36cfc03d"
......
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