<template>
    <!-- 广告服务 -->
    <div>
        <!-- 广告页面头部 -->
        <AdvertisingHead></AdvertisingHead>
        <div class="adDetail">
            <div class="inner">
                <!-- 标题 -->
                <h3>广告基本信息</h3>
                <!-- 工单头部 -->
                <div class="order">
                    <div class="title">
                        <span class="status left">{{ statusStore.orderStatus[order.status] }}</span>
                        <!-- <span class="status left">{{ order.status }}</span> -->
                        <span class="code left"> 
                            工单编号:
                            <span>{{ order.order_num }}</span>
                        </span>
                        <span class="createTime right">{{ order.created_at }}</span>
                    </div>
                    <!-- 工单内容 -->
                    <div class="text">
                        <span>开始时间:{{ order.sttime }}</span>
                        <span>结束时间:{{ order.edtime }}</span>
                        <span>
                            <span class="money">{{ order.price ? order.price : 260 }}</span>
                            元
                        </span>
                        <button @click="goReapply">再次申请</button>
                    </div>
                </div>

                <div class="detail">
                    <el-table :data="orderDetail" style="width: 100%">
                        <el-table-column prop="" label="图片信息" align="center">
                            <template #default="scope">
                                <div class="content">
                                    <img :src="scope.row.image_src" alt="" class="left">
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="" label="">
                            <template #default="scope">
                                <div class="content">
                                    <h5>{{ scope.row.apname }}</h5>
                                    <p>{{ scope.row.adname }}</p>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="website_name" label="网址" width="200px" align="center" />
                        <el-table-column prop="days" label="天数" width="200px" align="center" />
                        <el-table-column prop="state" label="审核状态" width="200px" align="center" />
                        <el-table-column prop="ad_status" label="广告状态" width="200px" align="center" />
                    </el-table>
                </div>

                <div class="pagination">
                    <HomePagination></HomePagination>
                </div>
            </div>

        </div>
        <!-- 广告页面底部 -->
        <AdvertisingFoot></AdvertisingFoot>
    </div>
</template>

<script setup>
import { onMounted } from 'vue';
import { ElTable, ElTableColumn } from 'element-plus'
import { useStatusStore } from "@/store/status.js"

const statusStore = useStatusStore()

// axios请求
const nuxtApp = useNuxtApp();
const axios = nuxtApp.$axios;

//工单列表页面跳转传递到的参数
let route = useRoute()
let order_id = route.query.id
let days = route.query.days
let state = route.query.status
let ad_status = route.query.status
console.log(order_id);

let pageSize = useState("pageSize", () => 10)
let page = useState("page", () => 1)


let order = useState("order", () => "")
let orderDetail = useState("orderDetail", () => "")
let newArr = useState("newArr", () => "")


// 获取订单详情
const getOrderDetail = async () => {
    try {
        const response = await axios.get(`/order/getOrderDetail?order_id=${order_id}&pageSize=${pageSize.value}&page=${page.value}`);
        // console.log(response.data);
        order.value = response.data.order
        orderDetail.value = response.data.orderads

        // 将state和days添加到orderDetail里面
        newArr.value = orderDetail.value.map((item) => {
            item.state = statusStore.orderStatus[state]  //审核状态
            // item.state = state  //审核状态
            // item.ad_status =ad_status //广告状态
            item.ad_status = statusStore.adStatus[ad_status]  //广告状态
            item.days = days + '天' // 过期时间
            return item
        })

    } catch (error) {
        console.error(error);
    }
}

let goReapply=()=>{
    navigateTo('/advertising')
}

onMounted(() => {
    // 获取订单详情
    getOrderDetail()
})





</script>

<style lang="less" scoped>
.adDetail {
    width: 100%;
    overflow: hidden;

    .inner {
        width: 1200px;
        overflow: hidden;

        h3 {
            font-family: Microsoft YaHei, Microsoft YaHei;
            font-weight: 400;
            font-size: 20px;
            color: #333333;
            margin: 40px 0;
        }

        .order {
            width: 1198px;
            height: 160px;
            border: 1px solid #e1e1e1;

            .title {
                height: 60px;
                line-height: 30px;
                border-bottom: 1px solid #e1e1e1;
                padding: 15px 24px 15px 50px;
                box-sizing: border-box;
                background-color: #fafafa;

                >span {
                    display: inline-block;
                    text-align: center;
                    font-family: Microsoft YaHei, Microsoft YaHei;
                }

                .status {
                    width: 70px;
                    height: 32px;
                    line-height: 32px;
                    margin-right: 50px;
                    background: #d5ecd2;
                    color: #33B023;
                    font-weight: 400;
                    font-size: 16px;
                }

                .code {
                    font-weight: 400;
                    font-size: 16px;
                    color: #333333;
                }

                .createTime {
                    font-weight: bold;
                    font-size: 16px;
                    color: #333333;
                }
            }

            .text {
                padding: 33px 70px 33px 50px;
                position: relative;

                span {
                    font-weight: 400;
                    font-size: 16px;
                    color: #333333;

                    .money {
                        font-weight: bold;
                        font-size: 24px;
                        color: #028E21;
                        padding-right: 10px;
                    }
                }

                >span:first-child {
                    padding-right: 80px;
                }

                >span:nth-child(2) {
                    padding-right: 200px;
                }

                >span:nth-child(3) {
                    padding-right: 183px;
                }

                button {
                    width: 82px;
                    height: 34px;
                    font-size: 13px;
                    background: #33B023;
                    color: #fff;
                    border: none;
                    border-radius: 4px;
                    position: absolute;
                    right: 70px;
                    top: 32px;
                }
            }

        }

        .detail {
            width: 1198px;
            overflow: hidden;
            border-right: 1px solid #e1e1e1;
            border-left: 1px solid #e1e1e1;

            /deep/.el-table .cell {
                box-sizing: border-box;
                line-height: 23px;
                overflow: hidden;
                overflow-wrap: break-word;
                padding: 12px 12px;
                text-overflow: ellipsis;
                white-space: normal;
                font-size: 16px;
                font-weight: 400;
            }

            /deep/.el-table__header th {
                color: #999999;
                /* 设置表头颜色 */
            }

            /deep/.el-table__body td {
                color: #333333;
                /* 设置表格内容字体颜色 */
            }

            .content {
                height: 95px;

                >img {
                    width: 150px;
                    height: 95px;
                    margin: 20px;
                }

                >h5 {
                    // margin-top: 20px;
                    width: 170px;
                    font-family: Microsoft YaHei, Microsoft YaHei;
                    color: #333333;
                    margin-bottom: 20px;
                    font-weight: 400;
                    font-size: 16px;
                }

                >p {
                    // margin-top: 40px;
                    width: 170px;
                    font-family: Microsoft YaHei, Microsoft YaHei;
                    font-weight: 400;
                    font-size: 16px;
                    color: #333333;
                }

            }

        }

        .pagination {
            margin-top: 60px;
            margin-bottom: 90px;
        }




    }

}
</style>