Commit 00d89c03 by zhonghao

弹窗优化3

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