add get current week function

This commit is contained in:
RainSun 2020-03-03 09:14:52 +08:00
parent 7959afa3ce
commit b248d01e29
2 changed files with 20 additions and 3 deletions

View File

@ -1,9 +1,9 @@
import axios from 'axios'
export const api = axios.create({
// baseURL: 'https://beta.powerrain.cn/api/',
baseURL: 'https://beta.powerrain.cn/api/',
// baseURL: 'https://coc.powerrain.cn/api/',
baseURL: window.location.origin + '/api/',
// baseURL: window.location.origin + '/api/',
// baseURL: 'http://152.136.99.231:8001' + '/api/',
//baseURL: 'http://127.0.0.1:5000/api',
headers: {

View File

@ -156,7 +156,8 @@ export default {
if(!this.schedule) return
//
// activated使keepalive
this.current_week = this.schedule.data.cur_week > 0 ? this.schedule.data.cur_week : 1;
// this.current_week = this.schedule.data.cur_week > 0 ? this.schedule.data.cur_week : 1;
this.getCurrentWeek()
this.show_week = lock ? this.current_week : this.show_week;
},
@ -204,6 +205,22 @@ export default {
goToGame() {
this.drawer = false;
this.$router.push('/game')
},
//
getCurrentWeek() {
let start = new Date("2020-02-24 00:00").getTime();
let now = new Date().getTime();
//
let days = Math.abs(Math.floor((now - start) / (1000 * 60 * 60 * 24)));
let current_week;
if (start >= now) {
//
this.current_week = 1;
} else {
//
this.current_week = Math.floor(days / 7) + 1;
}
}
},
created() {