import Mock from 'mockjs'
import global from '../Global'

let Random = Mock.Random;

// worldDetail
let worldDetail = function () {
    let item = [];
    for (var i = 0; i < 30; i++) {
        item.push({
            "id": "@guid",
            // "name": "@region",
            Name: "赵沂",
            "Confirmed": "@integer(36844, 368449)",
            "Deaths": "@integer(1099, 10993)",
            "Recovered": "@integer(1986, 19865)",
        })
    }

    let res = {
        Rs: item,
        Code: 0,
        Memo: ''
    };
    return res;
};

let testTable = function () {
    let item = [];

    let members = [
        {id: 1, name: '霍元甲', userCode: '15253135600', vipType: 1},
        {id: 2, name: '陈真', userCode: '15253135602', vipType: 2},
        {id: 3, name: '成龙', userCode: '15253135604', vipType: 1},
    ];

    for (var i = 0; i < 6; i++) {
        item.push({
            "id": "@guid",
            "userCode": "@integer(15253135600, 15253135699)",
            "name": "@region",
            "tel": "@integer(15253135600, 15253135699)",
            "shop": "@region",
            "create": "@datetime",
            "expTime": "@datetime",
            "valid": "@datetime",
            "Confirmed": "@integer(36844, 368449)",
            "Deaths": "@integer(1099, 10993)",
            "Recovered": "@integer(1986, 9999)",
            "kick": "@integer(1986, 9999)",
            "Status": "@integer(1, 2)",
            "color": "@hex",
            "memo": "@paragraph(1, 1)",
            "dialogValue": "@range(1, 3)",
            "vipType": "@integer(1, 2)",
            "members": members,
            "wxVisible": "@integer(0, 1)",
            "timeLong": "12:00-14:00",
            "timeScope": [new Date(2016, 9, 10, 8, 40), new Date(2016, 9, 10, 9, 40)],
        })
    }

    let res = {
        Rs: item,
        Code: 0,
        Memo: ''
    };
    return res;
};
// "percent":  "@integer(0, 100)",
let getUserList = function () {
    let item = [];

    let nameList = [
        {name: '杨东艳'},
        {name: '隋小飞'},
        {name: '刘晓蕾'},
        {name: '刘海生'},
        {name: '贾雨琦'},
        {name: '李延海'},
        {name: '宋凌晨'},
        {name: '段长鹏'},
        {name: '郑伟'},
        {name: '周睿'},
        {name: '贾奕'},
        {name: '王正祥'},
        {name: '高超'},
        {name: '武发鲁'},
        {name: '赵晋洪'},
        {name: '张岩'},
    ];

    let img = [
        {name: 'flyhead.png'},
    ];

    for (var i = 0; i < 16; i++) {
        item.push({
            "name": nameList[i].name,
            "ActivePercent": "@integer(0, 54)",
            "heartRate": "@integer(70, 150)",
            "calorie": "@integer(200, 1000)",
            "ck": "23.2",
            "topCk": "@integer(150, 200)",
            "step": "@integer(200, 20000)",
            "hubId": "@guid",
            "deviceId": "@guid",
            "userCode": "@integer(15253135600, 15253135699)",
        })
    }
    let res = {
        Rs: item,
        Code: 0,
        Memo: ''
    };
    return res;
};


let testStudent = function (num, team, mustbeTeamOne) {
    let item = [];
    let group = team == 2 ? "@integer(1, 2)" : "@integer(1, 3)";
    // group = 1;
    if (mustbeTeamOne) {
        group = mustbeTeamOne;
    }
    for (var i = 0; i < num; i++) {
        item.push({
            Age: 13,
            AvgHr: 0,
            BeginTime: 1608188579,
            Ck: "@float(1,10,0,1)",
            // Ck: "@float(0,0,0,0)",
            Cle: "@float(1,1500,0,1)",
            EI: "@float(1,3000,0,1)",
            EiCalcBean: {
                "acWeight":{
                    "100":100,
                    "39":10,
                    "54":20,
                    "69":40,
                    "79":60,
                    "89":80
                },
                "acMap":{
                    "100": "@integer(0, 33187)",
                    "39": "@integer(0, 73716)",
                    "54": "@integer(0, 70110)",
                    "69": "@integer(0, 65563)",
                    "79": "@integer(0, 55906)",
                    "89": "@integer(0, 50048)"
                }
            },
            DuId: 119,
            EndTime: 0,
            GroupNo: group,
            Head: require('../static/img/testhead.png'),
            Height: 160,
            HrId: 41,
            IsBirthday: "@integer(0, 1)",
            IsBreaking: "@integer(0, 1)",
            IsNewUser: 0,
            MaxHr: 80,
            PowerPercent: "@integer(10, 100)",
            // PowerPercent: "100",
            Name: "@cname",
            // Name: "姜泽志",
            PkSucessnum: '1',//胜场数
            PkTotalnum: '1',//总场数
            PlanId: 60,
            PureCalorieNoVo2: "@integer(1, 999)",
            Sex: "@integer(1, 2)",
            Sn: "22735",
            StaticHr: 60,
            Steps: "@float(1,9999,0,1)",
            SvId: 20,
            UserId: 104,
            UserMd5: "55661a861f8fae20dd505b2b4575dc0e",
            Weight: 50,
            // ActivePercent: "@integer(1, 200)",
            ActivePercent: "@integer(10, 150)",
            bmrMSjRmrcb: 66.00000000000001,
            FormatCk: "@integer(1, 50)",
            // FormatCk: "@integer(0, 0)",
            isAlive: true,
            isFinish: false,
            isOver: false,
            IsPrivate: "@integer(0, 1)",
            lastPushDataTime: 1608188947175,
            lastUpdateTime: 1608188945184,
            queuePushData: [],
            RealHr: "@integer(60, 180)",
            // RealHr: 0,
            vo2Max: "@float(1,9999,0,1)"
        })
    }

    let Dp = {
        "PlanId": 182,
        "ShopId": 1,
        "SvId": 1,
        "PlanName": "齐源大厦浏览器显示2020-12-02日08:40开始的竞技游戏",
        "Status": 3,
        "BeginTime": "17:15:18",
        "EndTime": 0,
        "ClassType": 2,
        "PkNum": 2,
        "Teacher": '测试教练',
    };
    return {
        Rs: item,
        Dp: Dp,
        Code: 0,
        Memo: ''
    };
};

let getNewUser = function (code, t) {

    let item = [];
    for (var i = 0; i < t; i++) {
        item.push({
            "SvId": "@guid",
            "UserId": "@integer(15253135600, 15253135699)",
            "name": "@cname",
            "Name": "@cname",
            "Sex": 1,
            "Head": require('../static/img/testhead.png'),

        })
    }

    return {
        Code: code,
        Memo: "Success",
        Rs: item,
    };
};

let getRecordBreak = function (code) {

    let item = {
        "SvId": "@guid",
        "UserId": "@integer(15253135600, 15253135699)",
        "UserName": "@cname",
        "Cle": "@integer(200, 1000)",
        "Ck": "@integer(10, 100)",
        "CleUnit": "千卡",
        "CkUnit": "CK",
        "Sex": 1,
        "Head": require('../static/img/testhead.png'),
    };

    return {
        Code: code,
        Memo: "Success",
        Rs: item,
    };
};
let CalorieStatsQuery = function () {
    let Rs = [
        {
            Title: '本<s>周</s>场馆卡路里总消耗',
            Result: [{'Values': "234356", Unite: '千卡'}],
        },
        {
            Title: '本<s>月</s>场馆卡路里总消耗',
            Result: [{'Values': "644321", Unite: '千卡'}],
        }
    ];
    return {
        Code: 0,
        Memo: "Success",
        Rs: Rs,
    };
};

let UserRankingQuery = function (num) {
    let item1 = [];
    let item2 = [];
    for (var i = 0; i < num; i++) {
        item1.push({
            "UserName": "@cname",
            // UserName: "赵沂",
            "Sex":  "@integer(1, 2)",
            "Values": "@integer(1000, 9999)",
            "Head": require('../static/img/testhead.png'),
            "IsBreaking": "@integer(0, 1)"
        })
    }
    for (var i = 0; i < num; i++) {
        item2.push({
            "UserName": "@cname",
            // UserName: "赵沂",
            "Sex":  "@integer(1, 2)",
            "Values": "@float(10,99,1,1)",
            "Head": require('../static/img/testhead.png'),
            "IsBreaking": "@integer(0, 1)"
        })
    }
    let Rs = [
        {
            Title: '月卡路里排行榜',
            Result: item1,
        }, {
            Title: '月CK排行榜',
            Result: item2,
        }, {
            Title: '周卡路里排行榜',
            Result: item1,
        }, {
            Title: '周CK排行榜',
            Result: item2,
        }
    ];
    return {
        Code: 0,
        Memo: "Success",
        Rs: Rs,
    };
};


let testHerosRankingQuery = function (num) {
    let item = [
        {
            "Title": "本周消耗卡路里英雄榜",
            "Style": "heros",
            "Result": [
                {
                    "UserName": "@cname",
                    // UserName: "赵沂",
                    "Sex": 2,
                    "Head": require('../static/img/testhead.png'),
                    "Values": "4744",
                    "Unite": "千卡",
                    "Message": ""
                },
                {
                    "UserName": "@cname",
                    // UserName: "赵沂",
                    "Sex": 1,
                    "Head": require('../static/img/testhead.png'),
                    "Values": "4034",
                    "Unite": "千卡",
                    "Message": ""
                },
                // {
                //     "UserName": "@cname",
                //     // UserName: "赵沂",
                //     "Sex": 1,
                //     "Head": require('../static/img/testhead.png'),
                //     "Values": "2290",
                //     "Unite": "千卡",
                //     "Message": ""
                // }
            ]
        },
        {
            "Title": "单次CK值(新个人记录)",
            "Style": "tops",
            "Result": [
                {
                    "UserName": "@cname",
                    // UserName: "赵沂",
                    "Sex": 1,
                    "Head": require('../static/img/testhead.png'),
                    "Values": "1022",
                    "Unite": "",
                    "Message": "打破了历史记录100000"
                }, {
                    "UserName": "@cname",
                    // UserName: "赵沂",
                    "Sex": 2,
                    "Head": require('../static/img/testhead.png'),
                    "Values": "1022",
                    "Unite": "",
                    "Message": "打破了历史记录100000"
                },
                {
                    "UserName": "@cname",
                    // UserName: "赵沂",
                    "Sex": 1,
                    "Head": require('../static/img/testhead.png'),
                    "Values": "1020",
                    "Unite": "",
                    "Message": "打破了历史记录100000"
                }
            ]
        },

    ];

    return {
        Code: 0,
        Memo: "Success",
        Rs: item,
    };
};

let getClassStat = function (ClassOn, dp) {
    return {
        ClassOn: ClassOn, //   // 0: 下课 团课/私教/PK 的排名
        Code: 0,
        Memo: "Success",
        dp: dp,
        // 1：团课/私教
        // 2：竞技课2PK
        // 3：竞技课threepk
    };
};

let t = 1;//0 is on 1 is off
if (t == 1) {
    // 列表测试
    Mock.mock('/api/testTable', 'post', testTable());
    Mock.mock('/api/getUserList', 'post', getUserList());

    let Mockapi = 'http://192.168.0.3:9000/';
    // let Mockapi = 'http://192.168.0.62:9000/';
    // let Mockapi = 'http://221.214.111.254:9000/';

    // if (runVersion == 'test') {
    // let curheadapi = 'http://cal.beswell.com:85/DataTransfer/';
    // let curheadapi = 'http://127.0.0.1/';
    let curheadapi = 'http://192.168.0.22/';
    // }
    // if (runVersion == 'outDoor') {
    //     curheadapi = 'http://192.168.0.105:9000/';
    // }

    // 0: 下课 团课/私教/PK 的排名
    let LessonClass = 0;
    let LessonDp = 0;
    // 1：团课/私教
    // 2：竞技课2PK
    // 3：竞技课threepk

    // 人数  1 3 5 10 17
    if (LessonClass == 1) {
        // 上团课
        Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(1, 1));
        Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(1, 1));
        Mock.mock(curheadapi + 'UserListInfo', 'post', testStudent(25, 1));//true
        Mock.mock(Mockapi + 'UserListInfo', 'post', testStudent(25, 2)); //
    } else if (LessonClass == 2) {
        // 上2队PK课
        Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(1, 2));
        Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(1, 2));
        Mock.mock(curheadapi + 'UserListInfo', 'post', testStudent(16, 2,));
        Mock.mock(Mockapi + 'UserListInfo', 'post', testStudent(16, 1,));
    } else if (LessonClass == 3) {
        // 上3队PK课
        Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(1, 3));
        Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(1, 3));
        Mock.mock(curheadapi + 'UserListInfo', 'post', testStudent(30, 3,));
        Mock.mock(Mockapi + 'UserListInfo', 'post', testStudent(30, 3,));
        Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(1, 2));
        Mock.mock(Mockapi + 'ClassUserRank', 'post', testStudent(1, 3));
    } else if (LessonClass == 0) {
        // 下课
        if (LessonDp == 0) {
            Mock.mock(curheadapi + 'UserListInfo', 'post', testStudent(9, 1));//true
            Mock.mock(Mockapi + 'UserListInfo', 'post', testStudent(15, 1)); //
            Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(0, 0));
            Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(0, 0));
            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(24, 2));
            Mock.mock(Mockapi + 'ClassUserRank', 'post', testStudent(16, 2));
        } else if (LessonDp == 1) {
            Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(0, 1));
            Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(0, 1));
            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(16, 2));
            Mock.mock(Mockapi + 'ClassUserRank', 'post', testStudent(16, 2));
        } else if (LessonDp == 2) {
            Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(0, 2));
            Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(0, 2));
            // 下课排名
            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(18, 2));
            Mock.mock(Mockapi + 'ClassUserRank', 'post', testStudent(18, 2));
        } else if (LessonDp == 3) {
            Mock.mock(curheadapi + 'ClassStatQuery', 'post', getClassStat(0, 3));
            Mock.mock(Mockapi + 'ClassStatQuery', 'post', getClassStat(0, 3));
            // 下课排名
            Mock.mock(curheadapi + 'ClassUserRank', 'post', testStudent(16, 3));
            Mock.mock(Mockapi + 'ClassUserRank', 'post', testStudent(16, 3));
        }
    }

    // wait
    // 英雄榜
    Mock.mock(curheadapi + 'HerosRankingQuery', 'post', testHerosRankingQuery(3));
    Mock.mock(Mockapi + 'HerosRankingQuery', 'post', testHerosRankingQuery(3));
    // 卡路里排行榜
    Mock.mock(curheadapi + 'CalorieStatsQuery', 'post', CalorieStatsQuery(1, 2));
    Mock.mock(Mockapi + 'CalorieStatsQuery', 'post', CalorieStatsQuery(1, 2));
    // 用户排行榜
    Mock.mock(curheadapi + 'UserRankingQuery', 'post', UserRankingQuery(8));
    Mock.mock(Mockapi + 'UserRankingQuery', 'post', UserRankingQuery(8));
    // 新同学 0 999
    Mock.mock(curheadapi + 'getNewUser', 'post', getNewUser(999, 10));
    Mock.mock(Mockapi + 'getNewUser', 'post', getNewUser(999, 12));
    // 彩蛋 0 999
    Mock.mock(curheadapi + 'getRecordBreak', 'post', getRecordBreak(999));
    Mock.mock(Mockapi + 'getRecordBreak', 'post', getRecordBreak(999));
}

export default Mock;
