Browse Source

init

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


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

@@ -95,7 +95,7 @@ export default {
}, },
openMenu(item = {}) { openMenu(item = {}) {
this.$store.dispatch("GetMenu", {type: true, id: item.id}).then(data => { this.$store.dispatch("GetMenu", {type: true, id: item.id}).then(data => {
// console.log(data,'这里是data');
console.log(data,'这里是data');
if (data.length !== 0) { if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true); 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) { formatRoutes: function(aMenu = [], first) {
const aRouter = [] const aRouter = []
// console.log(aMenu,first,'这里是动态路由');
// 通过接口获取路由地址 aMenu 和 first
// 定义基础配置
// 菜单的基础属性 包括label 标题 path 地址 icon 和子集
const propsConfig = this.$website.menu.props const propsConfig = this.$website.menu.props
// 获取默认配置

const propsDefault = { const propsDefault = {
label: propsConfig.label || 'label', label: propsConfig.label || 'label',
path: propsConfig.path || 'path', path: propsConfig.path || 'path',
@@ -70,33 +76,51 @@ RouterPlugin.install = function(router, store) {
children: propsConfig.children || 'children', children: propsConfig.children || 'children',
meta: propsConfig.meta || 'meta' meta: propsConfig.meta || 'meta'
} }
// console.log(propsConfig,propsDefault,'参数一');
console.log(this.routerList,'123');
// 当路由地址为空时返回
if (aMenu.length === 0) return if (aMenu.length === 0) return
// 循环地址数组
for (let i = 0; i < aMenu.length; i++) { for (let i = 0; i < aMenu.length; i++) {
const oMenu = aMenu[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 = (() => { const path = (() => {
// 此为获得的路由地址
console.log(oMenu[propsDefault.path]);
if (!oMenu[propsDefault.path]) { if (!oMenu[propsDefault.path]) {
// 如果没有返回
return return
} else if (first) { } else if (first) {
// 当他为 first 也就是true 的时候 返回替换过的路径,将index替换为''
return oMenu[propsDefault.path].replace('/index', '') return oMenu[propsDefault.path].replace('/index', '')
} else { } else {
// 如果为false 的时候 直接返回路由地址
return oMenu[propsDefault.path] return oMenu[propsDefault.path]
} }
})() })()


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


const Router = createRouter() const Router = createRouter()
console.log(Router,'路由');
AvueRouter.install(Router, Store) AvueRouter.install(Router, Store)
Router.$avueRouter.formatRoutes(Store.state.user.menu, true) 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/ * https://cli.vuejs.org/zh/config/
*/ */
// const url = 'http://pigx-gateway' // 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.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://192.168.31.100:9999' //王笑
// const url = 'http://nitu5e.natappfree.cc' //王笑 // const url = 'http://nitu5e.natappfree.cc' //王笑




Loading…
Cancel
Save