Merge branch 'add_game' into 'master' (merge request !9)

add_game
This commit is contained in:
RainSun 2020-02-28 09:42:55 +00:00
commit b9c295cf01
14 changed files with 889 additions and 80 deletions

View File

@ -58,4 +58,21 @@ export function delLAF(data) {
let params = new URLSearchParams();
params.append('data', JSON.stringify(data));
return api.post('/laf/del', params)
}
export function rankUpload(data) {
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
data.sign = sign
let params = new URLSearchParams();
params.append('data', JSON.stringify(data));
return api.post('/game/schedule/upload', params)
}
export function rankGet() {
let data = { sign_data: 'rEdrGwXtr8'}
var sign = CryptoJS.MD5(JSON.stringify(data).replace(/\"/g,"'")).toString().toUpperCase();
data.sign = sign
let params = new URLSearchParams();
params.append('data', JSON.stringify(data));
return api.post('/game/schedule/get', params)
}

View File

@ -1,6 +1,7 @@
import axios from 'axios'
export const api = axios.create({
// baseURL: 'https://beta.powerrain.cn/api/',
// baseURL: 'https://coc.powerrain.cn/api/',
baseURL: window.location.origin + '/api/',
// baseURL: 'http://152.136.99.231:8001' + '/api/',
@ -8,7 +9,7 @@ export const api = axios.create({
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Accept': 'application/json',
'Access-Control-Allow-Origin': '*'
// 'Access-Control-Allow-Origin': '*'
},
timeout: 30 * 1000
})

View File

@ -1,5 +1,5 @@
<template>
<footer>
<footer v-if="current_page != 'None'">
<div class="w">
<div class="content" @click="goToAddress('/schedule')">
<i :class="current_page == 'schedule'? 'select' : ''" class="el-icon-message-solid"></i>

View File

@ -31,7 +31,7 @@ export function isIOS() {
export function getGradeInitData() {
return {
errcode: 103,
data : {
data: {
total: {
total_GPA: 5.0,
total_credit: "∞",
@ -39,54 +39,108 @@ export function getGradeInitData() {
total_dead: "∞",
total_bixiu_GPA: 5.0,
},
split: [
{
term_GPA: 5.0,
term_credit: "∞",
term_dead: "∞",
term_grade: [
{
title: "如果你看到这些,先左上角试试获取数据",
credit: 0,
grade: 0,
class: 0
},
{
title: "如果还看到这些",
credit: 0,
grade: 0,
class: 0
},
{
title: "说明教务可能也没有数据",
credit: 0,
grade: 0,
class: 0
},
{
title: "如果教务有数据还看到这些",
credit: 0,
grade: 0,
class: 0
},
{
title: "加群告诉我好吗1030523678",
credit: 0,
grade: 0,
class: 0
},
{
title: "拜托了!!!!",
credit: 0,
grade: 0,
class: 0
}
],
term_kill: "∞",
term_time: "20451"
}
]
split: [{
term_GPA: 5.0,
term_credit: "∞",
term_dead: "∞",
term_grade: [{
title: "如果你看到这些,先左上角试试获取数据",
credit: 0,
grade: 0,
class: 0
},
{
title: "如果还看到这些",
credit: 0,
grade: 0,
class: 0
},
{
title: "说明教务可能也没有数据",
credit: 0,
grade: 0,
class: 0
},
{
title: "如果教务有数据还看到这些",
credit: 0,
grade: 0,
class: 0
},
{
title: "加群告诉我好吗1030523678",
credit: 0,
grade: 0,
class: 0
},
{
title: "拜托了!!!!",
credit: 0,
grade: 0,
class: 0
}
],
term_kill: "∞",
term_time: "20451"
}]
}
}
}
export function getGameInitData() {
return [{
name: '高等数学',
color: 0
}, {
name: '线性代数',
color: 1
}, {
name: '思想道德修养与法律基础',
color: 2
}, {
name: '马克思主义基本原理概论',
color: 3
}, {
name: '近现代纲要',
color: 4
}, {
name: '复变函数',
color: 5
}, {
name: '大学物理',
color: 6
}, {
name: '大学英语',
color: 7
}, {
name: '概率论与数理统计',
color: 0
}, {
name: '计算机网络',
color: 0
}, {
name: '计算机组成原理',
color: 1
}, {
name: '数据结构与算法',
color: 2
}, {
name: '操作系统',
color: 3
}, {
name: '概率论与数理统计',
color: 4
}, {
name: '大学物理',
color: 5
}, {
name: '高等数学',
color: 6
}, {
name: '线性代数',
color: 7
}, {
name: '',
color: 9
}]
}

View File

@ -67,6 +67,14 @@ const routes = [
keepAlive:true
},
},
{
path: '/game',
name: 'Game',
component: () => import(/* webpackChunkName: "game" */ '../views/Game.vue'),
meta:{
keepAlive:false
},
},
{
path: '*', // 页面不存在的情况下会跳到schedule
redirect: '/schedule',

View File

@ -16,7 +16,9 @@ export default new Vuex.Store({
// 失物招领首页刷新
LAF_reflash: false,
// 当前页面
current_page: null
current_page: null,
// 游戏
schedule_game: null,
},
mutations: {
// 设置用户信息
@ -42,7 +44,11 @@ export default new Vuex.Store({
// 设置失物招领首页刷新
SET_LAFREFLASH(state, LAF_reflash) {
state.LAF_reflash = LAF_reflash;
}
},
// 设置游戏
SET_SCHEDULE_GAME(state, schedule_game) {
state.schedule_game = schedule_game
}
},
actions: {
// 设置用户信息
@ -74,7 +80,12 @@ export default new Vuex.Store({
setLAFReflash({ commit }, arg) {
commit('SET_LAFREFLASH', arg[0]);
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
}
},
// 设置游戏
setScheduleGame({ commit }, arg) {
commit('SET_SCHEDULE_GAME', arg[0]);
localStorage.setItem("storeState", JSON.stringify(arg[1].$store.state));
},
},
modules: {
}

View File

@ -31,7 +31,6 @@ $create-cramera-border-color: #b5d9fe; // 圣诞 #c9faaf
$create-alert-color: #67c23a;
$create-alert-background: #f0f9eb;
$red: #e54d42;
$orange: #f37b1d;
$yellow: #fbbd08;

1
src/svg/firstPrize.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1552394764356" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4782" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><defs><style type="text/css"></style></defs><path d="M842.752 419.52L704 512s-12.16 4.8-17.92-4.096c-26.624-41.216-101.632-180.224-144-259.392a64 64 0 1 0-59.008 0.64c-37.504 73.6-101.888 199.04-134.4 255.68-4.8 8.32-11.648 9.856-20.608 4.8-10.048-5.76-90.24-56.256-145.92-91.456a64 64 0 1 0-39.36 28.16c21.12 88.512 59.392 246.528 77.248 304.832 4.096 13.44 8.704 16.832 23.808 16.832h537.088c14.08 0 18.944-3.456 22.976-16.832 21.568-70.848 57.536-220.032 77.504-304.832A64.192 64.192 0 0 0 960 384a64 64 0 1 0-117.248 35.52zM832 864a32 32 0 0 1-32 32h-576a32 32 0 1 1 0-64h576a32 32 0 0 1 32 32z" p-id="4783" fill="#FFD700"></path></svg>

After

Width:  |  Height:  |  Size: 973 B

1
src/svg/rank.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1582762424392" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1245" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M841.142857 859.428571H182.857143a18.285714 18.285714 0 0 1-18.285714-18.285714V438.857143a18.285714 18.285714 0 1 1 36.571428 0v384h182.857143v-438.857143H146.285714a18.285714 18.285714 0 1 1 0-36.571429h237.714286V256a18.285714 18.285714 0 1 1 36.571429 0v566.857143h182.857142V256a18.285714 18.285714 0 1 1 36.571429 0v274.285714H877.714286a18.285714 18.285714 0 1 1 0 36.571429h-237.714286v256h182.857143V621.714286a18.285714 18.285714 0 1 1 36.571428 0v219.428571a18.285714 18.285714 0 0 1-18.285714 18.285714z m-475.428571-658.285714a18.285714 18.285714 0 0 1 0-36.571428h292.571428a18.285714 18.285714 0 1 1 0 36.571428h-292.571428z" p-id="1246"></path></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

1
src/svg/secondPrize.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1552394764356" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4782" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><defs><style type="text/css"></style></defs><path d="M842.752 419.52L704 512s-12.16 4.8-17.92-4.096c-26.624-41.216-101.632-180.224-144-259.392a64 64 0 1 0-59.008 0.64c-37.504 73.6-101.888 199.04-134.4 255.68-4.8 8.32-11.648 9.856-20.608 4.8-10.048-5.76-90.24-56.256-145.92-91.456a64 64 0 1 0-39.36 28.16c21.12 88.512 59.392 246.528 77.248 304.832 4.096 13.44 8.704 16.832 23.808 16.832h537.088c14.08 0 18.944-3.456 22.976-16.832 21.568-70.848 57.536-220.032 77.504-304.832A64.192 64.192 0 0 0 960 384a64 64 0 1 0-117.248 35.52zM832 864a32 32 0 0 1-32 32h-576a32 32 0 1 1 0-64h576a32 32 0 0 1 32 32z" p-id="4783" fill="#F4A460"></path></svg>

After

Width:  |  Height:  |  Size: 973 B

1
src/svg/thirdPrize.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1552394764356" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4782" xmlns:xlink="http://www.w3.org/1999/xlink" width="128" height="128"><defs><style type="text/css"></style></defs><path d="M842.752 419.52L704 512s-12.16 4.8-17.92-4.096c-26.624-41.216-101.632-180.224-144-259.392a64 64 0 1 0-59.008 0.64c-37.504 73.6-101.888 199.04-134.4 255.68-4.8 8.32-11.648 9.856-20.608 4.8-10.048-5.76-90.24-56.256-145.92-91.456a64 64 0 1 0-39.36 28.16c21.12 88.512 59.392 246.528 77.248 304.832 4.096 13.44 8.704 16.832 23.808 16.832h537.088c14.08 0 18.944-3.456 22.976-16.832 21.568-70.848 57.536-220.032 77.504-304.832A64.192 64.192 0 0 0 960 384a64 64 0 1 0-117.248 35.52zM832 864a32 32 0 0 1-32 32h-576a32 32 0 1 1 0-64h576a32 32 0 0 1 32 32z" p-id="4783" fill="#D3D3D3"></path></svg>

After

Width:  |  Height:  |  Size: 973 B

685
src/views/Game.vue Normal file
View File

@ -0,0 +1,685 @@
<template>
<div class="schedule" >
<header>
<div class="w">
<i class="el-icon-back back" @click="turnToHome()"></i>
<div class="week-box">点点就会玩
</div>
<div class="rank-icon-box" @click="rank_dialog = true">
<icon class="rank" name="rank" ></icon>
</div>
</div>
</header>
<div style="height: 1.2rem;"></div>
<body>
<nav>
<div class="week-title" v-for="i in 7" :key="i">{{week_day[i-1]}}</div>
</nav>
<div class="main">
<aside>
<div class="lesson-title" v-for="i in 12" :key="i">{{i}}</div>
</aside>
<div class="lesson-warp">
<div class="day-box" v-for="(items, d) in show_game_data" :key="d">
<div class="lesson-box" v-for="(item, i) in items" :key="i">
<div class="lesson" :style="lessonStyle(item)" @click="clickCard(item, d, i)">
<p class="info">{{item.name}}</p>
</div>
</div>
</div>
</div>
</div>
<!-- 上传dialog -->
<div class="dialog" v-if="upload_dialog" @touchmove.prevent>
<div class="w dialog-w">
<div class="title">
成绩
<div class="icon-box" @click="closeUploadDialog()">
<i class="el-icon-close icon"></i>
</div>
</div>
<div class="dialog-main">
<p>您的用时<span>{{time_finish}}</span></p>
<p>您的总点击数<span>{{click_count}}</span></p>
<input type="text" placeholder="上传的话请在此输入昵称" v-model="nick"/>
<div class="btn-box">
<p @click="closeUploadDialog()"></p>
<p @click="uploadGrade()">上传</p>
</div>
</div>
</div>
</div>
<!-- rank -->
<div class="dialog dialog-rank" v-if="rank_dialog" @touchmove.prevent>
<div class="w dialog-w">
<div class="title">
排名榜
<div class="icon-box" @click="rank_dialog = false">
<i class="el-icon-close icon"></i>
</div>
<div class="reflash-box" @click="getGrade(true)">
<i class="el-icon-refresh icon"></i>
</div>
</div>
<v-touch @swiperight="rank_current_type = 'time'" @swipeleft="rank_current_type = 'count'">
<div class="dialog-main">
<div class="nav-box">
<div><p :class="rank_current_type == 'time'? 'line' :''" @click="rank_current_type = 'time'">时间榜</p></div>
<div><p :class="rank_current_type == 'count'? 'line' :''" @click="rank_current_type = 'count'">点击榜</p></div>
</div>
<div class="rank-title">
<p>昵称</p>
<p>点击数</p>
<p>时间</p>
</div>
<div class="time-rank-box" v-if="schedule_game && rank_current_type == 'time'">
<div class="price-box">
<div class="icon-box" v-if="schedule_game.time_rank.length >= 1"><icon name="firstPrize" class="icon"></icon></div>
<div class="icon-box" v-if="schedule_game.time_rank.length >= 2"><icon name="secondPrize" class="icon"></icon></div>
<div class="icon-box" v-if="schedule_game.time_rank.length >= 3"><icon name="thirdPrize" class="icon"></icon></div>
</div>
<div class="time-rank-content" v-for="(item, index) in schedule_game.time_rank" :key="index">
<p>{{item.nick.length > 7 ? item.nick.slice(0,7) : item.nick}}</p>
<p>{{item.count}}</p>
<p>{{item.time}}</p>
</div>
</div>
<div class="count-rank-box" v-if="schedule_game && rank_current_type == 'count'">
<div class="price-box">
<div class="icon-box" v-if="schedule_game.count_rank.length >= 1"><icon name="firstPrize" class="icon"></icon></div>
<div class="icon-box" v-if="schedule_game.count_rank.length >= 2"><icon name="secondPrize" class="icon"></icon></div>
<div class="icon-box" v-if="schedule_game.count_rank.length >= 3"><icon name="thirdPrize" class="icon"></icon></div>
</div>
<div class="count-rank-content" v-for="(item, index) in schedule_game.count_rank" :key="index">
<p>{{item.nick.length > 7 ? item.nick.slice(0,7) : item.nick}}</p>
<p>{{item.count}}</p>
<p>{{item.time}}</p>
</div>
</div>
</div>
</v-touch>
</div>
</div>
</body>
<FooterSpace></FooterSpace>
</div>
</template>
<script>
// @ is an alias to /src
import FooterSpace from "@/components/FooterSpace.vue";
import { mapState, mapActions } from "vuex";
import { rankGet, rankUpload } from '@/axios/api.js'
import { getGameInitData } from '@/lib/utils.js'
import { Loading } from 'element-ui';
export default {
name: "schedule",
data() {
return {
//
week_day: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
//
bg_color: ["e4f5ff", "defbf7", "e7e5fa", "fcebcf", "feeeef", "d7f0db", "ebd4ef", "f9d7ea", "ede1d9", '48f350'],
//
font_color: ["58a2d9", "2bbbbc", "8379d8", "e89812", "d36e88", "39b54a", "9c26b0", "e03997", "a5673f", '48f350'],
// dialog
upload_dialog: false,
// dialog
rank_dialog: false,
//
rank_current_type: 'time',
//
game_data: '',
//
random_game_data: [],
//
show_game_data: [],
//
has_clicked: [],
//
last_click_pos: [],
//
click_count: 0,
//
right_count: 0,
//
time_start: 0,
//
time_finish: 0,
//
nick: '',
};
},
computed: {
...mapState(["user_info", "current_page", "schedule", "schedule_game"]),
},
methods: {
...mapActions(["setCurrentPage","setScheduleGame"]),
//
lessonStyle(item) {
return `background:#${this.bg_color[item.color]};color:#${this.font_color[item.color]}`
},
//
initGame() {
// vuex
this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("storeState"))));
// footerNav
this.setCurrentPage(["None", this]);
this.getGrade()
//
this.nick = '';
this.click_count = 0;
this.right_count = 0;
this.time_start = 0;
this.upload_dialog = false;
// this.game_data = this.schedule ? this.schedule.data.game_list : this.game_data;
this.game_data = getGameInitData()
this.random_game_data = new Array(7);
this.show_game_data = new Array(7);
this.has_clicked = new Array(7);
for (var i=0; i<7; i++) {
this.random_game_data[i] = new Array(5);
this.show_game_data[i] = new Array(5);
this.has_clicked[i] = new Array(5);
}
//
var used_pos = new Array(35);
for (var i=0; i<35; i++) {
used_pos[i] = 0;
}
//
for (var i=0,j=0; i<35; i++) {
var pos = Math.floor(Math.random() * 35)
while (used_pos[pos]) {
pos = Math.floor(Math.random() * 35)
}
used_pos[pos] = 1;
this.random_game_data[parseInt(pos/5)][pos%5] = this.game_data[j];
this.show_game_data[parseInt(pos/5)][pos%5] = { name: '', color: 8};
this.has_clicked[parseInt(pos/5)][pos%5] = false;
if (i % 2 == 1){
j++;
}
}
},
//
clickCard(item, i, j) {
//
if (this.has_clicked[i][j]) {
return;
} else {
//
this.has_clicked[i][j] = !this.has_clicked[i][j];
this.click_count ++;
}
//
if (this.time_start == 0) {
this.time_start = new Date().getTime();
}
//
if (this.has_clicked[i][j]){
item.name = this.random_game_data[i][j].name;
item.color = this.random_game_data[i][j].color;
}
//
this.$forceUpdate();
//
if (this.last_click_pos.length == 2) {
//
let x = this.last_click_pos[0];
let y = this.last_click_pos[1];
//
if (item.name != this.random_game_data[x][y].name || item.color != this.random_game_data[x][y].color) {
//
this.has_clicked[i][j] = false;
this.has_clicked[x][y] = false;
// 1.1
setTimeout(function(){
this.show_game_data[i][j].name = '';
this.show_game_data[x][y].name = '';
this.show_game_data[i][j].color = 8;
this.show_game_data[x][y].color = 8;
this.$forceUpdate();
}.bind(this), 1100)
} else {
//
this.right_count += 2;
}
//
this.last_click_pos = [];
} else {
//
if (item.name != ''){
//
this.last_click_pos.push(i);
this.last_click_pos.push(j);
} else {
//
this.right_count ++;
}
}
//
if (this.right_count == 35 ) {
//
let time_diff = new Date().getTime() - this.time_start;
let s = parseInt(time_diff / 1000);
let ms = time_diff % 1000;
let min = parseInt(s / 60);
s = s % 60;
this.time_finish = String(min)+':'+String(s)+':'+String(ms);
// dialog
this.upload_dialog = true;
}
},
// dialog
closeUploadDialog() {
this.upload_dialog = false;
this.initGame()
},
//
uploadGrade() {
this.nick = this.nick.trim()
if(!this.nick) return;
let load = Loading.service({
background: "rgba(255,245,236,.7)",
target: document.querySelector(".dialog-w")
});
let data = {
nick: this.nick,
count: this.click_count,
time: this.time_finish
}
rankUpload(data).then(res => {
if(res.data.errcode == 200) {
load.close()
this.initGame()
this.$message({
message: "提交成功",
type: "success"
});
} else {
console.log(res.data)
load.close()
this.$message.error(`网络错误,错误码:${res.data.errcode}`);
}
}).catch(err => {
console.log(err)
load.close()
this.$message.error('网络错误,请重试');
})
},
//
getGrade( need_reflash = false ) {
let now = new Date().getTime()
//
if( this.schedule_game && (now - this.schedule_game.update_time < 1000 * 60 * 1) && !need_reflash) {
//
return
}
rankGet().then(res => {
if(res.data.errcode == 200) {
let schedule_game = res.data
schedule_game.update_time = new Date().getTime()
this.setScheduleGame([schedule_game, this])
if(need_reflash) {
this.$message({
message: "刷新成功",
type: "success"
});
}
} else if(need_reflash) {
this.$message.error('网络错误,请重试');
}
}).catch(err => {
console.log(err)
this.$message.error('网络错误,请重试');
})
},
//
turnToHome() {
this.$router.replace('/');
},
},
created() {
},
mounted() {
this.initGame();
},
activated() {
},
components: {
FooterSpace
}
};
</script>
<style scoped lang="scss" type="text/scss">
@import "../style/main";
.schedule {
width: 100%;
max-width: 500px;
margin: 0 auto;
background-color: #f8f8f8;
min-height: 100%;
position: relative;
overflow: hidden;
header {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 1.2rem;
z-index: 100;
.w {
height: 1.2rem;
width: 100%;
max-width: 500px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: center;
// background-image: linear-gradient(to right, #f0da4b, #ff005e);
background-image: $gradualLoginSubmit;
// background: #ffca9f;
color: #fff;
position: relative;
.left-box,
.right-box {
display: flex;
align-items: center;
justify-content: center;
width: 1.2rem;
height: 1.2rem;
}
.icon {
font-size: 0.5rem;
}
.week-box {
font-size: 0.5rem;
}
.more {
font-size: 0.6rem;
position: absolute;
left: 0.3rem;
}
.back {
font-size: 0.6rem;
position: absolute;
left: 0.3rem;
}
.refresh {
font-size: 0.6rem;
position: absolute;
right: 0.3rem;
}
.rank-icon-box {
position: absolute;
right: 0.3rem;
display: flex;
align-items: center;
justify-content: center;
.rank {
height: 0.7rem;
width: 0.7rem;
}
}
}
}
nav {
height: 0.8rem;
padding-left: 0.7rem;
display: flex;
.week-title {
flex: 1;
line-height: 0.8rem;
font-size: 0.3rem;
text-align: center;
}
.highlight {
color: #ff005e;
}
}
.main {
display: flex;
aside {
width: 0.7rem;
.lesson-title {
font-size: 0.3rem;
font-weight: 600;
text-align: center;
height: 1.4rem;
line-height: 1.4rem;
}
}
.lesson-warp {
flex: 1;
display: flex;
touch-action: pan-y!important;
// max-width: 94%;
.day-box {
width: 14%;
flex: 1;
flex-shrink: 1;
display: flex;
flex-direction: column;
.lesson-box {
height: 2.8rem;
border: 1px #eee solid;
display: flex;
align-items: center;
justify-content: center;
padding: 0.05rem;
box-sizing: border-box;
.lesson {
width: 100%;
height: 100%;
border-radius: 0.1rem;
word-wrap: break-word;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
.info {
font-size: 0.3rem;
margin-bottom: 0.1rem;
text-align: center;
}
}
}
}
}
}
.dialog {
position: fixed;
top: 0;
left: 0;
z-index: 101;
height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.4);
display: flex;
align-items: center;
justify-content: center;
.w {
width: 70%;
max-width: 350px;
height: 5rem;
background: #fff;
border-radius: 0.1rem;
overflow: hidden;
.title {
height: 1rem;
background-image: $gradualLoginSubmit;
font-size: 0.4rem;
text-align: center;
line-height: 1rem;
color: #fff;
position: relative;
.icon-box, .reflash-box {
position: absolute;
top: 0;
right: 0;
width: 1rem;
height: 1rem;
display: flex;
align-items: center;
justify-content: center;
.icon {
font-size: 0.5rem;
}
}
.reflash-box {
right: auto;
left: 0;
}
}
.dialog-main {
height: 4rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
p {
margin-bottom: 0.2rem;
text-align: center;
font-size: 0.3rem;
span {
font-size: 0.3rem;
color: $red;
}
}
input {
width: 3.5rem;
height: 0.4rem;
font-size: 0.3rem;
text-align: center;
color: $red;
border: 0;
outline:none;
border-bottom: 1px #eee solid;
}
input:focus { outline: none; }
.btn-box {
display: flex;
align-items: center;
margin-top: .3rem;
p {
height: .5rem;
width: 1.6rem;
border: 1px $red solid;
border-radius: .1rem;
line-height: .5rem;
}
p:first-of-type {
color: $red;
margin-right: .3rem;
}
p:last-of-type {
background-color: $red;
color: #fff;
}
}
}
}
}
.dialog-rank {
.w {
height: auto;
width: 90%;
max-width: 450px;
}
.dialog-main {
height: auto !important;
max-height: 15rem;
padding-bottom: .3rem;
box-sizing: border-box;
.nav-box {
display: flex;
align-items: center;
justify-content: space-between;
height: 1rem;
width: 100%;
div {
flex:1;
display: flex;
align-items: center;
justify-content: center;
p {
width: 1rem;
height: .5rem;
line-height: .5rem;
font-size: .3rem;
margin: 0 !important;
}
.line {
border-bottom: $red 2px solid;
}
}
}
.rank-title {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding-left: .5rem;
box-sizing: border-box;
margin-top: .3rem;
p {
width: 33.3%;
}
}
.time-rank-box, .count-rank-box {
overflow-y: scroll !important;
width:100%;
position:relative;
.price-box {
position: absolute;
left: .3rem;
top: 0;
width: .5rem;
display: flex;
align-items: center;
justify-content: flex-start;
flex-direction: column;
.icon-box {
height: .8rem;
width: .5rem;
display: flex;
align-items: center;
justify-content: center;
.icon {
width: .5rem;
height: .5rem;
}
}
}
.time-rank-content, .count-rank-content{
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
padding-left: .5rem;
box-sizing: border-box;
p {
height: .8rem;
width: 33.3%;
line-height: .8rem;
margin: 0 !important;
}
}
}
}
}
}
</style>

View File

@ -60,10 +60,13 @@ export default {
...mapState(['grade', 'schedule'])
},
methods: {
...mapActions(['setUserInfo', 'setGrade', 'setSchedule']),
...mapActions(['setUserInfo', 'setGrade', 'setSchedule', 'setCurrentPage']),
//
init() {
// vuex
this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("storeState"))));
// footerNav
this.setCurrentPage(["None", this]);
//
if (this.grade || this.schedule) {
this.$alert('如从教务获取信息失败,将保留原先数据', '提示', {

View File

@ -14,7 +14,6 @@
</div>
</header>
<div style="height: 1.2rem;"></div>
<body>
<nav>
<div class="week-title" v-for="i in hide_weekend? 5:7" :class="highlightWeek == i%7? 'highlight':''" :key="i">{{week_day[i-1]}}</div>
@ -25,14 +24,14 @@
<div class="lesson-title" v-for="i in 12" :key="i">{{i}}</div>
</aside>
</v-touch>
<v-touch class="lesson-warp" :swipe-options="{direction: 'horizontal'}" @swipeleft="swiperight" @swiperight="swipeleft">
<v-touch class="lesson-warp" :swipe-options="{direction: 'horizontal'}" @swipeleft="swipeRight" @swiperight="swipeLeft">
<div class="lesson-warp">
<div class="day-box" v-for="d in hide_weekend ? 5:7" :key="d">
<div class="lesson-box" v-for="i in 6" :key="i">
<template v-if="schedule && schedule.errcode === 200 && schedule.data.lesson[d-1][i-1] !== 0">
<template v-for="item in schedule.data.lesson[d-1][i-1]">
<template v-if="item.Time_split[show_week]">
<div class="lesson" :style="lesson_style(item)" @click="openDialog(item)">
<div class="lesson" :style="lessonStyle(item)" @click="openDialog(item)">
<p class="info">{{item.Lesson}}<br/>{{item.Room.replace(/\[.+\]/, "")}}</p>
</div>
</template>
@ -51,6 +50,7 @@
</div>
<div class="body">
<div class="options-w">
<div class="options" @click="goToGame()">课表小游戏<hr/></div>
<div class="options" @click="hide_weekend = !hide_weekend">隐藏周末<hr/></div>
<div class="options" @click="reflash">获取新数据<hr/></div>
</div>
@ -87,38 +87,46 @@
</div>
</div>
</body>
<FooterSpace></FooterSpace>
</div>
</template>
<script>
// @ is an alias to /src
import FooterSpace from "@/components/FooterSpace.vue";
import { mapState, mapActions } from "vuex";
import { loginInterceptor } from "@/lib/utils.js";
import { gameUpload } from '@/axios/api.js'
export default {
name: "schedule",
data() {
return {
//
//
current_week: 1,
//
show_week: 1,
//
max_week: 22,
//
drawer: false,
// dialog
detail: false,
//
hide_weekend: false,
//
week_day: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
bg_color: ["e4f5ff", "defbf7", "e7e5fa", "fcebcf", "feeeef", "d7f0db", "ebd4ef", "f9d7ea", "ede1d9"],
font_color: ["58a2d9", "2bbbbc", "8379d8", "e89812", "d36e88", "39b54a", "9c26b0", "e03997", "a5673f"],
init_lock: false
//
bg_color: ["e4f5ff", "defbf7", "e7e5fa", "fcebcf", "feeeef", "d7f0db", "ebd4ef", "f9d7ea", "ede1d9", '48f350'],
//
font_color: ["58a2d9", "2bbbbc", "8379d8", "e89812", "d36e88", "39b54a", "9c26b0", "e03997", "a5673f", '48f350'],
//
init_lock: false,
};
},
computed: {
...mapState(["user_info", "current_page", "schedule"]),
//
highlightWeek: function() {
if (!this.semester_start) return -1;
if (this.show_week == this.current_week) {
//
return new Date().getDay();
@ -129,7 +137,8 @@ export default {
},
methods: {
...mapActions(["setCurrentPage"]),
//
//
init(lock = false) {
// vuex
this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("storeState"))));
@ -147,9 +156,10 @@ export default {
if(!this.schedule) return
//
// activated使keepalive
let current_week = this.schedule.current_week > 0 ? this.schedule.current_week : 1;
this.show_week = lock ? current_week : this.show_week
this.current_week = this.schedule.data.cur_week > 0 ? this.schedule.data.cur_week : 1;
this.show_week = lock ? this.current_week : this.show_week;
},
//
changeWeek(dirction) {
if (dirction == "left")
@ -158,35 +168,48 @@ export default {
else if (this.show_week < this.max_week) this.show_week++;
else return;
},
//
reflash() {
this.drawer = false;
this.$router.push({ name: "login" });
},
// dialog
openDialog(data) {
this.detail = data;
},
// dialog
closeDialog() {
this.detail = false;
},
//
swipeleft(){
swipeLeft(){
if (this.show_week > 1)
this.show_week--;
},
swiperight(){
swipeRight(){
if (this.show_week < this.max_week)
this.show_week++;
},
//
lesson_style(item) {
return `background:#${this.bg_color[item.color]};color:#${this.font_color[item.color]}`
lessonStyle(item) {
return `background:#${this.bg_color[item.color]};color:#${this.font_color[item.color]}`
},
//
goToGame() {
this.drawer = false;
this.$router.push('/game')
}
},
created() {
this.init(true);
},
mounted() {
this.init(true);
},
mounted() {},
activated() {
this.init();
},
@ -240,12 +263,17 @@ export default {
.week-box {
font-size: 0.5rem;
}
.more{
.more {
font-size: 0.6rem;
position: absolute;
left: 0.3rem;
}
.refresh{
.back {
font-size: 0.6rem;
position: absolute;
left: 0.3rem;
}
.refresh {
font-size: 0.6rem;
position: absolute;
right: 0.3rem;
@ -268,7 +296,6 @@ export default {
}
.main {
display: flex;
aside {
width: 0.7rem;
.lesson-title {