如何修复导航

时间:2019-05-22 12:59:37

标签: react-native

我正在设置一项新服务以导航到“聊天”服务,但它什么也没做,我也不知道为什么。

这是一个新组件

这是使用“ getCustomerService”功能的“ onCancel”按钮。

 handleUnrecognizedUser = () => {
        const infoMsg = {
            onCancel: getCustomerService
        };
    };

这是被调用的“ getCustomerService”函数

import { AppStore, RoutingStore } from '../../stores'
import call from 'react-native-phone-call'

callServeiceCenter = (number) => {
    const args = {
        number, // String value with the number to call
        prompt: false // Optional boolean property. Determines if the user should be prompt prior to the call 
    }
    return call(args).catch(console.error)
}

export default getCustomerService = () => {
    if (AppStore.isWorkingHours)
        RoutingStore.goTo('Chat')
    else {
        callServeiceCenter(AppStore.getCallCenterPhone)
    }
}

这是针对“ RoutingStore”的:



import { observable, action, computed } from "mobx";
import { NavigationActions, StackActions, DrawerActions } from 'react-navigation'

class RoutingStore {
    @observable nav = null;
    @observable PrevPage = null;
    @observable curentPage = null;
    @observable isGoBackAvailable = true;
    @observable isLoggedIn = false;

    @action
    setNavigation(data) {
        this.nav = data
    }

    goTo = (data, _params) => {
        let { routeName, params } = data
        const navigateAction = NavigationActions.navigate(
            routeName
                ? { routeName, params }
                : { routeName: data, params: { ..._params } })

        this.nav.dispatch(navigateAction)
    }

    @action
    goBack = () => {
    }

    @action
    updateCurrentPage(data) {
        this.curentPage = data
    }

    @action
    updatePrevPage(data) {
        this.PrevPage = data
    }

    updatePages = (prev, cur) => {
        this.updatePrevPage(prev)
        this.updateCurrentPage(cur)
    }

    @action
    setLoggedIn(status) {
        this.isLoggedIn = status
    }

    @action
    openDrawer() {
        this.nav.dispatch(DrawerActions.openDrawer())
    }

    @action
    closeDrawer() {
        this.nav.dispatch(DrawerActions.closeDrawer())
    }

    @action
    toggleDrawer() {
        this.nav.dispatch(DrawerActions.toggleDrawer())
    }

    disableLoginRoute = (route) => {
        const resetAction = StackActions.reset({
            index: 0,
            key: null,
            actions: [NavigationActions.navigate({ routeName: route })],
        });
        this.nav.dispatch(resetAction)
    }

    isGoBackAllowed = () => {
        switch (this.curentPage) {
            case "Tabs": return false
            case "Login": return false
            default: return this.goBack()
        }
    }

    @computed
    get isNonLogin() {
        return this.isLoggedIn;
    }

    @computed
    get getCurentPage() {
        return this.curentPage;
    }

}

const routingStore = new RoutingStore();
export default routingStore;

我也希望导航到聊天室。

0 个答案:

没有答案