SubscribeApe.js 2.5 KB
//*
// 收藏预约模块
// */

import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import MessageTypes from "../MessageTypes";
import ErrorApe from "./ErrorApe";

let loger = Loger.getLoger('PC-SubscribeApe');
class SubscribeApe extends Ape {
    constructor() {
        super();
        this.id = '';
        this.addEvent();
        this.init();
    }

    init() {
        $('#lanclassContentApply').on('click',this._lanclassContentApplyHandler.bind(this));//我要报名
        $('#orderBtn').on('click',this._lanclassContentApplyHandler.bind(this));//我要预约
        $('#collectYes').on('click',this._lanclassContentApplyHandler.bind(this));//取消收藏
        $('#collectNo').on('click',this._lanclassContentApplyHandler.bind(this));//收藏

    }

    addEvent() {

    }
    _lanclassContentApplyHandler(evt){
        let that = this;
        let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/addStudentMeeting';
        let status = $(evt.currentTarget).attr('data');
        let id = $('#lanclassBox').attr('data');
        this.id = id;
        $.ajax({
            type: "POST",
            url: _url,
            data:{siteId:'markettest',
                "studentId":ClassDataProxy.id,
                "status":parseInt(status),
                "meetingId":id
            },
            headers: {siteId:'markettest',
                'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
            success:function(_data){
                let arr = ['收藏成功!','预约成功!','报名成功!']
                loger.log(_data,'预约信息')
                //获取课堂数据
                if(_data && _data.code == 200){
                    loger.log(_data,'预约信息')
                    ErrorApe.showWarnError(arr[status]);
                }else{
                    that.toLogin();
                }
            },
            error:function(error){
                //alert('首页数据获取失败')
                console.log(error,'首页数据获取失败')
            }
        })
    }
    toLogin(){
        $('#userLoginBox').show();
    }
    //工具类
    _format(str, obj) {
        return str.replace(/\{(\w+)\}/g, function (match, group, index) {
            return obj[group];
        });
    };
}
export default SubscribeApe;