<template>
    <!-- 内容 -->
    <view class="jy-mine-content">
        <!-- 卡片列表 -->
        <view class="card-list" v-for="(item, index) in cardList" :key="index">
            <!-- 卡片 标题 提示 -->
            <view class="card-item-top" v-if="item.left">
                <text class="card-item-text">{{ item.title }}</text>
                <view class="card-item-right" v-if="item.right" @click="goto('right', item)">
                    <text>{{ item.right_title }}</text>
                    <uni-icons v-if="item.right_icon" :type="item.right_icon"></uni-icons>
                </view>
            </view>
            <!-- 卡片 项 -->
            <view class="card-item-bottom">
                <view class="card-item-list" v-for="(item2, index2) in item.children" :key="index2"
                    @click="goto('item', item, item2)">
                    <image :src="item2.icon" class="card-item-list-item-icon" />
                    <text class="card-item-list-item-text wsn">{{ item2.title }}</text>
                </view>
            </view>
        </view>
    </view>
</template>
<script setup>
import { ref } from 'vue'
import mineDaifukuan from '@/static/mine-daifukuan.png'
import mineDaifahuo from '@/static/mine-daifahuo.png'
import mineDaishouhuo from '@/static/mine-daishouhuo.png'
import mineDaipingjia from '@/static/mine-daipingjia.png'
import mineTuikuanShouhou from '@/static/mine-tuikuan_shouhou.png'

import mineWodeshoucang from '@/static/mine-wodeshoucang.png'
import mineDianpushoucang from '@/static/mine-dianpushoucang.png'
import mineLishijilu from '@/static/mine-lishijilu.png'
import mineYouhuiquan from '@/static/mine-youhuiquan.png'

import mineRuzhushangjia from '@/static/mine-ruzhushangjia.png'
import mienDianpuguanli from '@/static/mien-dianpuguanli.png'
import mineDingdanguanli from '@/static/mine-dingdanguanli.png'
import mineKehuxiaoxi from '@/static/mine-kehuxiaoxi.png'
const goto = (type, item, item2) => {
    let url = ''
    switch (item.type) {
        case 'order':
            url = url + item.url
            switch (type) {
                case 'right':
                    url = item.url + '?currentTab=' + item.value
                    break;
                case 'item':
                    url = item.url + '?currentTab=' + item2.value
                    break;
                default:
                    break;
            }
            break;
        case 'historical':
            url = url + item2.url
            break;

        case 'merchants':
            url = url + item2.url
            break;
    }

    console.log(url);

    // 带参数跳转
    uni.navigateTo({
        url: url
    })
}

const cardList = ref([{
    left: true,
    title: '我的订单',
    right: true,
    right_icon: 'right',
    right_title: "全部",
    value: 1,
    url: '/pages/shop/order/index',
    type: 'order',
    children: [{
        icon: mineDaifukuan,
        title: '待付款',
        value: 2
    }, {
        icon: mineDaifahuo,
        title: '待发货',
        value: 3
    }, {
        icon: mineDaishouhuo,
        title: '待收货',
        value: 4
    }, {
        icon: mineDaipingjia,
        title: '待评价',
        value: 5
    }, {
        icon: mineTuikuanShouhou,
        title: '退款/售后',
        value: 6
    }]
}, {
    left: false,
    title: null,
    right: false,
    right_icon: null,
    right_title: null,
    type: 'historical',
    children: [{
        icon: mineWodeshoucang,
        title: '我的收藏',
        url: '/pages/mine/collection/index',

    }, {
        icon: mineDianpushoucang,
        title: '店铺收藏',
        url: '/pages/mine/target-store/index',
    }, {
        icon: mineLishijilu,
        title: '历史浏览',
        url: '/pages/mine/historical-browsing/index',

    }, {
        icon: mineYouhuiquan,
        title: '优惠券',
        url: '/pages/mine/coupon/index',

    }]
}, {
    left: true,
    title: '商家管理',
    right: false,
    right_icon: null,
    right_title: null,
    type: 'merchants',
    children: [{
        icon: mineRuzhushangjia,
        title: '入住商家',
        url: '/pages/shop/settle'
    }, {
        icon: mienDianpuguanli,
        title: '店铺管理',
        url: '/pages/merchant/business-operator/index'
    }, {
        icon: mineDingdanguanli,
        title: '订单管理',
        url: 'pages/merchant/order/index'
    }, {
        icon: mineKehuxiaoxi,
        title: '客户消息'
    }]
}])
</script>
<style scoped lang="scss">
.jy-mine-content {
    position: relative;
    z-index: 1;

    .card-list {
        background-color: #fff;
        padding: 16rpx 24rpx;
        border-radius: 20rpx;
        margin: 32rpx 0;

        .card-item-top {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 32rpx;

            .card-item-text {
                font-size: 32rpx;
                font-weight: 600;
            }

            .card-item-right {
                display: flex;
                flex-direction: row;
                align-items: center;
                color: #999999;
                font-size: 24rpx;

                text {
                    margin-right: 20rpx;
                }
            }
        }

        .card-item-bottom {
            //一行五列
            display: grid;
            grid-template-columns: repeat(5, 1fr);
            margin: 12rpx 0;

            .card-item-list {
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                margin: 0 26rpx;

                image {
                    width: 48rpx;
                    height: 48rpx;
                }

                text {
                    font-size: 24rpx;
                    color: #333333;
                    margin-top: 12rpx;
                }
            }
        }
    }
}
</style>