<template>
    <div class="page">
        <NavBar
            :showIcon="true"
            :showTitle="true"
            backIcon="#fff"
            textColor="#fff"
            title="邀请面试"
            backgroundBox="transparent"
        ></NavBar>
        <view class="bg"></view>

        <view class="card">
            <image src="@/static/image/user/default-avatar.png" mode="" />
            <view class="name">{{ data.realName || "无" }}</view>
            <view class="school">贵州大学·心理学</view>
            <view class="info-list">
                <view class="info flex-between">
                    <veiw class="label">面试时间</veiw>
                    <wd-datetime-picker
                        v-model="date"
                        style="z-index: 999 !important"
                        :min-date="new Date(new Date().setHours(0, 0, 0, 0)).getTime()"
                        use-default-slot
                        label="日期选择"
                        @confirm="dateConfirm"
                    >
                        <view class="data">{{ date ? dayjs(date).format("YYYY-MM-DD HH:mm") : "选择面试时间" }}</view>
                    </wd-datetime-picker>
                    <view class="arrow"></view>
                </view>
                <view class="info flex-between">
                    <veiw class="label">面试职位</veiw>
                    <view class="data">{{ data.jobName }}，{{ data.salary }}</view>
                    <view class="arrow"></view>
                </view>
                <view class="info flex-between">
                    <veiw class="label">联系人</veiw>
                    <view class="data">{{ data.contactPerson }}</view>
                    <view class="arrow"></view>
                </view>
                <view class="info flex-between">
                    <veiw class="label">联系电话</veiw>
                    <view class="data">{{ data.contactPhone }}</view>
                    <view class="arrow"></view>
                </view>
                <view class="info flex-between">
                    <veiw class="label">面试地址</veiw>
                    <view class="data">{{ data.address }}</view>
                    <view class="arrow"></view>
                </view>
                <map id="mapId" class="map" :latitude="mapCenter.latitude" :longitude="mapCenter.longitude" :markers="markers">
                </map>
            </view>
        </view>

        <view class="btn-wrap">
            <button class="bottom-btn" @click="submit">确定邀请</button>
        </view>
    </div>
</template>

<script setup>
import dayjs from "dayjs";
import { getApplicationByIdApi, inviteInterviewApi } from "@/api/postion";
import { reactive, ref } from "vue";
const date = ref("");
const dateConfirm = e => {
    console.log(e);
};
const data = ref({});
onLoad(({ id }) => {
    getApplicationByIdApi(id).then(res => {
        data.value = res.data;
    });
});
const back = () => {
    uni.navigateBack();
};
let mapCenter = reactive({
    latitude: 26.63,
    longitude: 106.67
});
// 地图点
let markers = reactive([
    {
        id: 1,
        latitude: 26.63,
        longitude: 106.67,
        width: 16,
        height: 20,
        iconPath: new URL("@/static/image/icon/markers.png", import.meta.url).href,
        callout: {
            content: "观山湖区高新区产业技术发展研究院",
            borderRadius: 2,
            padding: 7,
            display: "ALWAYS",
            textAlign: "center",
            bgColor: "#fff",
            color: "#000"
        }
    }
]);

const submit = () => {
    if (!date.value) {
        uni.showToast({
            title: "请选择面试时间",
            icon: "none"
        });
        return;
    }
    inviteInterviewApi({
        ...data.value,
        interviewTime: date.value
    }).then(res => {
        console.log(res);
        if (res.code === 200) {
            uni.showToast({
                title: "邀请成功",
                icon: "none"
            });
            uni.navigateBack();
        }
    });
};
</script>

<style lang="scss" scoped>
.page {
    height: 100%;
}
.nav-bar {
    .arrow {
        width: 20rpx;
        height: 20rpx;
        border-color: #ffffff;
        transform: rotateZ(135deg);
    }
}
.bg {
    position: absolute;
    top: 0rpx;
    left: 0rpx;
    z-index: -1;
    width: 752rpx;
    height: 522rpx;
    background: linear-gradient(181deg, #1f86ff 0%, #1f86ff 7%, rgb(241 248 255 / 0%) 90%);
}
.card {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 686rpx;
    height: 878rpx;
    padding-top: 112rpx;
    margin: 100rpx auto 0;
    background: #ffffff;
    border-radius: 12rpx;
    box-shadow: 0rpx 12rpx 31.4rpx rgb(185 217 255 / 56%);
    image {
        position: absolute;
        top: -80rpx;
        left: 50%;
        width: 160rpx;
        height: 160rpx;
        transform: translateX(-50%);
    }
    .name {
        font-size: 36rpx;
        font-weight: 500;
        line-height: 36rpx;
        color: #1b2026;
    }
    .school {
        padding-bottom: 32rpx;
        margin: 8rpx 32rpx 0;
        font-size: 24rpx;
        font-weight: normal;
        line-height: 36rpx;
        color: #1b2026;

        // border-bottom: 2rpx solid #F3F4F8;
    }
    .info-list {
        display: flex;
        flex-direction: column;
        gap: 48rpx;
        width: 620rpx;
        padding-top: 32rpx;
        border-top: 2rpx solid #f3f4f8;
        .info {
            box-sizing: border-box;
            .label {
                flex: 0 0 160rpx;
                font-size: 24rpx;
                line-height: 36rpx;
                color: #77818f;
            }
            .wd-picker {
                flex: 1;
            }
            .data {
                flex: 1;
                font-size: 28rpx;
                line-height: 36rpx;
                color: #1b2026;
            }
            .arrow {
                border-color: #77818f;
            }
        }
    }
    map {
        width: 620rpx;
        height: 176rpx;
        border-radius: 12rpx;
    }
}
.btn-wrap {
    position: fixed;
    bottom: 0;
    box-sizing: border-box;
    width: 100%;
    padding: 8px 32px;
    background-color: #ffffff;
    border-top: 1px solid #f3f4f8;
}
</style>
