How to distinguish the source channel of router.push jump fast application

Phenomenon description:

Jump from a fast app a to the B1 page of B fast app. A may be a fast app or a card with a negative screen. How can you tell which one comes from?

Solution:
fast application and card jump to other fast applications through router.push interface, which is realized by using the HAP link in deeplink. At the same time, parameters can be carried in the HAP link, and a flag parameter can be added when skipping. Parameters can be obtained from B1 page of B fast application. According to the parameter value, whether the source is a negative screen card or fast application a can be judged, Then do the corresponding logic processing according to the needs. Fast application uses this.xx to get parameters carried by jump.

Example code:
a fast application code:

<template>
    <div>
        <text class="button" onclick="router">test</text>
    </div>
</template>
<style>
    .button{
        width: 100%;
        height: 200px;
        color: #000000;
        font-size: 80px;
    }
</style>
<script>
    import router from '@system.router';
    module.exports = {
        data: {
            
        },
        onInit() {
            this.$page.setTitleBar({ text: '' })
        },
        router(){
            console.log("router");
            router.push({
                uri: 'hap://app/com.huawei.ceshi/Test?body=quickapp',
            })
        }
    }
</script>

Card related codes:

<template>
    <div>
        <text class="button" onclick="router">测试</text>
    </div>
</template>
<style>
    .button{
        width: 100%;
        height: 200px;
        color: #000000;
        font-size: 80px;
    }
</style>
<script>
    import router from '@system.router';
    module.exports = {
        data: {
            
        },
        onInit() {
            this.$page.setTitleBar({ text: '' })
        },
        router(){
            console.log("router");
            router.push({
                uri: 'hap://app/com.huawei.ceshi/Test?body=card',
            })
        }
    }
</script>

B fast application code:

In the oninit() life cycle method, the parameter value is obtained. In the following code, the accept variable is defined to receive the parameter value. For example, in the onbackpress() method, different business logic is implemented according to the source.

<template>
    <div style="flex-direction: column;">
        <text class="text">datas</text>
        <text class="text" style="background-color: black">{{accept}}</text>
    </div>
</template>
<style>
    .text {
        height: 80px;
        font-size: 50px;
        color: red;
        width: 500px;
    }
</style>
<script>
    import router from '@system.router';
    module.exports = {
        data: {
            accept: ""
        },
        onInit() {
            this.$page.setTitleBar({ text: '' })
            this.accept = this.body;
        },
        onBackPress() {
            if (this.accept === "quickapp") {
                console.log("this is quickapp");
            } else if (this.accept === "quickapp") {
                console.log("this is crad");
            }else{
                router.back()
            }
            return true;
        }
    }
</script>


Read More: