123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509 |
- require(['config'], function () {
- require(['jquery', 'utils', 'pagination', 'clipboard'], function ($, utils, pagination, Clipboard) {
- $(function () {
- var phoneReg = /^[1][345789][0-9]{9}$/;
- var code_time = 60;
-
- function bindmobileEvent() {
- $('#BindDialog .js-getcode').on('click', function () {
- var phone = $('#BindDialog .js-newphone').val();
- var that = this;
- console.log(phone);
- if (! phone || ! phoneReg.test(phone)) {
- layer.msg('请检查手机号格式是否正确!');
- return;
- }
- $.ajax({
- url: $('#sendCodeUrl').val(),
- data: {
- mobile: phone,
- smstype : 4
- },
- type: 'post',
- success: function (res) {
- if (res.error == 0) {
- layer.msg(res.msg, {icon: 6, time: 1000});
- $(that).attr('disabled',true)
- var code_Interval = setInterval(function () {
- if (code_time <= 0) {
- $(that).attr('disabled',false)
- $(that).html('获取')
- code_time = 60;
- clearInterval(code_Interval)
- return;
- }
- code_time--;
- $(that).html(code_time)
- },1000)
- } else {
- layer.msg(res.msg, {icon: 5, time: 1000});
- }
- }
- })
- })
- $('#BindDialog .close').on('click', function () {
- $('#BindDialog').fadeOut(250)
- utils.unlockY()
- })
- $('#BindDialog .js-save').on('click', function () {
- var dt = {
- mobile: $('#BindDialog .js-newphone').val(),
- code: $('#BindDialog .js-code').val()
- }
- if (!dt.mobile && !dt.code) {
- layer.msg('手机/验证码为必填项')
- return false;
- }
- $.ajax({
- url: $('#editmobileUrl').val(),
- data: dt,
- type: 'post',
- success: function (res) {
- if (res.error == 0){
- $('#BindDialog').fadeOut(250);
- $('#BindSuccessDialog').fadeIn(250);
- setTimeout(function () {
- window.location.reload()
- },250);
- } else {
- layer.msg(res.msg)
- }
- }
- })
- })
- }
-
- function resetmobileEvent() {
- $('#resetBindDialog .js-getcode').on('click', function () {
- // var phone = $('#resetBindDialog .js-oldphone').text();
- var phone = $('#resetBindDialog .js-oldphone').text();
- var that = this;
- $.ajax({
- url: $('#sendCodeUrl').val(),
- data: {
- mobile: phone,
- smstype : 4
- },
- type: 'post',
- success: function (res) {
- if (res.error == 0) {
- layer.msg(res.msg, {icon: 6, time: 1000});
- $(that).attr('disabled',true)
- var code_Interval = setInterval(function () {
- if (code_time <= 0) {
- $(that).attr('disabled',false)
- $(that).html('获取')
- code_time = 60;
- clearInterval(code_Interval)
- return;
- }
- code_time--;
- $(that).html(code_time)
- },1000)
- } else {
- layer.msg(res.msg, {icon: 5, time: 1000});
- }
- }
- })
- })
- $('#resetBindDialog .close').on('click', function () {
- $('#resetBindDialog').fadeOut(250)
- utils.unlockY()
- })
- $('#resetBindDialog .js-save').on('click', function () {
-
- var dt = {
- mobile: $('#resetBindDialog .js-oldphone').text(),
- code: $('#resetBindDialog .js-code').val()
- }
- if (!dt.code) {
- layer.msg('验证码为必填项');
- return false;
- }
- $.ajax({
- url: $('#checkmobileUrl').val(),
- data: dt,
- type: 'post',
- success: function (res) {
- if (res.error == 0){
- layer.msg(res.msg, {time: 700});
- $('#resetBindDialog').hide();
- $('#BindDialog').fadeIn(250);
- } else {
- layer.msg(res.msg);
- }
- }
- })
-
- })
- }
- bindmobileEvent();
- resetmobileEvent();
-
- $('#exChange').on('click', function () {
- $("#exchangeDialog").fadeIn(250)
- utils.lockY()
- })
- $('#exchangeDialog .close').on('click', function () {
- $('#exchangeDialog').fadeOut(250)
- utils.unlockY()
- })
-
- $('#PayDialog .close').on('click', function () {
- $('#PayDialog').fadeOut(250)
- utils.unlockY()
- })
-
- $(".js-resetUserData").on('click', function () {
- $('.UserTop_Toggle > div').eq(1).addClass('active').siblings().removeClass('active')
- })
- $(".js-resetUserPass").on('click', function () {
- $('.UserTop_Toggle > div').eq(2).addClass('active').siblings().removeClass('active')
- })
- $('.UserTop_Toggle .back').on('click', function () {
- $('.UserTop_Toggle > div').eq(0).addClass('active').siblings().removeClass('active')
- })
-
- $('.resetUserData .resetmobile').on('click',function () {
- $('#resetBindDialog').fadeIn(250)
- })
- $('.resetUserData .bindmobile').on('click',function () {
- $('#BindDialog').fadeIn(250)
- })
-
-
- $('.UserMneus_right .myNews li').on('click', function () {
- var index = $(this).index();
- $('#newsDialog').fadeIn(250);
- $('#newsDialog .u-Dialog__news .mainText').html(msg_list.list[index].content)
- $('#newsDialog .u-Dialog__news .auth').html(msg_list.list[index].type_value)
- $('#newsDialog .u-Dialog__news .time').html(msg_list.list[index].create_time)
- $(this).find('.readStatus').text('已读');
- $.ajax({
- url: $('#readUrl').val(),
- type: 'get',
- data: {msg_id: msg_list.list[index].id},
- success: function () {}
- })
- utils.lockY()
- })
- $('#newsDialog .close').on('click', function () {
- $('#newsDialog').fadeOut(250)
- utils.unlockY()
- })
-
-
-
- var UserTabIndex = 0; // 0: 礼包 1:消息 2:游戏币充值记录 3:平台币充值记录 4: 消费记录
- var gift_index = 1;
- var new_index = 1;
- var yxb_index = 1;
- var ptb_index = 1;
- var xf_index = 1;
-
- //导航切换
- $('.UserMneus_left li').on('click',function(){
- UserTabIndex = $(this).index();
- $(this).addClass('active').siblings().removeClass('active');
- $('.UserMneus_right > div').eq(UserTabIndex).show().siblings().hide();
-
- var total = 0;
- var number = 1;
- if (UserTabIndex == 0) {
- total = gift_list.count; //礼包
- number = gift_index;
- } else if (UserTabIndex == 1) {
- total = msg_list.count; //消息
- number = new_index;
- } else if (UserTabIndex == 2) {
- total = gm_recharge_log.count; //游戏币充值记录
- number = yxb_index;
- } else if (UserTabIndex == 3) {
- total = ptb_recharge_log.count;
- number = ptb_index; //平台币充值记录
- } else if (UserTabIndex == 4) {
- total = consumption_log.count; //消费记录
- number = xf_index;
-
- }
- // xf_index
- pagination({
- elem : '#pagination',
- total : total,
- size : 4,
- number : number,
- callback: renderGamelist
- });
-
- });
-
- // 页码
- renderPagination();
-
- function renderGamelist(page) {
- page = page || 1;
-
- var ajaxData;
- if (UserTabIndex == 0) {
- gift_index = page;
- ajaxData = {'gift_page': gift_index};
- } else if (UserTabIndex == 1) {
- new_index = page;
- ajaxData = {'msg_page': new_index};
- } else if (UserTabIndex == 2) {
- yxb_index = page;
- ajaxData = {'gm_page': yxb_index};
- }else if (UserTabIndex == 3) {
- ptb_index = page;
- ajaxData = {'ptb_page': ptb_index};
- }else if (UserTabIndex == 4) {
- xf_index = page;
- ajaxData = {'consum_page': xf_index};
- }
- $.ajax({
- url:'',
- data: ajaxData,
- type: 'get',
- success: function (res) {
- var resData = '';
- console.log(UserTabIndex);
- if (UserTabIndex == 0) {
- resData = res.gift_list.list; // 礼包
- $('.js-gift_tpl').html(giftDatatoHtml(resData))
-
- var clipboard = new Clipboard('.copyBtn');
- clipboard.on('success', function(e) {
- layer.msg('复制成功!', {tiem: 700})
- e.clearSelection();
- });
- clipboard.on('error', function(e) {
- layer.msg('请选择“拷贝”进行复制!', {tiem: 700})
- });
-
-
- } else if (UserTabIndex == 1) {
- resData = res.msg_list.list; // 消息
- $('.js-news_tpl').html(newsDatatoHtml(resData))
-
- $('.UserMneus_right .myNews li').on('click', function () {
- var index = $(this).index();
- $.ajax({
- url: $('#readUrl').val(),
- type: 'get',
- data: {msg_id: res.msg_list.list[index].id},
- success: function () {}
- })
- $(this).find('.readStatus').text('已读');
- $('#newsDialog').fadeIn(250);
- $('#newsDialog .u-Dialog__news .mainText').html(res.msg_list.list[index].content)
- $('#newsDialog .u-Dialog__news .auth').html(res.msg_list.list[index].type_value)
- $('#newsDialog .u-Dialog__news .time').html(res.msg_list.list[index].create_time)
-
- utils.lockY()
- })
-
- } else if (UserTabIndex == 2) {
- resData = res.gm_recharge_log.list; // 游戏币充值记录
- $('.js-gm_tpl').html(yxbDatatoHtml(resData))
- }else if (UserTabIndex == 3) {
- resData = res.ptb_recharge_log.list; // 平台币充值记录
- $('.js-tpb_tpl').html(ptbDatatoHtml(resData))
- }else if (UserTabIndex == 4) {
- resData = res.consumption_log.list; // 充值记录
- $('.js-xf_tpl').html(xfDatatoHtml(resData))
- }
- }
- })
- }
-
- function giftDatatoHtml(data) {
- var h = '';
- $.each(data, function (i, v) {
- var date = new Date(v.end_time * 1000)
- h += '<li>\n' +
- ' <div class="lImg">\n' +
- ' <a href="javascript:;"><img src="'+v.icon+'" alt=""></a>\n' +
- ' </div>\n' +
- ' <div class="text">\n' +
- ' <h3><a href="javascript:;">'+v.gamename+'('+v.gift_name+')</a></h3>\n' +
- ' <p class="p2">礼包码:<input readonly type="text" id="copy_text'+i+'" value="'+v.gift_code+'"</p>\n' +
- ' <p class="p2">使用方法:'+v.func+'</p>\n' +
- ' </div>\n' +
- ' <div class="rt">\n' +
- ' <button data-clipboard-target="#copy_text'+i+'" class="copyBtn">复制</button>\n' +
- ' </div>\n' +
- ' <div class="rb">\n' +
- ' <span>有效期至:'+date.format("yyyy-MM-dd hh:mm:ss")+'</span>\n' +
- ' </div>\n' +
- ' </li>'
- });
- return h;
-
- }
-
- function newsDatatoHtml(data) {
- var h = '';
- $.each(data, function (i, v) {
- var date = new Date(v.end_time * 1000)
- var t = '未读'
- if (v.readed == 1) {
- t = '未读'
- } else {
- t = '已读'
- }
- h += '<li>\n' +
- ' <div class="lImg">\n' +
- ' <div class="newBgColor">\n' +
- ' '+v.type_value+'\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="text">\n' +
- ' <p class="p">'+v.title+'</p>\n' +
- ' </div>\n' +
- ' <div class="rt">\n' +
- ' <button>详情</button>\n' +
- ' </div>\n' +
- ' <div class="rb">\n' +
- ' <span class="readStatus">'+t+'</span>\n' +
- ' </div>\n' +
- ' </li>'
- });
- return h;
-
- }
-
- function yxbDatatoHtml(data) {
- var h = '';
- $.each(data, function (i, v) {
- var date = new Date(v.pay_time * 1000)
- h += '<li>\n' +
- ' <div class="lImg">\n' +
- ' <div class="ptbPayBgColor">\n' +
- ' 充值\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="text">\n' +
- ' <div class="text_group">\n' +
- ' <span class="fz16">\n' +
- ' 游戏币充值: <b class="fz12">'+v.paytype+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 游戏:<b class="moneyColor">'+v.gamename+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' <div class="text_group">\n' +
- ' <span>\n' +
- ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 价值:<b class="moneyColor">'+v.gm_num+'游戏币</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="rt">\n' +
- ' <!--<button>删除</button>-->\n' +
- ' </div>\n' +
- ' <div class="rb">\n' +
- ' <span>交易日期:'+v.pay_time+'</span>\n' +
- ' </div>\n' +
- ' </li>'
- });
- return h;
-
- }
-
- function ptbDatatoHtml(data) {
- var h = '';
- $.each(data, function (i, v) {
- var date = new Date(v.pay_time * 1000)
- h += ' <li>\n' +
- ' <div class="lImg">\n' +
- ' <div class="ptbPayBgColor">\n' +
- ' 充值\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="text">\n' +
- ' <div class="text_group">\n' +
- ' <span class="fz16">\n' +
- ' 平台币充值: <b class="fz12">'+v.paytype+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' <div class="text_group">\n' +
- ' <span>\n' +
- ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 价值:<b class="moneyColor">'+v.ptbcnt+'平台币</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="rt">\n' +
- ' <!--<button>删除</button>-->\n' +
- ' </div>\n' +
- ' <div class="rb">\n' +
- ' <span>交易日期:'+v.pay_time+'</span>\n' +
- ' </div>\n' +
- ' </li>'
- });
- return h;
-
- }
-
- function xfDatatoHtml(data) {
- var h = '';
- $.each(data, function (i, v) {
- var date = new Date(v.pay_time * 1000)
- h += '<li>\n' +
- ' <div class="lImg">\n' +
- ' <div class="xfBgColor">\n' +
- ' 消费\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="text">\n' +
- ' <div class="text_group">\n' +
- ' <span class="fz16">\n' +
- ' 游戏: <b>'+v.gamename+'</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' <div class="text_group">\n' +
- ' <span>\n' +
- ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
- ' </span>\n' +
- ' <span>\n' +
- ' 花费金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
- ' </span>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' <div class="rt">\n' +
- ' <!--<button>删除</button>-->\n' +
- ' </div>\n' +
- ' <div class="rb">\n' +
- ' <span>交易日期:'+v.pay_time+'</span>\n' +
- ' </div>\n' +
- ' </li>'
- });
- return h;
-
- }
-
- function renderPagination() {
- renderGamelist();
- // 生成分页并绑定分页事件
- pagination({
- elem : '#pagination',
- total : gift_index.count,
- number : '',
- size : 4,
- callback: renderGamelist
- });
- }
- $('.UserMneus_left li').eq(0).click()
- })
- })
- })
|