Browse Source

新增用户状态

master
liaoxinyu 1 year ago
parent
commit
05638ba47c
  1. 61
      src/App.vue
  2. 7
      src/api/home.js
  3. 30
      src/views/contract/exchange-store.vue
  4. 9
      src/views/signIn/index.vue
  5. 20
      src/views/signUp/index.vue

61
src/App.vue

@ -12,17 +12,22 @@
<script>
import { mapState, mapActions } from "vuex";
import Member from "@/api/member";
import Home from "@/api/home";
export default {
name: "App",
data() {
return {
oldTheme: ""
oldTheme: "",
heartbeatInterval: null,
};
},
computed: {
isHome() {
return this.$route.path == "/home";
},
isLogin() {
return Boolean(localStorage.token);
},
...mapState({
theme: "theme",
appConfig: "appConfig"
@ -67,13 +72,65 @@ export default {
setConfig() {
document.getElementById("appTitle").innerText = this.appConfig.name;
document.getElementById("appIcon").href = this.appConfig.titles_logo;
}
},
logout(){
Member.logout().then((response) => {
// console.info(response);
// token
localStorage.removeItem("token");
localStorage.removeItem("auth");
location.reload();
}).catch((err) => {});
},
sendHeartbeat() {
if (this.isLogin){
Home.online().then((response) => {
console.log('心跳机制');
}).catch((err) => {});
}
},
startHeartbeat() {
if (!this.heartbeatInterval && this.isLogin) {
this.heartbeatInterval = setInterval(this.sendHeartbeat, 100000); // 1
console.log('心跳机制已启动');
}
},
stopHeartbeat() {
if (this.heartbeatInterval) {
clearInterval(this.heartbeatInterval);
this.heartbeatInterval = null;
console.log('心跳机制已停止');
}
},
handleVisibilityChange() {
if (document.visibilityState === 'visible') {
//
this.startHeartbeat();
} else {
//
this.stopHeartbeat();
}
}
},
beforeDestroy() {
//
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
this.stopHeartbeat();
},
created() {
this.getLogo();
},
mounted() {
this.setAppTheme();
//
document.addEventListener('visibilitychange', this.handleVisibilityChange);
//
if (this.isLogin){
this.sendHeartbeat()
}
//
this.startHeartbeat();
}
};
</script>

7
src/api/home.js

@ -26,7 +26,12 @@ class Home {
static getNewestVersion(){
return server.get('/getNewestVersion')
}
/*
* 获取用户在线接口
*/
static online(){
return server.get('/online',{config:{loading:false}})
}
}
export default Home;

30
src/views/contract/exchange-store.vue

@ -112,7 +112,7 @@
@input="sliderChangeBuy" -->
<el-slider
v-model="activeStepBuy"
@change="sliderChangeBuy"
@input="sliderChangeBuy"
:format-tooltip="tooltip"
:marks="marks"
:step="25"
@ -240,7 +240,7 @@
@input="sliderChangeSell" -->
<el-slider
v-model="activeStepSell"
@change="sliderChangeSell"
@input="sliderChangeSell"
:format-tooltip="tooltip"
:marks="marks"
:step="25"
@ -398,8 +398,10 @@ export default {
marginSell:0,
checkboxBuy: false,
checkboxSell: false,
activeStepBuy:0,
activeStepSell:0
activeStepBuy:100,
activeStepSell:100,
sliderActive:0,
sliderActive1:0
};
},
props: {
@ -448,7 +450,15 @@ export default {
if (n != o) {
this.contractAccount();
}
}
},
maxNum(n) {
//
this.buyform.amount = Math.round((this.maxNum * this.sliderActive) / 100);
this.marginBuy=this.buyform.amount/this.form.lever_rate;
//
this.sellform.amount = Math.round((this.maxNum * this.sliderActive1) / 100);
this.marginSell=this.sellform.amount/this.form.lever_rate;
}
},
destroyed() {
clearInterval(this._time);
@ -525,10 +535,10 @@ export default {
},
amountSell(){
// console.info(this.form.lever_rate)
// console.info(this.margin)
// console.info(this.marginSell)
if (!this.form.lever_rate || !this.marginSell) return 0;
let p=this.marginSell*this.form.lever_rate;
this.sellform.amount=p;
return p
}
@ -573,18 +583,20 @@ export default {
this.lever_rage = res.lever_rage;
this.unit_amount = res.unit_amount
this.$emit('getSymbolDetail',res)
if (!this.form.lever_rate) {
// if (!this.form.lever_rate) {
this.form.lever_rate = res.default_lever;
}
// }
});
},
//
sliderChangeBuy($ev) {
this.sliderActive = $ev
this.buyform.amount = Math.round((this.maxNum * $ev) / 100)||'';
// console.info(this.buyform)
this.marginBuy=this.buyform.amount/this.form.lever_rate || 0
},
sliderChangeSell($ev) {
this.sliderActive1 = $ev
this.sellform.amount = Math.round((this.maxNum * $ev) / 100)||'';
// console.info(this.sellform)
this.marginSell=this.sellform.amount/this.form.lever_rate || 0

9
src/views/signIn/index.vue

@ -16,10 +16,10 @@
<template v-if="step === 1 ">
<div class="form-group">
<input type="text" name="account" v-model="user.account" required :data-has="$t('login.effectivePhoneEmail')" class="form-control" :placeholder="$t('login.enterPhoneEmail')" :data-message="$t('login.effectivePhoneEmail')" />
<input type="text" name="account" v-model="user.account" required :data-has="$t('login.effectivePhoneEmail')" class="form-control" :placeholder="$t('login.enterPhoneEmail')" :data-message="$t('login.effectivePhoneEmail')" title="" />
</div>
<div class="form-group">
<input type="password" v-model="user.password" class="form-control" name="password" required :data-has="$t('login.emailCode',{num:'8-15'})" pattern="(?=.*([a-zA-Z].*))(?=.*[0-9].*)[a-zA-Z0-9-*/+.~!@#$%^&*()]{8,15}$" :data-message="$t('login.passwordLength',{num:'8-15'})" :placeholder="$t('login.password')" />
<input type="password" v-model="user.password" class="form-control" name="password" required :data-has="$t('login.emailCode',{num:'8-15'})" pattern="(?=.*([a-zA-Z].*))(?=.*[0-9].*)[a-zA-Z0-9-*/+.~!@#$%^&*()]{8,15}$" :data-message="$t('login.passwordLength',{num:'8-15'})" :placeholder="$t('login.password')" title="" />
<!-- <el-input v-model="user.password" show-password required :placeholder="$t('login.password')"></el-input> -->
</div>
<div class="text-right">
@ -114,6 +114,7 @@
import md5 from "md5";
import Member from "@/api/member";
import utils from '@/utils';
import Home from "@/api/home";
export default {
data() {
@ -437,6 +438,10 @@ export default {
email
} = response;
Home.online().then((response) => {
console.log('心跳机制');
}).catch((err) => {});
this.status = response; // 便
// checkType

20
src/views/signUp/index.vue

@ -32,7 +32,7 @@
show为默认的控制显示 这里替换为v-if的渲染 这样email和phone只能存在一个 避免同时创建require规则时报错-->
<div class="tab-pane fade" :class="{show:registerType == 1, active:registerType == 1}" v-if="registerType==1" id="email" role="tabpanel" aria-labelledby="email-tab">
<div class="form-group">
<input type="email" name="email" class="form-control" :placeholder="$t('login.pleaseEmail')" v-model="user.email" :data-has="$t('login.pleaseEmail')" :data-message="$t('login.invalidEmail')" />
<input type="email" name="email" class="form-control" :placeholder="$t('login.pleaseEmail')" v-model="user.email" :data-has="$t('login.pleaseEmail')" :data-message="$t('login.invalidEmail')" title="" />
</div>
</div>
<!-- phone number -->
@ -44,40 +44,40 @@
<el-option v-for="(item, index) in cacheOption" :key="index" :value="`${item.id}`" :label="`+${item.country_code} ${item.name} ${item.code}`"></el-option>
</el-select>
</div>
<input type="text" name="phone" class="form-control" :placeholder="$t('login.enterMobile')" v-model="user.phone" :data-has="$t('login.enterMobile')"/>
<input type="text" name="phone" class="form-control" :placeholder="$t('login.enterMobile')" v-model="user.phone" :data-has="$t('login.enterMobile')" title=""/>
</div>
</div>
</div>
</div>
<div class="form-group row password">
<input :type="pwdType" id="password" v-model="user.password" required :placeholder="$t('login.password')" class="form-control" />
<input :type="pwdType" id="password" v-model="user.password" required :placeholder="$t('login.password')" class="form-control" title="" />
<label for="password" @click="showType('pwdType')"></label>
</div>
<div class="form-group row password">
<!-- 使用data-type指定额外的类型验证 -->
<input :type="repwdType" id="repassword" v-model="user.repassword" required :placeholder="$t('login.confirm-password')" class="form-control" />
<input :type="repwdType" id="repassword" v-model="user.repassword" required :placeholder="$t('login.confirm-password')" class="form-control" title="" />
<label @click="showType('repwdType')"></label>
</div>
<div class="form-group row password">
<!-- 使用data-type指定额外的类型验证 -->
<input :type="repwdType" id="withdrawal_psw" v-model="user.withdrawal_psw" required :placeholder="$t('common.c13')" class="form-control" />
<input :type="repwdType" id="withdrawal_psw" v-model="user.withdrawal_psw" required :placeholder="$t('common.c13')" class="form-control" title="" />
<label @click="showType('repwdType')"></label>
</div>
<div class="form-group row password">
<!-- 增加图形验证码 -->
<input :type="txtType" id="gccode" v-model="user.gc_code" required :placeholder="$t('common.GraphicValidation')" class="form-control col-8" />
<input :type="txtType" id="gccode" v-model="user.gc_code" required :placeholder="$t('common.GraphicValidation')" class="form-control col-8" title="" />
<img class="" :src="Graph_che" @click="gett_gc_code" style="object-fit: contain;width: 166px;height: 56px;">
</div>
<div class="form-group row">
<input type="text" class="form-control" :disabled="$route.query.invite_code?true:false" v-model="user.parentCode" :placeholder="`${$t('login.referrer')}`" />
<input type="text" class="form-control" :disabled="$route.query.invite_code?true:false" v-model="user.parentCode" :placeholder="`${$t('login.referrer')}`" title="" />
<!-- ${$t('login.optional')} -->
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="form-checkbox" v-model="isAgree" />
<input type="checkbox" class="custom-control-input" id="form-checkbox" v-model="isAgree" title="" />
<label class="custom-control-label" for="form-checkbox" style="color: #101010;">
{{$t('login.iSee')}}
<router-link to="service/10">
@ -102,7 +102,7 @@
<section class="my-codes">
<header class="my-codes__title">{{$t('login.verCode')}}</header>
<div class="my-codes__controls">
<input style="color: #000;" type="text" v-for="pos in 6" :key="pos" pattern="[0-9]*" @focus="current=pos" @blur="current=-1" ref="spaces" class="form-control" @keyup="handleKeyUp(pos-1, $event)" @input="handleInput(pos-1, $event)" @paste="autofill" />
<input style="color: #000;" type="text" v-for="pos in 6" :key="pos" pattern="[0-9]*" @focus="current=pos" @blur="current=-1" ref="spaces" class="form-control" @keyup="handleKeyUp(pos-1, $event)" @input="handleInput(pos-1, $event)" @paste="autofill" title="" />
</div>
</section>
<aside class="prompt">
@ -127,7 +127,7 @@
<section class="my-codes">
<header class="my-codes__title">Code</header>
<div class="my-codes__controls">
<input type="text" v-for="pos in 6" :key="pos" pattern="[0-9]*" @focus="current=pos" @blur="current=-1" ref="spaces" class="form-control" @keyup="handleKeyUp(pos-1, $event)" @input="handleInput(pos-1, $event)" @paste="autofill" />
<input type="text" v-for="pos in 6" :key="pos" pattern="[0-9]*" @focus="current=pos" @blur="current=-1" ref="spaces" class="form-control" @keyup="handleKeyUp(pos-1, $event)" @input="handleInput(pos-1, $event)" @paste="autofill" title="" />
</div>
</section>
<aside class="prompt">

Loading…
Cancel
Save