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 {
*getOrderCounter(action, {call}) {
return yield call(api.getOrderCounter, action);
},
*cardPay(action, {call}) {
return yield call(api.cardPay, action);
},
},
};
......@@ -11,6 +11,7 @@ import store from './store';
import agora from './agora';
import lucky from './lucky';
import searchGoods from './searchGoods';
import card from './card';
const {width: _width, height: _height} = Dimensions.get('window');
......@@ -79,4 +80,5 @@ export default [
agora,
lucky,
searchGoods,
card,
];
......@@ -125,6 +125,32 @@ const CounterMixins = ComposeComponent => {
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 = () => {
clearInterval(this.clearListInter);
clearInterval(this.payInter);
......@@ -555,6 +581,9 @@ const CounterMixins = ComposeComponent => {
};
submitBarcode = async barcode => {
if (this.props.card) {
return await this.handleCard(barcode || this.barcode);
}
this.errGood = null;
if (!window.auth) {
const msg = '系统未授权,无法查询商品';
......@@ -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}) => {
......
......@@ -5,7 +5,6 @@ import Swiper from 'react-native-swiper';
import QRCode from 'react-native-qrcode-svg';
import Icon from 'react-native-vector-icons/Ionicons';
import Icons from 'react-native-vector-icons/MaterialIcons';
// import { connect } from 'react-redux';
import CounterMixins from './CounterMixins';
import NP from '../utils/np';
import AutoClick from '../utils/AutoClick';
......@@ -38,7 +37,6 @@ window.pageSize = pageSize;
// const wait = t => new Promise(resolve => setTimeout(resolve, t));
// @connect(({ app }) => ({ app }))
class VerticalPage extends Component {
state = {
contact: '',
......@@ -51,6 +49,7 @@ class VerticalPage extends Component {
logoVisible: true,
logo: '',
priceVisible: true,
isCard: false,
};
async componentWillMount() {
......@@ -139,6 +138,12 @@ class VerticalPage extends Component {
group,
});
if (data.code === 1 && data.data) {
if (data.data.cardCounter) {
// 是否支持刷卡
this.setState({
isCard: true,
});
}
await this.setState({
logo: `${ossLink}/${data.data.logo}`,
priceVisible: data.data.priceVisible,
......@@ -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() {
let {
admin,
......@@ -557,6 +570,7 @@ class VerticalPage extends Component {
logo,
priceVisible,
stype,
isCard,
} = this.state;
pageSize =
goods && goods.bags.length > 0
......@@ -897,14 +911,16 @@ class VerticalPage extends Component {
{/* })}*/}
{/*</View>*/}
<View style={styles.shadow} />
<Touch onPress={facepay}>
<Touch onPress={isCard ? this.cardPayPay : facepay}>
<View style={styles.guide}>
<Text style={styles.guideText}>点击进入</Text>
<Image
source={require('../assets/down.png')}
style={styles.down}
/>
<Text style={styles.guideText}>人脸支付</Text>
<Text style={styles.guideText}>
{isCard ? '刷卡支付' : '人脸支付'}
</Text>
</View>
</Touch>
<View style={styles.payment}>
......@@ -935,24 +951,35 @@ class VerticalPage extends Component {
</View>
</View>
<View style={styles.faceScan}>
<Touch onPress={facepay}>
<Touch onPress={isCard ? this.cardPayPay : facepay}>
<View>
<Image
source={require('../assets/Vertical/face.gif')}
style={styles.faceGif}
alt=""
/>
<View style={styles.facePay}>
{isCard ? (
<Image
source={require('../assets/Vertical/card.png')}
alt=""
/>
) : (
<Image
source={
this.state.faceType === 'wxpay'
? require('../assets/Vertical/wxpay.png')
: require('../assets/Vertical/alipay01.png')
}
style={styles.payImage}
source={require('../assets/Vertical/face.gif')}
style={styles.faceGif}
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>
</Touch>
......@@ -995,7 +1022,7 @@ class VerticalPage extends Component {
<Text style={styles.explainText2}>2</Text>
</View>
<Text style={styles.explainText1}>
微信/支付宝扫二维码或付款码付款
{isCard ? '刷卡付款' : '微信/支付宝扫二维码或付款码付款'}
</Text>
</View>
</View>
......
......@@ -78,3 +78,7 @@ export function balancePay(action) {
export function getOrderCounter() {
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:
prop-types "^15.5.10"
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:
version "12.1.0"
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