const cf = require("../../../../utils/checkFile");
Component({
    properties: {
        list: {
            type: Array,
            value: []
        },
        checkedId: {
            type: String,
            value: 0
        },
        changeId: {
            type: Function
        }
    },
    options: {
        addGlobalClass: true
    },
    data: {
        show: false,
        fileSelected: {},
    },
    methods: {
        /* 打开文件 */
        openFile(e) {
            const {
                item
            } = e.currentTarget.dataset;
            if (item.fileType == 'folder') {
                let pages = getCurrentPages();
                let prevPage = pages[pages.length - 1]; // 获取当前的页面栈
                if (prevPage.route == "pages/tabbar/smartStore/index") {
                    wx.navigateTo({
                        url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
                    })
                } else {
                    wx.redirectTo({
                        url: '/pages/tabbar/smartStore/folder?item=' + JSON.stringify(item),
                    })
                }
            } else {
                cf.checkFile(item)
            }
        },
        changeChecked(e) {
            this.triggerEvent("changeId", e.target.dataset.item)
        }
    }
})