<template>
    <view
        @tap="onJumpPage"
    >
        <view class="new-year-return c-font-small c-gap-inner-right c-gap-inner-left-small"><c-icon name="left" font-size="12px"/>返回</view>
    </view>
</template>

<script>
/**
 * @file 活动返回
 * @author mayifan02
 * @categories 业务组件
 * @tags [component]
 */
/* global getApp */

import CIcon from '@baidu/med-ui/components/Icon/Icon';
import {navigate} from '@utils/navigate';

export default {
    options: {
        addGlobalClass: true
    },
    config: {
        component: true
    },
    components: {
        CIcon
    },
    created() {
        this.params = this.$api.getStorageSync('new-user-query');
        this.$api.removeStorage({key: 'new-user-query'});
    },
    props: {
        /**
         * 返回url
         */
        url: {
            type: String,
            default: ''
        }
    },
    data() {
        return {
            showPath: '',
            curpath: '',
            params: ''
        };
    },
    methods: {
        onJumpPage () {
            let openType = 'navigate';
            // 活动上一层页面是否为活动页
            /* eslint-disable */
            let pages = getCurrentPages();
            if (pages && pages.length >= 2 && pages[pages.length - 2].route.indexOf('pages/act') > -1) {
                navigate({
                    openType: 'navigateBack'
                });
                return;
            }

            const url = this.url || '/pages/act/new-user/index' + '?' + this.params;
            /* eslint-enable */
            navigate({
                url,
                openType
            });
        }
    }
};
</script>

<style lang="less" scoped>
.new-year-return {
    position: fixed;
    left: 0;
    bottom: 18%;
    line-height: 27px;
    z-index: 40;
    display: flex;
    align-items: center;
    color: #fff;
    background: #ff3b41;
    border-radius: 0 30px 30px 0;
    z-index: 1000;
}
</style>
