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. var time = new Date(msg_list.list[index].create_time * 1000)
  168. $('#newsDialog').fadeIn(250);
  169. $('#newsDialog .u-Dialog__news .mainText').html(msg_list.list[index].content)
  170. $('#newsDialog .u-Dialog__news .auth').html(msg_list.list[index].type_value)
  171. $('#newsDialog .u-Dialog__news .time').html(time.format("yyyy-MM-dd hh:mm:ss"))
  172. $(this).find('.readStatus').text('已读');
  173. $.ajax({
  174. url: $('#readUrl').val(),
  175. type: 'get',
  176. data: {msg_id: msg_list.list[index].id},
  177. success: function () {}
  178. })
  179. utils.lockY()
  180. })
  181. $('#newsDialog .close').on('click', function () {
  182. $('#newsDialog').fadeOut(250)
  183. utils.unlockY()
  184. })
  185. var UserTabIndex = 0; // 0: 礼包 1:消息 2:游戏币充值记录 3:平台币充值记录 4: 消费记录
  186. var gift_index = 1;
  187. var new_index = 1;
  188. var yxb_index = 1;
  189. var ptb_index = 1;
  190. var xf_index = 1;
  191. //导航切换
  192. $('.UserMneus_left li').on('click',function(){
  193. UserTabIndex = $(this).index();
  194. $(this).addClass('active').siblings().removeClass('active');
  195. $('.UserMneus_right > div').eq(UserTabIndex).show().siblings().hide();
  196. var total = 0;
  197. var number = 1;
  198. if (UserTabIndex == 0) {
  199. total = gift_list.count; //礼包
  200. number = gift_index;
  201. } else if (UserTabIndex == 1) {
  202. total = msg_list.count; //消息
  203. number = new_index;
  204. } else if (UserTabIndex == 2) {
  205. total = gm_recharge_log.count; //游戏币充值记录
  206. number = yxb_index;
  207. } else if (UserTabIndex == 3) {
  208. total = ptb_recharge_log.count;
  209. number = ptb_index; //平台币充值记录
  210. } else if (UserTabIndex == 4) {
  211. total = consumption_log.count; //消费记录
  212. number = xf_index;
  213. }
  214. // xf_index
  215. pagination({
  216. elem : '#pagination',
  217. total : total,
  218. size : 4,
  219. number : number,
  220. callback: renderGamelist
  221. });
  222. });
  223. // 页码
  224. renderPagination();
  225. function renderGamelist(page) {
  226. page = page || 1;
  227. var ajaxData;
  228. if (UserTabIndex == 0) {
  229. gift_index = page;
  230. ajaxData = {'gift_page': gift_index};
  231. } else if (UserTabIndex == 1) {
  232. new_index = page;
  233. ajaxData = {'msg_page': new_index};
  234. } else if (UserTabIndex == 2) {
  235. yxb_index = page;
  236. ajaxData = {'gm_page': yxb_index};
  237. }else if (UserTabIndex == 3) {
  238. ptb_index = page;
  239. ajaxData = {'ptb_page': ptb_index};
  240. }else if (UserTabIndex == 4) {
  241. xf_index = page;
  242. ajaxData = {'consum_page': xf_index};
  243. }
  244. $.ajax({
  245. url:'',
  246. data: ajaxData,
  247. type: 'get',
  248. success: function (res) {
  249. var resData = '';
  250. console.log(UserTabIndex);
  251. if (UserTabIndex == 0) {
  252. resData = res.gift_list.list; // 礼包
  253. $('.js-gift_tpl').html(giftDatatoHtml(resData))
  254. var clipboard = new Clipboard('.copyBtn');
  255. clipboard.on('success', function(e) {
  256. layer.msg('复制成功!', {tiem: 700})
  257. e.clearSelection();
  258. });
  259. clipboard.on('error', function(e) {
  260. layer.msg('请选择“拷贝”进行复制!', {tiem: 700})
  261. });
  262. } else if (UserTabIndex == 1) {
  263. resData = res.msg_list.list; // 消息
  264. $('.js-news_tpl').html(newsDatatoHtml(resData))
  265. $('.UserMneus_right .myNews li').on('click', function () {
  266. var index = $(this).index();
  267. $.ajax({
  268. url: $('#readUrl').val(),
  269. type: 'get',
  270. data: {msg_id: res.msg_list.list[index].id},
  271. success: function () {}
  272. })
  273. $(this).find('.readStatus').text('已读');
  274. $('#newsDialog').fadeIn(250);
  275. $('#newsDialog .u-Dialog__news .mainText').html(res.msg_list.list[index].content)
  276. $('#newsDialog .u-Dialog__news .auth').html(res.msg_list.list[index].type_value)
  277. $('#newsDialog .u-Dialog__news .time').html(res.msg_list.list[index].create_time)
  278. utils.lockY()
  279. })
  280. } else if (UserTabIndex == 2) {
  281. resData = res.gm_recharge_log.list; // 游戏币充值记录
  282. $('.js-gm_tpl').html(yxbDatatoHtml(resData))
  283. }else if (UserTabIndex == 3) {
  284. resData = res.ptb_recharge_log.list; // 平台币充值记录
  285. $('.js-tpb_tpl').html(ptbDatatoHtml(resData))
  286. }else if (UserTabIndex == 4) {
  287. resData = res.consumption_log.list; // 充值记录
  288. $('.js-xf_tpl').html(xfDatatoHtml(resData))
  289. }
  290. }
  291. })
  292. }
  293. function giftDatatoHtml(data) {
  294. var h = '';
  295. $.each(data, function (i, v) {
  296. var date = new Date(v.end_time * 1000)
  297. h += '<li>\n' +
  298. ' <div class="lImg">\n' +
  299. ' <a href="javascript:;"><img src="'+v.icon+'" alt=""></a>\n' +
  300. ' </div>\n' +
  301. ' <div class="text">\n' +
  302. ' <h3><a href="javascript:;">'+v.gamename+'('+v.gift_name+')</a></h3>\n' +
  303. ' <p class="p2">礼包码:<input readonly type="text" id="copy_text'+i+'" value="'+v.gift_code+'"</p>\n' +
  304. ' <p class="p2">使用方法:'+v.func+'</p>\n' +
  305. ' </div>\n' +
  306. ' <div class="rt">\n' +
  307. ' <button data-clipboard-target="#copy_text'+i+'" class="copyBtn">复制</button>\n' +
  308. ' </div>\n' +
  309. ' <div class="rb">\n' +
  310. ' <span>有效期至:'+date.format("yyyy-MM-dd hh:mm:ss")+'</span>\n' +
  311. ' </div>\n' +
  312. ' </li>'
  313. });
  314. return h;
  315. }
  316. function newsDatatoHtml(data) {
  317. var h = '';
  318. $.each(data, function (i, v) {
  319. var date = new Date(v.end_time * 1000)
  320. var t = '未读'
  321. if (v.readed == 1) {
  322. t = '未读'
  323. } else {
  324. t = '已读'
  325. }
  326. h += '<li>\n' +
  327. ' <div class="lImg">\n' +
  328. ' <div class="newBgColor">\n' +
  329. ' '+v.type_value+'\n' +
  330. ' </div>\n' +
  331. ' </div>\n' +
  332. ' <div class="text">\n' +
  333. ' <p class="p">'+v.title+'</p>\n' +
  334. ' </div>\n' +
  335. ' <div class="rt">\n' +
  336. ' <button>详情</button>\n' +
  337. ' </div>\n' +
  338. ' <div class="rb">\n' +
  339. ' <span class="readStatus">'+t+'</span>\n' +
  340. ' </div>\n' +
  341. ' </li>'
  342. });
  343. return h;
  344. }
  345. function yxbDatatoHtml(data) {
  346. var h = '';
  347. $.each(data, function (i, v) {
  348. var date = new Date(v.pay_time * 1000)
  349. h += '<li>\n' +
  350. ' <div class="lImg">\n' +
  351. ' <div class="ptbPayBgColor">\n' +
  352. ' 充值\n' +
  353. ' </div>\n' +
  354. ' </div>\n' +
  355. ' <div class="text">\n' +
  356. ' <div class="text_group">\n' +
  357. ' <span class="fz16">\n' +
  358. ' 游戏币充值: <b class="fz12">'+v.paytype+'</b>\n' +
  359. ' </span>\n' +
  360. ' <span>\n' +
  361. ' 游戏:<b class="moneyColor">'+v.gamename+'</b>\n' +
  362. ' </span>\n' +
  363. ' <span>\n' +
  364. ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  365. ' </span>\n' +
  366. ' </div>\n' +
  367. ' <div class="text_group">\n' +
  368. ' <span>\n' +
  369. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  370. ' </span>\n' +
  371. ' <span>\n' +
  372. ' 价值:<b class="moneyColor">'+v.gm_num+'游戏币</b>\n' +
  373. ' </span>\n' +
  374. ' </div>\n' +
  375. ' </div>\n' +
  376. ' <div class="rt">\n' +
  377. ' <!--<button>删除</button>-->\n' +
  378. ' </div>\n' +
  379. ' <div class="rb">\n' +
  380. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  381. ' </div>\n' +
  382. ' </li>'
  383. });
  384. return h;
  385. }
  386. function ptbDatatoHtml(data) {
  387. var h = '';
  388. $.each(data, function (i, v) {
  389. var date = new Date(v.pay_time * 1000)
  390. h += ' <li>\n' +
  391. ' <div class="lImg">\n' +
  392. ' <div class="ptbPayBgColor">\n' +
  393. ' 充值\n' +
  394. ' </div>\n' +
  395. ' </div>\n' +
  396. ' <div class="text">\n' +
  397. ' <div class="text_group">\n' +
  398. ' <span class="fz16">\n' +
  399. ' 平台币充值: <b class="fz12">'+v.paytype+'</b>\n' +
  400. ' </span>\n' +
  401. ' <span>\n' +
  402. ' 金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  403. ' </span>\n' +
  404. ' </div>\n' +
  405. ' <div class="text_group">\n' +
  406. ' <span>\n' +
  407. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  408. ' </span>\n' +
  409. ' <span>\n' +
  410. ' 价值:<b class="moneyColor">'+v.ptbcnt+'平台币</b>\n' +
  411. ' </span>\n' +
  412. ' </div>\n' +
  413. ' </div>\n' +
  414. ' <div class="rt">\n' +
  415. ' <!--<button>删除</button>-->\n' +
  416. ' </div>\n' +
  417. ' <div class="rb">\n' +
  418. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  419. ' </div>\n' +
  420. ' </li>'
  421. });
  422. return h;
  423. }
  424. function xfDatatoHtml(data) {
  425. var h = '';
  426. $.each(data, function (i, v) {
  427. var date = new Date(v.pay_time * 1000)
  428. h += '<li>\n' +
  429. ' <div class="lImg">\n' +
  430. ' <div class="xfBgColor">\n' +
  431. ' 消费\n' +
  432. ' </div>\n' +
  433. ' </div>\n' +
  434. ' <div class="text">\n' +
  435. ' <div class="text_group">\n' +
  436. ' <span class="fz16">\n' +
  437. ' 游戏: <b>'+v.gamename+'</b>\n' +
  438. ' </span>\n' +
  439. ' </div>\n' +
  440. ' <div class="text_group">\n' +
  441. ' <span>\n' +
  442. ' 单号: <b class="dhColor">'+v.orderid+'</b>\n' +
  443. ' </span>\n' +
  444. ' <span>\n' +
  445. ' 花费金额:<b class="moneyColor">'+v.amount+'元</b>\n' +
  446. ' </span>\n' +
  447. ' </div>\n' +
  448. ' </div>\n' +
  449. ' <div class="rt">\n' +
  450. ' <!--<button>删除</button>-->\n' +
  451. ' </div>\n' +
  452. ' <div class="rb">\n' +
  453. ' <span>交易日期:'+v.pay_time+'</span>\n' +
  454. ' </div>\n' +
  455. ' </li>'
  456. });
  457. return h;
  458. }
  459. function renderPagination() {
  460. renderGamelist();
  461. // 生成分页并绑定分页事件
  462. pagination({
  463. elem : '#pagination',
  464. total : gift_index.count,
  465. number : '',
  466. size : 4,
  467. callback: renderGamelist
  468. });
  469. }
  470. $('.UserMneus_left li').eq(0).click()
  471. })
  472. })
  473. })