Commit 00d89c03 by zhonghao

弹窗优化3

parent 02273754
...@@ -24,6 +24,7 @@ import {qrHost} from '../utils/config'; ...@@ -24,6 +24,7 @@ import {qrHost} from '../utils/config';
import Icons from 'react-native-vector-icons/MaterialIcons'; import Icons from 'react-native-vector-icons/MaterialIcons';
import AutoClick from '../utils/AutoClick'; import AutoClick from '../utils/AutoClick';
import validity from '../utils/validity'; import validity from '../utils/validity';
import { simpleDebounce } from "../utils/tools";
@connect(({admin}) => ({admin})) @connect(({admin}) => ({admin}))
class FacePage extends Component { class FacePage extends Component {
...@@ -41,7 +42,7 @@ class FacePage extends Component { ...@@ -41,7 +42,7 @@ class FacePage extends Component {
tip: '', tip: '',
tipsModal: false, tipsModal: false,
faceType: 'wxpay', faceType: 'wxpay',
sleep: true, // 屏保模式 // sleep: true, // 屏保模式
loadingModal: false, loadingModal: false,
qrCode: '', qrCode: '',
goTipsModal: false, goTipsModal: false,
...@@ -52,9 +53,13 @@ class FacePage extends Component { ...@@ -52,9 +53,13 @@ class FacePage extends Component {
phone = ''; // 监听用户输入手机 phone = ''; // 监听用户输入手机
// 设备类型 // 设备类型
// sense = true; // 测试即拿刷脸设备 sense = true; // 测试即拿刷脸设备
async componentWillMount() { async componentWillMount() {
this.goodsCounterInter = setInterval(() => {
this.getOrderDetailMiniCounter();
}, 800);
this.orderDetailMiniPop(true);
this.storeKey = await AsyncStorage.getItem('KEY'); this.storeKey = await AsyncStorage.getItem('KEY');
let contact = await AsyncStorage.getItem('CONTACT'); let contact = await AsyncStorage.getItem('CONTACT');
let storeName = await AsyncStorage.getItem('NAME'); let storeName = await AsyncStorage.getItem('NAME');
...@@ -175,10 +180,11 @@ class FacePage extends Component { ...@@ -175,10 +180,11 @@ class FacePage extends Component {
orderDetailMini: true, orderDetailMini: true,
}); });
this.goodsCounterTimer = setTimeout(() => { this.goodsCounterTimer = setTimeout(() => {
let data = [];
clearInterval(this.goodsCounterInter); clearInterval(this.goodsCounterInter);
this.setState({ this.setState({
orderDetailMini: false, orderDetailMini: false,
goodsArr: [], goodsArr: data,
}); });
}, timeout); }, timeout);
}; };
...@@ -190,10 +196,12 @@ class FacePage extends Component { ...@@ -190,10 +196,12 @@ class FacePage extends Component {
const {data} = await this.props.dispatch({ const {data} = await this.props.dispatch({
type: 'goods/getOrderCounter', type: 'goods/getOrderCounter',
}); });
if (data.length !== 0) { if(data.length !== 0){
simpleDebounce(() => {
this.setState({ this.setState({
goodsArr: data, goodsArr: data,
}); });
}, 1000)
} }
} catch (error) { } catch (error) {
Toast.show('当前网络存在异常'); Toast.show('当前网络存在异常');
...@@ -393,9 +401,10 @@ class FacePage extends Component { ...@@ -393,9 +401,10 @@ class FacePage extends Component {
} else if (this.sense) { } else if (this.sense) {
this.setState({loadingModal: false}); this.setState({loadingModal: false});
if (ret.action === 'enter') { if (ret.action === 'enter') {
// 轮询获取订单数据
this.goodsCounterInter = setInterval(() => { this.goodsCounterInter = setInterval(() => {
this.getOrderDetailMiniCounter(); this.getOrderDetailMiniCounter();
}, 3000); }, 500);
this.orderDetailMiniPop(600000); // 十分钟后关闭弹窗 this.orderDetailMiniPop(600000); // 十分钟后关闭弹窗
} }
} }
......
/**
* 简单防抖
* @param {Function} 防抖回调函数
* @param {Number} 触发时间
*/
export function simpleDebounce(fn, delay = 500) {
let timer = null;
return function() {
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
fn.apply(this, arguments);
timer = null;
}, delay);
};
}
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