动态导航

master
夜良king 2022-02-27 18:24:35 +08:00
parent 7cd64553ab
commit 32336decc6
4 changed files with 112 additions and 84 deletions

View File

@ -1,7 +1,7 @@
import { getCurrentPermissionList } from "@/api/index";
import lazyLoading from './lazyLoading.js';
import Cookies from "js-cookie";
import { result } from './routerJson.js';
import { getCurrentPermissionList } from "@/api/index";
const config = require('@/config/index')
@ -327,55 +327,40 @@ util.initRouter = function (vm) { // 初始化路由
return;
}
if (!vm.$store.state.app.added) {
// 加载菜单
getCurrentPermissionList().then(res => {
if (!res.success) return false;
let menuData = result;
// 格式化数据,设置 空children 为 null
for (let i = 0; i < menuData.length; i++) {
let t = menuData[i].children;
for (let k = 0; k < t.length; k++) {
let tt = t[k].children;
for (let z = 0; z < tt.length; z++) {
tt[z].children = null;
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name;
}
if (!res.success) return false;
let menuData = res.result;
// 格式化数据,设置 空children 为 null
for (let i = 0; i < menuData.length; i++) {
let t = menuData[i].children
for (let k = 0; k < t.length; k++) {
let tt = t[k].children;
for (let z = 0; z < tt.length; z++) {
tt[z].children = null
// 给所有三级路由添加字段显示一级菜单name方便点击页签时的选中筛选
tt[z].firstRouterName = menuData[i].name
}
}
}
}
if (!menuData) {
return;
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit(
"updateAppRouter",
constRoutes.filter(item => item.children.length > 0)
);
// 添加全局路由
vm.$store.commit("updateDefaultRouter", otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem("menuData", JSON.stringify(menuData));
vm.$store.commit("setAdded", true);
});
} else {
// 读取缓存数据
let data = window.localStorage.getItem('menuData');
if (!data) {
vm.$store.commit('setAdded', false);
return;
}
let menuData = JSON.parse(data);
// 添加菜单路由
util.initMenuData(vm, menuData);
}
if (!menuData) {
return;
}
util.initAllMenuData(constRoutes, menuData);
util.initRouterNode(otherRoutes, otherRouter);
// 添加所有主界面路由
vm.$store.commit('updateAppRouter', constRoutes.filter(item => item.children.length > 0));
// 添加全局路由
vm.$store.commit('updateDefaultRouter', otherRoutes);
// 添加菜单路由
util.initMenuData(vm, menuData);
// 缓存数据 修改加载标识
window.localStorage.setItem('menuData', JSON.stringify(menuData));
vm.$store.commit('setAdded', true);
})
};
// 添加所有顶部导航栏下的菜单路由
@ -384,7 +369,6 @@ util.initAllMenuData = function (constRoutes, data) {
let allMenuData = [];
data.forEach(e => {
if (e.level == 0) {
console.log(e)
e.children.forEach(item => {
allMenuData.push(item);
})
@ -454,7 +438,6 @@ util.initRouterNode = function (routers, data) { // data为所有子菜单数
for (var item of data) {
let menu = Object.assign({}, item);
menu.component = lazyLoading(menu.frontRoute);
console.log(menu.component);
if (item.children && item.children.length > 0) {
menu.children = [];
util.initRouterNode(menu.children, item.children);

View File

@ -2,38 +2,66 @@
<div class="login" @click="$refs.verify.show = false">
<Row type="flex" @keydown.enter.native="submitLogin">
<Col style="width: 368px">
<Header />
<Row style="flex-direction: column;">
<Form ref="usernameLoginForm" :model="form" :rules="rules" class="form">
<FormItem prop="username">
<Input v-model="form.username" prefix="ios-contact" size="large" clearable placeholder="请输入用户名"
autocomplete="off" />
</FormItem>
<FormItem prop="password">
<Input type="password" v-model="form.password" prefix="ios-lock" size="large" password placeholder="请输入密码"
autocomplete="off" />
</FormItem>
</Form>
<Header />
<Row style="flex-direction: column">
<Form
ref="usernameLoginForm"
:model="form"
:rules="rules"
class="form"
>
<FormItem prop="username">
<Input
v-model="form.username"
prefix="ios-contact"
size="large"
clearable
placeholder="请输入用户名"
autocomplete="off"
/>
</FormItem>
<FormItem prop="password">
<Input
type="password"
v-model="form.password"
prefix="ios-lock"
size="large"
password
placeholder="请输入密码"
autocomplete="off"
/>
</FormItem>
</Form>
<Row>
<div class="login-btn" type="primary" size="large" :loading="loading" @click="submitLogin" long>
<span v-if="!loading"></span>
<span v-else></span>
</div>
<Row>
<div
class="login-btn"
type="primary"
size="large"
:loading="loading"
@click="submitLogin"
long
>
<span v-if="!loading"></span>
<span v-else></span>
</div>
</Row>
</Row>
</Row>
<Footer />
<!-- 拼图验证码 -->
<verify ref="verify" class="verify-con" verifyType="LOGIN" @change="verifyChange"></verify>
<Footer />
<!-- 拼图验证码 -->
<verify
ref="verify"
class="verify-con"
verifyType="LOGIN"
@change="verifyChange"
></verify>
</Col>
</Row>
</div>
</template>
<script>
import { getCurrentPermissionList } from "@/api/index";
import { login, userMsg } from "@/api/index";
import { validateMobile } from "@/libs/validate";
import Cookies from "js-cookie";
@ -95,6 +123,10 @@ export default {
},
};
},
created() {
window.localStorage.setItem("menuData", "");
},
methods: {
afterLogin(res) {
let accessToken = res.result.accessToken;
@ -104,6 +136,10 @@ export default {
//
userMsg().then((res) => {
if (res.success) {
// location.reload();
// this.$router.go(0);
console.log("Huoqu ");
this.setStore("saveLogin", this.saveLogin);
if (this.saveLogin) {
// 7
@ -113,9 +149,10 @@ export default {
} else {
Cookies.set("userInfoSeller", JSON.stringify(res.result));
}
util.initRouter(this);
this.$store.commit("setAvatarPath", res.result.storeLogo);
//
util.initRouter(this);
this.$router.push({
name: "home_index",
});
@ -139,8 +176,8 @@ export default {
this.loading = true;
let fd = new FormData();
fd.append('username',this.form.username)
fd.append('password',this.md5(this.form.password))
fd.append("username", this.form.username);
fd.append("password", this.md5(this.form.password));
login(fd)
.then((res) => {
this.loading = false;
@ -157,7 +194,6 @@ export default {
};
</script>
<style lang="scss" scoped>
.login {
height: 100%;
background: url("../assets/background.png") no-repeat;
@ -167,7 +203,6 @@ export default {
display: flex;
align-items: center;
justify-content: center;
.verify-con {
position: absolute;
@ -194,9 +229,8 @@ export default {
transition: 0.35s;
}
.login-btn:hover {
opacity: .9;
opacity: 0.9;
border-radius: 10px;
}
}
</style>

View File

@ -263,7 +263,6 @@
this.loading = false;
if (res.success) {
this.data = res.result.records;
this.total = res.result.total;
}
});

View File

@ -110,7 +110,7 @@
<Form ref="form" :model="form" :label-width="80" :rules="formValidate">
<FormItem label="手机号" prop="mobile">
<Input placeholder="请输入要添加的会员手机号码" maxlength="11" style="width: 75%" v-model="form.mobile"
autocomplete="off"/>
autocomplete="off" @on-change="checkClerks"/>
&nbsp;<Button v-if="!memberCheck" @click="checkClerk"></Button>
<Button v-if="memberCheck" @click="checkAgainClerk"></Button>
</FormItem>
@ -180,6 +180,7 @@ export default {
},
data() {
return {
open:0,
loading: true, //
selectCount: 0, //
selectList: [], //
@ -197,7 +198,7 @@ export default {
modalTitle: "", // modal
form: { //
username: "",
mobile: "",
mobile: 0,
sex: "",
isSuper: 0,
roles: [],
@ -448,6 +449,16 @@ export default {
init() {
this.getUserList();
},
checkClerks() {
this.open = this.form.mobile.length;
console.log(this.open)
if(this.open == 11 ){
this.checkClerk();
}
if(this.open < 11){
this.checkAgainClerk()
}
},
//
handleSelectDepTree(v) {
if (v) {
@ -626,6 +637,7 @@ export default {
},
//
add() {
// this.checkClerks();
this.modalType = 0;
this.modalTitle = "添加店员";
this.$refs.form.resetFields();
@ -637,7 +649,7 @@ export default {
departmentId: "",
departmentTitle: ""
},
this.oldMember = false
this.oldMember = false
this.newMember = false
this.userModalVisible = true;
},