let app = getApp();
import {
    companyRq
} from "../../../api/meeting/visitorIinvitation.js"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        IMG_NAME: app.IMG_NAME,
        value: '',
        companyShow: false,
        usernameShow: false,
        cardTypeShow: false,
        arriveShow: false,
        leaveShow: false,
        submitSuccesShow: false,
        companyColumns: ['公司1', '公司2', '公司3'],
        columns: ['身份证', '护照', '通行证'],
        fileList: [],
        currentDate: new Date().getTime(),
        /** 索引栏*/
        indexList: ["A", "B", "C", "D"],
        scrollTop: 0,
        /** mock客户数据*/
        customerList: [{
                firstLetter: "A",
                list: [{
                        code: "AB01",
                        name: "A1客户"
                    },
                    {
                        code: "AB02",
                        name: "A2客户"
                    },
                    {
                        code: "AB03",
                        name: "A3客户"
                    },
                ],
            },
            {
                firstLetter: "B",
                list: [{
                        code: "BB01",
                        name: "B1客户"
                    },
                    {
                        code: "BB02",
                        name: "B2客户"
                    },
                    {
                        code: "BB03",
                        name: "B3客户"
                    },
                    {
                        code: "BB04",
                        name: "B4客户"
                    },
                ],
            },
            {
                firstLetter: "C",
                list: [{
                        code: "CB01",
                        name: "C1客户"
                    },
                    {
                        code: "CB02",
                        name: "C2客户"
                    },
                    {
                        code: "CB03",
                        name: "C3客户"
                    },
                    {
                        code: "CB04",
                        name: "C4客户"
                    },
                    {
                        code: "CB05",
                        name: "C5客户"
                    },
                ],
            },
            {
                firstLetter: "D",
                list: [{
                        code: "DB01",
                        name: "D1客户"
                    },
                    {
                        code: "DB02",
                        name: "D2客户"
                    },
                    {
                        code: "DB03",
                        name: "D3客户"
                    },
                    {
                        code: "DB04",
                        name: "D4客户"
                    },
                    {
                        code: "DB05",
                        name: "D5客户"
                    },
                    {
                        code: "DB06",
                        name: "D6客户"
                    },
                ],
            },
        ],

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        // 页面初始化 options为页面跳转所带来的参数
        wx.setNavigationBarTitle({
            title: options.name
        })
        console.log('options.goods_id', options.name)
        companyRq({}).then(res => {
            console.log('res', res)
            if (res.code == 0) {
                // res.row 
            }

        })
    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },
    onChange(event) {
        // event.detail 为当前输入的值
        console.log(event.detail);
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    },
    getUsernameHandle() {
        // this.setData({
        //   usernameShow: true
        // });
        wx.navigateTo({
            url: '/pages/meeting/visitorIinvitation/indexBar/indexBar'
        })

    },
    getCompanyHandle() {
        this.setData({
            companyShow: true
        });
    },
    getCardTypeHandle() {
        this.setData({
            cardTypeShow: true
        });
    },
    changeHandler(e) {
        console.log(e)

    },
    // confirmHandle(){

    // },
    confirmHandle() {
        this.setData({
            companyShow: false,
            usernameShow: false,
            cardTypeShow: false,
            arriveShow: false,
            leaveShow: false
        });
    },
    cancelHandle() {
        this.setData({
            companyShow: false,
            usernameShow: false,
            cardTypeShow: false,
            arriveShow: false,
            leaveShow: false
        });
    },
    getArriveHandle() {
        this.setData({
            arriveShow: true
        });

    },
    getLeaveHandle() {
        this.setData({
            leaveShow: true
        });
    },
    onClose() {
        this.setData({
            usernameShow: true
        });
    },
    afterRead(event) {
        const {
            file
        } = event.detail;
        // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
        wx.uploadFile({
            url: 'https://example.weixin.qq.com/upload', // 仅为示例，非真实的接口地址
            filePath: file.url,
            name: 'file',
            formData: {
                user: 'test'
            },
            success(res) {
                // 上传完成需要更新 fileList
                const {
                    fileList = []
                } = this.data;
                fileList.push({
                    ...file,
                    url: res.data
                });
                this.setData({
                    fileList
                });
            },
        });
    },
    onInput(event) {
        this.setData({
            currentDate: event.detail,
        });
    },
    submitFormFn() {
        this.setData({
            submitSuccesShow: true,
        });

    },
    submitDialogFn() {
        this.setData({
            submitSuccesShow: false,
        });
        setTimeout(() => {
            wx.navigateTo({
                url: '/pages/meeting/visitorIinvitation/appointmentRecord/appointmentRecord',
            })
        }, 10);
    }
})