Vue.config.devtools = true;
var v = new Vue({
    el: ".index-box",
    data: function () {
        return {
            cata: [
                {name: "目录", active: 1, id: 1},
                {name: "专区详情", active: 0, id: 2}
            ],
            list: [],
            info: {},
            isLogin: 0,
            memToken: '',
            memHeadImg: '',
            userJf: -1,
            conferId: -1,
            playIndex: -1,
            ad: [],
            queryQrCode: {},
            consulting: {},
        }
    },
    created: function () {
        if ($.cookie("memToken")) {
            this.memToken = $.cookie("memToken");
            this.isLogin = 1;
        }
        if ($.cookie("memHeadImg")) {
            this.memHeadImg = $.cookie("memHeadImg");
        }
        this.conferId = $("#conferId").val();
        this.findUserIntegral();
        this.getIndexData();
        this.getAdInfo()
        this.getQueryQrCode()
        this.getConsulting()

    },
    methods: {
        getAdInfo() {
            var that = this;
            $.ajax({
                type: 'POST',
                url: serverHttp + "/meeting/getAdInfo",
                success: function (res) {
                    if (res.code == 200) {
                        that.ad = res.data;
                    }
                },
                error: function (data) {
                }
            });
        },
        findUserIntegral() {
            var that = this;
            $.ajax({
                type: 'POST',
                url: serverHttp + "/user/findUserIntegral",
                data: {
                    memToken: that.memToken
                },
                success: function (data) {
                    if (data.code == 200) {
                        that.userJf = data.data;
                    }
                },
                error: function (data) {
                }
            });
        },
        getIndexData() {
            //id：分类id id = -1 是全部分类
            $.ajax({
                type: 'POST',
                url: serverHttp + "/meeting/getDetailData",
                data: {
                    conferId: this.conferId
                },
                success: (data) => {
                    if (data.code == 200) {
                        this.info = data.data;
                        this.info.bigenTime = tsFormatTime(this.info.bigenTime, 'Y.M.D')
                        this.info.endTime = tsFormatTime(this.info.endTime, 'Y.M.D')
                    }
                },
                error: function (data) {

                }
            });
        },
        meetingDetails(id) {
            window.location.href = serverHttp + "/meeting/details?from=&conferId=" + id;
        },
        chooseTab(i) {
            this.cata.map((item, index) => {
                if (i == index) {
                    item.active = 1
                } else {
                    item.active = 0
                }
            })
            setTimeout(() => {
                $("img").each(function () {

                    if (!this.complete || (typeof this.naturalWidth == "undefined" && this.naturalWidth == 0) || !this.src) {
                        $(this).attr("src", "../img/img.jpg");
                    }
                });
            }, 1000)

        },
        // 查询社群二维码
        getQueryQrCode() {
            var that = this;
            $.ajax({
                type: 'POST',
                url: "/user/getQrImg",
                data: {
                    queryQrCode: that.queryQrCode
                },
                success: function (data) {
                    if (data.code == 200) {
                        // that.queryQrCode = data.data
                        that.queryQrCode= [
                            {
                                "id": 1,
                                "name": "赋能全科医生交流群",
                                "qrImg": "/web/img/fnqkysjl.png",
                                "stauts": 0
                            }
                        ]
                    }
                },
                error: function (data) {
                }
            });
        },

        // 咨询推荐
        getConsulting() {
            var that = this;
            $.ajax({
                type: 'POST',
                url: "/web/index/information",
                data: {
                    consulting: that.consulting
                },
                success: function (data) {
                    if (data.code == 200) {
                        that.consulting = data.data
                    }
                },
                error: function (data) {
                }
            });
        },
        jumpTo(url) {
            window.open(url)
        },
        jumpToLive(obj) {
            gotoRcmdPub(obj.zqFlag, obj.rcmdType, obj.rcmdObjId, obj.rcmdUrl, "web")
        },
    }
})
