<template>
    <view class="flex direction-column height-100pre">
        <view class="flex grow-1 height-0 width-100per">
            <page-dispatch ref="child" :isDispatch="true"></page-dispatch>
        </view>
    </view>
</template>

<script>
    import request from '../../utils/request';
    import user from '../../utils/user';
    import extend from '../../utils/extend';

    let userinfo = user.get();

    let isLoading = false;

    let isPullDownRefresh = false;

    export default {
        data() {
            return {
            };
        },
        async onLoad() {
        },
        async onShow() {
            console.log('userinfo:', userinfo);
            this.getSelectWorkingTeam();
        },

        onPullDownRefresh() {
            if (!isLoading) {
                isPullDownRefresh = true;
                this.getOrders();
            }
        },
        methods: {
            async getOrders() {
                isLoading = true;
                await this.$refs.child.load();
                isLoading = false;
                if (isPullDownRefresh) {
                    uni.stopPullDownRefresh();
                    isPullDownRefresh = false;
                }
            },

            getSelectWorkingTeam() {
                let workingTeam = extend.readStorage('select_workingTeam');
                console.log('workingTeam: ', workingTeam);
                if (extend.isObject(workingTeam)) {
                    this.$refs.child.currentWorkingTeam = workingTeam;
                    extend.removeStorage('select_workingTeam');
                }
            }
        }
    }
</script>

<style lang="scss">

</style>