/**
 * 全局事件控制
 */
// 存储全局变量
var rem = [];
var Player = {
    loadcount: 20,  // 搜索结果一次加载多少条
    version: "v2.41"    // 播放器当前版本号(仅供调试)
};
var musicList = [
    // 以下三个系统预留列表请勿更改，否则可能导致程序无法正常运行！
    // 预留列表：搜索结果
    {
        name: "搜索结果",   // 播放列表名字
        cover: "",          // 播放列表封面
        creatorName: "",        // 列表创建者名字
        creatorAvatar: "",      // 列表创建者头像
        item: []
    },
    // 预留列表：正在播放
    {
        name: "正在播放",   // 播放列表名字
        cover: "",          // 播放列表封面
        creatorName: "",        // 列表创建者名字
        creatorAvatar: "",      // 列表创建者头像
        item: []
    },
    // 预留列表：播放历史
    {
        name: "播放历史",   // 播放列表名字
        cover: "images/history.png",          // 播放列表封面
        creatorName: "",        // 列表创建者名字
        creatorAvatar: "",      // 列表创建者头像
        item: []
    },
    // 以上三个系统预留列表请勿更改，否则可能导致程序无法正常运行！
    //*********************************************
    // 自定义列表开始，您可以自由添加您的自定义列表
    {
        id: 3778678     // 云音乐热歌榜
    },
    {
        id: 3779629     // 云音乐新歌榜
    },
    {
        id: 4395559     // 华语金曲榜
    },
    {
        id: 64016     // 中国TOP排行榜（内地榜）
    },
    {
        id: 112504     // 中国TOP排行榜（港台榜）
    },
    {
        id: 19723756     // 云音乐飙升榜
    },
    {
        id: 2250011882     // "网易原创歌曲榜"
    },
    // 自定义列表教程开始！
    // 方式一：手动创建列表并添加歌曲信息
    // 温馨提示：各大音乐平台获取到的外链有效期均较短，因此 url 值应该设置为空，以让程序临时抓取
    {
        name: "自定义列表",   // 播放列表名字
        cover: "https://p3.music.126.net/34YW1QtKxJ_3YnX9ZzKhzw==/2946691234868155.jpg", // 播放列表封面图像
        creatorName: "",        // 列表创建者名字(暂时没用到，可空)
        creatorAvatar: "",      // 列表创建者头像(暂时没用到，可空)
        item: [                 // 这里面放歌曲
            {
                id: "436514312",  // 音乐ID
                name: "成都",  // 音乐名字
                artist: "赵雷", // 艺术家名字
                album: "成都",    // 专辑名字
                source: "netease",     // 音乐来源
                url_id: "436514312",  // 链接ID
                pic_id: "2946691234868155",  // 封面ID
                lyric_id: "436514312",  // 歌词ID
                pic: "https://p3.music.126.net/34YW1QtKxJ_3YnX9ZzKhzw==/2946691234868155.jpg",    // 专辑图片
                url: ""   // mp3链接（此项建议不填，除非你有该歌曲的比较稳定的外链）
            },
            // 下面演示插入各个平台的音乐。。。
            {
                id: "65528",
                name: "淘汰",
                artist: "陈奕迅",
                album: "认了吧",
                source: "netease",      // 网易云
                url_id: "65528",
                pic_id: "18782957139233959",
                lyric_id: "65528",
                pic: "https://p3.music.126.net/BFuOepLmD63tY75UJs1c0Q==/18872017579169120.jpg",
                url: ""
            },
            {
                id: "001JD1SR29d1hS",
                name: "特别的爱给特别的你",
                artist: "伍思凯",
                album: "特别的爱给特别的你",
                source: "tencent",      // 腾讯
                url_id: "001JD1SR29d1hS",
                pic_id: "004DYsvN2QCYcj",
                lyric_id: "001JD1SR29d1hS",
                pic: "https://y.gtimg.cn/music/photo_new/T002R300x300M000004DYsvN2QCYcj.jpg?max_age=2592000",
                url: ""     // 腾讯的外链有效期较短，插入时 url [必须]设置空值，播放时再临时抓取
            },
            {
                id: "81175",
                name: "让我欢喜让我忧",
                artist: "周华健",
                album: "让我欢喜让我忧",
                source: "xiami",    // 虾米
                url_id: "81175",
                pic_id: "81175",
                lyric_id: "81175",
                pic: "https://pic.xiami.net/images/album/img58/1258/66271400572139.jpg@300h_300w_100q_1c.jpg",
                url: ""     // 虾米的外链有效期较短，插入时 url [必须]设置空值，播放时再临时抓取
            },
            {
                id: "2a24dea6c74884195fe5b9732fd95ca8",
                name: "小幸运",
                artist: "金玟岐",
                album: "金玟岐翻唱作品集",
                source: "kugou",        // 酷狗
                url_id: "2a24dea6c74884195fe5b9732fd95ca8",
                pic_id: "2a24dea6c74884195fe5b9732fd95ca8",
                lyric_id: "2a24dea6c74884195fe5b9732fd95ca8",
                pic: "http://singerimg.kugou.com/uploadpic/softhead/400/20161226/20161226105135733.jpg",
                url: ""     // 酷狗的外链有效期较短，插入时 url [必须]设置空值，播放时再临时抓取
            },
            {
                id: "121004737",
                name: "难忘今宵",
                artist: "李谷一",
                album: "难忘今宵",
                source: "baidu",        // 百度
                url_id: "121004737",
                pic_id: "121004737",
                lyric_id: "121004737",
                pic: "http://musicdata.baidu.com/data2/pic/2733cd9816b8618afd3038d5d9444940/266105319/266105319.jpg@s_0,w_150",
                url: ""         // 百度的外链有效期较短，插入时 url [必须]设置空值，播放时再临时抓取
            }  // 列表中最后一首歌大括号后面不要加逗号
        ]
    },
    // 方式二：直接提供网易云歌单ID
    {
        id: 440103454   // 网易云歌单ID
    }   // 播放列表的最后一项大括号后面不要加逗号
];
/**
 * [通过参数名获取url中的参数值]
 * 示例URL:http://htmlJsTest/getrequest.html?uid=admin&rid=1&fid=2&name=小明
 * @param  {[string]} queryName [参数名]
 * @return {[string]}           [参数值]
 */
function GetQueryValue(queryName) {
    var query = decodeURI(window.location.search.substring(1));
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == queryName) { return pair[1]; }
    }
    return null;
}
$(document).on('pjax:complete', function() {
    /* **************************************播放器操作************************************** */
    $("#music-list-data").on("click","button", function(e) {
        rem.player_lid = $(this).attr('lid');
        rem.player_mold = $(this).attr('name');
        rem.player_list = 1;
        rem.player_jq = $('[lid="'+rem.player_lid+'"][mold="list-music1"]');
        if (rem.player_mold=='play'){  //播放
            player_show();
        }else if (rem.player_mold=='add'){ //添加
            var state = $('#music-list-data').attr('state');
            if (state=='0'){
                $('#music-list-data').attr('state','1');
                var pic_id = rem.player_jq.attr('pic_id');
                if (pic_id=='null') pic_id = rem.player_jq.attr('pic');
                var data = {
                    action:'add',
                    name:rem.player_jq.parents()[1].firstChild.parentNode.cells[1].innerText,
                    artist:rem.player_jq.parents()[1].firstChild.parentNode.cells[2].innerText,
                    album:rem.player_jq.parents()[1].firstChild.parentNode.cells[3].innerText,
                    url_id:rem.player_jq.attr('id'),
                    pic_id:pic_id,
                    lyric_id:rem.player_jq.attr('lyric_id'),
                    source:rem.player_jq.attr('source')
                };
                $(this).html('<i class="fa fa-spinner fa-spin"></i>');
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Music',
                    data: data,
                    dataType: "json",
                    success: function(json){
                        if (json.state=='ok'){
                            $('#music-list-data').attr('state','0');
                            $('[id="'+json.id+'"][name="add"]').html('<i class="ion-checkmark"></i>');
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#fa0714',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('#music-list-data').attr('state','0');
                            $('[lid="'+json.id+'"][name="add"]').html('<i class="ion-ios-plus"></i>');
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('添加歌曲失败，错误代码2，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('#music-list-data').attr('state','0');
                    }
                });
            }else{
                binyui.TipShow('请等上一个任务处理完毕后再进行操作！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        }else {
            binyui.TipShow('未知操作！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }
    });
    /* **************************************控制台************************************** */
    if (GetQueryValue('Mould')=='Home' || GetQueryValue('Mould')==null){
        /**
         **  BinySilderImg{Array}       用户自定义轮播图数组
         **  BinySilderSetting{Object}   用户自定义设置
         **/
        binyui.Silder([
            'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g5/M00/09/02/ChMkJ1ah6XqIFvFFAAa5bop774sAAHjswApOYsABrmG421.jpg',
            'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g5/M00/00/07/ChMkJ13qNJeIcWlLAAXZO1T9wbMAAvnJACT_eMABdlT817.jpg',
            'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g1/M00/0C/0B/Cg-4jlOo61uIffFgAA-NvTqSHGoAAOipAEfF2MAD43V097.jpg'
        ],{
            SilderId: '.BinySilderDemo', //要放置轮播图的盒子ID
            SilderTimer: true, //轮播图定时器开启
            SilderTimes: 3, //轮播图每3秒下一张
            SilderWidth: '930px', //轮播图盒子宽度
            SilderHight: '400px', //轮播图盒子高度
            SilderImgSize: 'cover', //轮播图平铺方式
            SilderImgRadius: '0px', //轮播图圆角
            SilderLeftAmin: 'bounceInUp', //点击上一张动画类名（Animation.css）
            SilderLeftAminTime: '1s', //点击上一张动画做的时长
            SilderRightAmin: 'bounceIn', //点击下一张动画类名（Animation.css）
            SilderRightAminTime: '1s', //点击下一张动画做的时长
            SilderHideAmin: 'fadeOut', //动画消失类名（Animation.css）
            SilderHideAminTime: '1s', //动画消失做的时长
            SilderRandomAmin: true, //动画随机
            SilderClickBtn: true, //可否点击按钮
        });
        $('.modal-dialog').on("click",'[name="luck-button"]', function(e) {
            $('.luck-progress').css('width','30%');
            $('.luck-progress').text('30%');
            $.ajax({
                type: 'POST',
                url : '?Mould=Home',
                data: {'action':'luck'},
                dataType: 'json',
                beforeSend : function(){
                    $('.luck-progress').css('width','50%');
                    $('.luck-progress').text('50%');
                },
                complete: function(){
                    $('.luck-progress').css('width','100%');
                    $('.luck-progress').text('100%');
                },
                success:function(json){
                    if (json.state='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        if (json.data.mold=='jq'){
                            $('#luck-result').html('恭喜您，获得了'+json.data.name+'，群号：'+json.data.num+'！');
                        }else if (json.data.mold=='money'){
                            $('#luck-result').html('恭喜您，获得了站长的'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                        }else if(json.data.mold=='q_quota'){
                            $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                        }else if (json.data.mold=='p_quota'){
                            $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                        }else if (json.data.mold=='s_quota'){
                            $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                        }else if (json.data.mold=='u_quota'){
                            $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                        }else{
                            $('#luck-result').html('好的，谢谢参与！');
                        }
                        $('#luck-num').html(0);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('抽奖失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
    }
    /* **************************************资料修改************************************** */
    if (GetQueryValue('Mould')=='User'){
        //查看更多
        $('[name="is_auto"]').click(function(){
            $(".is_auto").toggle(1000);
        });
        //修改资料
        $('[name="edit"]').click(function(){
            $('input,select,button').removeAttr('disabled');
        });
        $('[name="submit"]').click(function(){
            $('[name="submit"]').text('正在修改...');
            $('[name="submit"]').attr('disabled','disabled');
            var name = $('[name="name"]').val();
            var qq = $('[name="qq"]').val();
            var email = $('[name="email"]').val();
            var music_id = $('[name="music_id"]').val();
            var cqyzt = $('[name="cqyzt"]').val();
            var aqproblem = $('[name="aqproblem"]').val();
            var aqanswer = $('[name="aqanswer"]').val();
            var pwd = $('[name="pwd"]').val();
            var chat_bg = $('[name="chat_bg"]').val();
            if (name=='' || qq=='' || email=='' || music_id=='' || cqyzt=='' || aqproblem=='' || aqanswer==''){
                binyui.TipShow('所有带*号的都必须填写！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('点击保存');
                $('input,select,button').removeAttr('disabled');
            }else{
                $.ajax({
                    type: "POST",
                    url: '/Application/Mains.php?Mould=User',
                    data: {'action':'edit','name':name,'qq':qq,'email':email,'music_id':music_id,'cqyzt':cqyzt,'aqproblem':aqproblem,'aqanswer':aqanswer,'pwd':pwd,'chat_bg':chat_bg},
                    dataType: 'json',
                    success: function (data) {
                        if (data.state=='ok'){
                            binyui.TipShow(data.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('[name="submit"]').text('点击保存');
                            $('input,select,button').removeAttr('disabled');
                        }else{
                            binyui.TipShow(data.msg, {
                                msgTimer: 5,
                                msgColor: '#fa0714',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('[name="submit"]').text('点击保存');
                            $('input,select,button').removeAttr('disabled');
                        }
                    },
                    error:function (data) {
                        alert('保存失败，服务器内部错误！');
                        $('[name="submit"]').text('点击保存');
                        $('input,select,button').removeAttr('disabled');
                    }
                });
            }
        });
    }
    /* **************************************聊天专区************************************** */
    if (GetQueryValue('Mould')=='Chat') {
        var scrollHeight = $('#chat').prop("scrollHeight");
        $('#chat').animate({scrollTop:scrollHeight}, 400);
        $('[name="submit"]').click(function () {
            var content = $('[name="content"]').val();
            $('[name="content"]').val('');
            if (content!=''){
                $('#chat').append(chat(content.replace(/<[^>]+>/g,"")));
                $('#chat').animate({scrollTop:scrollHeight}, 400);
                $.ajax({
                    type: "POST",
                    url: '/Application/Mains.php?Mould=Chat',
                    data: {'action':'send','content':content},
                    dataType: 'json',
                    success: function (data) {
                        if (data.state=='ok'){
                            $('.chat-state').remove();
                        }else{
                            $('.chat-state').html('<i class="text-danger fa fa-exclamation-circle"></i>');
                        }
                    },
                    error:function () {
                        alert('发送失败，服务器内部错误！');
                    }
                });
            }else{
                binyui.TipShow('请输入聊天内容！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
        //发送内容的模板
        function chat(content) {
            var img = $('.w-full').attr('src');
            return '\t\t\t\t\t            <div class="p-a-md"><div class="m-b">\n' +
                '\t\t\t\t\t              <a href="#" class="pull-right w-40 m-l-sm">\n' +
                '\t\t\t\t\t              \t<img src="'+img+'" class="w-full img-circle" alt=".">\n' +
                '\t\t\t\t\t              </a>\n' +
                '\t\t\t\t\t              <div class="clear text-right">\n' +
                '\t\t\t\t\t                <div class="p-a p-y-sm success inline rounded text-left">\n' +
                '\t\t\t\t\t                  <a class="chat-state text-warning"><i class="fa fa-spinner fa-spin"></i></a> ' + content + '\n' +
                '\t\t\t\t\t                </div>\n' +
                '\t\t\t\t\t                <div class="text-muted text-xs m-t-xs">刚刚</div>\n' +
                '\t\t\t\t\t              </div>\n' +
                '\t\t\t\t\t            </div></div>';
        }
    }
    /* **************************************音乐大厅************************************** */
    if (GetQueryValue('Mould')=='Music') {
        //获取用户网易云音乐+资料
        function get_userInfo() {
            $('#user-music-list').html(''); //清空列表
            $('#music-info-refresh').addClass('fa-spin');   //添加过渡动画
            $.ajax({
                type: 'POST',
                url: music_api,
                data: "types=userlist&uid=" + music_id,
                dataType : "jsonp",
                success: function(json){
                    if (json.code!='400'){
                        if (json.playlist.length === 0 || typeof(json.playlist.length) === "undefined"){
                            binyui.TipShow('嘤嘤嘤，没有找到ID'+music_id+'的主人！', {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('#music-img').attr('src','http://q2.qlogo.cn/headimg_dl?bs=17404785&dst_uin=17404785&dst_uin=17404785&;dst_uin=17404785&spec=100&url_enc=0&referer=bu_interface&term_type=PC'); //更改头像
                            $('#music-nick').html('<i class="fa fa-user"></i> '+'昵称');    //更换昵称
                            $('#music-info').html('暂无信息！');    //更改资料
                            return false;
                        }else{
                            rem.music_uid = json.playlist[0].creator.userId;
                            rem.music_name = json.playlist[0].creator.nickname;
                            $('#music-img').attr('src',json.playlist[0].creator.avatarUrl); //更改头像
                            $('#music-blur').attr('src',json.playlist[0].creator.backgroundUrl);    //更换背景
                            $('#music-nick').html('<i class="fa fa-user"></i> '+rem.music_name);    //更换昵称
                            $('#music-info').html(' <i class="fa fa-heart"></i> 性别：'+(json.playlist[0].creator.gender?'男':'女')+' <i class="fa fa-calendar"></i> 注册时间：'+getMyDate(json.playlist[0].createTime));    //更换昵称
                            var tempList;
                            for (var i = 0; i < json.playlist.length; i++){
                                // 获取歌单信息
                                tempList = {
                                    id: json.playlist[i].id,    // 列表的网易云 id
                                    name: json.playlist[i].name,   // 列表名字
                                    playCount: json.playlist[i].playCount,   //播放次数
                                    cover: json.playlist[i].coverImgUrl  + "?param=200y200",   // 列表封面
                                    creatorID: json.playlist[i].creator.userId,   // 列表创建者id
                                    creatorName: json.playlist[i].creator.nickname,   // 列表创建者名字
                                    creatorAvatar: json.playlist[i].creator.avatarUrl,   // 列表创建者头像
                                    item: []
                                };
                                var html = '        <div class="col-md-1 user-music-list-style">\n' +
                                    '            <div class="box p-a-xs">\n' +
                                    '                <a class="user-music-load-list" id="'+tempList.id+'" title="'+tempList.name+'"><img src="https://p1.music.126.net/lArHZR-mrcB0Xckjr9qKsQ==/1366692955578988.jpg?param=140y140" alt="'+tempList.name+'" class="img-responsive"></a>\n' +
                                    '                <div class="user-music-list-count"><i class="fa fa-headphones"></i> '+tempList.playCount+' <span class="pull-right"><i class="fa fa-play-circle"></i></span></div>\n' +
                                    '                <div class="p-a-sm user-music-list-foot">\n' +
                                    '                    <div class="text-center text-ellipsis user-love-music-title">'+tempList.name+'</div>\n' +
                                    '                </div>\n' +
                                    '            </div>\n' +
                                    '        </div>';
                                $('#user-music-list').append(html);
                                $('.music-value').attr('name',json.playlist[0].name);
                                load_user_music(json.playlist[0].id);
                            }
                            $('#music-info-refresh').removeClass('fa-spin');
                        }
                    }
                },
                error:function (data) {
                    console.log('获取用户信息失败！错误代码：1！');
                }
            });//ajax
        }
        get_userInfo();
        //刷新用户网易云音乐+资料
        $(".music-info-refresh").on("click","#music-info-refresh", function() {
            get_userInfo();  //加载排行榜
        });
        //获取歌曲排行榜
        function get_toplist() {
            $('#toplist').html('<h1 id="load-toplist" class="text-center"><i class="fa fa-spinner fa-spin"></i></h1>');   //清空排行榜
            //获取排行榜
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Music',
                data: "action=toplist",
                dataType : "json",
                success: function(json){
                    for(var i=0;i<json.length;i++) {
                        $.ajax({
                            type: 'POST',
                            url: music_api,
                            data: "types=playlist&id=" + json[i].music_id,
                            dataType: "jsonp",
                            success: function (jsonData) {
                                toplist(jsonData.playlist.id, jsonData.playlist.coverImgUrl, jsonData.playlist.name, jsonData.playlist.description, jsonData.privileges.length,jsonData.playlist.playCount);
                                return false;
                            },
                            error: function (data) {
                                alert('获取歌单列表失败，服务器内部错误！');
                            }
                        });//ajax*/
                    }
                    $('#load-toplist').remove();
                    $('.fa-refresh').removeClass('fa-spin');
                },
                error:function (data) {
                    alert('获取歌单列表失败，服务器内部错误！错误代码：1！');
                }
            });//ajax*/
        }
        get_toplist();
        //刷新排行榜
        $(".refresh-toplist").on("click",".fa-refresh", function() {
            $('.fa-refresh').addClass('fa-spin');   //添加过渡动画
            get_toplist();  //加载排行榜
        });
        function toplist(id,img,name,description,num,playCount) {
            var list = '        <div class="list-item toplist-data" id="'+id+'" name="'+name+'">\n' +
                '          <div class="list-left">\n' +
                '            <img alt="." src="'+img+'" class="w-40 circle">\n' +
                '          </div>\n' +
                '          <div class="list-body">\n' +
                '            <a href="#" class="_500 text-ellipsis">'+name+' (共播放：'+playCount+'次)<span class="pull-right text-muted label success">共：'+num+'首</span></a>\n' +
                '            <small class="block text-muted text-ellipsis">'+description+'</small>\n' +
                '          </div>\n' +
                '        </div>';
            $('#toplist').append(list);
        }
        //打开隐藏歌单
        $('[name="user-music-list"]').click(function () {
            $("#user-music-list").toggle(1000);
        });
        //时间戳转换
        function getMyDate(str){
            var oDate = new Date(str),
                oYear = oDate.getFullYear(),
                oMonth = oDate.getMonth()+1,
                oDay = oDate.getDate(),
                oHour = oDate.getHours(),
                oMin = oDate.getMinutes(),
                oSen = oDate.getSeconds(),
                oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+getzf(oMin) +':'+getzf(oSen);//最后拼接时间
            return oTime;
        }
        //补0操作
        function getzf(num){
            if(parseInt(num) < 10){
                num = '0'+num;
            }
            return num;
        }
        //将第一个歌单载入列表
        function load_user_music(id) {
            $('#music-list-data').html('');
            $('#music-title').html($('.music-value').attr('name')+' - 歌曲列表 <span class="pull-right"><a><i class="fa fa-refresh music-list-data-refresh fa-spin"></i></a></span>');
            $.ajax({
                type: 'POST',
                url: music_api,
                data: "types=playlist&id=" + id,
                dataType : "jsonp",
                success: function(jsonData){
                    var tempList=[];
                    if(typeof jsonData.playlist.tracks !== undefined || jsonData.playlist.tracks.length !== 0) {
                        // 存储歌单中的音乐信息
                        for (var i = 0; i < jsonData.playlist.tracks.length; i++) {
                            tempList =  {
                                id: jsonData.playlist.tracks[i].id,  // 音乐ID
                                name: jsonData.playlist.tracks[i].name,  // 音乐名字
                                artist: jsonData.playlist.tracks[i].ar[0].name, // 艺术家名字
                                album: jsonData.playlist.tracks[i].al.name,    // 专辑名字
                                source: "netease",     // 音乐来源
                                url_id: jsonData.playlist.tracks[i].id,  // 链接ID
                                pic_id: null,  // 封面ID
                                lyric_id: jsonData.playlist.tracks[i].id,  // 歌词ID
                                pic: jsonData.playlist.tracks[i].al.picUrl + "?param=300y300",    // 专辑图片
                                url: null   // mp3链接
                            };
                            music_template(i,tempList.id,tempList.name,tempList.artist,tempList.album,tempList.pic_id,tempList.source,tempList.lyric_id,tempList.pic);
                            $('.music-list-data-refresh').removeClass('fa-spin');
                        }
                    }
                },
                error:function (data) {
                    alert('获取歌曲列表失败，服务器内部错误！错误代码：1！');
                }
            });//ajax*/
        }
        //歌曲加载模板
        function music_template(no,id,name,artist,album,pic_id,source,lyric_id,pic) {
            var html = '                                    <tr id="'+(no+1)+'">\n' +
                '                                        <th style="width:50px;" class="">'+(no+1)+'</th>\n' +
                '                                        <th style="width:370px;" class="">'+name+'</th>\n' +
                '                                        <th style="width:180px;" class="">'+artist+'</th>\n' +
                '                                        <th class="text-ellipsis" style="width: 250px;height:51px;">'+album+'</th>\n' +
                '                                        <th style="width:100px;" class=""><button class="btn btn-sm btn-icon pull-left success" lid="'+(no+1)+'" id="'+id+'" name="play" source="'+source+'" pic_id="'+pic_id+'" lyric_id="'+lyric_id+'" pic="'+pic+'" mold="list-music1"><i class="ion-play"></i></button> <button class="btn btn-sm btn-icon pull-right blue" lid="'+(no+1)+'" id="'+id+'" name="add" source="'+source+'" pic_id="'+pic_id+'" lyric_id="'+lyric_id+'" pic="'+pic+'" mold="list-music1"><i class="ion-ios-plus"></i></button></th>\n' +
                '                                    </tr>';
            $('#music-list-data').append(html);
        }
        //加载某个歌单的音乐
        $("#user-music-list").on("click",".user-music-load-list", function(e) {
            $('.music-value').attr('name',$(this).attr('title'));
            load_user_music($(this).attr('id'));
            rem.listState = 0;
        });
        //加载某个排行榜的音乐
        $("#toplist").on("click",".toplist-data", function(e) {
            $('.music-value').attr('name',$(this).attr('name'));
            load_user_music($(this).attr('id'));
            rem.listState = 0;
        });
        //搜索音乐
        $(".search-music").on("click",".search-music-source", function(e) {
            var content = $('[name="content"]').val();
            var source = $(this).attr('id');
            if (content=='' || source==''){
                binyui.TipShow('请输入要搜索的内容...', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }else{
                $('.row-inner').animate({scrollTop: 0},400);
                rem.loadPage = 1;   // 已加载页数复位
                rem.num = 0;
                rem.wd = content;    // 搜索词
                rem.source = source;    //音乐来源
                ajaxSearch();   // 加载搜索结果
                return false;
            }
        });
        // ajax加载搜索结果
        function ajaxSearch() {
            if(rem.loadPage == 1) { // 显示过度动画
                $('#music-title').html(rem.wd+' - 歌曲列表 <span class="pull-right"><a><i class="fa fa-refresh music-list-data-refresh fa-spin"></i></a></span>');
            }
            $.ajax({
                type: 'POST',
                url: music_api,
                data: "types=search&count=" + Player.loadcount + "&source=" + rem.source + "&pages=" + rem.loadPage + "&name=" + rem.wd,
                dataType : "jsonp",
                complete: function(XMLHttpRequest, textStatus) {
                    $('.music-list-data-refresh').removeClass('fa-spin');//关闭加载动画
                },  // complete
                success: function(jsonData){
                    if(rem.loadPage == 1){  //加载第一页
                        if(jsonData.length === 0)   // 返回结果为零
                        {
                            binyui.TipShow('没有找到相关歌曲！', {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            return false;
                        }
                        $('#music-list-data').html(''); //清空列表
                        musicList[0].item = [];
                    }else{
                        $("#list-foot").remove();     //已经是加载后面的页码了，删除之前的“加载更多”提示
                    }
                    if (jsonData.length === 0){
                        addListbar("nomore");  // 加载完了
                        $('#music-list-data').attr('num',0);
                        return false;
                    }
                    var tempItem = [], no = musicList[0].item.length;
                    for (var i = 0; i < jsonData.length; i++) {
                        no ++;
                        tempItem =  {
                            id: jsonData[i].id,  // 音乐ID
                            name: jsonData[i].name,  // 音乐名字
                            artist: jsonData[i].artist[0], // 艺术家名字
                            album: jsonData[i].album,    // 专辑名字
                            source: jsonData[i].source,     // 音乐来源
                            url_id: jsonData[i].url_id,  // 链接ID
                            pic_id: jsonData[i].pic_id,  // 封面ID
                            lyric_id: jsonData[i].lyric_id,  // 歌词ID
                            pic: null,    // 专辑图片
                            url: null   // mp3链接
                        };
                        $('#music-list-data').attr('num',no);
                        music_template(rem.num++,tempItem.id,tempItem.name,tempItem.artist,tempItem.album,tempItem.pic_id,tempItem.source,tempItem.lyric_id,tempItem.pic);
                    }
                    if(no < Player.loadcount) {
                        $('#music-list-data').attr('num',0);
                        addListbar("nomore");  // 没加载满，说明已经加载完了
                    }
                    rem.dislist = 0;    // 当前显示的是搜索列表
                    rem.loadPage ++;    // 已加载的列数+1
                    rem.listState = 1;
                    return false;
                },
                error:function (data) {
                    alert('获取歌曲列表失败，服务器内部错误！错误代码：2！');
                }
            });
        }
        // 加载列表中的提示条
        // 参数：类型（more、nomore、loading、nodata、clear）
        function addListbar(types) {
            var html
            switch(types) {
                case "more":    // 还可以加载更多
                    html = '<tr id="list-foot"><th class="light-blue-100 text-center load-more-music" style="cursor:pointer" colspan="5">点击加载更多...</th></tr>';
                    break;
                case "nomore":  // 数据加载完了
                    html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5">人家也是有底线的！！！</th></tr>';
                    break;
                case "loading": // 加载中
                    html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5"><i class="fa fa-refresh fa-spin"></i> 列表加载中...</th></tr>';
                    break;
                case "nodata":  // 列表中没有内容
                    html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5">这个列表很懒，什么也没留下。</th></tr>';
                    break;
            }
            $('#music-list-data').append(html);
        }
        //加载更多
        $(".row-inner").scroll(function(){
            var $this =$(this),
                viewH =$(this).height(),//可见高度
                contentH =$(this).get(0).scrollHeight,//内容高度
                scrollTop =$(this).scrollTop();//滚动高度
            if(scrollTop/(contentH -viewH) >= 0.95){ //当滚动到距离底部5%时
                if (rem.listState==1){
                    ajaxSearch();
                }else{
                    if (document.getElementById("list-foot")){
                        return false;
                    }else{
                        addListbar('nomore');
                    }
                }
            }
        });
    }
    /* **************************************创建播放器************************************** */
    if (GetQueryValue('Mould')=='Player'){
        //创建播放器
        $('[name="found"]').on("click",".found", function(e) {
            if ($('[name="found"]').attr('value')==0){
                $('#hall').hide(500);
                $('#found').show(500);
                $('[name="found"]').attr('value','1');
                $('.found').html('<i class="fa fa-fw fa-mail-reply text-muted"></i> 点击返回');
            }else{
                $('#hall').show(500);
                $('#found').hide(500);
                $('[name="found"]').attr('value','0');
                $('.found').html('<i class="fa fa-fw fa fa-plus text-muted"></i> 创建一个播放器');
            }
        });
        $('.wizard').on("click",".previous", function(e) {
            if ($('.wizard').attr('value')!=1) $('.wizard').attr('value',parseInt($('.wizard').attr('value'))-parseInt(1));
        });
        $('[name="style"]').change(function() {
            if (typeof $(this).find("option:selected").attr('img')!="undefined"){
                $('.form-group[id="img"]').html(('<img class="text-center" src="'+$(this).find("option:selected").attr('img')+'" style="width: 300px;height: 130px;">'));
            }
        });
        $('.wizard').on("click",".next", function(e) {
            if ($('.wizard').attr('value')!=2){
                $('.wizard').attr('value',parseInt($('.wizard').attr('value'))+parseInt(1));
            }else{
                if ($('[name="auto_play"]').val()==null || $('[name="play_mode"]').val()==null || $('[name="is_clone"]').val()==null){
                    binyui.TipShow('所有项不能为空！', {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }else{
                    $('.next').html('<a href="#" class="btn white">正在处理...</a>');
                    var data = {
                        action:'player',
                        name:$('[name="name"]').val(),
                        auto_play:$('[name="auto_play"]').val()[0],
                        play_mode:$('[name="play_mode"]').val()[0],
                        is_clone:$('[name="is_clone"]').val()[0],
                        style:$('[name="style"]').val(),
                    };
                    $.ajax({
                        type:'POST',
                        url:'/Application/Mains.php?Mould=Player',
                        data:data,
                        dataType : "json",
                        success:function (json) {
                            if (json.state=='ok'){
                                binyui.TipShow(json.msg, {
                                    msgTimer: 5,
                                    msgColor: '#78fa4a',
                                    msgAxis: 'centerTop',
                                    xNum: '10%',
                                    yNum: '10%',
                                    zIndex: '99999'
                                });
                                var num = $('.player-num').text();
                                $('.player-num').text(parseInt(num)+parseInt(1));
                                $('[data-target="#tab_2"]').click();
                                $('.next').html('<a href="#" class="btn white">下一步</a>');
                            }else{
                                binyui.TipShow(json.msg, {
                                    msgTimer: 5,
                                    msgColor: '#efd314',
                                    msgAxis: 'centerTop',
                                    xNum: '10%',
                                    yNum: '10%',
                                    zIndex: '99999'
                                });
                                $('.next').html('<a href="#" class="btn white">下一步</a>');
                            }
                        },
                        error:function (data) {
                            binyui.TipShow('创建播放器失败，错误代码1，请稍后再试！', {
                                msgTimer: 5,
                                msgColor: '#fa0714',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.next').html('<a href="#" class="btn white">下一步</a>');
                        }
                    });
                }
            }
        });
        $(".tab_2").on('click', '.del-player',function(){
            $(this).text('正在处理...');
            var data = {
                action:'delplayer',
                id:$(this).attr('del_id')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        var num = $('.player-num').text();
                        $('.player-num').text(parseInt(num)-parseInt(1));
                        $('[data-target="#tab_2"]').click();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[del_id="'+data.id+'"]').text('删除');
                    }
                },
                error:function (data) {
                    binyui.TipShow('删除播放器失败，错误代码1，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[del_id="'+data.id+'"]').text('删除');
                }
            });
        });
        //播放器生成
        $('.tab_2').on("click",".generate", function(e) {
            var data = {
                action:'generate',
                id:$(this).attr('create_id')
            };
            $('[create_id="'+data.id+'"]').text('正在生成...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[create_id="'+data.id+'"]').text('已生成');
                        prompt(json.msg,json.code);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[create_id="'+data.id+'"]').text('生成');
                    }
                },
                error:function (data) {
                    binyui.TipShow('删除播放器失败，错误代码1，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[create_id="'+data.id+'"]').text('生成');
                }
            });
        });
        $('[data-target="#tab_2"]').click(function(){
            $('.tab_2').html('<i class="fa fa-spinner fa-spin load-player"></i>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: "action=playerlist",
                dataType : "json",
                success:function (json) {
                    $('.tab_2').html('');
                    for (var i=0;i<json.length;i++){
                        template_player(json[i].id,json[i].name,json[i].auto_play,json[i].play_mode,json[i].is_clone);
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取播放器列表失败，错误代码2，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        $('[data-target="#tab_3"]').click(function(){
            $('#song_list').html('<i class="fa fa-spinner fa-spin load-song"></i>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: "action=songlist",
                dataType : "json",
                success:function (json) {
                    $('#song_list').html('');
                    for (var i=0;i<json.length;i++){
                        template_song(json[i].id,json[i].name,json[i].img,json[i].quota);
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取歌单列表失败，错误代码1，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        //歌单模板
        function template_song(id,name,img,quota) {
            var html = '                            <div class="col-md-2 user-music-list-style" id="song_'+id+'">\n' +
                '                                <div class="box p-a-xs">\n' +
                '                                    <a><img src="'+img+'" alt="" class="img-responsive song_img"></a>\n' +
                '                                    <div class="user-music-list-count"><i id="song3_'+id+'_info" name="ajax_song" song3_id="'+id+'" class="ion-android-hand"></i><span class="pull-right"><label class="md-check"><input type="radio" name="radio_song2" value="'+id+'"><i class="blue"></i></label></span></div>\n'+
                '                                    <div class="p-a-sm">\n' +
                '                                        <div class="text-center text-ellipsis">'+name+'</div>\n' +
                '                                    </div>\n' +
                '                                </div>\n' +
                '                            </div>';
            $('#song_list').append(html);
        }
        $('#song_list').on("click",'.ion-android-hand', function(e) {
            var data = {
                action:'getsonginfo',
                id:$(this).attr('song3_id')
            };
            $('#song3_'+data.id+'_info').html('<i class="fa fa-spinner fa-spin"></i>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    $('#song3_'+data.id+'_info').html('<i class="fa fa-music"></i> '+json.num+'/'+json.num2+'</span>');
                },
                error:function (data) {
                    binyui.TipShow('获取歌单信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        //播放器模板
        function template_player(id,name,auto_play,play_mode,is_clone) {
            if (auto_play==1){
                auto_play='是';
            }else{
                auto_play='否';
            }
            if (play_mode==1){
                play_mode='顺序播放';
            }else{
                play_mode='随机播放';
            }
            if (is_clone==1){
                is_clone='允许';
            }else{
                is_clone='不允许';
            }
            var html = '                        <div class="col-sm-12">\n' +
                '                            <div class="box white">\n' +
                '                                <div class="box-body">\n' +
                '                                    <a herf="" class="list-left m-r">\n' +
                '                                        <span class="w-40 circle green">'+id+'</span>\n' +
                '                                    </a>\n' +
                '                                    <div class="clear">\n' +
                '                                        <a class="text-ellipsis">'+name+'</a>\n' +
                '                                        <small class="block text-muted"><i class="fa fa-headphones"></i> 自动播放:'+auto_play+' /<i class="fa fa-pencil-square"></i> 播放模式:'+play_mode+' /<i class="fa fa-adjust"></i> 克隆:'+is_clone+'</small>\n' +
                '                                        <a class="label success generate" create_id="'+id+'">生成</a>\n' +
                '                                        <a href="?Mould=Player&id='+id+'" class="label info">编辑</a>\n' +
                '                                        <a class="label red del-player" del_id="'+id+'">删除</a>\n' +
                '                                    </div>\n' +
                '                                </div>\n' +
                '                            </div>\n' +
                '                        </div>';
            $('.tab_2').append(html);
        }
        //添加歌单
        $('.form-inline').on("click",'[name="submit_song"]', function(e) {
            var data = {
                action:'addsong',
                name:$('[name="song_name"]').val(),
                img:$('[name="song_img"]').val()
            };
            $('[name="submit_song"]').text('正在处理...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data:data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        var num = $('.song-num').text();
                        $('.song-num').text(parseInt(num)+parseInt(1));
                        $('[name="submit_song"]').text('点击添加');
                        $('[data-target="#tab_3"]').click();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit_song"]').text('点击添加');
                    }
                },
                error:function (data) {
                    binyui.TipShow('创建歌单失败，错误代码1，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song"]').text('点击添加');
                }
            });
        });
        $('[data-target="#tab_4"]').click(function(){
            song_list_refresh2();
            music_list_refresh2();
        });
        function song_list_refresh2(){
            $('.load-song_list_refresh').addClass('fa-spin');
            $('.tab_4_song_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌单...</li>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: "action=songlist",
                dataType : "json",
                success:function (json) {
                    $('.tab_4_song_list').html('');
                    $('.load-song_list_refresh').removeClass('fa-spin');
                    for (var i=0;i<json.length;i++){
                        var html = '                                    <li class="list-group-item">\n' +
                            '                                        <a href="#" class="pull-left w-40 m-r"><img song2_id="'+json[i].id+'" alt="." src="'+json[i].img+'" class="img-responsive img-circle"></a>\n' +
                            '                                        <div class="clear">\n' +
                            '                                            <a href="#" class="_500 block">'+json[i].name+' <label class="md-check pull-right"><input type="radio" name="song_list_checkbox" value="'+json[i].id+'"><i class="blue"></i></label></a>\n' +
                            '                                            <span class="text-muted">歌单创建日期：'+json[i].addtime+'</span>\n' +
                            '                                        </div>\n' +
                            '                                    </li>';
                        $('.tab_4_song_list').append(html);
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取歌单列表失败，错误代码3，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        }
        $('#song_list_refresh').on("click",".fa-refresh", function(e) {
            song_list_refresh2();
        });
        function music_list_refresh2(){
            $('.load_music_list_refresh2').addClass('fa-spin');
            $('.tab_4_music_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌曲...</li>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: "action=musiclist",
                dataType : "json",
                success:function (json) {
                    $('.tab_4_music_list').html('');
                    $('.load_music_list_refresh2').removeClass('fa-spin');
                    for (var i=0;i<json.length;i++){
                        var html='                                    <li class="list-group-item" id="music2_'+json[i].music_id+'">\n' +
                            '                                        <a class="pull-right text-muted m-l-xs label danger remove_music2_id reid_'+json[i].music_id+'" reid="'+json[i].music_id+'">移除</a>\n' +
                            '                                        <a class="pull-right label primary add_music2_id adid_'+json[i].music_id+'" adid="'+json[i].music_id+'">添加</a>\n' +
                            '                                        '+(parseInt(i+1))+'. '+json[i].music_name+' - '+json[i].music_artist+'\n' +
                            '                                    </li>';
                        $('.tab_4_music_list').append(html);
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取歌曲列表失败，错误代码3，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        }
        $('#music_list_home2 ').on("click",".load_music_list_home2", function(e) {
            music_list_refresh2();
        });
        $('#music_list_refresh2').on("click",".load_music_list_refresh2", function(e) {
            music_list_refresh2();
        });
        $('.tab_4_music_list').on("click",".add_music2_id", function(e) {
            var value = $('.tab_4_music_list').attr('value');
            if (value==0){
                $('.tab_4_music_list').attr('value','1');
                $(this).html('<i class="fa fa-spinner fa-spin"></i>');
                var data = {
                    action:'addmusicgosong',
                    song_id:$("input[name='song_list_checkbox']:checked").val(),
                    music_id:$(this).attr('adid')
                };
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Player',
                    data:data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.tab_4_music_list').attr('value','0');
                            $('#music2_'+data.music_id+'').remove();
                        }else {
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.tab_4_music_list').attr('value','0');
                            $('.adid_'+data.music_id+'').html('添加');
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('添加歌曲到指定歌单失败，错误代码3，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.tab_4_music_list').attr('value','0');
                        $('.adid_'+data.music_id+'').html('添加');
                    }
                });
            }else{
                binyui.TipShow('请先等待上一条任务完成后再进行操作！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
        $('.tab_4_music_list').on("click",".remove_music2_id", function(e) {
            var value = $('.tab_4_music_list').attr('value');
            if (value=='0'){
                $('.tab_4_music_list').attr('value','1');
                $(this).html('<i class="fa fa-spinner fa-spin"></i>');
                var data = {
                    action:'delmusicgosong',
                    music_id:$(this).attr('reid')
                };
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Player',
                    data:data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            var num = $('.music-num').text();
                            $('.music-num').text(parseInt(num)-parseInt(1));
                            $('.tab_4_music_list').attr('value','0');
                            $('#music2_'+data.music_id+'').remove();
                        }else {
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.tab_4_music_list').attr('value','0');
                            $('.reid_'+data.music_id+'').html('移除');
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('删除歌曲失败，错误代码3，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.tab_4_music_list').attr('value','0');
                        $('.reid_'+data.music_id+'').html('移除');
                    }
                });
            }else{
                binyui.TipShow('请先等待上一条任务完成后再进行操作！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
        $('.tab_4_song_list').on("click","img", function(e) {
            $('.load_music_list_refresh2').addClass('fa-spin');
            $('.tab_4_music_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌曲...</li>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: "action=getsonggomusic&song_id="+$(this).attr('song2_id'),
                dataType : "json",
                success:function (json) {
                    $('.tab_4_music_list').html('');
                    $('.load_music_list_refresh2').removeClass('fa-spin');
                    for (var i=0;i<json.length;i++){
                        var html='                                    <li class="list-group-item" id="music2_'+json[i].music_id+'">\n' +
                            '                                        <a class="pull-right text-muted m-l-xs label danger remove_music2_id reid_'+json[i].music_id+'" reid="'+json[i].music_id+'">移除</a>\n' +
                            '                                        <a class="pull-right label primary add_music2_id" adid="'+json[i].music_id+'">添加</a>\n' +
                            '                                        '+(parseInt(i+1))+'. '+json[i].music_name+' - '+json[i].music_artist+'\n' +
                            '                                    </li>';
                        $('.tab_4_music_list').append(html);
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取歌曲列表失败，错误代码3，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        $('.pull-right').on("click",'[name="submit_song_edit"]', function(e) {
            var data = {
                action:'getsonginfo2',
                id:$("input[name='radio_song2']:checked").val(),
            };
            $('[name="submit_song_edit"]').html('正在处理...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        $('#song_info').show(800);
                        $('#song_info').attr('value',data.id);
                        $('[name="submit_song_edit"]').html('编辑');
                        $('[name="song_name2"]').val(json.name);
                        $('[name="song_img2"]').val(json.img);
                        $('#player_name3').html(json.player);
                        $.ajax({
                            type: 'POST',
                            url: '/Application/Mains.php?Mould=Player',
                            data: "action=playerlist",
                            dataType : "json",
                            success:function (data) {
                                $('[name="payer_id2"]').html('');
                                for (var i=0;i<data.length;i++){
                                    $('[name="payer_id2"]').append('<option value="'+data[i].id+'">'+data[i].name+' [最大只能储存'+data[i].song_quota+'个歌单]</option>');
                                }
                            },
                            error:function (data) {
                                binyui.TipShow('获取播放器列表失败，错误代码2，请稍后再试！', {
                                    msgTimer: 5,
                                    msgColor: '#fa0714',
                                    msgAxis: 'centerTop',
                                    xNum: '10%',
                                    yNum: '10%',
                                    zIndex: '99999'
                                });
                            }
                        });
                    }else {
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit_song_edit"]').html('编辑');
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取要编辑的歌单信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song_edit"]').html('编辑');
                }
            });
        });
        $('#song_info').on("click",'[name="submit_song3"]', function(e) {
            $('[name="submit_song3"]').html('正在处理...');
            var data = {
                action:'editsong',
                id:$('#song_info').attr('value'),
                name:$('[name="song_name2"]').val(),
                img:$('[name="song_img2"]').val(),
                player:$('[name="payer_id2"]').val(),
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[data-target="#tab_3"]').click();
                        $('#song_info').hide(800);
                        $('[name="submit_song3"]').html('点击保存');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit_song3"]').html('点击保存');
                    }
                },
                error:function (data) {
                    binyui.TipShow('保存歌单信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song3"]').html('点击保存');
                }
            });
        });
        $('.pull-right').on("click",'[name="submit_song_del"]', function(e) {
            if (confirm('你确定要删除该歌单吗？删除后，歌单内的歌曲都恢复到默认音乐列表！')){
                var data = {
                    action:'delsong',
                    id:$("input[name='radio_song2']:checked").val(),
                };
                $('[name="submit_song_del"]').html('正在处理...');
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Player',
                    data: data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            var num = $('.song-num').text();
                            $('.song-num').text(parseInt(num)-parseInt(1));
                            $('#song_'+data.id).remove();
                            $('[name="submit_song_del"]').html('移除');
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('[name="submit_song_del"]').html('移除');
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('保存歌单信息失败，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit_song_del"]').html('移除');
                    }
                });
            }
        });
    }
    /* **************************************挂机管理************************************** */
    if (GetQueryValue('Mould')=='QQList'){
        //获取挂机信息
        $('[role="menu"]').on("click",'.qqinfo', function(e) {
            binyui.TipShow('正在获取数据...', {
                msgTimer: 15,
                msgColor: '#4BC0C0',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
            var data = {
                action:'info',
                id:$("input[name='radio_qq']:checked").val()
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=QQList',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow('获取信息成功！', {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.qqtx').attr('src','http://q2.qlogo.cn/headimg_dl?bs='+json.msg[0].qq+'&dst_uin='+json.msg[0].qq+'&dst_uin='+json.msg[0].qq+'&;dst_uin='+json.msg[0].qq+'&spec=100&url_enc=0&referer=bu_interface&term_type=PC');
                        $.get("https://cloud.xmyrs.cn/qqnick/?qq="+json.msg[0].qq, function(result){
                            $('.qqnick').text(result);
                        });
                        $('.qqnumber').text(json.msg[0].qq);
                        if (json.msg[0].status=='0'){
                            $('.qqzt').text('状态码正常');
                        }else{
                            $('.qqzt').text('QQ状态码已过期！');
                        }
                        $('.addtime').text(json.msg[0].addtime);
                        $('.gxtime').text(json.msg[0].gxtime);
                        $('#qqinfo').show(800);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 6,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取QQ信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        //删除挂机
        $('[role="menu"]').on("click",'.del', function(e) {
            var data = {
                action:'del',
                id:$("input[name='radio_qq']:checked").val()
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=QQList',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[qid="'+data.id+'"]').remove();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('删除挂机失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
    }
    /* **************************************QQ昵称修改************************************** */
    if (GetQueryValue('Mould')=='QQNick'){
        $('[name="qq"]').change(function(){
            $.get("https://cloud.xmyrs.cn/qqnick/?qq="+$('[value="'+$('[name="qq"]').val()+'"]').text(), function(result){
                $('.qqnick').val(result);
                $('[name="nick"]').removeAttr('disabled');
            });
        });
        $('.submit').on("click",'[name="submit"]', function(e) {
            var data = {
                action:'edit',
                qid:$('[name="qq"]').val(),
                nick:$('[name="nick"]').val()
            };
            $('[name="submit"]').text('正在处理...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=QQNick',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.qqnick').val(data.nick);
                        $('[name="submit"]').text('点击修改');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('点击修改');
                    }
                },
                error:function (data) {
                    binyui.TipShow('修改QQ昵称失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('点击修改');
                }
            });
        });
    }
    /* **************************************QQ亲密度查询************************************** */
    if (GetQueryValue('Mould')=='QQIntimacy'){
        $('.submit').on("click",'[name="submit"]', function(e) {
            $('[name="submit"]').text('正在处理...');
            var data = {
                action:'getqqcare',
                qid:$('[name="qid"]').val()
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=QQIntimacy',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('查询');
                        $('#fans_count').html('目前你有<b>'+json.used_count+'</b>位特别关心的好友，特别关心你的好友共有<b>'+json.fans_count+'</b>位。');
                        $('#me_care').html('');
                        for (var i=0;i<json.list1.length;i++){
                            var html = '                            <tr>\n' +
                                '                                <td>'+json.list1[i].index+'</td>\n' +
                                '                                <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list1[i].uin+'&amp;dst_uin='+json.list1[i].uin+'&amp;dst_uin='+json.list1[i].uin+'&amp;;dst_uin='+json.list1[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                                '                                <td>'+json.list1[i].name+'</td>\n' +
                                '                                <td>'+json.list1[i].uin+'</td>\n' +
                                '                                <td>'+json.list1[i].score+'</td>\n' +
                                '                                <td><a href="https://user.qzone.qq.com/'+json.list1[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a></td>\n' +
                                '                            </tr>';
                            $('#me_care').append(html);
                            $('.me_care').text(i);
                        }
                        $('#care_me').html('');
                        for (var i=0;i<json.list2.length;i++){
                            var html = '                            <tr>\n' +
                                '                                <td>'+json.list2[i].index+'</td>\n' +
                                '                                <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list2[i].uin+'&amp;dst_uin='+json.list2[i].uin+'&amp;dst_uin='+json.list2[i].uin+'&amp;;dst_uin='+json.list2[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                                '                                <td>'+json.list2[i].name+'</td>\n' +
                                '                                <td>'+json.list2[i].uin+'</td>\n' +
                                '                                <td>'+json.list2[i].score+'</td>\n' +
                                '                                <td><a href="https://user.qzone.qq.com/'+json.list2[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a></td>\n' +
                                '                            </tr>';
                            $('#care_me').append(html);
                            $('.care_me').text(i);
                        }
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('查询');
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                }
            });
        });
    }
    /* **************************************QQ查询可能认识的人************************************** */
    if (GetQueryValue('Mould')=='QQIsknow'){
        $('.submit').on("click",'[name="submit"]', function(e) {
            $('[name="submit"]').text('正在处理...');
            var data = {
                action:'isknow',
                qid:$('[name="qid"]').val()
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=QQIsknow',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('查询');
                        $('#isknow').html('');
                        for (var i=0;i<json.list.length;i++){
                            var html = '          <tr>\n' +
                                '            <td>'+i+'</td>\n' +
                                '            <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list[i].uin+'&amp;dst_uin='+json.list[i].uin+'&amp;dst_uin='+json.list[i].uin+'&amp;;dst_uin='+json.list[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                                '            <td>'+json.list[i].remark+'</td>\n' +
                                '            <td>'+json.list[i].uin+'</td>\n' +
                                '            <td>'+json.list[i].num+' 个</td>\n' +
                                '            <td>'+gender(json.list[i].gender)+'</td>\n' +
                                '            <td><a href="https://user.qzone.qq.com/'+json.list[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a> <a href="tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin='+json.list[i].uin+'" class="md-btn md-raised m-b-sm w-xs green">添加好友</a></td>\n' +
                                '          </tr>';
                            $('#isknow').append(html);
                        }
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('查询');
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                }
            });
        });
        function gender(gender) {
            if (gender=='2'){
                return '女';
            }else if (gender=='1'){
                return '男';
            }else{
                return '保密';
            }
        }
    }
    /* **************************************视频全能解析************************************** */
    if (GetQueryValue('Mould')=='Video'){
        $('.submit').on("click",'[name="submit"]', function(e) {
            $('[name="submit"]').text('正在处理...');
            var data = {
                api:$('[name="api"]').val(),
                url:$('[name="url"]').val()
            };
            if(data.api=='' || data.url==''){
                binyui.TipShow('所有项不能为空！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('开始解析');
            }else{
                $('#video').attr('src',$('[name="api"]').val()+$('[name="url"]').val());
                $('[name="submit"]').text('开始解析');
            }
        });
    }
    /* **************************************网站配置************************************** */
    if (GetQueryValue('Mould')=='Admin_website'){
        $('.website').on("click",'[name="website_submit"]', function(e) {
            $('[name="website_submit"]').text('正在处理...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_website',
                data: $('.website').serialize(),
                dataType : "json",
                success:function (json) {
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="website_submit"]').text('点击保存');
                },
                error:function (data) {
                    binyui.TipShow('保存数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="website_submit"]').text('点击保存');
                }
            });
        });
    }
    /* **************************************公告配置************************************** */
    if (GetQueryValue('Mould')=='Admin_notice'){
        var login_notice = UM.getEditor('login_notice');    //初始化1
        var users_notice = UM.getEditor('users_notice');    //初始化1
        var palyer_notice = UM.getEditor('palyer_notice');    //初始化1
        login_notice.addListener('blur',function(){
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_notice',
                data: {'action':'notice','login_notice':login_notice.getContent()},
                dataType : "json",
                success:function (json) {
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                },
                error:function (data) {
                    binyui.TipShow('保存数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        users_notice.addListener('blur',function(){
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_notice',
                data: {'action':'notice','users_notice':users_notice.getContent()},
                dataType : "json",
                success:function (json) {
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                },
                error:function (data) {
                    binyui.TipShow('保存数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        palyer_notice.addListener('blur',function(){
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_notice',
                data: {'action':'notice','palyer_notice':palyer_notice.getContent()},
                dataType : "json",
                success:function (json) {
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                },
                error:function (data) {
                    binyui.TipShow('保存数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
    }
    /* **************************************视频解析配置************************************** */
    if (GetQueryValue('Mould')=='Admin_Video'){
        //新增
        $('.submit').on("click",'[name="submit"]', function(e) {
            $('[name="submit"]').text('正在处理...');
            var data = {
                action:'add',
                name:$('[name="name"]').val(),
                api:$('[name="api"]').val()
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Video',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        var index = $(".api_list").find("tr").length+1;
                        $('.api_list').append('<tr api_id="'+index+'"><td>'+index+'</td><td>'+data.name+'</td><td>'+data.api+'</td><td><a class="label danger" title="移除" id="'+json.id+'">移除</a></td></tr>');
                        $('[name="submit"]').text('点击添加');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('点击添加');
                    }
                },
                error:function (data) {
                    binyui.TipShow('新增接口失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('点击添加');
                }
            });
        });
        //移除
        $('.api_list').on("click",'.del', function(e) {
            $(this).text('正在处理...');
            var data = {
                action:'del',
                id:$(this).attr('idm'),
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Video',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        console.log(data.id)
                        $('[idm="'+data.id+'"]').text('已移除');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[idm="'+data.id+'"]').text('移除');
                    }
                },
                error:function (data) {
                    binyui.TipShow('保存数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[idm="'+data.id+'"]').text('移除');
                }
            });
        });
    }
    /* **************************************用户管理************************************** */
    if (GetQueryValue('Mould')=='Admin_Users'){
        $('.user-list').on("click",'.query-qq-count', function(e) {
            var data = {
                action:'count',
                only:$(this).attr('only'),
            };
            $('[only="'+data.only+'"').text('请稍等...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Users',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        $('[only="'+data.only+'"').text('共：'+json.msg+' 个');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[only="'+data.only+'"').text('点击查看');
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[only="'+data.only+'"').text('点击查看');
                }
            });
        });
    }
    /* **************************************奖品配置************************************** */
    if (GetQueryValue('Mould')=='Admin_Prize'){
        $('.luck_table').on("click",'.luck_num', function(e) {
            var num=prompt("请输入要修改的值：",$(this).text());
            if (num!=null && num!=""){
                var data = {
                    action:'edit_num',
                    id:$(this).attr('id'),
                    num:num
                };
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Admin_Prize',
                    data: data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.luck_num_'+data.id+' a').text(num);
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('修改数据失败，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                });
            }
        });
        $('.luck_table').on("click",'.luck_edit', function(e) {
            var num=prompt("请输入要修改的值：",$(this).text());
            if (num!=null && num!=""){
                var data = {
                    action:'edit_luck',
                    id:$(this).attr('luck_id'),
                    num:num
                };
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Admin_Prize',
                    data: data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.luck_edit_'+data.id+' a').text(num);
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('修改数据失败，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                });
            }
        });
    }
    /* **************************************添加商品************************************** */
    if (GetQueryValue('Mould')=='Admin_Goods'){
        //添加商品
        $('#addgoods').on("click",'[name="submit"]', function(e) {
            $('[name="submit"]').html('正在处理...');
            var data={
                action:'add',
                name:$('[name="name"]').val(),
                image:$('[name="image"]').val(),
                content:$('[name="content"]').val(),
                stock:$('[name="stock"]').val(),
                mold:$('[name="mold"]').val(),
                money:$('[name="money"]').val(),
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Goods',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        window.location.reload();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').html('点击添加');
                    }
                },
                error:function (data) {
                    binyui.TipShow('新增数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').html('点击添加');
                }
            });
        });
        //获取信息
        $('#list').on("click",'.query', function(e) {
            var data = {
                action:'info',
                id:$(this).attr('queryid')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Goods',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('#img').html(json.data.image);
                        $('#name').html(json.data.name);
                        $('#content2').html(json.data.content);
                        $('#num').html(json.data.stock);
                        $('#addtime').html(json.data.addtime);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('获取商品信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
        //删除商品
        $('#list').on("click",'.del', function(e) {
            var data = {
                action:'del',
                id:$(this).attr('delid')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Goods',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        window.location.reload();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('新增数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        });
    }
    /* **************************************商品管理************************************** */
    if (GetQueryValue('Mould')=='Mall'){
        $('.box-footer').on("click",'[name="recharge"]', function(e) {
            layer.open({
                title:'彩虹屁充值',
                type: 2,
                content: $('[name="recharge"]').attr('src')+'?price='+$('[name="money"]').val()+'&type='+$('[name="mold"]').val()+'&user='+$('[name="only"]').val(),
                area: ['100%', '100%'],
                maxmin: true,
                end: function(){
                    window.location.reload();
                }
            });
        });
        $('#mall').on("click",'#buy', function(e) {
            var is=confirm("你确定要购买"+$(this).attr('name')+"吗？");
            binyui.TipShow('正在处理...', {
                msgTimer: 15,
                msgColor: '#01aaed',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
            if (is==true){
                var data = {
                    action:'buy',
                    id:$(this).attr('gid')
                };
                $.ajax({
                    type: 'POST',
                    url: '/Application/Mains.php?Mould=Mall',
                    data: data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            window.location.reload();
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('购买商品失败，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                });
            }
        });
    }
});
/* **************************************无pjax版************************************** */
//播放器页面/小工具
$('#tool-state').click(function () {
    if ($('#tool-state').attr('value')=='1'){
        $('#tool-state').attr('value','0'); //更改小工具栏状态
        $('#player-music').show(1000);  //打开音乐界面
        $('#system-config').hide(1000); //隐藏系统设置界面
        $('#tool-title').text('当前：播放器');    //更改标题
    }else{
        $('#tool-state').attr('value','1'); //更改小工具栏状态
        $('#player-music').hide(1000);  //打开音乐界面
        $('#system-config').show(1000); //隐藏系统设置界面
        $('#tool-title').text('当前：小工具');    //更改标题
    }
});
$('input:radio[name="color"]').click(function(){
    var checkValue = $('input:radio[name="color"]:checked').val();
    $('#app-header').attr('class','app-header '+checkValue+' bg b-b');
});
/* **************************************播放器操作************************************** */
$("#music-list-data").on("click","button", function(e) {
    rem.player_lid = $(this).attr('lid');
    rem.player_mold = $(this).attr('name');
    rem.player_list = 1;
    rem.player_jq = $('[lid="'+rem.player_lid+'"][mold="list-music1"]');
    if (rem.player_mold=='play'){  //播放
        player_show();
    }else if (rem.player_mold=='add'){ //添加
        var state = $('#music-list-data').attr('state');
        if (state=='0'){
            $('#music-list-data').attr('state','1');
            var pic_id = rem.player_jq.attr('pic_id');
            if (pic_id=='null') pic_id = rem.player_jq.attr('pic');
            var data = {
                action:'add',
                name:rem.player_jq.parents()[1].firstChild.parentNode.cells[1].innerText,
                artist:rem.player_jq.parents()[1].firstChild.parentNode.cells[2].innerText,
                album:rem.player_jq.parents()[1].firstChild.parentNode.cells[3].innerText,
                url_id:rem.player_jq.attr('id'),
                pic_id:pic_id,
                lyric_id:rem.player_jq.attr('lyric_id'),
                source:rem.player_jq.attr('source')
            };
            $(this).html('<i class="fa fa-spinner fa-spin"></i>');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Music',
                data: data,
                dataType: "json",
                success: function(json){
                    if (json.state=='ok'){
                        $('#music-list-data').attr('state','0');
                        $('[id="'+json.id+'"][name="add"]').html('<i class="ion-checkmark"></i>');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('#music-list-data').attr('state','0');
                        $('[lid="'+json.id+'"][name="add"]').html('<i class="ion-ios-plus"></i>');
                    }
                },
                error:function (data) {
                    binyui.TipShow('添加歌曲失败，错误代码2，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('#music-list-data').attr('state','0');
                }
            });
        }else{
            binyui.TipShow('请等上一个任务处理完毕后再进行操作！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }
    }else {
        binyui.TipShow('未知操作！', {
            msgTimer: 5,
            msgColor: '#efd314',
            msgAxis: 'centerTop',
            xNum: '10%',
            yNum: '10%',
            zIndex: '99999'
        });
    }
});
/* **************************************控制台************************************** */
if (GetQueryValue('Mould')=='Home' || GetQueryValue('Mould')==null){
    /**
     **  BinySilderImg{Array}       用户自定义轮播图数组
     **  BinySilderSetting{Object}   用户自定义设置
     **/
    binyui.Silder([
        'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g5/M00/09/02/ChMkJ1ah6XqIFvFFAAa5bop774sAAHjswApOYsABrmG421.jpg',
        'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g5/M00/00/07/ChMkJ13qNJeIcWlLAAXZO1T9wbMAAvnJACT_eMABdlT817.jpg',
        'https://desk-fd.zol-img.com.cn/t_s1366x768c5/g1/M00/0C/0B/Cg-4jlOo61uIffFgAA-NvTqSHGoAAOipAEfF2MAD43V097.jpg'
    ],{
        SilderId: '.BinySilderDemo', //要放置轮播图的盒子ID
        SilderTimer: true, //轮播图定时器开启
        SilderTimes: 3, //轮播图每3秒下一张
        SilderWidth: '930px', //轮播图盒子宽度
        SilderHight: '400px', //轮播图盒子高度
        SilderImgSize: 'cover', //轮播图平铺方式
        SilderImgRadius: '0px', //轮播图圆角
        SilderLeftAmin: 'bounceInUp', //点击上一张动画类名（Animation.css）
        SilderLeftAminTime: '1s', //点击上一张动画做的时长
        SilderRightAmin: 'bounceIn', //点击下一张动画类名（Animation.css）
        SilderRightAminTime: '1s', //点击下一张动画做的时长
        SilderHideAmin: 'fadeOut', //动画消失类名（Animation.css）
        SilderHideAminTime: '1s', //动画消失做的时长
        SilderRandomAmin: true, //动画随机
        SilderClickBtn: true, //可否点击按钮
    });
    $('.modal-dialog').on("click",'[name="luck-button"]', function(e) {
        $('.luck-progress').css('width','30%');
        $('.luck-progress').text('30%');
        $.ajax({
            type: 'POST',
            url : '?Mould=Home',
            data: {'action':'luck'},
            dataType: 'json',
            beforeSend : function(){
                $('.luck-progress').css('width','50%');
                $('.luck-progress').text('50%');
            },
            complete: function(){
                $('.luck-progress').css('width','100%');
                $('.luck-progress').text('100%');
            },
            success:function(json){
                if (json.state='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    if (json.data.mold=='jq'){
                        $('#luck-result').html('恭喜您，获得了'+json.data.name+'，群号：'+json.data.num+'！');
                    }else if (json.data.mold=='money'){
                        $('#luck-result').html('恭喜您，获得了站长的'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                    }else if(json.data.mold=='q_quota'){
                        $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                    }else if (json.data.mold=='p_quota'){
                        $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                    }else if (json.data.mold=='s_quota'){
                        $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                    }else if (json.data.mold=='u_quota'){
                        $('#luck-result').html('恭喜您，获得了'+json.data.name+json.data.num+'个，奖励已经发放到你的账户中！');
                    }else{
                        $('#luck-result').html('好的，谢谢参与！');
                    }
                    $('#luck-num').html(0);
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            },
            error:function (data) {
                binyui.TipShow('抽奖失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
}
/* **************************************资料修改************************************** */
if (GetQueryValue('Mould')=='User'){
    //查看更多
    $('[name="is_auto"]').click(function(){
        $(".is_auto").toggle(1000);
    });
    //修改资料
    $('[name="edit"]').click(function(){
        $('input,select,button').removeAttr('disabled');
    });
    $('[name="submit"]').click(function(){
        $('[name="submit"]').text('正在修改...');
        $('[name="submit"]').attr('disabled','disabled');
        var name = $('[name="name"]').val();
        var qq = $('[name="qq"]').val();
        var email = $('[name="email"]').val();
        var music_id = $('[name="music_id"]').val();
        var cqyzt = $('[name="cqyzt"]').val();
        var aqproblem = $('[name="aqproblem"]').val();
        var aqanswer = $('[name="aqanswer"]').val();
        var pwd = $('[name="pwd"]').val();
        var chat_bg = $('[name="chat_bg"]').val();
        if (name=='' || qq=='' || email=='' || music_id=='' || cqyzt=='' || aqproblem=='' || aqanswer==''){
            binyui.TipShow('所有带*号的都必须填写！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
            $('[name="submit"]').text('点击保存');
            $('input,select,button').removeAttr('disabled');
        }else{
            $.ajax({
                type: "POST",
                url: '/Application/Mains.php?Mould=User',
                data: {'action':'edit','name':name,'qq':qq,'email':email,'music_id':music_id,'cqyzt':cqyzt,'aqproblem':aqproblem,'aqanswer':aqanswer,'pwd':pwd,'chat_bg':chat_bg},
                dataType: 'json',
                success: function (data) {
                    if (data.state=='ok'){
                        binyui.TipShow(data.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('点击保存');
                        $('input,select,button').removeAttr('disabled');
                    }else{
                        binyui.TipShow(data.msg, {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit"]').text('点击保存');
                        $('input,select,button').removeAttr('disabled');
                    }
                },
                error:function (data) {
                    alert('保存失败，服务器内部错误！');
                    $('[name="submit"]').text('点击保存');
                    $('input,select,button').removeAttr('disabled');
                }
            });
        }
    });
}
/* **************************************聊天专区************************************** */
if (GetQueryValue('Mould')=='Chat') {
    var scrollHeight = $('#chat').prop("scrollHeight");
    $('#chat').animate({scrollTop:scrollHeight}, 400);
    $('[name="submit"]').click(function () {
        var content = $('[name="content"]').val();
        $('[name="content"]').val('');
        if (content!=''){
            $('#chat').append(chat(content.replace(/<[^>]+>/g,"")));
            $('#chat').animate({scrollTop:scrollHeight}, 400);
            $.ajax({
                type: "POST",
                url: '/Application/Mains.php?Mould=Chat',
                data: {'action':'send','content':content},
                dataType: 'json',
                success: function (data) {
                    if (data.state=='ok'){
                        $('.chat-state').remove();
                    }else{
                        $('.chat-state').html('<i class="text-danger fa fa-exclamation-circle"></i>');
                    }
                },
                error:function () {
                    alert('发送失败，服务器内部错误！');
                }
            });
        }else{
            binyui.TipShow('请输入聊天内容！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }
    });
    //发送内容的模板
    function chat(content) {
        var img = $('.w-full').attr('src');
        return '\t\t\t\t\t            <div class="p-a-md"><div class="m-b">\n' +
            '\t\t\t\t\t              <a href="#" class="pull-right w-40 m-l-sm">\n' +
            '\t\t\t\t\t              \t<img src="'+img+'" class="w-full img-circle" alt=".">\n' +
            '\t\t\t\t\t              </a>\n' +
            '\t\t\t\t\t              <div class="clear text-right">\n' +
            '\t\t\t\t\t                <div class="p-a p-y-sm success inline rounded text-left">\n' +
            '\t\t\t\t\t                  <a class="chat-state text-warning"><i class="fa fa-spinner fa-spin"></i></a> ' + content + '\n' +
            '\t\t\t\t\t                </div>\n' +
            '\t\t\t\t\t                <div class="text-muted text-xs m-t-xs">刚刚</div>\n' +
            '\t\t\t\t\t              </div>\n' +
            '\t\t\t\t\t            </div></div>';
    }
}
/* **************************************音乐大厅************************************** */
if (GetQueryValue('Mould')=='Music') {
    //获取用户网易云音乐+资料
    function get_userInfo() {
        $('#user-music-list').html(''); //清空列表
        $('#music-info-refresh').addClass('fa-spin');   //添加过渡动画
        $.ajax({
            type: 'POST',
            url: music_api,
            data: "types=userlist&uid=" + music_id,
            dataType : "jsonp",
            success: function(json){
                if (json.code!='400'){
                    if (json.playlist.length === 0 || typeof(json.playlist.length) === "undefined"){
                        binyui.TipShow('嘤嘤嘤，没有找到ID'+music_id+'的主人！', {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('#music-img').attr('src','http://q2.qlogo.cn/headimg_dl?bs=17404785&dst_uin=17404785&dst_uin=17404785&;dst_uin=17404785&spec=100&url_enc=0&referer=bu_interface&term_type=PC'); //更改头像
                        $('#music-nick').html('<i class="fa fa-user"></i> '+'昵称');    //更换昵称
                        $('#music-info').html('暂无信息！');    //更改资料
                        return false;
                    }else{
                        rem.music_uid = json.playlist[0].creator.userId;
                        rem.music_name = json.playlist[0].creator.nickname;
                        $('#music-img').attr('src',json.playlist[0].creator.avatarUrl); //更改头像
                        $('#music-blur').attr('src',json.playlist[0].creator.backgroundUrl);    //更换背景
                        $('#music-nick').html('<i class="fa fa-user"></i> '+rem.music_name);    //更换昵称
                        $('#music-info').html(' <i class="fa fa-heart"></i> 性别：'+(json.playlist[0].creator.gender?'男':'女')+' <i class="fa fa-calendar"></i> 注册时间：'+getMyDate(json.playlist[0].createTime));    //更换昵称
                        var tempList;
                        for (var i = 0; i < json.playlist.length; i++){
                            // 获取歌单信息
                            tempList = {
                                id: json.playlist[i].id,    // 列表的网易云 id
                                name: json.playlist[i].name,   // 列表名字
                                playCount: json.playlist[i].playCount,   //播放次数
                                cover: json.playlist[i].coverImgUrl  + "?param=200y200",   // 列表封面
                                creatorID: json.playlist[i].creator.userId,   // 列表创建者id
                                creatorName: json.playlist[i].creator.nickname,   // 列表创建者名字
                                creatorAvatar: json.playlist[i].creator.avatarUrl,   // 列表创建者头像
                                item: []
                            };
                            var html = '        <div class="col-md-1 user-music-list-style">\n' +
                                '            <div class="box p-a-xs">\n' +
                                '                <a class="user-music-load-list" id="'+tempList.id+'" title="'+tempList.name+'"><img src="https://p1.music.126.net/lArHZR-mrcB0Xckjr9qKsQ==/1366692955578988.jpg?param=140y140" alt="'+tempList.name+'" class="img-responsive"></a>\n' +
                                '                <div class="user-music-list-count"><i class="fa fa-headphones"></i> '+tempList.playCount+' <span class="pull-right"><i class="fa fa-play-circle"></i></span></div>\n' +
                                '                <div class="p-a-sm user-music-list-foot">\n' +
                                '                    <div class="text-center text-ellipsis user-love-music-title">'+tempList.name+'</div>\n' +
                                '                </div>\n' +
                                '            </div>\n' +
                                '        </div>';
                            $('#user-music-list').append(html);
                            $('.music-value').attr('name',json.playlist[0].name);
                            load_user_music(json.playlist[0].id);
                        }
                        $('#music-info-refresh').removeClass('fa-spin');
                    }
                }
            },
            error:function (data) {
                console.log('获取用户信息失败！错误代码：1！');
            }
        });//ajax
    }
    get_userInfo();
    //刷新用户网易云音乐+资料
    $(".music-info-refresh").on("click","#music-info-refresh", function() {
        get_userInfo();  //加载排行榜
    });
    //获取歌曲排行榜
    function get_toplist() {
        $('#toplist').html('<h1 id="load-toplist" class="text-center"><i class="fa fa-spinner fa-spin"></i></h1>');   //清空排行榜
        //获取排行榜
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Music',
            data: "action=toplist",
            dataType : "json",
            success: function(json){
                for(var i=0;i<json.length;i++) {
                    $.ajax({
                        type: 'POST',
                        url: music_api,
                        data: "types=playlist&id=" + json[i].music_id,
                        dataType: "jsonp",
                        success: function (jsonData) {
                            toplist(jsonData.playlist.id, jsonData.playlist.coverImgUrl, jsonData.playlist.name, jsonData.playlist.description, jsonData.privileges.length,jsonData.playlist.playCount);
                            return false;
                        },
                        error: function (data) {
                            alert('获取歌单列表失败，服务器内部错误！');
                        }
                    });//ajax*/
                }
                $('#load-toplist').remove();
                $('.fa-refresh').removeClass('fa-spin');
            },
            error:function (data) {
                alert('获取歌单列表失败，服务器内部错误！错误代码：1！');
            }
        });//ajax*/
    }
    get_toplist();
    //刷新排行榜
    $(".refresh-toplist").on("click",".fa-refresh", function() {
        $('.fa-refresh').addClass('fa-spin');   //添加过渡动画
        get_toplist();  //加载排行榜
    });
    function toplist(id,img,name,description,num,playCount) {
        var list = '        <div class="list-item toplist-data" id="'+id+'" name="'+name+'">\n' +
            '          <div class="list-left">\n' +
            '            <img alt="." src="'+img+'" class="w-40 circle">\n' +
            '          </div>\n' +
            '          <div class="list-body">\n' +
            '            <a href="#" class="_500 text-ellipsis">'+name+' (共播放：'+playCount+'次)<span class="pull-right text-muted label success">共：'+num+'首</span></a>\n' +
            '            <small class="block text-muted text-ellipsis">'+description+'</small>\n' +
            '          </div>\n' +
            '        </div>';
        $('#toplist').append(list);
    }
    //打开隐藏歌单
    $('[name="user-music-list"]').click(function () {
        $("#user-music-list").toggle(1000);
    });
    //时间戳转换
    function getMyDate(str){
        var oDate = new Date(str),
            oYear = oDate.getFullYear(),
            oMonth = oDate.getMonth()+1,
            oDay = oDate.getDate(),
            oHour = oDate.getHours(),
            oMin = oDate.getMinutes(),
            oSen = oDate.getSeconds(),
            oTime = oYear +'-'+ getzf(oMonth) +'-'+ getzf(oDay) +' '+ getzf(oHour) +':'+getzf(oMin) +':'+getzf(oSen);//最后拼接时间
        return oTime;
    }
    //补0操作
    function getzf(num){
        if(parseInt(num) < 10){
            num = '0'+num;
        }
        return num;
    }
    //将第一个歌单载入列表
    function load_user_music(id) {
        $('#music-list-data').html('');
        $('#music-title').html($('.music-value').attr('name')+' - 歌曲列表 <span class="pull-right"><a><i class="fa fa-refresh music-list-data-refresh fa-spin"></i></a></span>');
        $.ajax({
            type: 'POST',
            url: music_api,
            data: "types=playlist&id=" + id,
            dataType : "jsonp",
            success: function(jsonData){
                var tempList=[];
                if(typeof jsonData.playlist.tracks !== undefined || jsonData.playlist.tracks.length !== 0) {
                    // 存储歌单中的音乐信息
                    for (var i = 0; i < jsonData.playlist.tracks.length; i++) {
                        tempList =  {
                            id: jsonData.playlist.tracks[i].id,  // 音乐ID
                            name: jsonData.playlist.tracks[i].name,  // 音乐名字
                            artist: jsonData.playlist.tracks[i].ar[0].name, // 艺术家名字
                            album: jsonData.playlist.tracks[i].al.name,    // 专辑名字
                            source: "netease",     // 音乐来源
                            url_id: jsonData.playlist.tracks[i].id,  // 链接ID
                            pic_id: null,  // 封面ID
                            lyric_id: jsonData.playlist.tracks[i].id,  // 歌词ID
                            pic: jsonData.playlist.tracks[i].al.picUrl + "?param=300y300",    // 专辑图片
                            url: null   // mp3链接
                        };
                        music_template(i,tempList.id,tempList.name,tempList.artist,tempList.album,tempList.pic_id,tempList.source,tempList.lyric_id,tempList.pic);
                        $('.music-list-data-refresh').removeClass('fa-spin');
                    }
                }
            },
            error:function (data) {
                alert('获取歌曲列表失败，服务器内部错误！错误代码：1！');
            }
        });//ajax*/
    }
    //歌曲加载模板
    function music_template(no,id,name,artist,album,pic_id,source,lyric_id,pic) {
        var html = '                                    <tr id="'+(no+1)+'">\n' +
            '                                        <th style="width:50px;" class="">'+(no+1)+'</th>\n' +
            '                                        <th style="width:370px;" class="">'+name+'</th>\n' +
            '                                        <th style="width:180px;" class="">'+artist+'</th>\n' +
            '                                        <th class="text-ellipsis" style="width: 250px;height:51px;">'+album+'</th>\n' +
            '                                        <th style="width:100px;" class=""><button class="btn btn-sm btn-icon pull-left success" lid="'+(no+1)+'" id="'+id+'" name="play" source="'+source+'" pic_id="'+pic_id+'" lyric_id="'+lyric_id+'" pic="'+pic+'" mold="list-music1"><i class="ion-play"></i></button> <button class="btn btn-sm btn-icon pull-right blue" lid="'+(no+1)+'" id="'+id+'" name="add" source="'+source+'" pic_id="'+pic_id+'" lyric_id="'+lyric_id+'" pic="'+pic+'" mold="list-music1"><i class="ion-ios-plus"></i></button></th>\n' +
            '                                    </tr>';
        $('#music-list-data').append(html);
    }
    //加载某个歌单的音乐
    $("#user-music-list").on("click",".user-music-load-list", function(e) {
        $('.music-value').attr('name',$(this).attr('title'));
        load_user_music($(this).attr('id'));
        rem.listState = 0;
    });
    //加载某个排行榜的音乐
    $("#toplist").on("click",".toplist-data", function(e) {
        $('.music-value').attr('name',$(this).attr('name'));
        load_user_music($(this).attr('id'));
        rem.listState = 0;
    });
    //搜索音乐
    $(".search-music").on("click",".search-music-source", function(e) {
        var content = $('[name="content"]').val();
        var source = $(this).attr('id');
        if (content=='' || source==''){
            binyui.TipShow('请输入要搜索的内容...', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }else{
            $('.row-inner').animate({scrollTop: 0},400);
            rem.loadPage = 1;   // 已加载页数复位
            rem.num = 0;
            rem.wd = content;    // 搜索词
            rem.source = source;    //音乐来源
            ajaxSearch();   // 加载搜索结果
            return false;
        }
    });
    // ajax加载搜索结果
    function ajaxSearch() {
        if(rem.loadPage == 1) { // 显示过度动画
            $('#music-title').html(rem.wd+' - 歌曲列表 <span class="pull-right"><a><i class="fa fa-refresh music-list-data-refresh fa-spin"></i></a></span>');
        }
        $.ajax({
            type: 'POST',
            url: music_api,
            data: "types=search&count=" + Player.loadcount + "&source=" + rem.source + "&pages=" + rem.loadPage + "&name=" + rem.wd,
            dataType : "jsonp",
            complete: function(XMLHttpRequest, textStatus) {
                $('.music-list-data-refresh').removeClass('fa-spin');//关闭加载动画
            },  // complete
            success: function(jsonData){
                if(rem.loadPage == 1){  //加载第一页
                    if(jsonData.length === 0)   // 返回结果为零
                    {
                        binyui.TipShow('没有找到相关歌曲！', {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        return false;
                    }
                    $('#music-list-data').html(''); //清空列表
                    musicList[0].item = [];
                }else{
                    $("#list-foot").remove();     //已经是加载后面的页码了，删除之前的“加载更多”提示
                }
                if (jsonData.length === 0){
                    addListbar("nomore");  // 加载完了
                    $('#music-list-data').attr('num',0);
                    return false;
                }
                var tempItem = [], no = musicList[0].item.length;
                for (var i = 0; i < jsonData.length; i++) {
                    no ++;
                    tempItem =  {
                        id: jsonData[i].id,  // 音乐ID
                        name: jsonData[i].name,  // 音乐名字
                        artist: jsonData[i].artist[0], // 艺术家名字
                        album: jsonData[i].album,    // 专辑名字
                        source: jsonData[i].source,     // 音乐来源
                        url_id: jsonData[i].url_id,  // 链接ID
                        pic_id: jsonData[i].pic_id,  // 封面ID
                        lyric_id: jsonData[i].lyric_id,  // 歌词ID
                        pic: null,    // 专辑图片
                        url: null   // mp3链接
                    };
                    $('#music-list-data').attr('num',no);
                    music_template(rem.num++,tempItem.id,tempItem.name,tempItem.artist,tempItem.album,tempItem.pic_id,tempItem.source,tempItem.lyric_id,tempItem.pic);
                }
                if(no < Player.loadcount) {
                    $('#music-list-data').attr('num',0);
                    addListbar("nomore");  // 没加载满，说明已经加载完了
                }
                rem.dislist = 0;    // 当前显示的是搜索列表
                rem.loadPage ++;    // 已加载的列数+1
                rem.listState = 1;
                return false;
            },
            error:function (data) {
                alert('获取歌曲列表失败，服务器内部错误！错误代码：2！');
            }
        });
    }
    // 加载列表中的提示条
    // 参数：类型（more、nomore、loading、nodata、clear）
    function addListbar(types) {
        var html
        switch(types) {
            case "more":    // 还可以加载更多
                html = '<tr id="list-foot"><th class="light-blue-100 text-center load-more-music" style="cursor:pointer" colspan="5">点击加载更多...</th></tr>';
                break;
            case "nomore":  // 数据加载完了
                html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5">人家也是有底线的！！！</th></tr>';
                break;
            case "loading": // 加载中
                html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5"><i class="fa fa-refresh fa-spin"></i> 列表加载中...</th></tr>';
                break;
            case "nodata":  // 列表中没有内容
                html = '<tr id="list-foot"><th class="light-blue-100 text-center" colspan="5">这个列表很懒，什么也没留下。</th></tr>';
                break;
        }
        $('#music-list-data').append(html);
    }
    //加载更多
    $(".row-inner").scroll(function(){
        var $this =$(this),
            viewH =$(this).height(),//可见高度
            contentH =$(this).get(0).scrollHeight,//内容高度
            scrollTop =$(this).scrollTop();//滚动高度
        if(scrollTop/(contentH -viewH) >= 0.95){ //当滚动到距离底部5%时
            if (rem.listState==1){
                ajaxSearch();
            }else{
                if (document.getElementById("list-foot")){
                    return false;
                }else{
                    addListbar('nomore');
                }
            }
        }
    });
}
/* **************************************创建播放器************************************** */
if (GetQueryValue('Mould')=='Player'){
    //创建播放器
    $('[name="found"]').on("click",".found", function(e) {
      if ($('[name="found"]').attr('value')==0){
          $('#hall').hide(500);
          $('#found').show(500);
          $('[name="found"]').attr('value','1');
          $('.found').html('<i class="fa fa-fw fa-mail-reply text-muted"></i> 点击返回');
      }else{
          $('#hall').show(500);
          $('#found').hide(500);
          $('[name="found"]').attr('value','0');
          $('.found').html('<i class="fa fa-fw fa fa-plus text-muted"></i> 创建一个播放器');
      }
    });
    $('.wizard').on("click",".previous", function(e) {
        if ($('.wizard').attr('value')!=1) $('.wizard').attr('value',parseInt($('.wizard').attr('value'))-parseInt(1));
    });
    $('[name="style"]').change(function() {
        if (typeof $(this).find("option:selected").attr('img')!="undefined"){
            $('.form-group[id="img"]').html(('<img class="text-center" src="'+$(this).find("option:selected").attr('img')+'" style="width: 300px;height: 130px;">'));
        }
    });
    $('.wizard').on("click",".next", function(e) {
        if ($('.wizard').attr('value')!=2){
            $('.wizard').attr('value',parseInt($('.wizard').attr('value'))+parseInt(1));
        }else{
            if ($('[name="auto_play"]').val()==null || $('[name="play_mode"]').val()==null || $('[name="is_clone"]').val()==null){
                binyui.TipShow('所有项不能为空！', {
                    msgTimer: 5,
                    msgColor: '#efd314',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }else{
                $('.next').html('<a href="#" class="btn white">正在处理...</a>');
                var data = {
                    action:'player',
                    name:$('[name="name"]').val(),
                    auto_play:$('[name="auto_play"]').val()[0],
                    play_mode:$('[name="play_mode"]').val()[0],
                    is_clone:$('[name="is_clone"]').val()[0],
                    style:$('[name="style"]').val(),
                };
                $.ajax({
                    type:'POST',
                    url:'/Application/Mains.php?Mould=Player',
                    data:data,
                    dataType : "json",
                    success:function (json) {
                        if (json.state=='ok'){
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#78fa4a',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            var num = $('.player-num').text();
                            $('.player-num').text(parseInt(num)+parseInt(1));
                            $('[data-target="#tab_2"]').click();
                            $('.next').html('<a href="#" class="btn white">下一步</a>');
                        }else{
                            binyui.TipShow(json.msg, {
                                msgTimer: 5,
                                msgColor: '#efd314',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                            $('.next').html('<a href="#" class="btn white">下一步</a>');
                        }
                    },
                    error:function (data) {
                        binyui.TipShow('创建播放器失败，错误代码1，请稍后再试！', {
                            msgTimer: 5,
                            msgColor: '#fa0714',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.next').html('<a href="#" class="btn white">下一步</a>');
                    }
                });
            }
        }
    });
    $(".tab_2").on('click', '.del-player',function(){
        $(this).text('正在处理...');
        var data = {
            action:'delplayer',
            id:$(this).attr('del_id')
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    var num = $('.player-num').text();
                    $('.player-num').text(parseInt(num)-parseInt(1));
                    $('[data-target="#tab_2"]').click();
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[del_id="'+data.id+'"]').text('删除');
                }
            },
            error:function (data) {
                binyui.TipShow('删除播放器失败，错误代码1，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[del_id="'+data.id+'"]').text('删除');
            }
        });
    });
    //播放器生成
    $('.tab_2').on("click",".generate", function(e) {
        var data = {
            action:'generate',
            id:$(this).attr('create_id')
        };
        $('[create_id="'+data.id+'"]').text('正在生成...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[create_id="'+data.id+'"]').text('已生成');
                    prompt(json.msg,json.code);
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[create_id="'+data.id+'"]').text('生成');
                }
            },
            error:function (data) {
                binyui.TipShow('删除播放器失败，错误代码1，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[create_id="'+data.id+'"]').text('生成');
            }
        });
    });
    $('[data-target="#tab_2"]').click(function(){
        $('.tab_2').html('<i class="fa fa-spinner fa-spin load-player"></i>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: "action=playerlist",
            dataType : "json",
            success:function (json) {
                $('.tab_2').html('');
                for (var i=0;i<json.length;i++){
                    template_player(json[i].id,json[i].name,json[i].auto_play,json[i].play_mode,json[i].is_clone);
                }
            },
            error:function (data) {
                binyui.TipShow('获取播放器列表失败，错误代码2，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    $('[data-target="#tab_3"]').click(function(){
        $('#song_list').html('<i class="fa fa-spinner fa-spin load-song"></i>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: "action=songlist",
            dataType : "json",
            success:function (json) {
                $('#song_list').html('');
                for (var i=0;i<json.length;i++){
                    template_song(json[i].id,json[i].name,json[i].img,json[i].quota);
                }
            },
            error:function (data) {
                binyui.TipShow('获取歌单列表失败，错误代码1，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    //歌单模板
    function template_song(id,name,img,quota) {
        var html = '                            <div class="col-md-2 user-music-list-style" id="song_'+id+'">\n' +
            '                                <div class="box p-a-xs">\n' +
            '                                    <a><img src="'+img+'" alt="" class="img-responsive song_img"></a>\n' +
            '                                    <div class="user-music-list-count"><i id="song3_'+id+'_info" name="ajax_song" song3_id="'+id+'" class="ion-android-hand"></i><span class="pull-right"><label class="md-check"><input type="radio" name="radio_song2" value="'+id+'"><i class="blue"></i></label></span></div>\n'+
            '                                    <div class="p-a-sm">\n' +
            '                                        <div class="text-center text-ellipsis">'+name+'</div>\n' +
            '                                    </div>\n' +
            '                                </div>\n' +
            '                            </div>';
        $('#song_list').append(html);
    }
    $('#song_list').on("click",'.ion-android-hand', function(e) {
        var data = {
            action:'getsonginfo',
            id:$(this).attr('song3_id')
        };
        $('#song3_'+data.id+'_info').html('<i class="fa fa-spinner fa-spin"></i>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: data,
            dataType : "json",
            success:function (json) {
                $('#song3_'+data.id+'_info').html('<i class="fa fa-music"></i> '+json.num+'/'+json.num2+'</span>');
            },
            error:function (data) {
                binyui.TipShow('获取歌单信息失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    //播放器模板
    function template_player(id,name,auto_play,play_mode,is_clone) {
        if (auto_play==1){
            auto_play='是';
        }else{
            auto_play='否';
        }
        if (play_mode==1){
            play_mode='顺序播放';
        }else{
            play_mode='随机播放';
        }
        if (is_clone==1){
            is_clone='允许';
        }else{
            is_clone='不允许';
        }
        var html = '                        <div class="col-sm-12">\n' +
            '                            <div class="box white">\n' +
            '                                <div class="box-body">\n' +
            '                                    <a herf="" class="list-left m-r">\n' +
            '                                        <span class="w-40 circle green">'+id+'</span>\n' +
            '                                    </a>\n' +
            '                                    <div class="clear">\n' +
            '                                        <a class="text-ellipsis">'+name+'</a>\n' +
            '                                        <small class="block text-muted"><i class="fa fa-headphones"></i> 自动播放:'+auto_play+' /<i class="fa fa-pencil-square"></i> 播放模式:'+play_mode+' /<i class="fa fa-adjust"></i> 克隆:'+is_clone+'</small>\n' +
            '                                        <a class="label success generate" create_id="'+id+'">生成</a>\n' +
            '                                        <a href="?Mould=Player&id='+id+'" class="label info">编辑</a>\n' +
            '                                        <a class="label red del-player" del_id="'+id+'">删除</a>\n' +
            '                                    </div>\n' +
            '                                </div>\n' +
            '                            </div>\n' +
            '                        </div>';
        $('.tab_2').append(html);
    }
    //添加歌单
    $('.form-inline').on("click",'[name="submit_song"]', function(e) {
        var data = {
            action:'addsong',
            name:$('[name="song_name"]').val(),
            img:$('[name="song_img"]').val()
        };
        $('[name="submit_song"]').text('正在处理...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data:data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    var num = $('.song-num').text();
                    $('.song-num').text(parseInt(num)+parseInt(1));
                    $('[name="submit_song"]').text('点击添加');
                    $('[data-target="#tab_3"]').click();
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song"]').text('点击添加');
                }
            },
            error:function (data) {
                binyui.TipShow('创建歌单失败，错误代码1，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit_song"]').text('点击添加');
            }
        });
    });
    $('[data-target="#tab_4"]').click(function(){
        song_list_refresh2();
        music_list_refresh2();
    });
    function song_list_refresh2(){
        $('.load-song_list_refresh').addClass('fa-spin');
        $('.tab_4_song_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌单...</li>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: "action=songlist",
            dataType : "json",
            success:function (json) {
                $('.tab_4_song_list').html('');
                $('.load-song_list_refresh').removeClass('fa-spin');
                for (var i=0;i<json.length;i++){
                    var html = '                                    <li class="list-group-item">\n' +
                        '                                        <a href="#" class="pull-left w-40 m-r"><img song2_id="'+json[i].id+'" alt="." src="'+json[i].img+'" class="img-responsive img-circle"></a>\n' +
                        '                                        <div class="clear">\n' +
                        '                                            <a href="#" class="_500 block">'+json[i].name+' <label class="md-check pull-right"><input type="radio" name="song_list_checkbox" value="'+json[i].id+'"><i class="blue"></i></label></a>\n' +
                        '                                            <span class="text-muted">歌单创建日期：'+json[i].addtime+'</span>\n' +
                        '                                        </div>\n' +
                        '                                    </li>';
                    $('.tab_4_song_list').append(html);
                }
            },
            error:function (data) {
                binyui.TipShow('获取歌单列表失败，错误代码3，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    }
    $('#song_list_refresh').on("click",".fa-refresh", function(e) {
        song_list_refresh2();
    });
    function music_list_refresh2(){
        $('.load_music_list_refresh2').addClass('fa-spin');
        $('.tab_4_music_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌曲...</li>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: "action=musiclist",
            dataType : "json",
            success:function (json) {
                $('.tab_4_music_list').html('');
                $('.load_music_list_refresh2').removeClass('fa-spin');
                for (var i=0;i<json.length;i++){
                    var html='                                    <li class="list-group-item" id="music2_'+json[i].music_id+'">\n' +
                        '                                        <a class="pull-right text-muted m-l-xs label danger remove_music2_id reid_'+json[i].music_id+'" reid="'+json[i].music_id+'">移除</a>\n' +
                        '                                        <a class="pull-right label primary add_music2_id adid_'+json[i].music_id+'" adid="'+json[i].music_id+'">添加</a>\n' +
                        '                                        '+(parseInt(i+1))+'. '+json[i].music_name+' - '+json[i].music_artist+'\n' +
                        '                                    </li>';
                    $('.tab_4_music_list').append(html);
                }
            },
            error:function (data) {
                binyui.TipShow('获取歌曲列表失败，错误代码3，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    }
    $('#music_list_home2 ').on("click",".load_music_list_home2", function(e) {
        music_list_refresh2();
    });
    $('#music_list_refresh2').on("click",".load_music_list_refresh2", function(e) {
        music_list_refresh2();
    });
    $('.tab_4_music_list').on("click",".add_music2_id", function(e) {
        var value = $('.tab_4_music_list').attr('value');
        if (value==0){
            $('.tab_4_music_list').attr('value','1');
            $(this).html('<i class="fa fa-spinner fa-spin"></i>');
            var data = {
                action:'addmusicgosong',
                song_id:$("input[name='song_list_checkbox']:checked").val(),
                music_id:$(this).attr('adid')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data:data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.tab_4_music_list').attr('value','0');
                        $('#music2_'+data.music_id+'').remove();
                    }else {
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.tab_4_music_list').attr('value','0');
                        $('.adid_'+data.music_id+'').html('添加');
                    }
                },
                error:function (data) {
                    binyui.TipShow('添加歌曲到指定歌单失败，错误代码3，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('.tab_4_music_list').attr('value','0');
                    $('.adid_'+data.music_id+'').html('添加');
                }
            });
        }else{
            binyui.TipShow('请先等待上一条任务完成后再进行操作！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }
    });
    $('.tab_4_music_list').on("click",".remove_music2_id", function(e) {
        var value = $('.tab_4_music_list').attr('value');
        if (value=='0'){
            $('.tab_4_music_list').attr('value','1');
            $(this).html('<i class="fa fa-spinner fa-spin"></i>');
            var data = {
                action:'delmusicgosong',
                music_id:$(this).attr('reid')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data:data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        var num = $('.music-num').text();
                        $('.music-num').text(parseInt(num)-parseInt(1));
                        $('.tab_4_music_list').attr('value','0');
                        $('#music2_'+data.music_id+'').remove();
                    }else {
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.tab_4_music_list').attr('value','0');
                        $('.reid_'+data.music_id+'').html('移除');
                    }
                },
                error:function (data) {
                    binyui.TipShow('删除歌曲失败，错误代码3，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('.tab_4_music_list').attr('value','0');
                    $('.reid_'+data.music_id+'').html('移除');
                }
            });
        }else{
            binyui.TipShow('请先等待上一条任务完成后再进行操作！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
        }
    });
    $('.tab_4_song_list').on("click","img", function(e) {
        $('.load_music_list_refresh2').addClass('fa-spin');
        $('.tab_4_music_list').html('<li class="list-group-item text-center"><i class="fa fa-spinner fa-spin"></i> 正在获取歌曲...</li>');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: "action=getsonggomusic&song_id="+$(this).attr('song2_id'),
            dataType : "json",
            success:function (json) {
                $('.tab_4_music_list').html('');
                $('.load_music_list_refresh2').removeClass('fa-spin');
                for (var i=0;i<json.length;i++){
                    var html='                                    <li class="list-group-item" id="music2_'+json[i].music_id+'">\n' +
                        '                                        <a class="pull-right text-muted m-l-xs label danger remove_music2_id reid_'+json[i].music_id+'" reid="'+json[i].music_id+'">移除</a>\n' +
                        '                                        <a class="pull-right label primary add_music2_id" adid="'+json[i].music_id+'">添加</a>\n' +
                        '                                        '+(parseInt(i+1))+'. '+json[i].music_name+' - '+json[i].music_artist+'\n' +
                        '                                    </li>';
                    $('.tab_4_music_list').append(html);
                }
            },
            error:function (data) {
                binyui.TipShow('获取歌曲列表失败，错误代码3，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    $('.pull-right').on("click",'[name="submit_song_edit"]', function(e) {
        var data = {
            action:'getsonginfo2',
            id:$("input[name='radio_song2']:checked").val(),
        };
        $('[name="submit_song_edit"]').html('正在处理...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    $('#song_info').show(800);
                    $('#song_info').attr('value',data.id);
                    $('[name="submit_song_edit"]').html('编辑');
                    $('[name="song_name2"]').val(json.name);
                    $('[name="song_img2"]').val(json.img);
                    $('#player_name3').html(json.player);
                    $.ajax({
                        type: 'POST',
                        url: '/Application/Mains.php?Mould=Player',
                        data: "action=playerlist",
                        dataType : "json",
                        success:function (data) {
                            $('[name="payer_id2"]').html('');
                            for (var i=0;i<data.length;i++){
                                $('[name="payer_id2"]').append('<option value="'+data[i].id+'">'+data[i].name+' [最大只能储存'+data[i].song_quota+'个歌单]</option>');
                            }
                        },
                        error:function (data) {
                            binyui.TipShow('获取播放器列表失败，错误代码2，请稍后再试！', {
                                msgTimer: 5,
                                msgColor: '#fa0714',
                                msgAxis: 'centerTop',
                                xNum: '10%',
                                yNum: '10%',
                                zIndex: '99999'
                            });
                        }
                    });
                }else {
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song_edit"]').html('编辑');
                }
            },
            error:function (data) {
                binyui.TipShow('获取要编辑的歌单信息失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit_song_edit"]').html('编辑');
            }
        });
    });
    $('#song_info').on("click",'[name="submit_song3"]', function(e) {
        $('[name="submit_song3"]').html('正在处理...');
        var data = {
            action:'editsong',
            id:$('#song_info').attr('value'),
            name:$('[name="song_name2"]').val(),
            img:$('[name="song_img2"]').val(),
            player:$('[name="payer_id2"]').val(),
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Player',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[data-target="#tab_3"]').click();
                    $('#song_info').hide(800);
                    $('[name="submit_song3"]').html('点击保存');
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song3"]').html('点击保存');
                }
            },
            error:function (data) {
                binyui.TipShow('保存歌单信息失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit_song3"]').html('点击保存');
            }
        });
    });
    $('.pull-right').on("click",'[name="submit_song_del"]', function(e) {
        if (confirm('你确定要删除该歌单吗？删除后，歌单内的歌曲都恢复到默认音乐列表！')){
            var data = {
                action:'delsong',
                id:$("input[name='radio_song2']:checked").val(),
            };
            $('[name="submit_song_del"]').html('正在处理...');
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Player',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        var num = $('.song-num').text();
                        $('.song-num').text(parseInt(num)-parseInt(1));
                        $('#song_'+data.id).remove();
                        $('[name="submit_song_del"]').html('移除');
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('[name="submit_song_del"]').html('移除');
                    }
                },
                error:function (data) {
                    binyui.TipShow('保存歌单信息失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit_song_del"]').html('移除');
                }
            });
        }
    });
}
/* **************************************挂机管理************************************** */
if (GetQueryValue('Mould')=='QQList'){
    //获取挂机信息
    $('[role="menu"]').on("click",'.qqinfo', function(e) {
        binyui.TipShow('正在获取数据...', {
            msgTimer: 15,
            msgColor: '#4BC0C0',
            msgAxis: 'centerTop',
            xNum: '10%',
            yNum: '10%',
            zIndex: '99999'
        });
        var data = {
            action:'info',
            id:$("input[name='radio_qq']:checked").val()
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=QQList',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow('获取信息成功！', {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('.qqtx').attr('src','http://q2.qlogo.cn/headimg_dl?bs='+json.msg[0].qq+'&dst_uin='+json.msg[0].qq+'&dst_uin='+json.msg[0].qq+'&;dst_uin='+json.msg[0].qq+'&spec=100&url_enc=0&referer=bu_interface&term_type=PC');
                    $.get("https://cloud.xmyrs.cn/qqnick/?qq="+json.msg[0].qq, function(result){
                        $('.qqnick').text(result);
                    });
                    $('.qqnumber').text(json.msg[0].qq);
                    if (json.msg[0].status=='0'){
                        $('.qqzt').text('状态码正常');
                    }else{
                        $('.qqzt').text('QQ状态码已过期！');
                    }
                    $('.addtime').text(json.msg[0].addtime);
                    $('.gxtime').text(json.msg[0].gxtime);
                    $('#qqinfo').show(800);
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 6,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            },
            error:function (data) {
                binyui.TipShow('获取QQ信息失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    //删除挂机
    $('[role="menu"]').on("click",'.del', function(e) {
        var data = {
            action:'del',
            id:$("input[name='radio_qq']:checked").val()
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=QQList',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[qid="'+data.id+'"]').remove();
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            },
            error:function (data) {
                binyui.TipShow('删除挂机失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
}
/* **************************************QQ昵称修改************************************** */
if (GetQueryValue('Mould')=='QQNick'){
    $('[name="qq"]').change(function(){
        $.get("https://cloud.xmyrs.cn/qqnick/?qq="+$('[value="'+$('[name="qq"]').val()+'"]').text(), function(result){
            $('.qqnick').val(result);
            $('[name="nick"]').removeAttr('disabled');
        });
    });
    $('.submit').on("click",'[name="submit"]', function(e) {
        var data = {
            action:'edit',
            qid:$('[name="qq"]').val(),
            nick:$('[name="nick"]').val()
        };
        $('[name="submit"]').text('正在处理...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=QQNick',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('.qqnick').val(data.nick);
                    $('[name="submit"]').text('点击修改');
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('点击修改');
                }
            },
            error:function (data) {
                binyui.TipShow('修改QQ昵称失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('点击修改');
            }
        });
    });
}
/* **************************************QQ亲密度查询************************************** */
if (GetQueryValue('Mould')=='QQIntimacy'){
    $('.submit').on("click",'[name="submit"]', function(e) {
        $('[name="submit"]').text('正在处理...');
        var data = {
            action:'getqqcare',
            qid:$('[name="qid"]').val()
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=QQIntimacy',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                    $('#fans_count').html('目前你有<b>'+json.used_count+'</b>位特别关心的好友，特别关心你的好友共有<b>'+json.fans_count+'</b>位。');
                    $('#me_care').html('');
                    for (var i=0;i<json.list1.length;i++){
                        var html = '                            <tr>\n' +
                            '                                <td>'+json.list1[i].index+'</td>\n' +
                            '                                <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list1[i].uin+'&amp;dst_uin='+json.list1[i].uin+'&amp;dst_uin='+json.list1[i].uin+'&amp;;dst_uin='+json.list1[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                            '                                <td>'+json.list1[i].name+'</td>\n' +
                            '                                <td>'+json.list1[i].uin+'</td>\n' +
                            '                                <td>'+json.list1[i].score+'</td>\n' +
                            '                                <td><a href="https://user.qzone.qq.com/'+json.list1[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a></td>\n' +
                            '                            </tr>';
                        $('#me_care').append(html);
                        $('.me_care').text(i);
                    }
                    $('#care_me').html('');
                    for (var i=0;i<json.list2.length;i++){
                        var html = '                            <tr>\n' +
                            '                                <td>'+json.list2[i].index+'</td>\n' +
                            '                                <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list2[i].uin+'&amp;dst_uin='+json.list2[i].uin+'&amp;dst_uin='+json.list2[i].uin+'&amp;;dst_uin='+json.list2[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                            '                                <td>'+json.list2[i].name+'</td>\n' +
                            '                                <td>'+json.list2[i].uin+'</td>\n' +
                            '                                <td>'+json.list2[i].score+'</td>\n' +
                            '                                <td><a href="https://user.qzone.qq.com/'+json.list2[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a></td>\n' +
                            '                            </tr>';
                        $('#care_me').append(html);
                        $('.care_me').text(i);
                    }
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                }
            },
            error:function (data) {
                binyui.TipShow('获取数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('查询');
            }
        });
    });
}
/* **************************************QQ查询可能认识的人************************************** */
if (GetQueryValue('Mould')=='QQIsknow'){
    $('.submit').on("click",'[name="submit"]', function(e) {
        $('[name="submit"]').text('正在处理...');
        var data = {
            action:'isknow',
            qid:$('[name="qid"]').val()
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=QQIsknow',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                    $('#isknow').html('');
                    for (var i=0;i<json.list.length;i++){
                        var html = '          <tr>\n' +
                            '            <td>'+i+'</td>\n' +
                            '            <td><img src="http://q2.qlogo.cn/headimg_dl?bs='+json.list[i].uin+'&amp;dst_uin='+json.list[i].uin+'&amp;dst_uin='+json.list[i].uin+'&amp;;dst_uin='+json.list[i].uin+'&amp;spec=100&amp;url_enc=0&amp;referer=bu_interface&amp;term_type=PC" style=" width: 50px; height: 50px; "></td>\n' +
                            '            <td>'+json.list[i].remark+'</td>\n' +
                            '            <td>'+json.list[i].uin+'</td>\n' +
                            '            <td>'+json.list[i].num+' 个</td>\n' +
                            '            <td>'+gender(json.list[i].gender)+'</td>\n' +
                            '            <td><a href="https://user.qzone.qq.com/'+json.list[i].uin+'" target="view_window" class="md-btn md-raised m-b-sm w-xs blue">进入空间</a> <a href="tencent://AddContact/?fromId=45&fromSubId=1&subcmd=all&uin='+json.list[i].uin+'" class="md-btn md-raised m-b-sm w-xs green">添加好友</a></td>\n' +
                            '          </tr>';
                        $('#isknow').append(html);
                    }
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('查询');
                }
            },
            error:function (data) {
                binyui.TipShow('获取数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('查询');
            }
        });
    });
    function gender(gender) {
        if (gender=='2'){
            return '女';
        }else if (gender=='1'){
            return '男';
        }else{
            return '保密';
        }
    }
}
/* **************************************视频全能解析************************************** */
if (GetQueryValue('Mould')=='Video'){
    $('.submit').on("click",'[name="submit"]', function(e) {
        $('[name="submit"]').text('正在处理...');
        var data = {
            api:$('[name="api"]').val(),
            url:$('[name="url"]').val()
        };
        if(data.api=='' || data.url==''){
            binyui.TipShow('所有项不能为空！', {
                msgTimer: 5,
                msgColor: '#efd314',
                msgAxis: 'centerTop',
                xNum: '10%',
                yNum: '10%',
                zIndex: '99999'
            });
            $('[name="submit"]').text('开始解析');
        }else{
            $('#video').attr('src',$('[name="api"]').val()+$('[name="url"]').val());
            $('[name="submit"]').text('开始解析');
        }
    });
}
/* **************************************网站配置************************************** */
if (GetQueryValue('Mould')=='Admin_website'){
    $('.website').on("click",'[name="website_submit"]', function(e) {
        $('[name="website_submit"]').text('正在处理...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_website',
            data: $('.website').serialize(),
            dataType : "json",
            success:function (json) {
                binyui.TipShow(json.msg, {
                    msgTimer: 5,
                    msgColor: '#78fa4a',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="website_submit"]').text('点击保存');
            },
            error:function (data) {
                binyui.TipShow('保存数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="website_submit"]').text('点击保存');
            }
        });
    });
}
/* **************************************公告配置************************************** */
if (GetQueryValue('Mould')=='Admin_notice'){
    var login_notice = UM.getEditor('login_notice');    //初始化1
    var users_notice = UM.getEditor('users_notice');    //初始化1
    var palyer_notice = UM.getEditor('palyer_notice');    //初始化1
    login_notice.addListener('blur',function(){
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_notice',
            data: {'action':'notice','login_notice':login_notice.getContent()},
            dataType : "json",
            success:function (json) {
                binyui.TipShow(json.msg, {
                    msgTimer: 5,
                    msgColor: '#78fa4a',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            },
            error:function (data) {
                binyui.TipShow('保存数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    users_notice.addListener('blur',function(){
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_notice',
            data: {'action':'notice','users_notice':users_notice.getContent()},
            dataType : "json",
            success:function (json) {
                binyui.TipShow(json.msg, {
                    msgTimer: 5,
                    msgColor: '#78fa4a',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            },
            error:function (data) {
                binyui.TipShow('保存数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    palyer_notice.addListener('blur',function(){
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_notice',
            data: {'action':'notice','palyer_notice':palyer_notice.getContent()},
            dataType : "json",
            success:function (json) {
                binyui.TipShow(json.msg, {
                    msgTimer: 5,
                    msgColor: '#78fa4a',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            },
            error:function (data) {
                binyui.TipShow('保存数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
}
/* **************************************视频解析配置************************************** */
if (GetQueryValue('Mould')=='Admin_Video'){
    //新增
    $('.submit').on("click",'[name="submit"]', function(e) {
        $('[name="submit"]').text('正在处理...');
        var data = {
            action:'add',
            name:$('[name="name"]').val(),
            api:$('[name="api"]').val()
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Video',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    var index = $(".api_list").find("tr").length+1;
                    $('.api_list').append('<tr api_id="'+index+'"><td>'+index+'</td><td>'+data.name+'</td><td>'+data.api+'</td><td><a class="label danger" title="移除" id="'+json.id+'">移除</a></td></tr>');
                    $('[name="submit"]').text('点击添加');
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').text('点击添加');
                }
            },
            error:function (data) {
                binyui.TipShow('新增接口失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').text('点击添加');
            }
        });
    });
    //移除
    $('.api_list').on("click",'.del', function(e) {
        $(this).text('正在处理...');
        var data = {
            action:'del',
            id:$(this).attr('idm'),
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Video',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    console.log(data.id)
                    $('[idm="'+data.id+'"]').text('已移除');
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[idm="'+data.id+'"]').text('移除');
                }
            },
            error:function (data) {
                binyui.TipShow('保存数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[idm="'+data.id+'"]').text('移除');
            }
        });
    });
}
/* **************************************用户管理************************************** */
if (GetQueryValue('Mould')=='Admin_Users'){
    $('.user-list').on("click",'.query-qq-count', function(e) {
        var data = {
            action:'count',
            only:$(this).attr('only'),
        };
        $('[only="'+data.only+'"').text('请稍等...');
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Users',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    $('[only="'+data.only+'"').text('共：'+json.msg+' 个');
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[only="'+data.only+'"').text('点击查看');
                }
            },
            error:function (data) {
                binyui.TipShow('获取数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[only="'+data.only+'"').text('点击查看');
            }
        });
    });
}
/* **************************************奖品配置************************************** */
if (GetQueryValue('Mould')=='Admin_Prize'){
    $('.luck_table').on("click",'.luck_num', function(e) {
        var num=prompt("请输入要修改的值：",$(this).text());
        if (num!=null && num!=""){
            var data = {
                action:'edit_num',
                id:$(this).attr('id'),
                num:num
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Prize',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.luck_num_'+data.id+' a').text(num);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('修改数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        }
    });
    $('.luck_table').on("click",'.luck_edit', function(e) {
        var num=prompt("请输入要修改的值：",$(this).text());
        if (num!=null && num!=""){
            var data = {
                action:'edit_luck',
                id:$(this).attr('luck_id'),
                num:num
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Admin_Prize',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        $('.luck_edit_'+data.id+' a').text(num);
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('修改数据失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        }
    });
}
/* **************************************添加商品************************************** */
if (GetQueryValue('Mould')=='Admin_Goods'){
    //添加商品
    $('#addgoods').on("click",'[name="submit"]', function(e) {
        $('[name="submit"]').html('正在处理...');
        var data={
            action:'add',
            name:$('[name="name"]').val(),
            image:$('[name="image"]').val(),
            content:$('[name="content"]').val(),
            stock:$('[name="stock"]').val(),
            mold:$('[name="mold"]').val(),
            money:$('[name="money"]').val(),
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Goods',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    window.location.reload();
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('[name="submit"]').html('点击添加');
                }
            },
            error:function (data) {
                binyui.TipShow('新增数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
                $('[name="submit"]').html('点击添加');
            }
        });
    });
    //获取信息
    $('#list').on("click",'.query', function(e) {
        var data = {
            action:'info',
            id:$(this).attr('queryid')
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Goods',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    $('#img').html(json.data.image);
                    $('#name').html(json.data.name);
                    $('#content2').html(json.data.content);
                    $('#num').html(json.data.stock);
                    $('#addtime').html(json.data.addtime);
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            },
            error:function (data) {
                binyui.TipShow('获取商品信息失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
    //删除商品
    $('#list').on("click",'.del', function(e) {
        var data = {
            action:'del',
            id:$(this).attr('delid')
        };
        $.ajax({
            type: 'POST',
            url: '/Application/Mains.php?Mould=Admin_Goods',
            data: data,
            dataType : "json",
            success:function (json) {
                if (json.state=='ok'){
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#78fa4a',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                    window.location.reload();
                }else{
                    binyui.TipShow(json.msg, {
                        msgTimer: 5,
                        msgColor: '#efd314',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            },
            error:function (data) {
                binyui.TipShow('新增数据失败，请稍后再试！', {
                    msgTimer: 5,
                    msgColor: '#fa0714',
                    msgAxis: 'centerTop',
                    xNum: '10%',
                    yNum: '10%',
                    zIndex: '99999'
                });
            }
        });
    });
}
/* **************************************商品管理************************************** */
if (GetQueryValue('Mould')=='Mall'){
    $('.box-footer').on("click",'[name="recharge"]', function(e) {
        layer.open({
            title:'彩虹屁充值',
            type: 2,
            content: $('[name="recharge"]').attr('src')+'?price='+$('[name="money"]').val()+'&type='+$('[name="mold"]').val()+'&user='+$('[name="only"]').val(),
            area: ['100%', '100%'],
            maxmin: true,
            end: function(){
                window.location.reload();
            }
        });
    });
    $('#mall').on("click",'#buy', function(e) {
        var is=confirm("你确定要购买"+$(this).attr('name')+"吗？");
        binyui.TipShow('正在处理...', {
            msgTimer: 15,
            msgColor: '#01aaed',
            msgAxis: 'centerTop',
            xNum: '10%',
            yNum: '10%',
            zIndex: '99999'
        });
        if (is==true){
            var data = {
                action:'buy',
                id:$(this).attr('gid')
            };
            $.ajax({
                type: 'POST',
                url: '/Application/Mains.php?Mould=Mall',
                data: data,
                dataType : "json",
                success:function (json) {
                    if (json.state=='ok'){
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#78fa4a',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                        window.location.reload();
                    }else{
                        binyui.TipShow(json.msg, {
                            msgTimer: 5,
                            msgColor: '#efd314',
                            msgAxis: 'centerTop',
                            xNum: '10%',
                            yNum: '10%',
                            zIndex: '99999'
                        });
                    }
                },
                error:function (data) {
                    binyui.TipShow('购买商品失败，请稍后再试！', {
                        msgTimer: 5,
                        msgColor: '#fa0714',
                        msgAxis: 'centerTop',
                        xNum: '10%',
                        yNum: '10%',
                        zIndex: '99999'
                    });
                }
            });
        }
    });
}