user.min.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. require(['config'], function () {
  2. require(['jquery', 'utils', 'pagination', 'clipboard'], function ($, utils, pagination, Clipboard) {
  3. $(function () {
  4. var phoneReg = /^[1][345789][0-9]{9}$/;
  5. var code_time = 60;
  6. function bindmobileEvent() {
  7. $('#BindDialog .js-getcode').on('click', function () {
  8. var phone = $('#BindDialog .js-newphone').val();
  9. var that = this;
  10. console.log(phone);
  11. if (! phone || ! phoneReg.test(phone)) {
  12. layer.msg('请检查手机号格式是否正确!');
  13. return;
  14. }
  15. $.ajax({
  16. url: $('#sendCodeUrl').val(),
  17. data: {
  18. mobile: phone,
  19. smstype : 4
  20. },
  21. type: 'post',
  22. success: function (res) {
  23. if (res.error == 0) {
  24. layer.msg(res.msg, {icon: 6, time: 1000});
  25. $(that).attr('disabled',true)
  26. var code_Interval = setInterval(function () {
  27. if (code_time <= 0) {
  28. $(that).attr('disabled',false)
  29. $(that).html('获取')
  30. code_time = 60;
  31. clearInterval(code_Interval)
  32. return;
  33. }
  34. code_time--;
  35. $(that).html(code_time)
  36. },1000)
  37. } else {
  38. layer.msg(res.msg, {icon: 5, time: 1000});
  39. }
  40. }
  41. })
  42. })
  43. $('#BindDialog .close').on('click', function () {
  44. $('#BindDialog').fadeOut(250)
  45. utils.unlockY()
  46. })
  47. $('#BindDialog .js-save').on('click', function () {
  48. var dt = {
  49. mobile: $('#BindDialog .js-newphone').val(),
  50. code: $('#BindDialog .js-code').val()
  51. }
  52. if (!dt.mobile && !dt.code) {
  53. layer.msg('手机/验证码为必填项')
  54. return false;
  55. }
  56. $.ajax({
  57. url: $('#editmobileUrl').val(),
  58. data: dt,
  59. type: 'post',
  60. success: function (res) {
  61. if (res.error == 0){
  62. $('#BindDialog').fadeOut(250);
  63. $('#BindSuccessDialog').fadeIn(250);
  64. setTimeout(function () {
  65. window.location.reload()
  66. },250);
  67. } else {
  68. layer.msg(res.msg)
  69. }
  70. }
  71. })
  72. })
  73. }
  74. function resetmobileEvent() {
  75. $('#resetBindDialog .js-getcode').on('click', function () {
  76. // var phone = $('#resetBindDialog .js-oldphone').text();
  77. var phone = $('#resetBindDialog .js-oldphone').text();
  78. var that = this;
  79. $.ajax({
  80. url: $('#sendCodeUrl').val(),
  81. data: {
  82. mobile: phone,
  83. smstype : 4
  84. },
  85. type: 'post',
  86. success: function (res) {
  87. if (res.error == 0) {
  88. layer.msg(res.msg, {icon: 6, time: 1000});
  89. $(that).attr('disabled',true)
  90. var code_Interval = setInterval(function () {
  91. if (code_time <= 0) {
  92. $(that).attr('disabled',false)
  93. $(that).html('获取')
  94. code_time = 60;
  95. clearInterval(code_Interval)
  96. return;
  97. }
  98. code_time--;
  99. $(that).html(code_time)
  100. },1000)
  101. } else {
  102. layer.msg(res.msg, {icon: 5, time: 1000});
  103. }
  104. }
  105. })
  106. })
  107. $('#resetBindDialog .close').on('click', function () {
  108. $('#resetBindDialog').fadeOut(250)
  109. utils.unlockY()
  110. })
  111. $('#resetBindDialog .js-save').on('click', function () {
  112. var dt = {
  113. mobile: $('#resetBindDialog .js-oldphone').text(),
  114. code: $('#resetBindDialog .js-code').val()
  115. }
  116. if (!dt.code) {
  117. layer.msg('验证码为必填项');
  118. return false;
  119. }
  120. $.ajax({
  121. url: $('#checkmobileUrl').val(),
  122. data: dt,
  123. type: 'post',
  124. success: function (res) {
  125. if (res.error == 0){
  126. layer.msg(res.msg, {time: 700});
  127. $('#resetBindDialog').hide();
  128. $('#BindDialog').fadeIn(250);
  129. } else {
  130. layer.msg(res.msg);
  131. }
  132. }
  133. })
  134. })
  135. }
  136. bindmobileEvent();
  137. resetmobileEvent();
  138. $('#exChange').on('click', function () {
  139. $("#exchangeDialog").fadeIn(250)
  140. utils.lockY()
  141. })
  142. $('#exchangeDialog .close').on('click', function () {
  143. $('#exchangeDialog').fadeOut(250)
  144. utils.unlockY()
  145. })
  146. $('#PayDialog .close').on('click', function () {
  147. $('#PayDialog').fadeOut(250)
  148. utils.unlockY()
  149. })
  150. $(".js-resetUserData").on('click', function () {
  151. $('.UserTop_Toggle > div').eq(1).addClass('active').siblings().removeClass('active')
  152. })
  153. $(".js-resetUserPass").on('click', function () {
  154. $('.UserTop_Toggle > div').eq(2).addClass('active').siblings().removeClass('active')
  155. })
  156. $('.UserTop_Toggle .back').on('click', function () {
  157. $('.UserTop_Toggle > div').eq(0).addClass('active').siblings().removeClass('active')
  158. })
  159. $('.resetUserData .resetmobile').on('click',function () {
  160. $('#resetBindDialog').fadeIn(250)
  161. })
  162. $('.resetUserData .bindmobile').on('click',function () {
  163. $('#BindDialog').fadeIn(250)
  164. })
  165. $('.UserMneus_right .myNews li').on('click', function () {
  166. var index = $(this).index();
  167. $('#newsDialog').fadeIn(250);
  168. $('#newsDialog .u-Dialog__news .mainText').html(msg_list.list[index].content)
  169. $('#newsDialog .u-Dialog__news .auth').html(msg_list.list[index].type_value)
  170. $('#newsDialog .u-Dialog__news .time').html(msg_list.list[index].create_time)
  171. $(this).find('.readStatus').text('已读');
  172. $.ajax({
  173. url: $('#readUrl').val(),
  174. type: 'get',
  175. data: {msg_id: msg_list.list[index].id},
  176. success: function () {}
  177. })
  178. utils.lockY()
  179. })
  180. $('#newsDialog .close').on('click', function () {
  181. $('#newsDialog').fadeOut(250)
  182. utils.unlockY()
  183. })
  184. var UserTabIndex = 0; // 0: 礼包 1:消息 2:游戏币充值记录 3:平台币充值记录 4: 消费记录
  185. var gift_index = 1;
  186. var new_index = 1;
  187. var yxb_index = 1;
  188. var ptb_index = 1;
  189. var xf_index = 1;
  190. //导航切换
  191. $('.UserMneus_left li').on('click',function(){
  192. UserTabIndex = $(this).index();
  193. $(this).addClass('active').siblings().removeClass('active');
  194. $('.UserMneus_right > div').eq(UserTabIndex).show().siblings().hide();
  195. var total = 0;
  196. var number = 1;
  197. if (UserTabIndex == 0) {
  198. total = gift_list.count; //礼包
  199. number = gift_index;
  200. } else if (UserTabIndex == 1) {
  201. total = msg_list.count; //消息
  202. number = new_index;
  203. } else if (UserTabIndex == 2) {
  204. total = gm_recharge_log.count; //游戏币充值记录
  205. number = yxb_index;
  206. } else if (UserTabIndex == 3) {
  207. total = ptb_recharge_log.count;
  208. number = ptb_index; //平台币充值记录
  209. } else if (UserTabIndex == 4) {
  210. total = consumption_log.count; //消费记录
  211. number = xf_index;
  212. }
  213. // xf_index
  214. pagination({
  215. elem : '#pagination',
  216. total : total,
  217. size : 4,
  218. number : number,
  219. callback: renderGamelist
  220. });
  221. });
  222. // 页码
  223. renderPagination();
  224. function renderGamelist(page) {
  225. page = page || 1;
  226. var ajaxData;
  227. if (UserTabIndex == 0) {
  228. gift_index = page;
  229. ajaxData = {'gift_page': gift_index};
  230. } else if (UserTabIndex == 1) {
  231. new_index = page;
  232. ajaxData = {'msg_page': new_index};
  233. } else if (UserTabIndex == 2) {
  234. yxb_index = page;
  235. ajaxData = {'gm_page': yxb_index};
  236. }else if (UserTabIndex == 3) {
  237. ptb_index = page;
  238. ajaxData = {'ptb_page': ptb_index};
  239. }else if (UserTabIndex == 4) {
  240. xf_index = page;
  241. ajaxData = {'consum_page': xf_index};
  242. }
  243. $.ajax({
  244. url:'',
  245. data: ajaxData,
  246. type: 'get',
  247. success: function (res) {
  248. var resData = '';
  249. console.log(UserTabIndex);
  250. if (UserTabIndex == 0) {
  251. resData = res.gift_list.list; // 礼包
  252. $('.js-gift_tpl').html(giftDatatoHtml(resData))
  253. var clipboard = new Clipboard('.copyBtn');
  254. clipboard.on('success', function(e) {
  255. layer.msg('复制成功!', {tiem: 700})
  256. e.clearSelection();
  257. });
  258. clipboard.on('error', function(e) {
  259. layer.msg('请选择“拷贝”进行复制!', {tiem: 700})
  260. });
  261. } else if (UserTabIndex == 1) {
  262. resData = res.msg_list.list; // 消息
  263. $('.js-news_tpl').html(newsDatatoHtml(resData))
  264. $('.UserMneus_right .myNews li').on('click', function () {
  265. var index = $(this).index();
  266. $.ajax({
  267. url: $('#readUrl').val(),
  268. type: 'get',
  269. data: {msg_id: res.msg_list.list[index].id},
  270. success: function () {}
  271. })
  272. $(this).find('.readStatus').text('已读');
  273. $('#newsDialog').fadeIn(250);
  274. $('#newsDialog .u-Dialog__news .mainText').html(res.msg_list.list[index].content)
  275. $('#newsDialog .u-Dialog__news .auth').html(res.msg_list.list[index].type_value)
  276. $('#newsDialog .u-Dialog__news .time').html(res.msg_list.list[index].create_time)
  277. utils.lockY()
  278. })
  279. } else if (UserTabIndex == 2) {
  280. resData = res.gm_recharge_log.list; // 游戏币充值记录
  281. $('.js-gm_tpl').html(yxbDatatoHtml(resData))
  282. }else if (UserTabIndex == 3) {
  283. resData = res.ptb_recharge_log.list; // 平台币充值记录
  284. $('.js-tpb_tpl').html(ptbDatatoHtml(resData))
  285. }else if (UserTabIndex == 4) {
  286. resData = res.consumption_log.list; // 充值记录
  287. $('.js-xf_tpl').html(xfDatatoHtml(resData))
  288. }
  289. }
  290. })
  291. }
  292. function giftDatatoHtml(data) {
  293. var h = '';
  294. $.each(data, function (i, v) {
  295. var date = new Date(v.end_time * 1000)
  296. h += '<li>\n' +
  297. ' <div class="lImg">\n' +
  298. ' <a href="javascript:;"><img src="'+v.icon+'" alt=""></a>\n' +
  299. ' </div>\n' +
  300. ' <div class="text">\n' +
  301. ' <h3><a href="javascript:;">'+v.gamename+'('+v.gift_name+')</a></h3>\n' +
  302. ' <p class="p2">礼包码:<input readonly type="text" id="copy_text'+i+'" value="'+v.gift_code+'"</p>\n' +
  303. ' <p class="p2">使用方法:'+v.func+'</p>\n' +
  304. ' </div>\n' +
  305. ' <div class="rt">\n' +
  306. ' <button data-clipboard-target="#copy_text'+i+'" class="copyBtn">复制</button>\n' +
  307. ' </div>\n' +
  308. ' <div class="rb">\n' +
  309. ' <span>有效期至:'+date.format("yyyy-MM-dd hh:mm:ss")+'</span>\n' +
  310. ' </div>\n' +
  311. ' </li>'
  312. });
  313. return h;
  314. }
  315. function newsDatatoHtml(data) {
  316. var h = '';
  317. $.each(data, function (i, v) {
  318. var date = new Date(v.end_time * 1000)
  319. var t = '未读'
  320. if (v.readed == 1) {
  321. t = '未读'
  322. } else {
  323. t = '已读'
  324. }
  325. h += '<li>\n' +
  326. ' <div class="lImg">\n' +
  327. ' <div class="newBgColor">\n' +
  328. ' '+v.type_value+'\n' +
  329. ' </div>\n' +
  330. ' </div>\n' +
  331. ' <div class="text">\n' +
  332. ' <p class="p">'+v.title+'</p>\n' +
  333. ' </div>\n' +
  334. ' <div class="rt">\n' +
  335. ' <button>详情</button>\n' +
  336. ' </div>\n' +
  337. ' <div class="rb">\n' +
  338. ' <span class="readStatus">'+t+'</span>\n' +
  339. ' </div>\n' +
  340. ' </li>'
  341. });
  342. return h;
  343. }
  344. function yxbDatatoHtml(data) {
  345. var h = '';
  346. $.each(data, function (i, v) {
  347. var date = new Date(v.pay_time * 1000)
  348. h += '<li>\n' +
  349. ' <div class="lImg">\n' +
  350. ' <div class="ptbPayBgColor">\n' +
  351. ' 充值\n' +
  352. ' </div>\n' +
  353. ' </div>\n' +
  354. ' <div class="text">\n' +
  355. ' <div class="text_group">\n' +
  356. ' <span class="fz16">\n' +
  357. ' 游戏币充值: <b class="fz12">'+v.paytype+'</b>\n' +
  358. ' </span>\n' +
  359. ' <span>\n' +
  360. ' 游戏:<b class="moneyColor">'+v.gamename+'</b>\n' +
  361. ' </span>\n' +
  362. ' <span>\n' +
  363. ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  364. ' </span>\n' +
  365. ' </div>\n' +
  366. ' <div class="text_group">\n' +
  367. ' <span>\n' +
  368. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  369. ' </span>\n' +
  370. ' <span>\n' +
  371. ' 价值:<b class="moneyColor">'+v.gm_num+'游戏币</b>\n' +
  372. ' </span>\n' +
  373. ' </div>\n' +
  374. ' </div>\n' +
  375. ' <div class="rt">\n' +
  376. ' <!--<button>删除</button>-->\n' +
  377. ' </div>\n' +
  378. ' <div class="rb">\n' +
  379. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  380. ' </div>\n' +
  381. ' </li>'
  382. });
  383. return h;
  384. }
  385. function ptbDatatoHtml(data) {
  386. var h = '';
  387. $.each(data, function (i, v) {
  388. var date = new Date(v.pay_time * 1000)
  389. h += ' <li>\n' +
  390. ' <div class="lImg">\n' +
  391. ' <div class="ptbPayBgColor">\n' +
  392. ' 充值\n' +
  393. ' </div>\n' +
  394. ' </div>\n' +
  395. ' <div class="text">\n' +
  396. ' <div class="text_group">\n' +
  397. ' <span class="fz16">\n' +
  398. ' 平台币充值: <b class="fz12">'+v.paytype+'</b>\n' +
  399. ' </span>\n' +
  400. ' <span>\n' +
  401. ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  402. ' </span>\n' +
  403. ' </div>\n' +
  404. ' <div class="text_group">\n' +
  405. ' <span>\n' +
  406. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  407. ' </span>\n' +
  408. ' <span>\n' +
  409. ' 价值:<b class="moneyColor">'+v.ptbcnt+'平台币</b>\n' +
  410. ' </span>\n' +
  411. ' </div>\n' +
  412. ' </div>\n' +
  413. ' <div class="rt">\n' +
  414. ' <!--<button>删除</button>-->\n' +
  415. ' </div>\n' +
  416. ' <div class="rb">\n' +
  417. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  418. ' </div>\n' +
  419. ' </li>'
  420. });
  421. return h;
  422. }
  423. function xfDatatoHtml(data) {
  424. var h = '';
  425. $.each(data, function (i, v) {
  426. var date = new Date(v.pay_time * 1000)
  427. h += '<li>\n' +
  428. ' <div class="lImg">\n' +
  429. ' <div class="xfBgColor">\n' +
  430. ' 消费\n' +
  431. ' </div>\n' +
  432. ' </div>\n' +
  433. ' <div class="text">\n' +
  434. ' <div class="text_group">\n' +
  435. ' <span class="fz16">\n' +
  436. ' 游戏: <b>'+v.gamename+'</b>\n' +
  437. ' </span>\n' +
  438. ' </div>\n' +
  439. ' <div class="text_group">\n' +
  440. ' <span>\n' +
  441. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  442. ' </span>\n' +
  443. ' <span>\n' +
  444. ' 花费金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  445. ' </span>\n' +
  446. ' </div>\n' +
  447. ' </div>\n' +
  448. ' <div class="rt">\n' +
  449. ' <!--<button>删除</button>-->\n' +
  450. ' </div>\n' +
  451. ' <div class="rb">\n' +
  452. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  453. ' </div>\n' +
  454. ' </li>'
  455. });
  456. return h;
  457. }
  458. function renderPagination() {
  459. renderGamelist();
  460. // 生成分页并绑定分页事件
  461. pagination({
  462. elem : '#pagination',
  463. total : gift_index.count,
  464. number : '',
  465. size : 4,
  466. callback: renderGamelist
  467. });
  468. }
  469. $('.UserMneus_left li').eq(0).click()
  470. })
  471. })
  472. })