Browse Source

init

newStyle
lancer 2 years ago
parent
commit
ffeb0a8e33
5 changed files with 63 additions and 19 deletions
  1. +20
    -10
      src/page/check/chose.vue
  2. +1
    -1
      src/page/index/index.vue
  3. +38
    -5
      src/router/avue-router.js
  4. +2
    -1
      src/router/router.js
  5. +2
    -2
      vue.config.js

+ 20
- 10
src/page/check/chose.vue View File

@@ -42,7 +42,7 @@
>{{ item.residueTime > 0 ? "服务中" : "已过期" }}</span
>
</div>
<div class="text-3">{{ item.address }}</div>
<div class="text-3">{{ item.address|| "暂无" }}</div>
</div>
</div>
</div>
@@ -170,7 +170,7 @@
>{{ item.residueTime > 0 ? "服务中" : "已过期" }}</span
>
</div>
<div class="text-3">{{ item.address }}</div>
<div class="text-3">{{ item.address|| "暂无" }}</div>
</div>
</div>
</div>
@@ -387,15 +387,25 @@ export default {
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.currentPage = val;
// if (this.flag == 1) {
// // 获取代理商
// this.getAgentList();
// } else if (this.flag == 2) {
// // 获取公司
// this.getCompanyList();
// } else {
// // 获取楼盘
// }
if (this.flag == 1) {
// 获取代理商
this.getAgentList();
} else if (this.flag == 2) {
// 获取公司
this.getCompanyList();
} else {
// 获取楼盘
}
// 获取代理商
// return
this.getAgentList();
} else if (this.flag == 2) {
// 获取公司
this.getCompanyList();
} else {
this.findByUserName();
}
},
locationsChange(e) {
console.log(e);


+ 1
- 1
src/page/index/index.vue View File

@@ -95,7 +95,7 @@ export default {
},
openMenu(item = {}) {
this.$store.dispatch("GetMenu", {type: true, id: item.id}).then(data => {
// console.log(data,'这里是data');
console.log(data,'这里是data');
if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true);
}


+ 38
- 5
src/router/avue-router.js View File

@@ -62,7 +62,13 @@ RouterPlugin.install = function(router, store) {
// 动态路由
formatRoutes: function(aMenu = [], first) {
const aRouter = []
// console.log(aMenu,first,'这里是动态路由');
// 通过接口获取路由地址 aMenu 和 first
// 定义基础配置
// 菜单的基础属性 包括label 标题 path 地址 icon 和子集
const propsConfig = this.$website.menu.props
// 获取默认配置

const propsDefault = {
label: propsConfig.label || 'label',
path: propsConfig.path || 'path',
@@ -70,33 +76,51 @@ RouterPlugin.install = function(router, store) {
children: propsConfig.children || 'children',
meta: propsConfig.meta || 'meta'
}
// console.log(propsConfig,propsDefault,'参数一');
console.log(this.routerList,'123');
// 当路由地址为空时返回
if (aMenu.length === 0) return
// 循环地址数组
for (let i = 0; i < aMenu.length; i++) {
const oMenu = aMenu[i]
if (this.routerList.includes(oMenu[propsDefault.path])) return
console.log(oMenu[propsDefault.path],'这里是地址');
// 在这里时还可以进行下一步,但是this.routerList[]值不知何处取得
console.log(this.routerList.includes(oMenu[propsDefault.path]));
// 判断路由地址的是否包括routerList[building] 如果没有则返回 为去重操作?
// if (this.routerList.includes(oMenu[propsDefault.path])) return
// console.log(3);
// 定义地址
const path = (() => {
// 此为获得的路由地址
console.log(oMenu[propsDefault.path]);
if (!oMenu[propsDefault.path]) {
// 如果没有返回
return
} else if (first) {
// 当他为 first 也就是true 的时候 返回替换过的路径,将index替换为''
return oMenu[propsDefault.path].replace('/index', '')
} else {
// 如果为false 的时候 直接返回路由地址
return oMenu[propsDefault.path]
}
})()

//特殊处理组件
// 定义子组件名称为 views 加上地址
const component = 'views' + oMenu.path
// 设置名称
const name = oMenu[propsDefault.label]
// 设置icon
const icon = oMenu[propsDefault.icon]
// 设置子组件
const children = oMenu[propsDefault.children]
// 定义查看是否有暂存区
const meta = {
keepAlive: Number(oMenu['keepAlive']) === 1
}
// 定义他是否有子集
const isChild = children.length !== 0
// 第一一个路由地址
const oRouter = {
path: path,
component(resolve) {
@@ -116,6 +140,7 @@ RouterPlugin.install = function(router, store) {
name: name,
icon: icon,
meta: meta,
// 路由重定向
redirect: (() => {
if (!isChild && first && !isURL(path)) return `${path}/index`
else return ''
@@ -137,17 +162,25 @@ RouterPlugin.install = function(router, store) {
return this.formatRoutes(children, false)
})()
}
console.log(2);
// 将路由地址放入aRouter
aRouter.push(oRouter)
}
// 如果他为true 的时候
if (first) {
// 当他的地址不为第一个路径时
if (!this.routerList.includes(aRouter[0][propsDefault.path])) {
this.safe.$router.addRoutes(aRouter)
// 将用户地址放入routerList
this.routerList.push(aRouter[0][propsDefault.path])
}
} else {
// 如果不是则返回
return aRouter
}
console.log(aRouter,'内容');
}
}
}
console.log(RouterPlugin,'配置');
export default RouterPlugin

+ 2
- 1
src/router/router.js View File

@@ -8,7 +8,7 @@ Vue.use(VueRouter)
//创建路由
// console.log(PageRouter,ViewsRouter,'123')
// console.log(Store)
console.log(process.env.BASE_URL,123);
// console.log(process.env.BASE_URL,123);
export const createRouter = () => new VueRouter({
// mode:'history',
// base:'/wel/index',
@@ -17,6 +17,7 @@ export const createRouter = () => new VueRouter({
})

const Router = createRouter()
console.log(Router,'路由');
AvueRouter.install(Router, Store)
Router.$avueRouter.formatRoutes(Store.state.user.menu, true)
// 重置路由


+ 2
- 2
vue.config.js View File

@@ -3,9 +3,9 @@
* https://cli.vuejs.org/zh/config/
*/
// const url = 'http://pigx-gateway'
// const url = 'http://39.97.167.65:9999' //测试
const url = 'http://39.97.167.65:9999' //测试
// const url = 'http://192.168.31.169:9999' //长龙
const url = 'http://192.168.31.134:9999' //嘉豪
// const url = 'http://192.168.31.134:9999' //嘉豪
// const url = 'http://192.168.31.100:9999' //王笑
// const url = 'http://nitu5e.natappfree.cc' //王笑



Loading…
Cancel
Save