From 1fbf694f7f28a440866e76352941139df870c449 Mon Sep 17 00:00:00 2001 From: tianea Date: Fri, 1 Apr 2022 10:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E8=A1=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/src/api/competition.js | 11 +++ front/src/api/member.js | 45 ++++++++++ front/src/api/task.js | 22 +++++ front/src/router/index.js | 19 ++++- front/src/views/competition/first.vue | 17 ++-- front/src/views/competition/index.vue | 35 ++++++-- front/src/views/competition/ranking.vue | 105 +++++++++++------------- front/src/views/competition/second.vue | 77 ++++++++++++----- front/src/views/login/index.vue | 2 +- front/src/views/member/index.vue | 73 +++++++++++++--- front/src/views/system/exam.vue | 42 ++++++++-- front/src/views/system/index.vue | 99 ++++++++++++++++------ front/src/views/system/portrait.vue | 2 +- 13 files changed, 401 insertions(+), 148 deletions(-) create mode 100644 front/src/api/task.js diff --git a/front/src/api/competition.js b/front/src/api/competition.js index d9faf21..29885ff 100644 --- a/front/src/api/competition.js +++ b/front/src/api/competition.js @@ -33,6 +33,17 @@ export function position(q){ }) } +export function getGroup(compId,stageId){ + return request({ + url: baseUrl+ "group", + method: 'get', + params: { + compId: compId, + stageId: stageId + } + }) +} + export function get(q){ return request({ url: baseUrl+ "get", diff --git a/front/src/api/member.js b/front/src/api/member.js index adf5484..ac96c5c 100644 --- a/front/src/api/member.js +++ b/front/src/api/member.js @@ -1,9 +1,54 @@ import request from '@/utils/request' +import * as auth from '@/utils/auth' let baseUrl = '/api/user/' +let authUrl = '/auth/competition/member' + export function login(data){ return request({ url: baseUrl+"login/password", method: 'post', data: data }) +} + +export function getMemberInfo(compId,stageId){ + return request({ + url: authUrl+"/get", + method: 'get', + params: { + compId: compId, + stageId: stageId + } + }) +} + +export function getPaper(compId,stageId){ + return request({ + url: authUrl+"paper", + method: 'get', + params: { + compId: compId, + stageId: stageId + } + }) +} + +export function loginout(){ + let userInfo = auth.getInfo() + return request({ + url: baseUrl+"login/out", + method: 'get', + params: { + userNo: userInfo.id + } + }) +} + +export function saveInfo(info){ + let url = "/auth/user/complete" + return request({ + url: url, + method: 'post', + data: info + }) } \ No newline at end of file diff --git a/front/src/api/task.js b/front/src/api/task.js new file mode 100644 index 0000000..4b2afdc --- /dev/null +++ b/front/src/api/task.js @@ -0,0 +1,22 @@ +import request from '@/utils/request' +let baseUrl = "auth/competition/task" +export function list(compId){ + return request({ + url: authUrl+"list", + method: 'get', + params: { + compId: compId + } + }) +} + +export function get(compId,stageId){ + return request({ + url: authUrl+"list", + method: 'get', + params: { + compId: compId, + stageId: stageId + } + }) +} \ No newline at end of file diff --git a/front/src/router/index.js b/front/src/router/index.js index ae780bf..ffe2efb 100644 --- a/front/src/router/index.js +++ b/front/src/router/index.js @@ -6,10 +6,11 @@ import Login from '@/views/login/index' import Exam from '@/views/system/exam' import Member from '@/views/member/index' import System from '@/views/system/index' +import {getInfo} from '@/utils/auth' Vue.use(Router) -export default new Router({ +let router = new Router({ mode: 'history', routes: [ { @@ -44,3 +45,19 @@ export default new Router({ } ] }) +export default router + +router.beforeEach((to,from,next) =>{ + let userInfo = getInfo() + if(!!userInfo){ + + if((!userInfo.complete)&&to.path!='/member'){ + alert("请完善个人信息!") + next('/member') + }else{ + next() + } + }else{ + next() + } +}) diff --git a/front/src/views/competition/first.vue b/front/src/views/competition/first.vue index edb66e8..04cb568 100644 --- a/front/src/views/competition/first.vue +++ b/front/src/views/competition/first.vue @@ -72,25 +72,22 @@ diff --git a/front/src/views/competition/second.vue b/front/src/views/competition/second.vue index 41864b0..8a67c65 100644 --- a/front/src/views/competition/second.vue +++ b/front/src/views/competition/second.vue @@ -5,7 +5,7 @@ - +
@@ -23,34 +23,34 @@ - +
个人总收益率
-
117.91%
+
{{memberInfo.currentRatio}}
个人综合排名
-
1
+
{{memberInfo.personalRank}}
- +
团队综合排名
-
1
+
{{memberInfo.teamRank}}
个人总资产
-
217.58万
+
{{memberInfo.totalFounds}}万
@@ -64,7 +64,7 @@
- 吴和静的总成绩 + {{userInfo.name}}的总成绩
@@ -80,7 +80,7 @@
个人收益率趋势
-
创建日期2021-10-10
+
创建日期{{createTime}}
@@ -92,7 +92,7 @@
团队收益率趋势
-
创建日期2021-10-10
+
创建日期{{createTime}}
@@ -109,7 +109,7 @@ 个人综合排名走势
-
创建日期2021-10-10
+
创建日期{{createTime}}
@@ -122,7 +122,7 @@ 团队综合排名走势 -
创建日期2021-10-10
+
创建日期{{createTime}}
@@ -202,6 +202,7 @@ import * as echarts from 'echarts' import * as competitionApi from '@/api/competition' import { getInfo } from '@/utils/auth' +import * as memberApi from '@/api/member' export default { data(){ return { @@ -210,10 +211,18 @@ export default { personalRankingCharts: null, teamRankingCharts: null, compId: 0, - competition: {}, stageId: 0, + currentStage: null, positionList:[], - userInfo:null + userInfo:null, + memberInfo: null, + createTime: new Date().Format('yyyy-MM-dd') + } + }, + props:{ + competition:{ + type: Object, + default: null } }, created(){ @@ -221,15 +230,19 @@ export default { this.compId = this.$route.query.id } this.userInfo = getInfo() - competitionApi.get({compId: this.compId}).then(res=> { - if(res.code == 200 ){ - this.competition = res.data - this.stageId = this.competition.stageList[0].id - this.listPosition() - } - }) + + }, + watch:{ + competition:function(nv){ + this.stageId = this.competition.stageList[0].id + this.loadData() + } }, mounted(){ + if(this.competition){ + this.stageId = this.competition.stageList[0].id + this.loadData() + } this.draw("personalRatio") this.draw("teamRatio") this.drawRanking("personalRanking") @@ -244,9 +257,21 @@ export default { } }) }, + getMemberInfo(){ + memberApi.getMemberInfo(this.compId,this.stageId).then(res=>{ + if(res.code == 200){ + this.memberInfo = res.data + } + }) + }, + loadData(){ + this.listPosition() + this.getMemberInfo() + }, changeStage(id){ this.stageId = id - this.listPosition() + this.getCurrentStage(id) + this.loadData() }, numberFixed(num){ if(typeof num == 'number'){ @@ -255,6 +280,14 @@ export default { return 0; } }, + getCurrentStage(id){ + let stage = this.competition.stageList.filter(st =>{ + return st.id == id + }) + if(stage){ + this.currentStage = stage + } + }, draw(id){ let base = +new Date(1968, 9, 3); let oneDay = 24 * 3600 * 1000; diff --git a/front/src/views/login/index.vue b/front/src/views/login/index.vue index 9420c63..256e251 100644 --- a/front/src/views/login/index.vue +++ b/front/src/views/login/index.vue @@ -19,7 +19,7 @@ export default { return { user: { username:'2020096911', - password:'tz2022' + password:'abc123ddd' }, msg: '' } diff --git a/front/src/views/member/index.vue b/front/src/views/member/index.vue index 4d2d660..ea391e4 100644 --- a/front/src/views/member/index.vue +++ b/front/src/views/member/index.vue @@ -14,7 +14,7 @@ 个人中心
-
+
退出
@@ -42,16 +42,16 @@
- 上次登录1天前 + 上次登录{{formatLastTime()}}前
- 上次登陆IP: 110.12.68.64 - IP登陆地: 广东省深圳市宝安区 + 上次登陆IP: {{userInfo.ip}} + IP登陆地: {{userInfo.location}}
编辑 - 保存 + 保存
@@ -67,7 +67,7 @@
- 姓名:伍金林 + 姓名:{{ userInfo.name}}
班级:天择1班 @@ -75,10 +75,10 @@
- 学号:20171031 + 学号:{{userInfo.username}}
- 学校:天择大学 + 学校:{{ userInfo.school }}
@@ -86,15 +86,15 @@ 学历:本科
- 电话: + 电话:
- 邮箱: + 邮箱:
- 密码: + 密码:
@@ -106,13 +106,25 @@ @@ -557,9 +607,7 @@ export default { color: white; margin-left: 25rem; } -.tz-bold{ - font-weight: bold; -} + .tz-flex div{ min-height: 80px; align-items: center; @@ -657,6 +705,7 @@ export default { border-radius: 3px; border: 2px solid white; margin-right: 1rem; + width: 18rem; } .comp-type{ display: inline-block; @@ -672,8 +721,6 @@ export default { min-height: 387px; max-width: 86rem; background: white; - display: block; - width: 100%; border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; } diff --git a/front/src/views/system/portrait.vue b/front/src/views/system/portrait.vue index 3d7a919..4bebb32 100644 --- a/front/src/views/system/portrait.vue +++ b/front/src/views/system/portrait.vue @@ -6,7 +6,7 @@
欢迎 - {{userInfo.name}} + {{ userInfo? userInfo.name: ''}}