From a9654112b19a6c060aab089cf0b4609dc396bfbe Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Tue, 15 Apr 2025 14:32:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=8E=A5=E5=8F=A3=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E9=A6=96=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.js | 34 ++++ src/assets/image/home/exit.png | Bin 0 -> 551 bytes src/assets/image/home/sunny.png | Bin 0 -> 786 bytes src/assets/image/home/temperature.png | Bin 0 -> 875 bytes src/router/index.js | 6 +- src/store/modules/user.js | 71 ++++---- .../home-video/components/left-one-model.vue | 4 +- src/views/home/index.vue | 84 ++++++++-- src/views/index.vue | 2 +- src/views/login/index.vue | 154 ++++++++++++++---- vue.config.js | 5 +- 11 files changed, 264 insertions(+), 96 deletions(-) create mode 100644 src/api/login.js create mode 100644 src/assets/image/home/exit.png create mode 100644 src/assets/image/home/sunny.png create mode 100644 src/assets/image/home/temperature.png diff --git a/src/api/login.js b/src/api/login.js new file mode 100644 index 0000000..8774cc7 --- /dev/null +++ b/src/api/login.js @@ -0,0 +1,34 @@ +import request from '@/utils/request' + +// 登录方法 +export function login(data) { + return request({ + url: '/auth/login', + headers: { + isToken: false, + repeatSubmit: false, + }, + method: 'post', + data: data, + }) +} + +export function isAdmin(data) { + return request({ + url: '/auth/isAdmin', + headers: { + isToken: false, + repeatSubmit: false, + }, + method: 'post', + data: data, + }) +} + +// 退出方法 +export function logout() { + return request({ + url: '/auth/logout', + method: 'post', + }) +} diff --git a/src/assets/image/home/exit.png b/src/assets/image/home/exit.png new file mode 100644 index 0000000000000000000000000000000000000000..5eef3427135667e7c5cf463ba45c8387c8d51fdb GIT binary patch literal 551 zcmV+?0@(eDP)K~#7Fv+6$`ND2I^#6Sg50#x7y3t+8)wE{y0Vg(R^_@~eTCGcaSiD5jmEYIb!yPtZJ z&D`8Och1btJp=qJG={47rMcrBI&dGFLqZ($-Am9IXn;>VBO!#oZlHc5f`&N??nF^= zBQ4+rBAOlelgB#A^2j$bj zw@848FouUG*IW0*+sa;%=QnL%%Og@EC`v%n=a-WURAK~NRH8C`WQB*W8UC{BdMkoj z_KU*_GJ&r}%%%N3q`mUzHj*hlQMQ|%!O5PNiW0}1qm6(tD+8zF8e>3|9-ySqa+M@9M$YaVh zd{#GEYQ(*1oE^s8ihmKeuHV>i~pcg?9-vk|;0n!T{etEgM``;Jcv$B4W$ROW1; pM9p%bi literal 0 HcmV?d00001 diff --git a/src/assets/image/home/sunny.png b/src/assets/image/home/sunny.png new file mode 100644 index 0000000000000000000000000000000000000000..970a90d46b1761e0f39d4bcd1228908406084aea GIT binary patch literal 786 zcmV+t1MU2YP)_b?T71}P{VmxhSW<^^z4QQk!Y zrF4XlV&Cr0Ftc}#VmoKq1yV*@-QCX2_wD@b9KdZ7v~Nk)GCsjF#$*wel^KG|!G0*u zO0}I%>(DqTJ3g`B@CH9M4Sol(D42Jt0>jo*PD+R>*QzB?rR^NXT8#5a1 z1S;rIMp30U8MT^svdd&QM2%g34TY<)XC9>_9ZZz+YD|MpL^qGXIn(8og_1TjsK}tC zP&s4e8_?NDh^9N}w^o)W`17;XVvtZkr9CCTXr(^fsuqc?CCre?FbwX(-qHkUX^)(v z99&5FT~2NDXnaJh!_0xRu3m=Yi+s_4g`80(S*|`g@O2?$*CEKlG#)bZw31SY?=vQtoyJUyx^&~rkr^R>vORj)OVC%E_YaHgBc zVUOMG9Byk)#mU2$$Lp|w{QmO1&$U?7N+lz3&06#=9qT5G%#)BbhYyfCR1qvFdgLOf zq3iz^sOB3dhg)INsfRb|&OUF_*}*0)>$k8ZohGFpoB!{h3=V007jBLG0||(zPpHOj Q;Q#;t07*qoM6N<$f;aPNod5s; literal 0 HcmV?d00001 diff --git a/src/assets/image/home/temperature.png b/src/assets/image/home/temperature.png new file mode 100644 index 0000000000000000000000000000000000000000..4ae2f5b5b9945af518588a4fe2e11a887c6ed4a5 GIT binary patch literal 875 zcmV-x1C;!UP)+p@q!bHdqu7`P1+noGo0MKaQLs2|ENo(G z!CY#KyDKySi>x3dcRT-o|IFScDK2}L+`t?=J2UUid;ibBMd+c;eEk<@V4x@#8!y!8<_^Pxr=#r{3Ng{Fb)ggD#CkibMj2p@QJ$ZC3@G zF^lrxn{NA472GK|!;D88YK;Kn*oQ)5$xK|jflFI~<`8OhvS}Dc>YG^E3Sxt0qfWGdm5^+A zbQ+7lE&&*pCRUQbAB%v*Ut{5{2D7R?=ibr23fKjcW8%6o9FW9oVX>O+nIL?6u*;1lC-#YP0<*u$j z3+h>&G7xF~nba7~DQ*Dvt|KmPFN`cguL|1jtdamj(GA2=wIVO=t&xU&;m`BY<)bjV zepO^2R|D{QUKNZhNiHFS8lYDK+FOlYUaqC>{|~lK_F6EOoQMDb002ovPDHLkV1m^T BkHY`} literal 0 HcmV?d00001 diff --git a/src/router/index.js b/src/router/index.js index e8ce695..00cdbc8 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -4,14 +4,10 @@ import VueRouter from 'vue-router' Vue.use(VueRouter) const routes = [ - // { - // path: '/demo', - // name: 'index', - // component: () => import('../views/index.vue'), - // }, { path: '/', name: 'index', + redirect: '/login', component: () => import('../views/index.vue'), }, { diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 92a009f..21f85c3 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -1,5 +1,5 @@ -// import { login, logout } from '@/api/login' -import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth' +import { login, isAdmin, logout } from '@/api/login' +import { getToken, setToken, removeToken } from '@/utils/auth' // import { encrypt } from '@/utils/jsencrypt' @@ -16,50 +16,37 @@ const user = { actions: { // 登录 - async Login({ commit }, userInfo) { - // const username = userInfo.username.trim() - // const password = encrypt(userInfo.password) - // // const password = userInfo.password - // const code = userInfo.code - // const uuid = userInfo.uuid - // const textCode = userInfo.textCode - // return new Promise((resolve, reject) => { - // login(username, password, code, uuid, textCode) - // .then((res) => { - // let data = res.data - // localStorage.setItem( - // 'isCode', - // data.login_user.forceChangePwd || '', - // ) - // setToken(data.access_token) - // commit('SET_TOKEN', data.access_token) - // localStorage.setItem('token', data.access_token) - // setExpiresIn(data.expires_in) - // commit('SET_EXPIRES_IN', data.expires_in) - // resolve() - // }) - // .catch((error) => { - // reject(error) - // }) - // }) + Login({ commit }, userInfo) { + return login(userInfo) + .then((res) => { + const { access_token } = res.data + setToken(access_token) + commit('SET_TOKEN', access_token) + return res + }) + .catch((error) => Promise.reject(error)) + }, + + IsAdmin({ commit }, userInfo) { + console.log(commit) + return isAdmin(userInfo) + .then((res) => res) + .catch((error) => Promise.reject(error)) }, // 退出系统 LogOut({ commit, state }) { - // return new Promise((resolve, reject) => { - // logout(state.token) - // .then(() => { - // commit('SET_TOKEN', '') - // commit('SET_ROLES', []) - // commit('SET_PERMISSIONS', []) - // removeToken() - // localStorage.removeItem('isCode') - // resolve() - // }) - // .catch((error) => { - // reject(error) - // }) - // }) + return new Promise((resolve, reject) => { + logout(state.token) + .then(() => { + commit('SET_TOKEN', '') + removeToken() + resolve() + }) + .catch((error) => { + reject(error) + }) + }) }, }, } diff --git a/src/views/home-video/components/left-one-model.vue b/src/views/home-video/components/left-one-model.vue index 04e1988..ecc5dc5 100644 --- a/src/views/home-video/components/left-one-model.vue +++ b/src/views/home-video/components/left-one-model.vue @@ -100,7 +100,7 @@ export default { background-size: 100% 100%; transform: scale(1.5); position: relative; - z-index: 9999; + z-index: 9; div { width: 14px; @@ -147,7 +147,7 @@ export default { align-items: center; justify-content: space-around; font-size: 16px; - z-index: 9999; + z-index: 9; div { display: flex; diff --git a/src/views/home/index.vue b/src/views/home/index.vue index f161faa..76665d5 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -20,17 +20,19 @@
智慧工地
-
- -
- - {{ dateYear }} - {{ dateWeek }} - - {{ dateDay }} - - -
+
+ 今天天气 + + + + + 16 ~ 30℃ + +
@@ -297,6 +299,21 @@ export default { this.navShow = false } }, + + // 退出登录 + async onHandleLogout() { + this.$confirm('确定退出系统吗?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then(() => { + this.$store.dispatch('LogOut').then(() => { + location.href = '/' + }) + }) + .catch(() => {}) + }, }, } @@ -328,14 +345,18 @@ export default { height: 83px; background: url('../../assets/image/home/title_bg.png') no-repeat; background-size: 100% 100%; - display: flex; - justify-content: center; - align-items: center; + position: relative; + // display: flex; + // justify-content: center; + // align-items: center; background-color: #031837; .title-name { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); padding-bottom: 24px; - margin: 0 17%; font-size: 28px; color: #fff; letter-spacing: 4px; @@ -343,6 +364,10 @@ export default { } & .time-box { + position: absolute; + top: 50%; + left: 12%; + transform: translateY(-50%); color: #fff; display: flex; align-items: center; @@ -357,6 +382,35 @@ export default { display: inline-block; } } + + .weather-box { + position: absolute; + top: 50%; + right: 12%; + transform: translateY(-50%); + color: #fff; + display: flex; + align-items: center; + + img { + width: 20px; + height: 20px; + } + + & span:first-child { + margin-right: 18px; + } + & span:nth-child(3) { + margin: 0 18px; + } + & span:nth-child(5) { + margin: 0 18px; + } + & img:nth-child(6) { + transform: translateX(160px); + cursor: pointer; + } + } } .content { diff --git a/src/views/index.vue b/src/views/index.vue index fde2750..1a0c10f 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -3,7 +3,7 @@ export default { created() { // const { params, query } = this.$route // const { path } = params - this.$router.replace({ path: '/login' }) + this.$router.replace({ path: `${this.$router.options.base}/login` }) }, render: function (h) { return h() // avoid warning message diff --git a/src/views/login/index.vue b/src/views/login/index.vue index fa3b9e3..b30d4a7 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -3,17 +3,16 @@