Commit ccce3f01 authored by leidahong's avatar leidahong

登录

parent 07db4c1f
......@@ -18,13 +18,13 @@ const router = createRouter({
});
// 路由守卫
// router.beforeEach((to, from, next) => {
// if (to.path === "/login") {
// next();
// } else {
// const token = getToken();
// if (token) next();
// else next("/login");
// }
// });
router.beforeEach((to, from, next) => {
const token = getToken();
if (to.path === "/login") {
if (token) next("/");
else next();
} else {
next();
}
});
export { router };
......@@ -33,15 +33,17 @@ export function drawLabel(
backgroundColor: Cesium.Color.fromCssColorString(backgroundColor),
backgroundPadding: new Cesium.Cartesian2(10, 8),
font: "18px sans-serif",
pixelOffset: new Cesium.Cartesian2(0, -75),
pixelOffset: new Cesium.Cartesian2(0, imgName ? -75 : -25),
...labelOptions,
},
billboard: {
billboard: imgName
? {
image: new URL(`../assets/imgs/${imgName}.png`, import.meta.url).href, // 图标图片的路径
width: 40,
height: 50,
pixelOffset: new Cesium.Cartesian2(0, -25),
},
}
: null,
});
}
export function drawPolygonLine(position, color = "#37b9ff", withAlpha = 1) {
......
......@@ -15,7 +15,7 @@ const service = axios.create({
service.interceptors.request.use(
(config) => {
config.headers["Authorization"] = "Bearer " + getToken();
config.headers["Authorization"] = getToken() ? "Bearer " + getToken() : "";
return config;
},
(error) => {
......@@ -31,6 +31,7 @@ service.interceptors.response.use(
if (code === 401 || code === 403) {
if (!isRelogin.show) {
isRelogin.show = true;
removeToken();
ElMessageBox.confirm(
"登录状态已过期,您可以继续留在该页面,或者重新登录",
"系统提示",
......@@ -42,7 +43,6 @@ service.interceptors.response.use(
)
.then(() => {
isRelogin.show = false;
router.push("/login");
})
.catch(() => {
......
......@@ -2,37 +2,51 @@
<div class="screen" id="screen">
<top-header></top-header>
<div class="title"></div>
<el-form class="form" ref="formRef" :model="loginForm" :rules="loginRules" @keyup.enter.native="submitForm(formRef)">
<el-form
class="form"
ref="formRef"
:model="loginForm"
:rules="loginRules"
@keyup.enter.native="submitForm(formRef)"
>
<el-form-item label="" prop="username">
<el-input v-model="loginForm.username" placeholder="请输入账号">
<template #prefix>
<img src="@/assets/imgs/user_icon.png" alt="">
<img src="@/assets/imgs/user_icon.png" alt="" />
</template>
</el-input>
</el-form-item>
<el-form-item label="" prop="password">
<el-input v-model="loginForm.password" placeholder="请输入密码" type="password">
<el-input
v-model="loginForm.password"
placeholder="请输入密码"
type="password"
>
<template #prefix>
<img src="@/assets/imgs/password_icon.png" alt="">
<img src="@/assets/imgs/password_icon.png" alt="" />
</template>
</el-input>
</el-form-item>
<el-form-item prop="code" v-if="captchaEnabled">
<el-input v-model="loginForm.code" auto-complete="off" style="width:266px;" placeholder="验证码">
<el-input
v-model="loginForm.code"
auto-complete="off"
style="width: 266px"
placeholder="验证码"
>
<template #prefix>
<img src="@/assets/imgs/yzm_icon.png" alt="">
<img src="@/assets/imgs/yzm_icon.png" alt="" />
</template>
</el-input>
<div class="login-code">
<img :src="codeUrl" @click="getCode" class="login-code-img" />
</div>
</el-form-item>
<el-button type="primary" @click="submitForm(formRef)">登录{{ $store.state.count }}</el-button>
<el-button type="primary" @click="submitForm(formRef)"
>登录{{ $store.state.count }}</el-button
>
</el-form>
</div>
</template>
......@@ -42,11 +56,11 @@ import topHeader from "@/components/header.vue";
import { setToken } from "@/utils/auth";
import { getCodeImg, login, getUserType } from "@/api/user";
import { useRouter } from "vue-router";
import { useStore } from 'vuex'
const store = useStore()
import { useStore } from "vuex";
const store = useStore();
const loginForm = reactive({
username: "cbht",
password: "xcsq1234,",
username: "",
password: "",
code: "",
uuid: "",
rememberMe: false,
......
......@@ -41,6 +41,12 @@ watch(currentCommunityInfo, (val) => {
console.log("currentCommunityInfo", val);
let position = JSON.parse(val.solid);
flyTo({ longitude: position.x, latitude: position.y });
const removeArr = [];
viewer.entities.values.forEach((item) => {
if (item._data && item._data.type === "house") removeArr.push(item);
});
removeArr.forEach((item) => viewer.entities.remove(item));
getHouseListFunc(val.id);
});
function communityChangeHandle(index) {
......@@ -84,6 +90,7 @@ function getUserTypeInfo() {
// 获取小区列表
function getHouseListFunc(communityId) {
getHouseList(communityId).then((res) => {
console.log("getHouseList", res.data);
drawHouseMarker(res.data);
getHouseInfoFunc(res.data[0].id);
});
......@@ -114,14 +121,18 @@ function getHouseInfoFunc(houseId) {
currentHouseInfo.value = res.data;
let { solid, coordinates } = currentHouseInfo.value;
drawLabel(
JSON.parse(solid),
currentHouseInfo.value.name,
"#003860",
"blue_dw_icon"
);
// drawLabel(
// JSON.parse(solid),
// currentHouseInfo.value.name,
// "#003860",
// "blue_dw_icon"
// );
if (res.data.remark) {
JSON.parse(res.data.remark).forEach((item) => {
drawLabel(JSON.parse(item.solid), item.name, "#003860", null, item);
});
}
// drawPolygonLine(JSON.parse(coordinates));
flyTo(cartesianToDegrees(JSON.parse(solid)));
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment