AboutClassApe.js 10.7 KB
//*
// 约课模块
// */

import Loger from "../Loger";
import Ape from "./Ape";
import $ from "jquery";
import ClassDataProxy from "proxy/ClassDataProxy";
import dateUI from 'libs/laydate';
import ErrorApe from "./ErrorApe";

let loger = Loger.getLoger('PC-AboutClassApe');
const adminListTit = `<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" id="t_box" class="t_box">
                        <tbody>
                            <tr align="center" height="44" class="tr_center" bgcolor="#fff" bordercolor="#e6e6e6">
                                <th width="6%" class="tr_center">
                                    姓名
                                </th>
                                <th width="7%" class="tr_center">
                                    电话
                                </th>
                                <th width="8%" class="tr_center">
                                    年龄
                                </th>
                                <th width="7%" class="tr_center">
                                    所约课程
                                </th>
                                <th width="9%" class="tr_center">
                                    操作
                                </th>
                            </tr>
`;
//管理首页
const adminList = `<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">
                                <td width="7%" class="tr_main tr_mainLeft">{_userName}</td>
                                <td width="8%" class="tr_main">{_phone}</td>
                                <td width="8%" class="tr_main">{_age}</td>
                                <td width="8%" class="tr_main">{_course}</td>
                                <td  width="10%" class="tr_main tr_mainRight" align="center" >
                                <a class="classHandlePort" href="###">&nbsp;</a>
                                    <a id="{_removeInd}" class="classHandlePort" href="###">删除</a>
                                    <a class="classHandlePort" href="###">&nbsp;</a>
                                    <a id="{_stay}" class="classHandlePort" data="{_aboutMsg}" href="###">待回访</a>
                                    <a class="classHandlePort" href="###">&nbsp;</a>
                                </td>
                            </tr>
`;
const adminListEnd = `</tbody></table>`;

const adminListTit1 = `<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0" id="t_box" class="t_box">
                        <tbody>
                            <tr align="center" height="44" class="tr_center" bgcolor="#fff" bordercolor="#e6e6e6">
                                <th width="6%" class="tr_center">
                                    姓名
                                </th>
                                <th width="7%" class="tr_center">
                                    电话
                                </th>
                                <th width="8%" class="tr_center">
                                    年龄
                                </th>
                                <th width="7%" class="tr_center">
                                    约课老师
                                </th>
                                <th width="9%" class="tr_center">
                                    操作
                                </th>
                            </tr>
`;
//管理首页
const adminList1 = `<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">
                                <td width="7%" class="tr_main tr_mainLeft">{_userName}</td>
                                <td width="8%" class="tr_main">{_phone}</td>
                                <td width="8%" class="tr_main">{_age}</td>
                                <td width="8%" class="tr_main">{_course}</td>
                                <td  width="10%" class="tr_main tr_mainRight" align="center" >
                                    <a class="classHandlePort1" href="###">&nbsp;&nbsp;</a>
                                    <a id="{_removeInd}" class="classHandlePort" href="###">删除</a>
                                    <a class="classHandlePort1" href="###">&nbsp;&nbsp;</a>
                                </td>
                            </tr>
`;
class AboutClassApe extends Ape {
    constructor() {
        super();
        this.classDateList = {};//创建课堂信息
        this.isLocalStorage();
        this.pageNo = 0;
        this.presentInd = 1;
        this.addEvent();
        this.init();
    }

    init() {
        $('#aboutClassList4 li').on('click',this._userClassListHandler.bind(this));//用户列表

        $('#classHandlerHomePage4').on('click',this._homePageHandler.bind(this));//首页
        $('#classHandlerUpPage4').on('click',this._upPageHandler.bind(this));//上页
        $('#classHandlerDownPage4').on('click',this._downPageHandler.bind(this));//下页
        $('#classHandlerEndPage4').on('click',this._endPageHandler.bind(this));//尾页
        $('#classHandlerSpecificPage4').on('click',this._assignPageHandler.bind(this));//指定页
    }

    addEvent() {

    }
    isLocalStorage(){

    }
    //首页
    _homePageHandler(){
        this.presentInd = 1;
        this.userAdminHandler(this.presentInd);
    }
    //上页
    _upPageHandler(){
        if(this.presentInd >1){
            this.presentInd--;
            this.userAdminHandler(this.presentInd);
        }
    }
    //下页
    _downPageHandler(){
        if(this.presentInd < this.pageNo){
            this.presentInd++;
            this.userAdminHandler(this.presentInd);
        }
    }
    //尾页
    _endPageHandler(){
        this.presentInd = this.pageNo;
        this.userAdminHandler(this.presentInd);
    }
    //指定页
    _assignPageHandler(){
        let inputVal = $('#classHandlerPageInfoInput4').val();
        if(parseInt(inputVal) <= this.pageNo || parseInt(inputVal) >= 1 ){
            this.userAdminHandler(parseInt(inputVal));
        }
    }
    // 约课界面
    userAdminHandler(ind){
        let _url = ClassDataProxy.locationProtocol + ClassDataProxy.locationProt + '/studentMeeting/queryStudentMeeting/markettest';
        let that = this;

        $.ajax({
            type: "POST",
            url: _url,
            timeout:5000,
            data:{siteId:ClassDataProxy.siteId,userType:ClassDataProxy.USER_TYPE_8},
            headers: {siteId:ClassDataProxy.siteId,
                pageno:7,
                'page':ind,
                'token':'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IlhXQnJlRU00T0swYTVqUUIyUTFicGtObHlxOUFWbXZkIiwibmFtZSI6ImFkbWluIiwiY29kZSI6MSwiaWF0IjoxNTAzNDUxODU0LCJleHAiOjIyODEwNTE4NTR9.3kTVzKd_jbP7l69nxOpNaFeSjVnnjZkagYMzRB8fjNo'},
            success:function(_data){
                //获取课堂数据
                if(_data && _data.code == 200){
                    let ind = $('#aboutClassList4').find('.liveInfoLeftLiCheck').attr('data');
                    if(ind == 0 ){
                        //显示课程界面
                        that._gainUserClassData(_data.returnData.data);
                    }else{
                        //显示老师界面
                        that._gainUserClassData1(_data.returnData.data);
                    }
                }
            },
            error:function(error){
                //alert('直播数据获取失败')
                that._gainUserClassDataErr();
                loger.log(error,'约课数据获取失败')
            }
        })
    }
    _gainUserClassData(_data){
        let _dataList = _data.users;
        let courseContent = $('#courseContent4');
        courseContent.empty();
        let count = _data.count;
        let page = _data.page;
        let pageno = _data.pageno;
        let pagenum = Math.ceil(count / pageno);
        this.pageNo = pagenum;
        loger.log('预约显示页码',_data)
        $('#classHandlerPageMsg4').html('第'+page+'页/共'+pagenum+'页,有'+count+'个记录');
        courseContent.append(adminListTit);
        if(_dataList){
            if(count <= 7){
                $('#classHandlerPageBox4').hide();
            }
            for(let i = 0;i<_dataList.length;i++){
                let _adminList = this._format(adminList,{
                    _userName : _dataList[i].loginName,
                    _phone : _dataList[i].userMobile,
                    _age : '女',
                    _totalNmu : '2',
                    _course : '《少儿英语》',
                    _removeInd : 'classDoc'+i,
                    _stay : 'classMedia'+i,
                    _aboutMsg : _dataList[i].id
                })
                courseContent.append(_adminList);
            }
            courseContent.append(adminListEnd);
        }
    }
    _gainUserClassDataErr(){
        let courseContent = $('#courseContent4');
        courseContent.empty();
        courseContent.append(adminListTit);
        let _adminList = '<tr align="center" bgcolor="#FFFFFF" height="44" bordercolor="#e6e6e6">' +
            '<td class="tr_main tr_mainNone">' +
            '该课堂暂无约课数据~'+
            '</td>>'+
            '</tr>'
        courseContent.append(_adminList);
        courseContent.append(adminListEnd);
    }
    /*_gainUserClassData1(_data){
        let _dataList = _data.users;
        let courseContent = $('#courseContent4');
        courseContent.empty();
        let count = _data.count;
        let page = _data.page;
        let pageno = _data.pageno;
        this.pageNo = pageno;

        $('#classHandlerPageMsg4').html('第'+page+'页/共'+pageno+'页,有'+count+'个记录');
        courseContent.append(adminListTit1);
        if(_dataList){
            if(count <= 7){
                $('#classHandlerPageBox4').hide();
            }
            for(let i = 0;i<_dataList.length;i++){
                let _adminList = this._format(adminList1,{
                    _userName : _dataList[i].loginName,
                    _phone : _dataList[i].userMobile,
                    _age : '女',
                    _totalNmu : '2',
                    _course : _dataList[i].userName,
                    _removeInd : 'classDoc'+i,
                    _stay : 'classMedia'+i,
                    _aboutMsg : _dataList[i].id
                })
                courseContent.append(_adminList);
            }
            courseContent.append(adminListEnd);
        }
    }*/
    _switchover(evt){
        $(evt.currentTarget).addClass('liveInfoLeftLiCheck').siblings().removeClass('liveInfoLeftLiCheck');
    }
    _userClassListHandler(evt){
        this._switchover(evt);
        this.userAdminHandler(1);
    }
    //工具类
    _format(str, obj) {
        return str.replace(/\{(\w+)\}/g, function (match, group, index) {
            return obj[group];
        });
    };
}
export default AboutClassApe;