Commit 4c3ba8ed authored by ganjingcun's avatar ganjingcun

时区修正

parent 5fb0c7f6
...@@ -105,7 +105,9 @@ ...@@ -105,7 +105,9 @@
} else { } else {
this.isNew = false; this.isNew = false;
this.avatar_url = res.data.data.url this.avatar_url = res.data.data.url
this.avatar_url_new = res.data.data.url
this.form.desc = res.data.data.content this.form.desc = res.data.data.content
this.form.desc_new = res.data.data.content
} }
}, (res) => { }, (res) => {
this.hasError = true this.hasError = true
......
...@@ -165,10 +165,10 @@ ...@@ -165,10 +165,10 @@
} }
}, },
formatter1(row, column) { formatter1(row, column) {
return moment(row.start_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm') return moment(row.start_time).format('YYYY-MM-DD HH:mm')
}, },
formatter2(row, column) { formatter2(row, column) {
return moment(row.end_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm') return moment(row.end_time).format('YYYY-MM-DD HH:mm')
}, },
renderTable: function () { renderTable: function () {
var params = { var params = {
......
...@@ -154,7 +154,6 @@ ...@@ -154,7 +154,6 @@
<script> <script>
import querystring from 'querystring'; import querystring from 'querystring';
import language from './lang';
import img1 from '../assets/img/images1.jpeg' import img1 from '../assets/img/images1.jpeg'
import img2 from '../assets/img/images2.jpeg' import img2 from '../assets/img/images2.jpeg'
...@@ -196,9 +195,6 @@ ...@@ -196,9 +195,6 @@
} }
}, },
created: function () { created: function () {
this.init()
var lang = localStorage.getItem('lang');
this.initLang(lang);
var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i; var regex_match = /(nokia|iphone|android|motorola|^mot-|softbank|foma|docomo|kddi|up.browser|up.link|htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte-|longcos|pantech|gionee|^sie-|portalmmm|jigs browser|hiptop|^benq|haier|^lct|operas*mobi|opera*mini|320x320|240x320|176x220)/i;
var u = navigator.userAgent; var u = navigator.userAgent;
...@@ -213,21 +209,19 @@ ...@@ -213,21 +209,19 @@
} }
}, },
events: {
'lang-change': function (lang) {
this.initLang(lang)
}
},
watch: { watch: {
lang: function (val) { lang: function (val) {
console.log('lang change1', val) this.init()
this.init2()
}, },
}, },
mounted: function () { mounted: function () {
this.init2(); var _this = this
$("#search").click(function () {
_this.renderPage();
})
this.init()
window.onhashchange = this.init; window.onhashchange = this.init;
}, },
...@@ -238,130 +232,116 @@ ...@@ -238,130 +232,116 @@
}, },
methods: { methods: {
onSubmit: function () { onSubmit: function () {
this.searchByUsername(this.searchText) this.searchByUsername(this.searchText)
}, },
init: function () { init: function () {
var username = querystring.parse(location.hash.slice(11)).username var username = querystring.parse(location.hash.slice(11)).username
this.searchText = username; this.searchText = username;
this.searchByUsername(username) this.searchByUsername(username)
}, },
init2: function () {
function renderPage() { renderPage: function () {
if (rankTable) {
rankTable.destroy();
}
if (rankTable2) {
rankTable2.destroy();
}
var username = this.searchText
var type = 1;
rankTable = this.renderRankTable("#athletic_rank");
rankTable2 = this.renderRankTable("#entertain_rank");
if (!username) return;
API.getUserDueHistory({ username: username, type: "1", page_num: 100 }).then((res) => {
if (rankTable) { if (rankTable) {
rankTable.destroy(); rankTable.destroy();
} }
rankTable = this.renderRankTable("#athletic_rank", res.data.data)
}, (res) => {
console.log(res)
});
API.getUserDueHistory({ username: username, type: "2", page_num: 100 }).then((res) => {
if (rankTable2) { if (rankTable2) {
rankTable2.destroy(); rankTable2.destroy();
} }
rankTable2 = this.renderRankTable("#entertain_rank", res.data.data)
}, (res) => {
console.log(res)
});
},
var username = $("#searchText").val() renderRankTable: function (id, tableData) {
var type = 1; tableData = tableData || [];
var lang = localStorage.getItem('lang') || 'cn';
rankTable = renderRankTable("#athletic_rank");
rankTable2 = renderRankTable("#entertain_rank");
if (!username) return;
API.getUserDueHistory({ username: username, type: "1", page_num: 100 }).then((res) => {
if (rankTable) {
rankTable.destroy();
}
rankTable = renderRankTable("#athletic_rank", res.data.data)
}, (res) => {
console.log(res)
});
API.getUserDueHistory({ username: username, type: "2", page_num: 100 }).then((res) => {
if (rankTable2) {
rankTable2.destroy();
}
rankTable2 = renderRankTable("#entertain_rank", res.data.data)
}, (res) => {
console.log(res)
});
}
function renderRankTable(id, tableData) { var rank = 1;
tableData = tableData || []; var processData = tableData.map(function (d) {
var lang = localStorage.getItem('lang') || 'cn'; return [d.usernamea, d.usernameb, moment(d.start_time).format('YYYY-MM-DD HH:mm'), moment(d.end_time).format('YYYY-MM-DD HH:mm'), d.userscorea, d.userscoreb];
});
var rank = 1; var table = $(id).DataTable({
var processData = tableData.map(function (d) { paging: true,
return [d.usernamea, d.usernameb, moment(d.start_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm'), moment(d.end_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm'), d.userscorea, d.userscoreb]; searching: false,
}); ordering: false,
var table = $(id).DataTable({ lengthChange: false,
paging: true, info: false,
searching: false, data: processData,
ordering: false,
lengthChange: false, columns: [
info: false, { title: tb_language[lang].playerA },
data: processData, { title: tb_language[lang].playerB },
{ title: tb_language[lang].startTime },
columns: [ { title: tb_language[lang].endTime },
{ title: tb_language[lang].playerA },
{ title: tb_language[lang].playerB }, ],
{ title: tb_language[lang].startTime }, "columnDefs": [
{ title: tb_language[lang].endTime }, {
"render": function (data, type, row) {
], var userscorea = row[4];
"columnDefs": [ var userscoreb = row[5];
{ if (userscorea < 0) {
"render": function (data, type, row) { return "<a href='#/userinfo?username=" + data + "'><span class='label label-danger'>" + data + "</span></a>";
var userscorea = row[4]; }
var userscoreb = row[5];
if (userscorea < 0) { if (userscorea > userscoreb) {
return "<a href='#/userinfo?username=" + data + "'><span class='label label-danger'>" + data + "</span></a>"; return "<a href='#/userinfo?username=" + data + "'><span class='label label-success'>" + data + "</span></a>";
} }
if (userscorea > userscoreb) { return "<a href='#/userinfo?username=" + data + "'><span class='label label-info'>" + data + "</span></a>";
return "<a href='#/userinfo?username=" + data + "'><span class='label label-success'>" + data + "</span></a>";
}
return "<a href='#/userinfo?username=" + data + "'><span class='label label-info'>" + data + "</span></a>";
},
"targets": 0
}, },
{ "targets": 0
"render": function (data, type, row) { },
var userscorea = row[4]; {
var userscoreb = row[5]; "render": function (data, type, row) {
if (userscoreb < 0) { var userscorea = row[4];
return "<a href='#/userinfo?username=" + data + "'><span class='label label-danger'>" + data + "</span></a>"; var userscoreb = row[5];
} if (userscoreb < 0) {
return "<a href='#/userinfo?username=" + data + "'><span class='label label-danger'>" + data + "</span></a>";
if (userscorea < userscoreb) { }
return "<a href='#/userinfo?username=" + data + "'><span class='label label-success'>" + data + "</span></a>";
} if (userscorea < userscoreb) {
return "<a href='#/userinfo?username=" + data + "'><span class='label label-success'>" + data + "</span></a>";
return "<a href='#/userinfo?username=" + data + "'><span class='label label-info'>" + data + "</span></a>"; }
},
"targets": 1 return "<a href='#/userinfo?username=" + data + "'><span class='label label-info'>" + data + "</span></a>";
}, },
], "targets": 1
"language": lang === 'en' ? tb_language.en : tb_language.cn },
}); ],
"language": lang === 'en' ? tb_language.en : tb_language.cn
return table; });
}
renderPage();
$("#search").click(function () { return table;
renderPage();
})
}, },
initLang: function (lang) {
this.lang = language[lang]
$("#search").trigger('click');
},
searchByUsername: function (username) { searchByUsername: function (username) {
// 0 1 2 // 0 1 2
var rand = Math.floor(Math.random() * 3); var rand = Math.floor(Math.random() * 3);
......
...@@ -172,10 +172,10 @@ ...@@ -172,10 +172,10 @@
} }
}, },
formatter1(row, column) { formatter1(row, column) {
return moment(row.start_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm') return moment(row.start_time).format('YYYY-MM-DD HH:mm')
}, },
formatter2(row, column) { formatter2(row, column) {
return moment(row.end_time).subtract(8, 'h').format('YYYY-MM-DD HH:mm') return moment(row.end_time).format('YYYY-MM-DD HH:mm')
}, },
renderTable: function(){ renderTable: function(){
// var URL = "http://localhost:3000" // var URL = "http://localhost:3000"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment