index.vue 1.66 KB
Newer Older
程智春 committed
1
<template>
2
    <div class="text">
3 4
        <div v-if="loadFlag<=1">正在跳转到其他小程序...</div>
        <div v-else class="toMini" @click="toMini">点击跳转到其他小程序</div>
程智春 committed
5 6 7 8 9
    </div>
</template>

<script>
    export default {
10 11 12 13 14 15
        data(){
            return {
                loadFlag: 0,
                options: "",
            }
        },
程智春 committed
16
        onLoad(options){
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
            this.options = options;
            console.log("onLoad",this.loadFlag)
            this.toMini();
        },
        onShow(){
            this.loadFlag ++;
            console.log("onShow",this.loadFlag)
            this.toMini();
        },
        methods: {
            toMini(){
                let _this = this;
                wx.navigateToMiniProgram({
                    appId: _this.options.weappAppId,
                    path: decodeURIComponent(_this.options.weappPage),
                    // envVersion: 'release',
                    extraData: _this.options.extraData && JSON.parse(_this.options.extraData),
                    success(res) {
                        console.log(res,'--------打开成功')
                        // 打开成功
                    },
                    complete(res){
                        console.log(res,'------------------38')
                    }
                })
            }
程智春 committed
43 44 45 46 47
        }
    }
</script>

<style lang="scss" scoped>
48 49 50 51 52 53
.text{
    text-align: center;
    margin-top: 30px;
    font-size: 16px;
    color: #333;
}
54 55 56 57 58 59 60 61 62 63 64
.toMini{
    width: 60%;
    margin: 0 auto;
    margin-top: 40vh;
    height: 40px;
    line-height: 40px;
    padding: 0 30px;
    color: #fff;
    background: #41c867;
    border-radius: 40px;
}
程智春 committed
65
</style>