add get current week function
This commit is contained in:
parent
7959afa3ce
commit
b248d01e29
@ -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: {
|
||||
|
@ -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() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user