Files
aida_front/src/views/HomeMain.vue
2024-07-17 16:26:54 +08:00

755 lines
20 KiB
Vue

<template>
<div class="homeMain_max Guide_1_16_1">
<header class="homeMain_heade">
<div class="homeMain_right_content">
<div class="homeMain_user_icon"></div>
<div class="homeMain_user_content">
<div v-if="isTest" class="username"><span>/</span> {{$t('Header.hello')}}@{{ $t('isTest.userName') }}</div>
<div v-else class="username"><span>/</span> {{$t('Header.hello')}}@{{ userInfo?.userName }}</div>
<div
v-if="!isMurmur"
:class="[
'icon',
'iconfont',
'icon-xiala',
isShowOperate ? 'icon_rotate' : '',
]"
@click.stop="changeShowOperateContent()"
></div>
</div>
<div
class="trialApproval button_second credits hideChecked"
>
{{$t('Header.Credits')}}:&nbsp;
<span :title="credits">
<!-- <div>{{ String(credits.value[credits.value.legnth-1]) }}</div> -->
<div class="credits_item" v-for="item in String(credits)" :style="{'transform': 'translateY('+item*-100+'%)'}">
<div v-for="numItem in 10">{{ numItem-1 }}</div>
</div>
</span>
<i @click="getCredits" class="fi fi-br-refresh" :class="[activeCredits?'active':'']"></i>
<!-- <i @click="Assignment" class="fi fi-rr-gift" title="Assignment"></i> -->
<i @click="UpgradePlan" title="Purchase" class="fi fi-rr-shop"></i>
</div>
</div>
<nav class="homeMain_nav_content">
<router-link :class="['nav_item',$route.name === 'homePage' ? 'select_nav' : '', ]" :to="`/home/homePage`">
{{$t('Header.HOME')}}
</router-link>
<router-link :class="['nav_item',$route.name === 'library' ? 'select_nav' : '', ]" :to="`/home/library`">
{{$t('Header.LIBRARY')}}
</router-link>
<router-link :class="['nav_item',$route.name === 'history' ? 'select_nav' : '', ]" :to="`/home/history`">
{{$t('Header.HISTORY')}}
</router-link>
<router-link :class="['nav_item',$route.name === 'works' ? 'select_nav' : '', ]" :to="`/home/works`">
{{$t('Header.WORKS')}}
</router-link>
</nav>
<div class="homeMain_right">
<img
class="homeMain_logo"
@click="turnToNewPage('https://www.aidlab.hk/en/')"
src="@/assets/images/loginPage/aida_logo.png"
/>
<Habit></Habit>
</div>
<nav class="select_block" v-show="isShowOperate">
<!-- <div class="select_item" @click="showBindEmailModal()">
<span class="icon iconfont icon-youxiang"></span><span class="select_item_des">{{$t('Header.bindEmail')}}</span>
</div> -->
<div class="select_item" @click.stop="isLanguage = !isLanguage">
<span class="icon iconfont icon-yuyan"></span>
<span class="select_item_des">{{$t('Header.language')}}</span>
</div>
<!-- <div class="select_item" @click="openTask()">
<i class="icon iconfont icon-renwu"></i>
<span class="select_item_des">{{$t('Header.TaskList')}}</span>
</div> -->
<div class="select_item" @click="orderForm()">
<i class="fi fi-rs-notebook"></i>
<span class="select_item_des">{{$t('Header.ViewOrders')}}</span>
</div>
<router-link class="select_item" v-if="AdministratorUserIdList.indexOf(userInfo?.userId) >= 0" :to="`/administrator`">
<span class="icon iconfont icon-yonghu"></span>
<span class="select_item_des">Administrator</span>
</router-link>
<div class="select_item" @click="getTutorial()">
<span class="fi fi-rr-book-user"></span>
<span class="select_item_des">{{$t('Header.Tutorial')}}</span>
</div>
<div class="select_item" @click="logout()">
<span class="icon iconfont icon-tuichu"></span>
<span class="select_item_des">{{$t('Header.logOff')}}</span>
</div>
</nav>
<ul class="select_block select_list" v-show="isLanguage">
<li class="select_item" v-for="item in language" @click="setLocale(item.value)">
<span class="select_item_des">{{ item.name }}</span>
</li>
</ul>
<payOrder ref="payOrder"></payOrder>
<UpgradePlan ref="UpgradePlan"></UpgradePlan>
<TaskPage ref="TaskPage"></TaskPage>
</header>
<div class="homeMain_content_body">
<!-- <router-view v-slot="{ Component }" @setTask = "setTask">
<keep-alive>
<component :key="$route.name" :is="Component" v-if="$route.meta.keepAlive"/>
</keep-alive>
<component :key="$route.name" :is="Component" v-if="!$route.meta.keepAlive"/>
</router-view> -->
<router-view @setTask = "setTask" :getLangIsShowMark="getLangIsShowMark"></router-view>
</div>
<RobotAssist></RobotAssist>
<scaleVideo ref="scaleVideo"></scaleVideo>
</div>
</template>
<script >
import { defineComponent, createVNode, ref, computed } from "vue";
import { isEmail } from "@/tool/util";
import { setCookie, getCookie, WriteCookie,clonAllCookie } from "@/tool/cookie";
import payOrder from "@/component/Pay/payOrder.vue";
import VerificationCodeInput from "@/component/LoginPage/verificationCodeInput.vue";
import Habit from "@/component/Detail/habit.vue";
import TaskPage from "@/component/HomePage/TaskPage.vue";
import UpgradePlan from "@/component/HomePage/UpgradePlan.vue";
import { Https } from "@/tool/https";
import { Modal, message } from "ant-design-vue";
import { ExclamationCircleOutlined } from "@ant-design/icons-vue";
import RobotAssist from "@/component/HomePage/RobotAssist.vue";
import scaleVideo from "@/component/HomePage/scaleVideo.vue";
import { useStore } from "vuex";
import { setLang } from "@/tool/guide";
import showViewVideo from "@/tool/mount";
import { useI18n } from "vue-i18n";
export default defineComponent({
components: {
VerificationCodeInput,
Habit,
RobotAssist,
scaleVideo,
UpgradePlan,
payOrder,
TaskPage,
},
setup(){
const store = useStore();
const {t} = useI18n()
const {locale} = useI18n()
let isTest = ref()
let isMurmur = ref()
let credits = computed(()=>{
return store.state.UserHabit.credits.value
})
let activeCredits = ref(false)
let getLangIsShowMark = ref(true)
let AdministratorUserIdList = [88,6,46,31,73,83,87,4]
return {
store,
t,
locale,
isTest,
isMurmur,
credits,
activeCredits,
getLangIsShowMark,
AdministratorUserIdList,
}
},
data() {
return {
isShowOperate: false,
bindEmailVisible: false,
isHaveBindEmail: false,
bindEmailStep: 1,
email: "",
emailCode: ["", "", "", "", "", ""], //邮箱验证码
time: 60, //60秒倒计时
timer: 0,
userInfo: {},
timerOperate: null,
numTime: 30,
timerSec: null,
modalWarning: null,
isLanguage: false,
language:[
{name:'English',value:'ENGLISH'},
{name:'中文',value:'CHINESE_SIMPLIFIED'},
// {name:'한국인',value:'KOREAN'},
// {name:'にほんご',value:'JAPANESE'},
// {name:'Русский',value:'RUSSIAN'},
// {name:'Français',value:'FRENCH'},
// {name:'แบบไทย',value:'THAI'},
// {name:'Tiếng Việt',value:'VIETNAMESE'},
// {name:'Italiano',value:'ITALIAN'},
],
};
},
watch: {
// credits.value(newVal,oldVal){
// console.log(String(newVal).length);
// }
},
mounted() {
let isTest = getCookie('isTest')//获取是否是试用用户
this.isTest =JSON.parse(isTest)
let isMurmur = getCookie('isMurmur')//获取是否是试用用户
this.isMurmur =JSON.parse(isMurmur)
this.userInfo = JSON.parse(getCookie("userInfo"));
if (!this.userInfo) {
this.$router.replace("/");
} else {
this.accountIsLogin(this.userInfo);
}
this.isHaveBindEmail = this.userInfo?.email ? true : false;
if(!isMurmur){
this.operateClick();
document.addEventListener("click", this.operateClick);
}
this.getCredits()
this.getLang('')
//语言适配
this.store.dispatch('getLangType').then(()=>{
this.getLangIsShowMark = false
})
},
methods: {
setTask(data){
this.openTask(data)
},
turnToNewPage(url) {
window.open(url);
},
turnToPage(name) {
let noRefresh = name === "home" ? true : false;
this.$router.push({ name: name, params: { noRefresh: noRefresh } });
},
UpgradePlan(){//购买积分
let UpgradePlan = this.$refs.UpgradePlan
UpgradePlan.init()
},
Assignment(){//任务
// let num = 123+this.credits
// this.store.commit('setCredits',num)
},
getCredits(){//刷新当前积分
if(!this.activeCredits){
this.activeCredits = true
this.store.dispatch('getCredits').then((rv)=>{
setTimeout(()=>{
this.activeCredits = false
},300)
})
}else{
this.activeCredits = false
}
},
//点击下拉图标出现操作
changeShowOperateContent() {
this.isShowOperate = !this.isShowOperate;
document.addEventListener(
"click",
this.closeShowOperateContent,
false
);
},
changeLanguage(){
this.isLanguage = !this.isLanguage;
document.addEventListener(
"click",
this.closeShowOperateContent,
false
);
},
//关闭下拉图标
closeShowOperateContent() {
this.isShowOperate = false;
this.isLanguage = false
document.removeEventListener("click", this.closeShowOperateContent);
},
//查看订单
orderForm(){
let payOrder = this.$refs.payOrder
payOrder.init()
},
//教程
getTutorial(){
let url = 'https://code-create.com.hk/wp-content/uploads/2024/07/aida_3.0-使用手册-0705.pdf'
if(this.locale == 'ENGLISH'){
url = 'https://code-create.com.hk/wp-content/uploads/2024/07/aida_3.0-Manual-0705-1.pdf'
showViewVideo({url:'https://code-create.com.hk/wp-content/uploads/2024/07/AiDA-demo-video_0709_EN.webm'})
}else{
showViewVideo({url:'https://code-create.com.hk/wp-content/uploads/2024/07/AiDA-demo-video_0709_CN.webm'})
}
//打开视频
const a = document.createElement('a');
a.href = url;
a.target = '_blank';
a.download = 'aida_3.0-Manual.pptx'; // 下载的文件名
document.body.appendChild(a);
a.click();
},
//登出
async logout() {
let data = {
userId: this.userInfo.userId,
};
let isTest = getCookie('isTest')
// console.log(getCookie("token"));
if(JSON.parse(isTest)){
await Https.axiosGet(Https.httpUrls.trialUserLogout,).then((rv) => {
Https.axiosPost(Https.httpUrls.accountLogout, data).then((rv) => {
this.$router.replace("/");
// WriteCookie("token");
});
})
}else{
await Https.axiosPost(Https.httpUrls.accountLogout, data).then((rv) => {
// WriteCookie("token");
});
this.$router.replace("/");
}
this.store.commit('clearSystemUser')
// WriteCookie("token");
// window.location.reload()
},
//判断是否登录
accountIsLogin(userInfo) {
let data = {
userId: userInfo.userId,
};
Https.axiosPost(Https.httpUrls.accountIsLogin, data).then((rv) => {
if (!rv) {
this.$router.replace("/");
}
});
},
//点击重置判断是否长时间五操作
operateClick() {
if (this.timer) {
clearTimeout(this.timer);
}
let _this = this;
let timeNum = 1000 * 60 * 120;
this.timer = setTimeout(() => {
this.modalWarning = Modal.warning({
title: () =>
this.t('Header.jsContent3',{numTime:_this.numTime}),
icon: createVNode(ExclamationCircleOutlined),
okText: "Ok",
centered:true,
onOk() {
_this.numTime = 30;
clearInterval(_this.timerSec);
},
});
_this.numCounter();
}, timeNum);
},
numCounter() {
this.timerSec = setInterval(() => {
if (this.numTime > 0) {
this.numTime = this.numTime - 1;
} else {
clearTimeout(this.timer);
clearInterval(this.timerSec);
this.logout();
this.modalWarning.destroy();
}
}, 1000);
},
//获取当前语言
getLang(v){
let data
Https.axiosPost(Https.httpUrls.getUserLanguage, data).then(
(rv) => {
if (rv) {
this.locale = rv
setLang(rv)
}
}
);
},
setLang(v){
Https.axiosGet(Https.httpUrls.changeUserLanguage,{params:{language:v}}).then((rv) => {
if (rv) {
if (rv) {
let token = rv;
setCookie("token", token);
this.getLang('')
// if(this.$router.currentRoute._value.path == '/home'){
// this.$router.push("/home")
// }else{
// this.$router.push("/home")
// }
this.store.commit('clearAllData')
window.location.reload()
}
}
})
},
setLocale(v){
this.setLang(v)
},
openTask(data){
let taskPage = this.$refs.TaskPage
taskPage.init(data)
},
},
});
</script>
<style lang="less" scoped>
.homeMain_max{
position: relative;
display: flex;
height: 100vh;
flex-direction: column;
.homeMain_content_body{
flex: 1;
height: calc(100vh - 7rem);
}
}
.homeMain_heade {
flex-shrink: 0;
display: flex;
justify-content: space-between;
// padding: 0 30px;
padding: 0 9rem;
width: 100%;
height: 7rem;
background: rgba(255, 255, 255, 0.2);
// border-bottom: 0.1rem solid rgba(3, 3, 3, 0.1);
position: relative;
align-items: center;
z-index: 1049;
background-color: #fff;
.homeMain_right{
width: 33%;
display: flex;
justify-content: flex-end;
align-items: center;
}
.homeMain_logo {
width: 14.4rem;
height: 3.2rem;
margin: 2.1rem 2.8rem 0 ;
// position: absolute;
margin-top: 0;
}
.homeMain_nav_content {
display: flex;
// margin-left: 28.9rem;
// margin-left: 46.2rem;
align-items: center;
.nav_item {
padding: 1.1rem 1rem;
border-bottom: 0.1rem solid transparent;
margin-right: 3.4rem;
font-size: 1.6rem;
line-height: 1.3rem;
// color: #333333;
color: #000;
cursor: pointer;
font-weight: 900;
position: relative;
&.nav_item:last-child{
margin: 0;
}
&.nav_item::before {
position: absolute;
content: "";
display: block;
background: #000;
height: .3rem;
left: 50%;
transform: translateX(-50%);
bottom: .3rem;
width: 0px;
transition: 0.3s all;
}
&.select_nav {
color: #000;
transform: scale(1.15);
}
&.select_nav::before {
width: 80%;
}
}
}
.homeMain_right_content {
// position: absolute;
top: 0;
// right: 3.2rem;
left: 0;
display: flex;
width: 33%;
height: 100%;
align-items: center;
overflow: hidden;
.homeMain_icon {
font-size: 3.6rem;
position: relative;
top: 0.3rem;
}
.homeMain_user_icon{
height: 4rem;
width: 4rem;
background-color: #000;
border-radius: 50%;
transform: translateX(-40%)scale(1.3);
}
.homeMain_user_content {
// margin-left: 2rem;
display: flex;
align-items: center;
position: relative;
// top: 1.2rem;
height: 3.7rem;
&.marLeft2{
margin-left: 2rem;
}
.username {
font-size: 1.8rem;
color: #1a1a1a;
margin: 0 0.8rem;
font-weight: 900;
span{
margin: .7rem;
}
}
.icon-xiala {
font-size: 1.4rem;
cursor: pointer;
transition: .3s all;
}
.icon_rotate {
-moz-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
animation-direction: 0.5s;
}
}
.credits{
font-size: 1.8rem;
color: #1a1a1a;
font-weight: 900;
width: auto;
padding: 0 1rem;
cursor: auto;
display: flex;
span{
width: 5rem;
display: inline-block;
overflow: hidden;
display: flex;
margin-right: .9rem;
.credits_item{
transition: .3s all;
// height: 4rem;
height: 3.2rem;
div{
height: 100%;
}
}
}
i{
height: 100%;
display: inline-block;
border-left: .1rem solid ;
padding-left: .9rem;
margin-left: .9rem;
font-size: 1.8rem;
cursor: pointer;
}
.fi-br-refresh{
margin-left: 0;
border-left: none;
padding-left: 0;
&.active{
transition: all .3s;
transform: rotate(360deg);
}
}
}
.trialApproval{
margin-left: 2rem;
}
}
}
.select_block {
z-index: 1050;
position: absolute;
left: 15.5rem;
top: 6rem;
width: 13.5rem;
background: #ffffff;
box-shadow: 0px 0.4rem 0.4rem 0px rgba(0, 0, 0, 0.1);
overflow: hidden;
border: 1px solid #000000;
height: auto;
&.select_list{
// display: none;
transform: translateX(105%);
// transform: translateX(120%);
}
.select_item {
padding-left: 1.5rem;
height: 4.1rem;
color: #4d4d4d;
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
&:hover {
background: #f7f7f7;
}
.iconfont ,.fi-rr-book-user {
font-size: 1.4rem;
}
.select_item_des {
font-size: 1.3rem;
margin-left: 0.8rem;
}
}
}
.modal_component {
.skip_content {
width: 6rem;
height: 3rem;
line-height: 2.8rem;
border: 0.1rem solid #343579;
font-size: 1.4rem;
color: #343579;
position: absolute;
top: 1.8rem;
right: 1.8rem;
cursor: pointer;
}
.bind_email_content {
padding: 4.8rem 9.2rem 6rem;
.bind_email_tip {
font-size: 1.8rem;
color: #a5b0c2;
line-height: 1.9rem;
text-align: center;
}
.bind_email {
margin-top: 2rem;
font-size: 2.2rem;
font-weight: 400;
color: #030303;
text-align: center;
}
.bind_email_form_content {
.bind_email_form_title {
font-size: 2.2rem;
font-weight: bold;
color: #030303;
line-height: 2.4rem;
}
.bind_email_form_input {
width: 100%;
height: 4.6rem;
margin-top: 1rem;
border: 0.1rem solid #b4bed7;
padding-left: 2.1rem;
line-height: 4.6rem;
font-size: 1.8rem;
box-sizing: border-box;
&::placeholder {
color: #a5b0c2;
}
}
}
.bind_email_submit_button {
height: 4.6rem;
line-height: 4.6rem;
background: #343579;
font-size: 1.6rem;
font-weight: 500;
color: #ffffff;
width: 12.8rem;
text-align: center;
cursor: pointer;
margin: 3rem auto 0;
}
.icon--shangyibu {
font-size: 2.5rem;
font-weight: bold;
color: #030303;
}
.email_last_step_content {
margin-left: 1rem;
font-size: 2.2rem;
font-family: PingFang SC;
font-weight: bold;
color: #030303;
}
.tip_content {
font-size: 1.3rem;
font-weight: bold;
color: #343579;
cursor: pointer;
}
.email_last_step_des {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 2.5rem;
margin-bottom: 1.5rem;
.sent_email_content {
font-size: 1.8rem;
font-weight: bold;
color: #a5b0c2;
}
}
}
}
</style>