Browse Source

修正菜单样式

孙旺 2 years ago
parent
commit
d720e7644e

+ 44 - 11
src/pages/globalPages/components/account.vue

@@ -5,7 +5,7 @@
 		</view>
 		<view class="content" v-if="list&&list.length>0">
 			<block v-for="item in list" :key="item.id">
-				<view class="menu-list">
+				<view class="menu-list" v-if="item.type==1">
 					<view class="menu-list-title">
 						{{item.meta.title}}
 					</view>
@@ -13,7 +13,8 @@
 						<block v-for="item1 in item.children" :key="item1.id">
 							<view class="menu-item flex flex-direction align-center" @click="clickMenu(item1)">
 								<view class="menu-img">
-									<xy-svg width="60" height="60" :url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item1.meta.icon}.svg`"></xy-svg>
+									<xy-svg width="60" height="60"
+										:url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item1.meta.icon}.svg`"></xy-svg>
 								</view>
 								<view class="menu-name">
 									{{item1.meta.title}}
@@ -22,6 +23,17 @@
 						</block>
 					</view>
 				</view>
+				<view class="menu-list menu-list-notitle flex flex-wrap justify-start" v-if="item.type==2">
+					<view class="menu-item flex flex-direction align-center" @click="clickMenu(item)">
+						<view class="menu-img">
+							<xy-svg width="60" height="60"
+								:url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item.meta.icon}.svg`"></xy-svg>
+						</view>
+						<view class="menu-name">
+							{{item.meta.title}}
+						</view>
+					</view>
+				</view>
 			</block>
 		</view>
 		<view class="empty" v-else>
@@ -67,14 +79,14 @@
 		return tempList
 	})
 
-  /**
-   * 点击菜单
-   */
-  function clickMenu (item) {
-    console.log("888********",`/pages${item.path}`)
+	/**
+	 * 点击菜单
+	 */
+	function clickMenu(item) {
+		console.log("888********", `/pages${item.path}`)
 
-    proxy.$tab.navigateTo(`/pages${item.path}`)
-  }
+		proxy.$tab.navigateTo(`/pages${item.path}`)
+	}
 </script>
 
 <style lang="scss" scoped>
@@ -87,6 +99,27 @@
 				background-color: #fff;
 				border-radius: 8rpx;
 
+				&.menu-list-notitle {
+					padding-top: 24rpx;
+
+					.menu-item {
+						width: 25%;
+						text-align: center;
+						margin-bottom: 24rpx;
+
+						.menu-img {
+							width: 60rpx;
+							height: 60rpx;
+							margin-bottom: 18rpx;
+						}
+
+						.menu-name {
+							font-size: 26rpx;
+							color: #333;
+						}
+					}
+				}
+
 				.menu-list-title {
 					font-size: 30rpx;
 					font-weight: bold;
@@ -109,7 +142,7 @@
 							margin-bottom: 18rpx;
 						}
 
-						.menu-name{
+						.menu-name {
 							font-size: 26rpx;
 							color: #333;
 						}
@@ -122,4 +155,4 @@
 			margin-top: 50%;
 		}
 	}
-</style>
+</style>

+ 39 - 4
src/pages/globalPages/components/commodity.vue

@@ -5,7 +5,7 @@
 		</view>
 		<view class="content" v-if="list&&list.length>0">
 			<block v-for="item in list" :key="item.id">
-				<view class="menu-list">
+				<view class="menu-list" v-if="item.type==1">
 					<view class="menu-list-title">
 						{{item.meta.title}}
 					</view>
@@ -13,7 +13,8 @@
 						<block v-for="item1 in item.children" :key="item1.id">
 							<view class="menu-item flex flex-direction align-center">
 								<view class="menu-img">
-									<xy-svg width="60" height="60" :url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item1.meta.icon}.svg`"></xy-svg>
+									<xy-svg width="60" height="60"
+										:url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item1.meta.icon}.svg`"></xy-svg>
 								</view>
 								<view class="menu-name">
 									{{item1.meta.title}}
@@ -22,6 +23,19 @@
 						</block>
 					</view>
 				</view>
+				<view class="menu-list menu-list-notitle flex flex-wrap justify-start" v-if="item.type==2">
+					<view class="menu-item flex flex-direction align-center"
+					      @click="clickMenu(item)">
+					  <view class="menu-img">
+					    <xy-svg width="60"
+					            height="60"
+					            :url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item.meta.icon}.svg`"></xy-svg>
+					  </view>
+					  <view class="menu-name">
+					    {{item.meta.title}}
+					  </view>
+					</view>
+				</view>
 			</block>
 		</view>
 		<view class="empty" v-else>
@@ -78,6 +92,27 @@
 				background-color: #fff;
 				border-radius: 8rpx;
 
+				&.menu-list-notitle {
+					padding-top: 24rpx;
+
+					.menu-item {
+						width: 25%;
+						text-align: center;
+						margin-bottom: 24rpx;
+
+						.menu-img {
+							width: 60rpx;
+							height: 60rpx;
+							margin-bottom: 18rpx;
+						}
+
+						.menu-name {
+							font-size: 26rpx;
+							color: #333;
+						}
+					}
+				}
+
 				.menu-list-title {
 					font-size: 30rpx;
 					font-weight: bold;
@@ -99,8 +134,8 @@
 							height: 60rpx;
 							margin-bottom: 18rpx;
 						}
-						
-						.menu-name{
+
+						.menu-name {
 							font-size: 26rpx;
 							color: #333;
 						}

+ 34 - 1
src/pages/globalPages/components/equipment.vue

@@ -5,7 +5,7 @@
 		</view>
 		<view class="content" v-if="list&&list.length>0">
 			<block v-for="item in list" :key="item.id">
-				<view class="menu-list">
+				<view class="menu-list" v-if="item.type==1">
 					<view class="menu-list-title">
 						{{item.meta.title}}
 					</view>
@@ -23,6 +23,19 @@
 						</block>
 					</view>
 				</view>
+				<view class="menu-list menu-list-notitle flex flex-wrap justify-start" v-if="item.type==2">
+					<view class="menu-item flex flex-direction align-center"
+					      @click="clickMenu(item)">
+					  <view class="menu-img">
+					    <xy-svg width="60"
+					            height="60"
+					            :url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item.meta.icon}.svg`"></xy-svg>
+					  </view>
+					  <view class="menu-name">
+					    {{item.meta.title}}
+					  </view>
+					</view>
+				</view>
 			</block>
 		</view>
 		<view class="empty" v-else>
@@ -78,6 +91,26 @@
 				margin-left: 12rpx;
 				background-color: #fff;
 				border-radius: 8rpx;
+				
+				&.menu-list-notitle{
+						  padding-top:24rpx;
+						  .menu-item {
+						    width: 25%;
+						    text-align: center;
+						    margin-bottom: 24rpx;
+						  
+						    .menu-img {
+						      width: 60rpx;
+						      height: 60rpx;
+						      margin-bottom: 18rpx;
+						    }
+						  
+						    .menu-name {
+						      font-size: 26rpx;
+						      color: #333;
+						    }
+						  }
+				}
 
 				.menu-list-title {
 					font-size: 30rpx;

+ 36 - 1
src/pages/globalPages/components/home.vue

@@ -8,7 +8,7 @@
 
       <block v-for="item in list"
              :key="item.id">
-        <view class="menu-list">
+        <view class="menu-list" v-if="item.type==1">
           <view class="menu-list-title">
             {{item.meta.title}}
           </view>
@@ -29,6 +29,19 @@
             </block>
           </view>
         </view>
+		<view class="menu-list menu-list-notitle flex flex-wrap justify-start" v-if="item.type==2">
+			<view class="menu-item flex flex-direction align-center"
+			      @click="clickMenu(item)">
+			  <view class="menu-img">
+			    <xy-svg width="60"
+			            height="60"
+			            :url="`https://cdn.ossfile.mxrvending.com/assets/xy_mana_mini/images/icons/svg/${item.meta.icon}.svg`"></xy-svg>
+			  </view>
+			  <view class="menu-name">
+			    {{item.meta.title}}
+			  </view>
+			</view>
+		</view>
       </block>
     </view>
     <view class="empty"
@@ -94,6 +107,26 @@ function clickMenu (item) {
       margin-left: 12rpx;
       background-color: #fff;
       border-radius: 8rpx;
+	  
+	  &.menu-list-notitle{
+		  padding-top:24rpx;
+		  .menu-item {
+		    width: 25%;
+		    text-align: center;
+		    margin-bottom: 24rpx;
+		  
+		    .menu-img {
+		      width: 60rpx;
+		      height: 60rpx;
+		      margin-bottom: 18rpx;
+		    }
+		  
+		    .menu-name {
+		      font-size: 26rpx;
+		      color: #333;
+		    }
+		  }
+	  }
 
       .menu-list-title {
         font-size: 30rpx;
@@ -124,6 +157,8 @@ function clickMenu (item) {
         }
       }
     }
+	
+	
   }
 
   .empty {

+ 197 - 191
src/stores/permission.js

@@ -1,222 +1,228 @@
-import { defineStore } from 'pinia'
+import {
+	defineStore
+} from 'pinia'
 import storage from '@/utils/storage'
 import constant from '@/utils/constant'
 import request from '../utils/request.js'
-import { deepClone } from '@/utils/common.js'
+import {
+	deepClone
+} from '@/utils/common.js'
 
 const usePermissionStore = defineStore('permission', {
-  state: () => ({
-    permissions_menu: storage.get(constant.permissions_menu),
-    permissions_btn: storage.get(constant.permissions_btn),
-  }),
-  actions: {
-    // 获取用户权限信息
-    GetPermis() {
-      return new Promise(async (resolve, reject) => {
-        let sysIds = await getSystemMenus()
-        if (sysIds.length > 0) {
-          request({
-            url: '/authorize/sys-menu/workMenuList',
-            data: {
-              sysId: sysIds, //平台端获取固定系统ID
-            },
-          })
-            .then((res) => {
-              if (res && res.length > 0) {
-                const sdata = JSON.parse(JSON.stringify(res))
-                let assembleData = refitRouterList(sdata)
-
-                // 按钮权限集合
-                this.permissions_btn = assembleData.btn
-                storage.set(constant.permissions_btn, assembleData.btn)
-                // 菜单权限集合
-                this.permissions_menu = assembleData.tree
-                storage.set(
-                  constant.permissions_menu,
-                 this.permissions_menu
-                )
-              }
-              resolve(res)
-            })
-            .catch((error) => {
-              reject(error)
-            })
-        } else {
-          reject('没有权限')
-        }
-      })
-    },
-  },
+	state: () => ({
+		permissions_menu: storage.get(constant.permissions_menu),
+		permissions_btn: storage.get(constant.permissions_btn),
+	}),
+	actions: {
+		// 获取用户权限信息
+		GetPermis() {
+			return new Promise(async (resolve, reject) => {
+				let sysIds = await getSystemMenus()
+				if (sysIds.length > 0) {
+					request({
+							url: '/authorize/sys-menu/workMenuList',
+							data: {
+								sysId: sysIds, //平台端获取固定系统ID
+							},
+						})
+						.then((res) => {
+							if (res && res.length > 0) {
+								const sdata = JSON.parse(JSON.stringify(res))
+								let assembleData = refitRouterList(sdata)
+
+								// 按钮权限集合
+								this.permissions_btn = assembleData.btn
+								storage.set(constant.permissions_btn, assembleData.btn)
+								// 菜单权限集合
+								this.permissions_menu = assembleData.tree
+								storage.set(
+									constant.permissions_menu,
+									this.permissions_menu
+								)
+							}
+							resolve(res)
+						})
+						.catch((error) => {
+							reject(error)
+						})
+				} else {
+					reject('没有权限')
+				}
+			})
+		},
+	},
 })
 
 //获取顶部系统
 function getSystemMenus() {
-  return new Promise((resolve, reject) => {
-    request({
-      url: '/authorize/sys-system/list',
-      data: {},
-    })
-      .then((res) => {
-        console.log('getSystemMenus', res)
-        let arr = []
-        //pc固定的四个系统id,如有改动,对应调整
-        // let menuIds = [371447078143236, 374535658992901, 374535711753477, 374535878972677];
-        //pc固定的四个系统标识,如有改动,对应调整
-        let menuCodes = ['xy_system', 'xy_quality', 'xy_data', 'xy_merc_be']
-        if (res && res.length) {
-          res.forEach((i) => {
-            if (menuCodes.find((j) => j == i.code)) {
-              arr.push(i.id)
-            }
-          })
-        }
-        resolve(arr)
-      })
-      .catch((err) => {
-        reject(err)
-      })
-  })
+	return new Promise((resolve, reject) => {
+		request({
+				url: '/authorize/sys-system/list',
+				data: {},
+			})
+			.then((res) => {
+				console.log('getSystemMenus', res)
+				let arr = []
+				//pc固定的四个系统id,如有改动,对应调整
+				// let menuIds = [371447078143236, 374535658992901, 374535711753477, 374535878972677];
+				//pc固定的四个系统标识,如有改动,对应调整
+				let menuCodes = ['xy_system', 'xy_quality', 'xy_data', 'xy_merc_be']
+				if (res && res.length) {
+					res.forEach((i) => {
+						if (menuCodes.find((j) => j == i.code)) {
+							arr.push(i.id)
+						}
+					})
+				}
+				resolve(arr)
+			})
+			.catch((err) => {
+				reject(err)
+			})
+	})
 }
 
 //组装路由
 function refitRouterList(allRouterMenu) {
-  let newRouterList = new Array()
-  let btnPromission = new Array() //按钮权限
-
-  for (let index = 0; index < allRouterMenu.length; index++) {
-    const element = allRouterMenu[index]
-    //系统路由转换
-    let newSystemItem = adjustRouterList(element, true)
-    if (element.menu && element.menu.length > 0) {
-      //格式转换后的路由,同时收集按钮菜单权限
-      let newMenuList = new Array()
-      let menuList = element.menu
-      for (let index = 0; index < menuList.length; index++) {
-        const router = menuList[index]
-        let newRouterItem = adjustRouterList(router) //其他菜单路由转换
-        newMenuList.push(newRouterItem) //添加到数据待用
-        //按钮权限集合
-        if (router.type !== 1) {
-          btnPromission.push(router.code)
-        }
-      }
-      newSystemItem.children = assembleRouter(newMenuList)
-    }
-
-    newRouterList.push(newSystemItem)
-  }
-
-  return {
-    tree: newRouterList,
-    btn: btnPromission,
-  }
+	let newRouterList = new Array()
+	let btnPromission = new Array() //按钮权限
+
+	for (let index = 0; index < allRouterMenu.length; index++) {
+		const element = allRouterMenu[index]
+		//系统路由转换
+		let newSystemItem = adjustRouterList(element, true)
+		if (element.menu && element.menu.length > 0) {
+			//格式转换后的路由,同时收集按钮菜单权限
+			let newMenuList = new Array()
+			let menuList = element.menu
+			for (let index = 0; index < menuList.length; index++) {
+				const router = menuList[index]
+				let newRouterItem = adjustRouterList(router) //其他菜单路由转换
+				newMenuList.push(newRouterItem) //添加到数据待用
+				//按钮权限集合
+				if (router.type !== 1) {
+					btnPromission.push(router.code)
+				}
+			}
+			newSystemItem.children = assembleRouter(newMenuList)
+		}
+
+		newRouterList.push(newSystemItem)
+	}
+
+	return {
+		tree: newRouterList,
+		btn: btnPromission,
+	}
 }
 
 // 遍历系统模块下菜单,转化为路由组件对象
 function adjustRouterList(routerItem, isSystemMenu = false) {
-  let newRouterItem = {}
-  if (isSystemMenu) {
-    newRouterItem = {
-      id: routerItem.id,
-      name: routerItem.code,
-      hidden: false,
-      meta: {
-        title: routerItem.name,
-        icon: routerItem.icon,
-      },
-      path: '/' + routerItem.code, //路由路径
-      component: 'Layout', //组件地址
-      children: [],
-    }
-    return newRouterItem
-  }
-  newRouterItem.name = routerItem.code
-  newRouterItem.id = routerItem.id
-  newRouterItem.paterId = routerItem.paterId
-  newRouterItem.hidden = false
-  newRouterItem.meta = {
-    icon: routerItem.icon,
-    title: routerItem.name,
-  }
-
-  //根目录及其他目录处理
-  if (
-    (routerItem.paterId === null && routerItem.type != 2) ||
-    routerItem.type == 1
-  ) {
-    newRouterItem.path = '/' + routerItem.route //路由路径
-    newRouterItem.component = 'ParentView'
-  }
-
-  //菜单项处理
-  if (routerItem.type == 2) {
-    newRouterItem.path = '/' + routerItem.route //路由路径
-    newRouterItem.component = routerItem.route
-    newRouterItem.code = routerItem.code
-  }
-
-  //按钮/功能处理
-  if (routerItem.type == 3) {
-    newRouterItem = routerItem
-  }
-
-  return newRouterItem
+	let newRouterItem = {}
+	if (isSystemMenu) {
+		newRouterItem = {
+			id: routerItem.id,
+			name: routerItem.code,
+			hidden: false,
+			meta: {
+				title: routerItem.name,
+				icon: routerItem.icon,
+			},
+			path: '/' + routerItem.code, //路由路径
+			component: 'Layout', //组件地址
+			children: [],
+		}
+		return newRouterItem
+	}
+	newRouterItem.name = routerItem.code
+	newRouterItem.id = routerItem.id
+	newRouterItem.paterId = routerItem.paterId
+	newRouterItem.hidden = false
+	newRouterItem.type = routerItem.type
+	newRouterItem.meta = {
+		icon: routerItem.icon,
+		title: routerItem.name,
+	}
+
+	//根目录及其他目录处理
+	if (
+		(routerItem.paterId === null && routerItem.type != 2) ||
+		routerItem.type == 1
+	) {
+		newRouterItem.path = '/' + routerItem.route //路由路径
+		newRouterItem.component = 'ParentView'
+	}
+
+	//菜单项处理
+	if (routerItem.type == 2) {
+		newRouterItem.path = '/' + routerItem.route //路由路径
+		newRouterItem.component = routerItem.route
+		newRouterItem.code = routerItem.code
+	}
+
+	//按钮/功能处理
+	if (routerItem.type == 3) {
+		newRouterItem = routerItem
+	}
+
+	return newRouterItem
 }
 
 //遍历后台传来的路由,组成路由树结构
 function assembleRouter(allRouterMenu) {
-  // 收集每一项的下标
-  const idMapping = allRouterMenu.reduce((acc, el, i) => {
-    acc[el.id] = i
-    return acc
-  }, {})
-  let root = []
-  allRouterMenu.forEach((el) => {
-    // 判断根节点
-    if (el.paterId === null || el.paterId === 0) {
-      root.push(el)
-      return
-    }
-    // 用映射表找到父元素
-    const parentEl = allRouterMenu[idMapping[el.paterId]]
-    // 把当前元素添加到父元素的`children`数组中
-    if (el.type !== 3) {
-      //非按钮,组成路由树结构
-      parentEl.children = [...(parentEl.children || []), el]
-    }
-  })
-  return root
+	// 收集每一项的下标
+	const idMapping = allRouterMenu.reduce((acc, el, i) => {
+		acc[el.id] = i
+		return acc
+	}, {})
+	let root = []
+	allRouterMenu.forEach((el) => {
+		// 判断根节点
+		if (el.paterId === null || el.paterId === 0) {
+			root.push(el)
+			return
+		}
+		// 用映射表找到父元素
+		const parentEl = allRouterMenu[idMapping[el.paterId]]
+		// 把当前元素添加到父元素的`children`数组中
+		if (el.type !== 3) {
+			//非按钮,组成路由树结构
+			parentEl.children = [...(parentEl.children || []), el]
+		}
+	})
+	return root
 }
 
 //遍历树节点,组装成二级路由
 function recombineRoute(tree) {
-  let newTree = deepClone(tree)
-  let newRouter = []
-  for (let index = 0; index < newTree.length; index++) {
-    const element = newTree[index]
-    if (element.children && element.children.length > 0) {
-      element.children = filtNode(element.children)
-    }
-    newRouter.push(element)
-  }
-  return newRouter
+	let newTree = deepClone(tree)
+	let newRouter = []
+	for (let index = 0; index < newTree.length; index++) {
+		const element = newTree[index]
+		if (element.children && element.children.length > 0) {
+			element.children = filtNode(element.children)
+		}
+		newRouter.push(element)
+	}
+	return newRouter
 }
 
 //树形结构抓取所有末尾节点,组装数组
 function filtNode(tree) {
-  let nodeList = []
-  findLastNode(tree)
-  function findLastNode(childList) {
-    for (let index = 0; index < childList.length; index++) {
-      const element = childList[index]
-      if (!element.children) {
-        nodeList.push(element)
-      } else {
-        findLastNode(element.children)
-      }
-    }
-  }
-  return nodeList
+	let nodeList = []
+	findLastNode(tree)
+
+	function findLastNode(childList) {
+		for (let index = 0; index < childList.length; index++) {
+			const element = childList[index]
+			if (!element.children) {
+				nodeList.push(element)
+			} else {
+				findLastNode(element.children)
+			}
+		}
+	}
+	return nodeList
 }
 
-export default usePermissionStore
+export default usePermissionStore