const _Http = getApp().globalData.http,
    MFT = require("../../utils/matchingFeilType");
Page({
    data: {
        active: 0,
        detailData: {},
        currentVideo: {},
    },
    tabChange({
        detail
    }) {
        console.log(detail)
        this.setData({
            active: detail.index
        })
    },
    onLoad(options) {
        let auth = wx.getStorageSync('auth').warchives_sc.optionnames,
            dataAuth = '';
        if (auth.includes('团队内部数据分析') && auth.includes('经销商数据分析')) {
            dataAuth = 'all';
        } else {
            dataAuth = auth.includes('团队内部数据分析') ? '内部' : '经销商'
        }
        this.setData({
            dataAuth,
            viewData: auth.includes('团队内部数据分析') || auth.includes('经销商数据分析')
        });
        _Http.basic({
            "classname": "saletool.courseware.courseware",
            "method": "selectDetail",
            "content": {
                "sat_coursewareid": options.id
            }
        }, false).then(res => {
            if (res.msg != '成功') return wx.showToast({
                title: res.msg,
                icon: "none"
            });
            let list = MFT.fileList(res.data.attinfos);
            this.setData({
                detailData: res.data,
                flieList: list,
                currentVideo: list.find(v => v.fileType == 'video')
            })
        });
    },
    callBack({
        detail
    }) {
        console.log(detail)
        this.setData({
            currentVideo: detail
        })
    },
    /* 更新下载记录 */
    downLoadRecord() {
        _Http.basic({
            "classname": "saletool.courseware.courseware",
            "method": "updateDownloadLog",
            "content": {
                "sat_coursewareid": this.data.detailData.sat_coursewareid
            }
        })
    },
    onShareAppMessage(res) {}
})