Commit 0fb65816 by 黄日华

设置无码商品,刷卡切换

parent 468dc578
......@@ -53,6 +53,9 @@ export default {
? yield call(api.token, action)
: yield call(api.refreshToken);
if (data && data.code === 1) {
if (data.data && data.data.closeNoBarcode) {
yield call(AsyncStorage.setItem, 'closeNoBarcode', '1');
}
if (data.data && data.data.type) {
// 设备类型
yield call(AsyncStorage.setItem, 'STYPE', data.data.type);
......
......@@ -76,6 +76,7 @@ const CounterMixins = ComposeComponent => {
numberValue: '',
human: false,
totalNum: 0,
hasCard: false,
};
componentWillMount = async () => {
......@@ -187,8 +188,9 @@ const CounterMixins = ComposeComponent => {
const state = {priceVisible: data.data.priceVisible};
if (data.data.cardCounter) {
// 是否支持刷卡
state.isCard = true;
window.cardCounter = data.data.cardCounter;
// state.isCard = true;
// window.cardCounter = data.data.cardCounter;
state.hasCard = true;
}
if (data.data.logo) state.logo = `${ossLink}/${data.data.logo}`;
this.setState(state);
......
......@@ -39,6 +39,8 @@ window.restart = Restart.restartApp;
let pageSize = 8; // 分页大小
window.pageSize = pageSize;
let cardCount = 0;
class VerticalPage extends Component {
state = {
contact: '',
......@@ -51,17 +53,20 @@ class VerticalPage extends Component {
logoVisible: true,
logo: '',
priceVisible: true,
isCard: false,
isCard: 0,
cardVisible: false,
noBuyModal: false,
hasCard: false,
closeNoBarcode: 0,
};
async componentWillMount() {
let stype = await AsyncStorage.getItem('STYPE');
let contact = await AsyncStorage.getItem('CONTACT');
let closeNoBarcode = await AsyncStorage.getItem('closeNoBarcode');
// let lock = await AsyncStorage.getItem('settingLock');
// if (lock) this.props.dispatch({ type: 'app/lock', lock });
this.setState({stype, contact});
this.setState({stype, contact, closeNoBarcode: Number(closeNoBarcode)});
this.storeKey = await AsyncStorage.getItem('KEY');
if (!this.init) {
this.init = await WxFacepay.initialize(10000);
......@@ -154,8 +159,14 @@ class VerticalPage extends Component {
const state = {priceVisible: data.data.priceVisible};
if (data.data.cardCounter) {
// 是否支持刷卡
state.isCard = true;
window.cardCounter = data.data.cardCounter;
// state.isCard = true;
// window.cardCounter = data.data.cardCounter;
this.hasCardCounter = data.data.cardCounter;
state.hasCard = true;
state.isCard = Number((await AsyncStorage.getItem('isCard')) || 0);
if (state.isCard) {
window.cardCounter = this.hasCardCounter;
}
}
if (data.data.logo) state.logo = `${ossLink}/${data.data.logo}`;
this.setState(state);
......@@ -586,6 +597,36 @@ class VerticalPage extends Component {
}, 30000);
};
cardFirstStep = () => {
cardCount++;
if (cardCount === 3 && this.state.hasCard) {
this.setState({
isCard: 1,
});
window.cardCounter = this.hasCardCounter;
AsyncStorage.setItem('isCard', '1');
cardCount = 0;
}
setTimeout(() => {
cardCount = 0;
}, 2000);
};
cardSecondStep = () => {
cardCount++;
if (cardCount === 3 && this.state.hasCard) {
this.setState({
isCard: 0,
});
window.cardCounter = null;
AsyncStorage.setItem('isCard', '0');
cardCount = 0;
}
setTimeout(() => {
cardCount = 0;
}, 2000);
};
render() {
let {
admin,
......@@ -606,6 +647,7 @@ class VerticalPage extends Component {
stype,
isCard,
noBuyModal,
closeNoBarcode,
} = this.state;
pageSize =
goods && goods.bags.length > 0
......@@ -722,6 +764,7 @@ class VerticalPage extends Component {
justifyContent: 'flex-end',
alignItems: 'center',
}}>
{!closeNoBarcode ? (
<Touch onPress={() => this.props.handleCodeless()}>
<View
style={[
......@@ -731,6 +774,14 @@ class VerticalPage extends Component {
<Text style={styles.callText}>无码商品</Text>
</View>
</Touch>
) : (
<View
style={[
styles.guardModal_button_nobuy,
{marginRight: 50, opacity: 0},
]}
/>
)}
<Touch onPress={() => this.props.handleBarcode()}>
<View style={styles.guardModal_button_nobuy}>
<Text style={styles.callText}>输入条码</Text>
......@@ -1006,7 +1057,7 @@ class VerticalPage extends Component {
style={{backgroundColor: '#fc4000', marginRight: 50}}>
<Text style={styles.btnText}>输入条码</Text>
</Touch>
{priceVisible && (
{priceVisible && !closeNoBarcode && (
<Touch
onPress={() => this.props.handleCodeless()}
style={{
......@@ -1138,10 +1189,12 @@ class VerticalPage extends Component {
</View>
<View style={styles.paymentRight}>
{isCard ? (
<Touch onPress={() => this.cardSecondStep()}>
<Image
style={{width: scaleSize(200), height: scaleSize(200)}}
source={require('../assets/logo2.png')}
/>
</Touch>
) : (
<View style={styles.paymentRightTitle}>
<View style={styles.paymentRightContents}>
......@@ -1158,6 +1211,7 @@ class VerticalPage extends Component {
alt=""
/>
</View>
<Touch onPress={() => this.cardFirstStep()}>
<View style={styles.paymentRightCode}>
<QRCode
logoSize={width > 801 ? 60 : scaleSize(75)}
......@@ -1169,6 +1223,7 @@ class VerticalPage extends Component {
}`}
/>
</View>
</Touch>
</View>
)}
</View>
......
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