import { defineStore } from 'pinia';
import {ref,watch} from "vue";
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import storage from "@/utils/storage.js";
dayjs.locale('zh-cn');
export const useUserStore = defineStore('user', ()=>{
const idCardInfo=ref({})
const iDCardImage=ref({
    front:'',
    back:''
})
    const formatToCustomDate=(dateString)=> {
        const date = dayjs(dateString);
        const amOrPm = date.hour() < 12 ? 'AM' : 'PM';
        return date.format(`YYYY年MM月DD日, hh:mm`) + amOrPm;
    }
    const telNum=ref('')
    const selectAddress=ref(null)
    const recentPhoto=ref('')
    const detailAddress=ref('')
    const submitReturnData=ref(storage.getItem('submitReturnData'))
    const temSubmitReturnData=ref(null)
    watch(submitReturnData,()=>{
            storage.setItem('submitReturnData',submitReturnData.value)
    })
    return {
        idCardInfo,
        iDCardImage,
        recentPhoto,
        telNum,
        selectAddress,
        detailAddress,
        submitReturnData,
        formatToCustomDate,
        temSubmitReturnData
}
});
