Commit ccce3f01 authored by leidahong's avatar leidahong

登录

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