personal_v3.0.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759
  1. (function(window) {
  2. window.staticImg = "http://static.lolbox.duowan.com/images";
  3. jQuery.cookie = function (name, value, options) {
  4. if (typeof value != 'undefined') { // name and value given, set cookie
  5. options = options || {};
  6. if (value === null) {
  7. value = '';
  8. options.expires = -1;
  9. }
  10. var expires = '';
  11. if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
  12. var date;
  13. if (typeof options.expires == 'number') {
  14. date = new Date();
  15. date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
  16. } else {
  17. date = options.expires;
  18. }
  19. expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
  20. }
  21. var path = options.path ? '; path=' + options.path : '';
  22. var domain = options.domain ? '; domain=' + options.domain : '';
  23. var secure = options.secure ? '; secure' : '';
  24. document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
  25. } else { // only name given, get cookie
  26. var cookieValue = '';
  27. if (document.cookie && document.cookie != '') {
  28. var cookies = document.cookie.split(';');
  29. for (var i = 0; i < cookies.length; i++) {
  30. var cookie = jQuery.trim(cookies[i]);
  31. // Does this cookie string begin with the name we want?
  32. if (cookie.substring(0, name.length + 1) == (name + '=')) {
  33. cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
  34. break;
  35. }
  36. }
  37. }
  38. return cookieValue;
  39. }
  40. };
  41. //格式化段位显示,优化前人留下的一大堆重复性代码
  42. var formatDW = function(zdlData) {
  43. var tierName;
  44. if (!zdlData) {
  45. tierName = '无段位';
  46. } else if (zdlData['t_zh'] == '无段位') {
  47. tierName = zdlData['t_zh'];
  48. } else {
  49. tierName = zdlData['t_zh'] + zdlData['r_zh'];
  50. }
  51. return tierName;
  52. }
  53. var personalInfoTpl = __inline("../tpl/personalInfo.tmpl"); //用户信息渲染模板
  54. var generalHistoryTpl = __inline("../tpl/generalHistory.tmpl"); //最近比赛渲染模板
  55. var generalEchartsTpl = __inline("../tpl/generalEcharts.tmpl"); //最近比赛渲染模板
  56. var Personal = function(type) {
  57. this.gameZone = getURLParam("gameZone");
  58. this.userId = getURLParam("userId");
  59. this.urlServerName = getURLParam("serverName");
  60. this.urlPlayerName = getURLParam("playerName");
  61. this.serverName = encodeURIComponent(this.urlServerName);
  62. this.playerName = encodeURIComponent(this.urlPlayerName);
  63. this.boxUserId = $.cookie("boxUserId");
  64. this.boxPlayerName = encodeURIComponent($.cookie("boxPlayerName"));
  65. this.boxPlayerName = encodeURIComponent($.cookie("boxPlayerName"));
  66. this.type = type;//页面类型
  67. this.Services = "http://api.lolbox.duowan.com/api/v3/player/";
  68. this.baseUrl = "http://api.lolbox.duowan.com/api/v3/player/"+ this.gameZone +"/" + this.userId + '/';
  69. //饼图默认设置
  70. this.highchartsOpts = {
  71. chart: {
  72. type: 'pie'
  73. },
  74. plotOptions: {
  75. series: {
  76. dataLabels: {
  77. enabled: false
  78. }
  79. }
  80. },
  81. tooltip: {
  82. enabled:false
  83. },
  84. drilldown: {
  85. series: null
  86. }
  87. };
  88. this.init();
  89. };
  90. Personal.prototype = {
  91. constructor: Personal,
  92. init: function() {
  93. var self = this;
  94. self.bindEvents();
  95. //获取除开KDA那行的其他数据
  96. self._getData().done(function(result, status, xhr) {
  97. // 数据重组
  98. var isMyself = result.is_myself;
  99. var followed = result.followed;
  100. var data = result.player_list[0];
  101. self.userInfo = data; // 缓存数据
  102. data.isSelf = isMyself;
  103. data.followed = followed;
  104. // 视图渲染
  105. self._render(data);
  106. self.renderByPageType();
  107. self._moreGameResult();
  108. });
  109. $('#modeTabs>li').each(function(item) {
  110. var pageName = $(this).data('name');
  111. $(this).find('a').attr('href', pageName + '.html?serverName=' + self.serverName + '&playerName=' + self.playerName + '&userId=' + self.userId + '&gameZone=' + self.gameZone);
  112. });
  113. // 非本人才显示返回按钮
  114. if ( self.boxUserId != self.userId ) {
  115. $('.common-page__goBack').css('visibility', 'visible');
  116. }
  117. },
  118. // 页面渲染路由
  119. renderByPageType: function() {
  120. switch(this.type) {
  121. case 'tab1': this.renderTab1();break;
  122. case 'tab2': this.renderTab2();break;
  123. case 'tab3': this.renderTab3();break;
  124. case 'tab4': this.renderTab4();break;
  125. }
  126. },
  127. // 战绩总览页面渲染入口
  128. renderTab1: function() {
  129. var self = this;
  130. //近20场比赛
  131. $('#compositeRateContainer').highcharts($.extend({}, this.highchartsOpts, {
  132. colors: ['#eeeeee', '#9ec8eb'],
  133. series: [{
  134. colorByPoint: true,
  135. data: [{
  136. y: 100 - self.userInfo.stat_perf.kda.average_win_rate
  137. }, {
  138. y: self.userInfo.stat_perf.kda.average_win_rate
  139. }]
  140. }]
  141. }));
  142. var userPosition = parseInt($('.data-userPosition').attr("data-percent"), 10) || 0;
  143. userPosition = userPosition >= 100 ? 100 : userPosition;
  144. //最强位置
  145. $('#jungleAreaContainer').highcharts($.extend({}, this.highchartsOpts, {
  146. colors: ['#eeeeee','#a1d8b9'],
  147. series: [{
  148. colorByPoint: true,
  149. data: [{
  150. y: 100 - userPosition
  151. }, {
  152. y: userPosition
  153. }]
  154. }]
  155. }));
  156. // 最近比赛跳转
  157. $(document).on('click', '#history li', function() {
  158. var historyId = $(this).index();
  159. location.href = "historyRecord.html?serverName=" + self.serverName + "&playerName=" + self.playerName + "&userId=" + self.userId + "&gameZone=" + self.gameZone + '&historyId=' + historyId;
  160. })
  161. },
  162. // 历史战绩页面渲染入口
  163. renderTab2: function() {},
  164. // 擅长领域页面渲染入口
  165. renderTab3: function() {
  166. var self = this;
  167. var defaultColors = ['#eeeeee', '#9ec8eb'];
  168. var navLists = ['打野','输出','辅助'];
  169. // TAB切换
  170. $('.content-nav li').on('click', function(e) {
  171. e.preventDefault();
  172. var id = $(this).data('id');
  173. renderByNav(id);
  174. $(this).addClass('active').siblings().removeClass('active');
  175. });
  176. //初始化第一个TAB
  177. renderByNav(0);
  178. // 内容渲染
  179. function renderByNav(index) {
  180. var type = decodeURI(navLists[index]);
  181. //获取视频数据
  182. getVideosData(type, 4).done(function(resp) {
  183. if(resp && resp.videos) {
  184. // 更多推荐视频路由
  185. var videos = resp.videos, moreLink;
  186. switch(index) {
  187. case 0: moreLink = 'http://v.huya.com/lol/jiaoxue/daye.html';break;
  188. case 1: moreLink = 'http://v.huya.com/t/shuchushipin.html';break;
  189. case 2: moreLink = 'http://v.huya.com/t/fuzhushipin.html';break;
  190. };
  191. videos.moreLink = moreLink;
  192. // 推荐视频渲染
  193. var templateVideos = _.template($("#detailVideosTemp").html());
  194. $("#detailVideos").html(templateVideos({
  195. data: videos
  196. }));
  197. }
  198. });
  199. // 获取区间数据
  200. self.getUserRank().done(function(o) {
  201. if ( o.results[0] ) {
  202. self.ZoneData = o.results;
  203. renderMainModule(index); // 依赖区间数据
  204. }
  205. })
  206. }
  207. // 擅长领域中间部分数据重组和渲染
  208. function renderMainModule(index) {
  209. // 用户段位
  210. var duanwei = parseInt($('.userDuanwei').attr('data-duanwei'), 10);
  211. // 算法表
  212. var title = [
  213. '个人参团数/团队团战数', //参团率
  214. '小龙击杀数量/小龙复活次数', //大小龙率
  215. '支援成功次数/支援次数', //GANK率
  216. '个人存活时间/游戏持续时间', //存活率
  217. '个人输出量/团队总体输出量', //输出率
  218. '个人插(排)眼数/团队总(插)眼数', //插/反眼率
  219. ];
  220. // 数据构造
  221. var positionEname = ['jungler','adc','support'];
  222. var Position = self.userInfo.stat_perf.position_perf;
  223. var Database = {
  224. // 饼图名字关系表
  225. t_chart__name: [
  226. {'name1': '参团率', 'name2': '小龙率', 'name3': 'GANK率', 'title1': title[0], 'title2': title[1], 'title3': title[2]},
  227. {'name1': '存活率', 'name2': '参团率', 'name3': '输出率', 'title1': title[3], 'title2': title[0], 'title3': title[4]},
  228. {'name1': '存活率', 'name2': '参团率', 'name3': '视野率', 'title1': title[3], 'title2': title[0], 'title3': title[5]}
  229. ],
  230. // 概率关系表
  231. t_chart_rate: [
  232. {'rate1': Position.rate_assists_jungler, 'rate2': Position.rate_dragon_killed_jungler || 0, 'rate3': Position.rate_gank_jungler},
  233. {'rate1': Position.rate_keep_alive_adc, 'rate2': Position.rate_assists_adc, 'rate3': Position.rate_damage_adc},
  234. {'rate1': Position.rate_keep_alive_support, 'rate2': Position.rate_assists_support, 'rate3': Position.rate_vision_support}
  235. ],
  236. // 区间概率
  237. zone: [
  238. {'zone1': self.ZoneData[duanwei]['rate_assists_jungler'], 'zone2': self.ZoneData[duanwei]['rate_dragon_killed_jungler'], 'zone3': self.ZoneData[duanwei]['rate_gank_jungler']},
  239. {'zone1': self.ZoneData[duanwei]['rate_keep_alive_adc'], 'zone2': self.ZoneData[duanwei]['rate_assists_adc'], 'zone3': self.ZoneData[duanwei]['rate_damage_adc']},
  240. {'zone1': self.ZoneData[duanwei]['rate_keep_alive_support'], 'zone2': self.ZoneData[duanwei]['rate_assists_support'], 'zone3': self.ZoneData[duanwei]['rate_vision_support']}
  241. ],
  242. // 列表标题关系表
  243. t_list__name: ['打野', '输出', '辅助'],
  244. // 底部场均信号沟通等数据
  245. t_bottom: [
  246. {signal: Position.signals_sent_jungler, eye: Position.rate_vision_jungler || 0, kill: Position.neutral_minions_killed_jungler, tower: Position.turrets_killed_jungler}, //打野
  247. {signal: Position.signals_sent_adc, eye: Position.rate_vision_adc || 0, kill: Position.neutral_minions_killed_adc, tower: Position.turrets_killed_adc}, //输出
  248. {signal: Position.signals_sent_support, eye: Position.rate_vision_support || 0, kill: Position.neutral_minions_killed_support, tower: Position.turrets_killed_support} //辅助
  249. ]
  250. }
  251. // 渲染
  252. var templateMain = _.template($("#detailMainTemp").html());
  253. $("#detailMain").html(templateMain({
  254. data: {
  255. // 三个概率图
  256. chart1: {
  257. name: Database.t_chart__name[index]['name1'],
  258. rate: Database.t_chart_rate[index]['rate1'],
  259. title: Database.t_chart__name[index]['title1']
  260. },
  261. chart2: {
  262. name: Database.t_chart__name[index]['name2'],
  263. rate: Database.t_chart_rate[index]['rate2'],
  264. title: Database.t_chart__name[index]['title2']
  265. },
  266. chart3: {
  267. name: Database.t_chart__name[index]['name3'],
  268. rate: Database.t_chart_rate[index]['rate3'],
  269. title: Database.t_chart__name[index]['title3']
  270. },
  271. // 常在打野、输出、辅助列表
  272. list: {
  273. title: Database.t_list__name[index],
  274. data: self.userInfo.stat_perf.position_champ[positionEname[index]]
  275. },
  276. // 底部场均信号沟通等数据
  277. bottom: Database.t_bottom[index],
  278. zone: Database.zone[index],
  279. All: Position
  280. }
  281. }));
  282. // 渲染饼图
  283. renderEcharts({
  284. rate1: Database.t_chart_rate[index]['rate1'],
  285. rate2: Database.t_chart_rate[index]['rate2'],
  286. rate3: Database.t_chart_rate[index]['rate3']
  287. });
  288. }
  289. // 渲染饼图
  290. function renderEcharts(rateData) {
  291. $('#gankContainer').highcharts($.extend({}, self.highchartsOpts, {
  292. colors: defaultColors,
  293. series: [{
  294. colorByPoint: true,
  295. data: [{
  296. y: 100 - rateData.rate1
  297. }, {
  298. y: rateData.rate1
  299. }]
  300. }]
  301. }));
  302. $('#joinPartyContainer').highcharts($.extend({}, self.highchartsOpts, {
  303. colors: ['#eeeeee', '#f7cebe'],
  304. series: [{
  305. colorByPoint: true,
  306. data: [{
  307. y: 100 - rateData.rate2
  308. }, {
  309. y: rateData.rate2
  310. }]
  311. }]
  312. }));
  313. $('#dragonContainer').highcharts($.extend({}, self.highchartsOpts, {
  314. colors: defaultColors,
  315. series: [{
  316. colorByPoint: true,
  317. data: [{
  318. y: 100 - rateData.rate3
  319. }, {
  320. y: rateData.rate3
  321. }]
  322. }]
  323. }));
  324. }
  325. // 获取推荐视频
  326. function getVideosData(type, limit) {
  327. var url = 'http://v.huya.com/?r=api/GetVideoForBox&location=' + type + '&limit=' + limit;
  328. return $.ajax({
  329. url: url,
  330. dataType: 'jsonp'
  331. });
  332. }
  333. },
  334. // 个人成就页面渲染入口
  335. renderTab4: function() {
  336. var self = this;
  337. // 个人成就拆分逻辑加载
  338. $.getScript( achievementJS, function() {
  339. App.highchartsOpts = self.highchartsOpts;
  340. App.defaultColors = ['#eeeeee', '#9ec8eb'];
  341. });
  342. },
  343. // 事件绑定
  344. bindEvents: function() {
  345. var self = this;
  346. $("body").delegate(".handles .copy", "click", function(e) {
  347. event.preventDefault();
  348. if (window.clipboardData && window.clipboardData.setData !== undefined) {
  349. var achievement = $(this).parent().find(".copy-text").text();
  350. window.clipboardData.setData('Text', achievement);
  351. alert('复制成功');
  352. }
  353. });
  354. $("body").delegate(".combat-explain,.handles a", 'click', function(e) {
  355. var stat = $(this).attr("stat-sign") || '',
  356. yaDxinesc = $(this).attr("stat-desc") || '',
  357. yaCode = "click/"+stat;
  358. try {
  359. window.external.data_report(yaCode, yaDxinesc);
  360. } catch(err) {}
  361. });
  362. $("body").delegate('.blacklist', 'click', function(e) {
  363. e.preventDefault();
  364. if($(this).hasClass('hide-list')) {
  365. $(this).removeClass('hide-list').html('隐藏拉黑');
  366. $('.blacklist-content2').show();
  367. } else{
  368. $(this).addClass('hide-list').html('拉黑');
  369. $('.blacklist-content2').hide();
  370. }
  371. });
  372. $("body").on('mouseenter', '.table-history__lastseason .toggle-s4-s5', function(e) {
  373. $('.s4-s5').show();
  374. $('.table-arrow').addClass('up');
  375. }).on('mouseleave', '.table-history', function() {
  376. $('.s4-s5').hide();
  377. $('.table-arrow').removeClass('up');
  378. });;
  379. $("#screenshot").on("click", function(e) {
  380. $('.share').removeClass('hover');
  381. setTimeout(function () {
  382. window.location.href = 'lolboxphoto://'+data.game_zone.server_name+'_'+data.pn+'_玩家详情';
  383. }, 200);
  384. });
  385. /* 关注鼠标悬浮显示 */
  386. $(document).on('mouseenter', '.name-info', function(event) {
  387. $('.userInfo-common__focus').show();
  388. }).on('mouseleave', '.name-info', _.debounce(function(){
  389. $('.userInfo-common__focus').hide();
  390. }, 4000))
  391. //关注、取消关注
  392. $("body").delegate(".attention", "click", function(e) {
  393. e.preventDefault();
  394. if(!self.boxUserId) {
  395. alert('非法操作,请至少登陆一次游戏!');
  396. return;
  397. }
  398. var type = $(this).attr("data-action"), that = this;
  399. var action = type == 'addFocus' ? 'follow' : 'unfollow';
  400. var url = "http://api.lolbox.duowan.com/api/v3/player/"+self.gameZone+"/" + self.boxUserId + '/'+action+'/?user_id='+self.userId;
  401. $.ajax({
  402. url: url,
  403. type: 'get',
  404. dataType: 'jsonp',
  405. success: function(result) {
  406. if (result) {
  407. if(type == "addFocus") {
  408. $(that).addClass("already").attr("data-action", "removeFocus")
  409. .find("span").html("已关注");
  410. } else {
  411. $(that).removeClass("already").attr("data-action", "addFocus")
  412. .find("span").html("关注");
  413. }
  414. }
  415. }
  416. });
  417. });
  418. // 返回上一页
  419. $('.common-page__goBack').on('click', function() {
  420. window.history.back();
  421. return false;
  422. });
  423. // 刷新按钮
  424. $('.common-page__reflash').on('click', function() {
  425. location.reload();
  426. });
  427. },
  428. // 获取个人详细信息
  429. _getData: function() {
  430. var url = this.baseUrl;
  431. var args = {};
  432. var boxUrlData = $.cookie("boxUrlData");
  433. var wsSecret = boxUrlData.split("&")[1];
  434. var ts = boxUrlData.split("&")[0];
  435. args['wsSecret'] = wsSecret;
  436. args['ts'] = ts;
  437. return $.ajax({
  438. url: url,
  439. data: args,
  440. type: 'GET',
  441. dataType: 'jsonp'
  442. });
  443. },
  444. _getKDAData: function() {
  445. var url = this.baseUrl + "?_do=personal/positionhonorkda&serverName=" + this.serverName + "&playerName=" + this.playerName;
  446. return $.ajax({
  447. url: url,
  448. type: 'GET',
  449. dataType: 'jsonp'
  450. });
  451. },
  452. // 数据渲染入口
  453. _render: function(data) {
  454. var self = this;
  455. self.userInfo = data; // 数据备份
  456. self.playerId = data.user_id;
  457. // 个人信息数据渲染
  458. self._renderPersonalInfo(data);
  459. //战绩总览数据渲染
  460. if( self.type == 'tab1' ) {
  461. $(".fighting-history__view").html(generalEchartsTpl({data: data}));
  462. try{
  463. self._renderHistory(data);
  464. self._renderKDA(data);
  465. }catch(e){}
  466. }
  467. // 广告接入
  468. $('.p-adwrap').html($('.ad-module a'));
  469. // 内容显示
  470. $(".box-bd").show();
  471. },
  472. // 个人信息通用模块渲染
  473. _renderPersonalInfo: function(data) {
  474. var href = "historyRecord.html?serverName=" + this.serverName + "&playerName=" + this.playerName + "&userId=" + this.userId + "&gameZone=" + this.gameZone;
  475. var attentionUrl = "http://lolbox.duowan.com/webApi.php?serverName=" + this.serverName + "&playerName=" + this.playerName + "&targetServerName=" + this.boxServerName + "&targetPlayerName=" + this.boxPlayerName + "&action=";
  476. //储存个人信息
  477. data.global = {};
  478. //二维码url
  479. data.global.qrcodeUrl = "http://lolbox.duowan.com/qrcode.php?openmode=barcode&amp;serverName=" + this.serverName + "&amp;playerName=" + this.playerName;
  480. //头像url,点击去到战绩页面
  481. data.global.href = href;
  482. //关注/取消关注接口baseUrl
  483. data.global.aUrl = attentionUrl;
  484. $("#currentNav").html(data.pn+"("+data.game_zone.alias+")").attr("href", location.href);
  485. // 头部个人信息模板渲染
  486. $("#personalInfo").html(personalInfoTpl({data: data}));
  487. var client = new ZeroClipboard( document.getElementById("copy-button") );
  488. client.on( "ready", function( readyEvent ) {
  489. client.on( "aftercopy", function( event ) {
  490. alert("复制成功!用户名:" + event.data["text/plain"] );
  491. });
  492. });
  493. // 称号图片地址
  494. // if ( data.honor_title ) {
  495. // var placeholder = $('.userMedal').attr('src');
  496. // var src = placeholder.replace('placeholder', ['a_level_', data.honor_title].join(''));
  497. // $('.userMedal').attr('src', src);
  498. // }
  499. },
  500. _renderKDA: function(data) {
  501. this._renderDaYe(data);
  502. this._renderKDADetail(data);
  503. },
  504. _renderDaYe: function(data) {
  505. var colorsArr = ['#fbb28f','#cea9d7','#fa9f9f','#80c989','#9dc7eb'], setColors = [], setData = [], i=0;
  506. var statPosition = data.stat_position;//英雄位置统计
  507. if(statPosition) {
  508. for(var key in statPosition) {
  509. var value = statPosition[key];
  510. if(key != 'total_game' && value != 0) {
  511. var keyTxt = '';
  512. switch(key) {
  513. case 'adc': keyTxt = 'ADC';break;
  514. case 'jungler': keyTxt = '打野';break;
  515. case 'mid': keyTxt = '中单';break;
  516. case 'support': keyTxt = '辅助';break;
  517. case 'top': keyTxt = '上单';break;
  518. };
  519. setData.push({
  520. value: value,
  521. label: keyTxt
  522. });
  523. setColors.push(colorsArr[i++]);
  524. }
  525. }
  526. }
  527. $("body").delegate("#daYe, .kda-li, .kill-li", "mouseenter", function(e) {
  528. e.preventDefault();
  529. if($(this).hasClass("da-ye")) {
  530. $(".daye-hover").show();
  531. } else if($(this).hasClass("kda-li")) {
  532. $(".kda-hover").show();
  533. } else {
  534. $(".kill-hover").show();
  535. }
  536. });
  537. $("body").delegate("#daYe, .kda-li, .kill-li", "mouseleave", function(e) {
  538. e.preventDefault();
  539. if($(this).hasClass("da-ye")) {
  540. $(".daye-hover").hide();
  541. } else if($(this).hasClass("kda-li")) {
  542. $(".kda-hover").hide();
  543. } else {
  544. $(".kill-hover").hide();
  545. }
  546. });
  547. //近7天英雄使用次数
  548. $("#heroTime").html(statPosition.total_game);
  549. },
  550. _renderKDADetail: function(data) {
  551. var template = _.template($("#kdaTemp").html());
  552. $("#kda").html(template({
  553. data: data
  554. }));
  555. },
  556. _renderHistory: function(data) {
  557. var nextFirstWinTime = data.timestamp_until_next_first_win_bonus;
  558. var currentTime = new Date().getTime();
  559. $(".f-time").html('首胜可用');
  560. $("#firstMsg").addClass('active-status');
  561. if ( currentTime < nextFirstWinTime*1000 ) {
  562. $("#firstMsg").removeClass('active-status');
  563. countDown(nextFirstWinTime, '.f-time');
  564. }
  565. $("#firstMsg").on('mouseenter', function(e) {
  566. $('.first-win-hover').show();
  567. }).on('mouseleave', function(e) {
  568. $('.first-win-hover').hide();
  569. });
  570. // 倒计时方法
  571. function countDown(times, target) {
  572. var times = Math.ceil(parseInt(times)*1000);
  573. var timerId = setInterval(function() {
  574. if ( times <= 0 ) {
  575. $(target).html('首胜可用');
  576. $("#firstMsg").addClass('active-status');
  577. return;
  578. }
  579. var h = parseInt(times % 86400 / 3600),
  580. m = parseInt(times % 86400 % 3600 / 60),
  581. s = parseInt(times % 86400 % 3600 % 60 % 60);
  582. s = s < 10 ? '0' + s : s;
  583. $(target).html([h,':',m,':',s].join(''));
  584. times--;
  585. }, 1*1000);
  586. }
  587. //最近战绩
  588. setTimeout(function() {
  589. $("#history").html(generalHistoryTpl({
  590. data: data.game_recent_list
  591. })).niceScroll({
  592. cursorcolor: "#D9D9D9",
  593. cursorwidth: "8",
  594. cursoropacitymin: 1,
  595. cursorborder: 'none'
  596. });
  597. });
  598. },
  599. _moreGameResult: function() {
  600. var href = "historyRecord.html?serverName=" + this.urlServerName + "&playerName=" + this.urlPlayerName+'&userId='+this.userId+'&gameZone='+this.gameZone;
  601. $("#moreGameResult").attr("href", href);
  602. },
  603. // 获取【擅长领域】TAB区间数据
  604. getUserRank: function() {
  605. var self = this;
  606. return $.ajax({
  607. url: self.Services + self.gameZone + '/perf_ave/',
  608. dataType: 'jsonp'
  609. });
  610. }
  611. };
  612. function getURLParam(name) {
  613. var value = location.search.match(new RegExp("[?&]" + name + "=([^&]*)(&?)", "i"));
  614. return value ? decodeURIComponent(value[1]) : value;
  615. }
  616. function getCookie(cookieName) {
  617. var cookieString = document.cookie;
  618. var start = cookieString.indexOf(cookieName + '=');
  619. // 加上等号的原因是避免在某些 Cookie 的值里有
  620. // 与 cookieName 一样的字符串。
  621. if (start == -1) // 找不到
  622. return null;
  623. start += cookieName.length + 1;
  624. var end = cookieString.indexOf(';', start);
  625. if (end == -1)
  626. return cookieString.substring(start);
  627. return cookieString.substring(start, end);
  628. }
  629. function beenBlockedTimes(action) {
  630. var boxPlayerName = decodeURI(getCookie('boxPlayerName'));
  631. var boxServerName = decodeURI(getCookie('boxServerName'));
  632. $.ajax({
  633. url: "http://lolbox.duowan.com/webApi.php",
  634. data: {serverName: boxServerName, playerName: boxPlayerName, action: action},
  635. cache: false,
  636. success: function (msg) {
  637. if (msg == 1) {
  638. location.reload();
  639. } else if (msg == -1) {
  640. alert('非法操作,请至少登陆一次游戏!');
  641. }
  642. },
  643. error: function () {
  644. }
  645. });
  646. }
  647. window.Personal = Personal;
  648. })(window);
  649. $(function() {
  650. new Personal('tab1');
  651. });