From a3222d77620ad699094944f1028ac6f3079eace9 Mon Sep 17 00:00:00 2001 From: unclekh <5177787+unclekh@user.noreply.gitee.com> Date: Wed, 3 Jun 2020 01:30:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E7=BB=83=E4=B9=A0=E3=80=81=E5=80=92=E8=AE=A1=E6=97=B6=E3=80=81?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E7=AD=89=20=E9=A1=B5=E9=9D=A2=E6=93=8D?= =?UTF-8?q?=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/yyyf.js | 21 +++ src/components/common/header.vue | 285 ++++++++++++++++++++++++++----- src/pages/entry.vue | 64 +++++-- src/pages/yyyflogin.vue | 64 ++++--- 4 files changed, 358 insertions(+), 76 deletions(-) diff --git a/src/api/yyyf.js b/src/api/yyyf.js index b6d3b26..8b8f8de 100644 --- a/src/api/yyyf.js +++ b/src/api/yyyf.js @@ -31,3 +31,24 @@ export function getExamDetails(data) { params: data, }); } + +export function getUserTimeMoneyDto() { + return request({ + method: 'get', + url: Host + 'exam/getUserTimeMoneyDto', + }); +} + +export function submit() { + return request({ + method: 'get', + url: Host + 'exam/submit', + }); +} + +export function reStart() { + return request({ + method: 'get', + url: Host + 'exam/reStart', + }); +} diff --git a/src/components/common/header.vue b/src/components/common/header.vue index b8a427e..2c15e36 100644 --- a/src/components/common/header.vue +++ b/src/components/common/header.vue @@ -21,8 +21,15 @@
- 提交 - 重新开始 + 提交 + 重新开始
@@ -195,6 +202,7 @@ class="counting" @click="showCounting = !showCounting" :style="{width: showCounting ? '150px' : '30px'}" + v-if="reqType == 0" >

考试进行中 @@ -202,7 +210,11 @@


-

00:12:25

+

+ {{ hour }} : {{ mins }} : {{ sec }} +

@@ -213,6 +225,8 @@ import {getExchangeRateCookie, setExchangeRateCookie} from '@/utils/auth'; import {logOut} from '@/api/user'; import Cookie from '@/common/cookie'; import {FILE_URL} from '@/api/app'; +import {submit, reStart} from '@/api/yyyf'; +import {signUp, signIn} from '@/api/user'; const Menu = { icon: [{t: 'nav.menu_name', link: '/'}], @@ -282,6 +296,16 @@ export default { perUrl: 'personal', file: '', showCounting: true, + //0 考试 1 练习 2 不计分 + reqType: 2, + //剩余时间 + remainingTime: 0, + //防止重复提交 + isSubmit: false, + hour: 0, + mins: 0, + sec: 0, + setIntervalInt: 0, }; }, @@ -297,6 +321,7 @@ export default { created() { let yyyfToken = localStorage.getItem('yyyfToken'); + this.isSubmit = localStorage.getItem('isSubmit') == 'true' ? true : false; if (yyyfToken == '' || yyyfToken == undefined) { this.$alert('未从以渔有方登录,点击确定关闭浏览器', '提示', { type: 'error', @@ -307,43 +332,196 @@ export default { this.closeWindow(); }, }); - } - this.file = FILE_URL; - this.perUrl = window.location.pathname.split('/')[1]; - // console.log(this.perUrl); - - // this.userData = Cookie.get('userData'); - this.userData = localStorage.getItem('userData'); - - if (this.userData != '' && this.userData != undefined) { - this.userData = JSON.parse(localStorage.getItem('userData')); - // console.log(this.userData); - if (this.userData.avatar != null) { - this.headerImg = this.file + this.userData.avatar; - } else { - this.headerImg = this.userData.avatar; + } else { + //请求类型 + this.reqType = localStorage.getItem('reqType'); + //如果考试 + if (this.reqType == 0) { + //获取考试剩余时间 + this.remainingTime = localStorage.getItem('remainingTime'); + //启动倒计时 + this.setIntervalInt = setInterval(this.showTime, 1000); } - } - // console.log(this.headerImg); + this.file = FILE_URL; + this.perUrl = window.location.pathname.split('/')[1]; + // console.log(this.perUrl); + + // this.userData = Cookie.get('userData'); + this.userData = localStorage.getItem('userData'); - const currentLang = getCurrentLanguage(); - for (let item of this.lang.list) { - if (item.lang === currentLang) { - this.lang.current = item; - break; + if (this.userData != '' && this.userData != undefined) { + this.userData = JSON.parse(localStorage.getItem('userData')); + // console.log(this.userData); + if (this.userData.avatar != null) { + this.headerImg = this.file + this.userData.avatar; + } else { + this.headerImg = this.userData.avatar; + } } - } - const currentrate = getExchangeRateCookie(); - for (let item of this.exRate.list) { - if (item.id === currentrate) { - this.exRate.current = item; - // setExchangeRateCookie(currentrate); - break; + // console.log(this.headerImg); + + const currentLang = getCurrentLanguage(); + for (let item of this.lang.list) { + if (item.lang === currentLang) { + this.lang.current = item; + break; + } + } + const currentrate = getExchangeRateCookie(); + for (let item of this.exRate.list) { + if (item.id === currentrate) { + this.exRate.current = item; + // setExchangeRateCookie(currentrate); + break; + } } } }, methods: { + showTime: function() { + let remainingTime = this.remainingTime; + remainingTime -= 1; + localStorage.setItem('remainingTime', remainingTime); + this.remainingTime = remainingTime; + let h = 0; + let m = 0; + let s = 0; + if (remainingTime > 0) { + h = Math.floor(remainingTime / 60 / 60); + m = Math.floor((remainingTime / 60) % 60); + s = Math.floor(remainingTime % 60); + } + if (h < 10) { + this.hour = this.format(h, 2); + } else { + this.hour = h; + } + this.mins = this.format(m, 2); + this.sec = this.format(s, 2); + if (h <= 0 && m <= 0 && s <= 0) { + if (!this.isSubmit) + this.$message.warning('考试时间到,系统将自动提交试卷'); + this.submitExam(); + } + }, + format: function(num, n) { + return (Array(n).join(0) + num).slice(-n); + }, + submitExam: function() { + let self = this; + //防止重复提交 + if (!self.isSubmit) { + self.isSubmit = true; + } else { + return false; + } + + submit().then(res => { + if (res.data.code === 200) { + this.$message.success({ + message: '提交成功', + onClose: function() { + if (self.reqType == 0) { + self.closeWindow(); + } else { + localStorage.setItem('isSubmit', JSON.stringify(true)); + self.isSubmit = false; + } + }, + }); + } else { + this.$message.warning({ + message: res.data.msg, + onClose: function() { + self.closeWindow(); + }, + }); + } + }); + }, + reStartTest: function() { + let self = this; + //防止重复提交 + if (!self.isSubmit) { + this.isSubmit = true; + } else { + return false; + } + //退出当前用户 + this.exit(1); + reStart().then(res => { + if (res.data.code === 200) { + this.$message.success({ + message: '重新开始成功', + onClose: function() { + let signParams = { + tel: res.data.data.tel, + nickName: res.data.data.nickName, + code: res.data.data.code, + password: res.data.data.password, + internationalCode: null, + invitationCode: '', + }; + self.sign(signParams); + }, + }); + } else { + this.$message.warning({ + message: res.data.msg, + onClose: function() { + self.closeWindow(); + }, + }); + } + }); + }, + sign(params) { + signUp(params).then(res => { + if (res.data.code === 200) { + this.login({ + tel: params.tel, + password: params.password, + }); + } else { + this.$message.warning(res.data.msg); + this.isSubmit = false; + } + }); + }, + login(params) { + signIn(params).then(res => { + // console.log(res); + if (res.data.code === 200) { + //判断是否保存自动登录 + // if( this.checked === true ){ + // Cookie.set('phoneNum',num) + // Cookie.set('password',pass) + // } + //保存登录的token到cookie + // Cookie.set('token', res.data.data.token); + localStorage.setItem('token', res.data.data.token); + //重复提交标识 + localStorage.setItem('isSubmit', JSON.stringify(false)); + //保存登录的用户信息到cookie + // Cookie.set('userData', res.data.data); + localStorage.setItem('userData', JSON.stringify(res.data.data)); + // console.log(JSON.parse(localStorage.getItem('userData'))); + + // 保存userID的信息到cookie + // Cookie.set('userID', res.data.data.id); + localStorage.setItem('userID', res.data.data.id); + + // 保存邀请码信息 + localStorage.setItem('invitationCode', res.data.data.invitationCode); + this.isSubmit = false; + //location.href = '/entry'; + } else { + this.$message.warning(res.data.msg); + this.isSubmit = false; + } + }); + }, closeWindow: function() { if ( navigator.userAgent.indexOf('Firefox') != -1 || @@ -392,7 +570,7 @@ export default { location.href = '/personal?perUrl=' + this.perUrl + '#/' + command; } }, - exit() { + exit(params) { logOut().then(res => { if (res.data.code === 200 || res.data.code === 202) { // Cookie.set('userData', ''); @@ -400,7 +578,10 @@ export default { localStorage.removeItem('userpass'); localStorage.removeItem('userdate'); localStorage.removeItem('nowPassNOValue'); - window.location.href = '/'; + if (params == undefined) { + //window.location.href = '/'; + this.closeWindow(); + } // let pathName = window.location.pathname.split('/')[1]; // console.log(pathName); @@ -442,6 +623,7 @@ export default { align-items: center; // margin-left: 12.6%; margin-right: 7.9%; + img { width: 45px; height: 45px; @@ -465,15 +647,20 @@ export default { flex: 1; display: flex; margin-left: 2%; + .nav-menu { width: 60%; } + .menu-item { margin-right: 3%; } } + .centerNav { - flex: 1; + //flex: 1; + width: 230px; + .el-button { color: #ffffff; } @@ -512,10 +699,12 @@ export default { > a { // color: $local-menu-text-color; color: #545663; + &.is-active { color: white; } } + span { color: #545663; } @@ -531,6 +720,7 @@ export default { // padding: 0 10px; } } + .nav-menuRight { display: flex; flex-wrap: wrap; @@ -541,6 +731,7 @@ export default { align-items: center; font-size: 14px; color: $local-menu-text-color; + &.no-padding { padding: 0; } @@ -548,10 +739,12 @@ export default { > a { // color: $local-menu-text-color; color: #545663; + &.is-active { color: white; } } + span { color: #545663; } @@ -571,6 +764,7 @@ export default { .navColor { color: #e8494a !important; position: relative; + &::after { content: ''; width: 100%; @@ -586,6 +780,7 @@ export default { /* logo area */ .nav-logo-area { padding: 0; + .logo_text { font-size: 26px; color: #ffffff; @@ -625,10 +820,12 @@ export default { &:not(.is-disabled):hover { background-color: #d3dae2; } + .is-active { color: #666 !important; } } + .dropdown-menu-item-inner { color: #666; } @@ -641,12 +838,15 @@ export default { .langDropdown { left: -50% !important; } + .userDropdown { left: -5% !important; width: 110px; + .el-dropdown-menu__item { padding: 0; } + .dropdown-menu-item-inner { text-align: center; } @@ -697,16 +897,20 @@ export default { display: flex; justify-content: center; align-items: center; + span { color: #fff !important; } + &:hover { background-color: #fff; + span { color: #e8494a !important; } } } + // .userAvatar { // width: 40px; // height: 40px; @@ -721,10 +925,7 @@ export default { // } // } } -.btn-self-style { - background: #f56c6c !important; - color: #fff !important; -} + .main-nav { .counting { position: fixed; @@ -742,10 +943,16 @@ export default { height: 200px; z-index: 999; cursor: pointer; + p { width: 100%; text-align: center; } } } + +.btn-self-style { + background: #f56c6c !important; + color: #fff !important; +} diff --git a/src/pages/entry.vue b/src/pages/entry.vue index f9848f5..5f47a04 100644 --- a/src/pages/entry.vue +++ b/src/pages/entry.vue @@ -2,27 +2,46 @@
- +
- - 余额:1 - 余额:20 - 余额:30 - 余额:40 + + 余额:{{ userTimeMoneyDto.btc }} + 余额:{{ userTimeMoneyDto.usdt }} + 余额:{{ userTimeMoneyDto.eos }} + 余额:{{ userTimeMoneyDto.eth }}
@@ -32,18 +51,33 @@ diff --git a/src/pages/yyyflogin.vue b/src/pages/yyyflogin.vue index d154540..02d131c 100644 --- a/src/pages/yyyflogin.vue +++ b/src/pages/yyyflogin.vue @@ -19,6 +19,8 @@ export default { loading: null, tel: null, pass: null, + //0 考试 1 练习 2 不计分 + reqType: null, }; }, @@ -26,6 +28,7 @@ export default { created() { this.startLoading(); let params = this.parseUrl(); + this.reqType = params.reqType; //判断是否来自以渔有方 if ( !$.isEmptyObject(params) && @@ -112,7 +115,8 @@ export default { //保存登录的token到cookie // Cookie.set('token', res.data.data.token); localStorage.setItem('token', res.data.data.token); - + //重复提交标识 + localStorage.setItem('isSubmit', JSON.stringify(false)); //保存登录的用户信息到cookie // Cookie.set('userData', res.data.data); localStorage.setItem('userData', JSON.stringify(res.data.data)); @@ -125,43 +129,40 @@ export default { // 保存邀请码信息 localStorage.setItem('invitationCode', res.data.data.invitationCode); this.endLoading(); - location.href = '/'; + location.href = '/entry'; } else { this.$message.warning(res.data.msg); } }); }, loginFromYyyf: function(params) { + let self = this; signInYyyf(params).then(res => { if (res.data.code === 200) { let status = res.data.data.status; + localStorage.setItem('yyyfToken', res.data.data.yyyfUserToken); + + //0 考试 1 练习 2 不计分 + localStorage.setItem('reqType', self.reqType); + if (self.reqType == 0) { + //考试 保留考试剩余 + localStorage.setItem('remainingTime', res.data.data.remainingTime); + } + if (status == 1) { //保存登录的token到cookie // Cookie.set('token', res.data.data.token); - localStorage.setItem('yyyfToken', res.data.data.yyyfUserToken); - let code = res.data.data.code; - this.tel = res.data.data.tel; - this.pass = res.data.data.password; - //注册 - if (code != undefined && code != '') { - let signParams = { - tel: this.tel, - nickName: res.data.data.nickName, - code: res.data.data.code, - password: this.pass, - internationalCode: null, - invitationCode: '', - }; - this.sign(signParams); - } else { - this.login(); - } + self.dealLogin(res); } else { this.$message.warning({ message: res.data.data.msg, onClose: function() { - this.closeWindow(); + if (status == 3) { + self.dealLogin(res); + } else { + self.closeWindow(); + } }, }); } @@ -169,12 +170,31 @@ export default { this.$message.warning({ message: res.data.msg, onClose: function() { - this.closeWindow(); + self.closeWindow(); }, }); } }); }, + dealLogin: function(res) { + let code = res.data.data.code; + this.tel = res.data.data.tel; + this.pass = res.data.data.password; + //注册 + if (code != undefined && code != '') { + let signParams = { + tel: this.tel, + nickName: res.data.data.nickName, + code: res.data.data.code, + password: this.pass, + internationalCode: null, + invitationCode: '', + }; + this.sign(signParams); + } else { + this.login(); + } + }, closeWindow: function() { if ( navigator.userAgent.indexOf('Firefox') != -1 || From 7d87d35f9241b01da0f6cf016c7cc65ef183e8fc Mon Sep 17 00:00:00 2001 From: unclekh <5177787+unclekh@user.noreply.gitee.com> Date: Mon, 13 Jul 2020 23:14:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=85=A8=E6=99=AF=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=80=BB=E9=A2=9D=E3=80=81=E5=9C=B0=E5=9D=80=E3=80=81=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=8E=BB=E6=8E=89=E6=B3=95=E5=B8=81=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E7=9A=84=E5=85=85=E5=80=BC=E3=80=81=E6=8F=90=E5=B8=81=EF=BC=8C?= =?UTF-8?q?=E5=B8=81=E5=B8=81=E4=BA=A4=E6=98=93=E7=9A=84=E5=85=85=E5=80=BC?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=85=85=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/balances/banlanes-tabds.vue | 25 +++---- src/components/common/header.vue | 2 +- src/locales/lang/balances.zh-CN.js | 2 +- src/locales/lang/balances.zh-HK.js | 2 +- src/pages/entry.vue | 79 +++++++++++++++++++--- 5 files changed, 85 insertions(+), 25 deletions(-) diff --git a/src/components/balances/banlanes-tabds.vue b/src/components/balances/banlanes-tabds.vue index 2f9dc92..aeca8d6 100644 --- a/src/components/balances/banlanes-tabds.vue +++ b/src/components/balances/banlanes-tabds.vue @@ -78,19 +78,19 @@ o.oooooo
-->
- + + > --> +
- + + >--> +
- + + >--> +

微信

-

初始资金:{{ userTimeMoneyDto.wxPayInit }}

-

余额:{{ userTimeMoneyDto.wxPay }}CNY

+

初始资金:{{ userTimeMoneyDto.wxPayInit}} CNY

+

余额:{{ userTimeMoneyDto.wxPay }} CNY

@@ -31,16 +31,16 @@
余额:{{ userTimeMoneyDto.btc }}余额:{{ userTimeMoneyDto.btc }}

总额≈:{{tatolPrice}} CNY

地址:{{userTimeMoneyDto.assessUserId}} 余额:{{ userTimeMoneyDto.usdt }}余额:{{ userTimeMoneyDto.usdt }}

总额≈:{{tatolPrice}} CNY

地址:{{userTimeMoneyDto.assessUserId}} 余额:{{ userTimeMoneyDto.eos }}余额:{{ userTimeMoneyDto.eos }}

总额≈:{{tatolPrice}} CNY

地址:{{userTimeMoneyDto.assessUserId}} 余额:{{ userTimeMoneyDto.eth }}余额:{{ userTimeMoneyDto.eth }}

总额≈:{{tatolPrice}} CNY

地址:{{userTimeMoneyDto.assessUserId}}
@@ -52,22 +52,81 @@ import NavHeader from '@/components/common/header'; import Footer from '@/components/common/footer'; import {getUserTimeMoneyDto} from '@/api/yyyf'; +import {getLeftPrice} from '@/api/currency.js'; export default { name: 'entry', data() { return { activeName: 'BTC', userTimeMoneyDto: {}, + tatolPrice:0 }; }, components: { NavHeader, Footer, }, + methods:{ + getUSDTPrie() { + getLeftPrice().then(res => { + this.USDTPrie = res.data.data; + // console.log(this.USDTPrie); + + // 获取币种汇率 + let cnyAmount = this.USDTPrie[0].cnyAmount; + let btcCount=0; + let usdtCount=this.userTimeMoneyDto.usdt; + let eosCount=0; + let ethCount=0; + + for (let i = 0; i < this.USDTPrie.length; i++) { + // 获取btc转usdt资产 + if (this.USDTPrie[i].currencyPair == 'BTC-USDT') { + // console.log(this.USDTPrie[i].amount); + // + btcCount = this.userTimeMoneyDto.btc * this.USDTPrie[i].amount; + // console.log('btc'+this.btcPrice); + } + // return this.btcPrice; + } + for (let i = 0; i < this.USDTPrie.length; i++) { + // 获取btc转usdt资产 + if (this.USDTPrie[i].currencyPair == 'EOS-USDT') { + // console.log(this.USDTPrie[i].amount); + // + eosCount = this.userTimeMoneyDto.eos * this.USDTPrie[i].amount; + // console.log('btc'+this.btcPrice); + } + // return this.btcPrice; + } + + for (let i = 0; i < this.USDTPrie.length; i++) { + // 获取btc转usdt资产 + if (this.USDTPrie[i].currencyPair == 'ETH-USDT') { + // console.log(this.USDTPrie[i].amount); + // + ethCount = this.userTimeMoneyDto.eth * this.USDTPrie[i].amount; + // console.log('btc'+this.btcPrice); + } + // return this.btcPrice; + } + + let digitWallet= (btcCount+usdtCount+eosCount+ethCount)*cnyAmount; + + let total=digitWallet+this.userTimeMoneyDto.aliPay+this.userTimeMoneyDto.wxPay+this.userTimeMoneyDto.bankCard; + // 获取总资产 + this.tatolPrice =Math.floor(total*10) / 10; + + // console.log(this.tatolPrice); + }); + } + }, created() { getUserTimeMoneyDto().then(res => { if (res.data.code === 200) { this.userTimeMoneyDto = res.data.data; + this.getUSDTPrie(); + } else { this.$message.warning({ message: res.data.msg,