菜单接口

This commit is contained in:
2024-07-09 09:56:03 +08:00
parent 84af341162
commit fda12b5d0d
2 changed files with 269 additions and 143 deletions

View File

@@ -65,82 +65,20 @@
if (this.$store.getters.userInfo) { if (this.$store.getters.userInfo) {
this.userName = JSON.parse(this.$store.getters.userInfo).username this.userName = JSON.parse(this.$store.getters.userInfo).username
} }
this._allAuthority() this._authority()
}, },
methods: { methods: {
// async _authority () {
// let res = await authority()
// if (res.code === '1') {
// if (res.result.hasOwnProperty('rf_menu0')) {
// this.menuList1 = [...res.result.rf_menu0.sonTree]
// } else {
// this.tab = 2
// }
// if (res.result.hasOwnProperty('rf_menu1')) {
// this.menuList2 = [...res.result.rf_menu1.sonTree]
// } else {
// this.tab = 1
// }
// if (this.tab === 2) {
// this.menuList = [...this.menuList2]
// } else {
// this.menuList = [...this.menuList1]
// }
// } else {
// uni.showToast({
// title: res.desc,
// icon: 'none'
// })
// }
// },
async _allAuthority () {
let res = await allAuthority()
this.rf_menu0 = res.result.rf_menu0.sonTree
this.rf_menu1 = res.result.rf_menu1.sonTree
this._authority()
},
async _authority () { async _authority () {
let res = await authority() let res = await authority()
// let res = await allAuthority()
if (res.code === '1') { if (res.code === '1') {
if (res.result.hasOwnProperty('rf_menu0')) { if (res.result.hasOwnProperty('rf_menu0')) {
let arr = [...res.result.rf_menu0.sonTree] this.menuList1 = [...res.result.rf_menu0.sonTree]
let arr1 = this.rf_menu0.filter(item1 =>
arr.some(item2 => item2.title === item1.title)
)
arr1.map(e => {
let carr = []
arr.map(ele => {
if (ele.title === e.title) {
carr = ele.sonTree
}
})
let carr1 = e.sonTree.filter(item1 =>
carr.some(item2 => item2.title === item1.title)
)
e.sonTree = carr1
})
this.menuList1 = arr1
} else { } else {
this.tab = 2 this.tab = 2
} }
if (res.result.hasOwnProperty('rf_menu1')) { if (res.result.hasOwnProperty('rf_menu1')) {
let arr = [...res.result.rf_menu1.sonTree] this.menuList2 = [...res.result.rf_menu1.sonTree]
let arr1 = this.rf_menu1.filter(item1 =>
arr.some(item2 => item2.title === item1.title)
)
arr1.map(e => {
let carr = []
arr.map(ele => {
if (ele.title === e.title) {
carr = ele.sonTree
}
})
let carr1 = e.sonTree.filter(item1 =>
carr.some(item2 => item2.title === item1.title)
)
e.sonTree = carr1
})
this.menuList2 = arr1
} else { } else {
this.tab = 1 this.tab = 1
} }

View File

@@ -1,70 +1,177 @@
<template> <template>
<view class="zd_content"> <view class="zd_container">
<view class="header">首页</view> <view class="header"><span class="page_name">首页</span></view>
<view class="userInfo-wrap"> <view class="zd_content">
<view class="userInfo"> <view class="userInfo_wrap">
<text class="p1">{{$store.getters.userInfo !== '' ? JSON.parse($store.getters.userInfo).user_name : ''}}</text> <view class="userInfo_content">
<text class="p2">欢迎进入铜箔手持系统</text> <view class="userInfo">
</view> <text v-if="userName !== ''" class="p1">{{userName}}</text>
<view class="exit" @tap="Quit"> <text class="p2">欢迎进入铜箔手持系统</text>
<view class="icon-exit"></view> </view>
<view class="exit-text">退出</view> <view class="exit" @tap="Quit">
</view> <view class="icon-exit"></view>
</view> <view class="exit-text">退出</view>
<view class="zd_wrapper">
<view class="menu-wrap">
<view class="menu-item" v-for="(e, i) in menuList" :key="i" @tap="toPage1(e)">
<image class="menu-img" :src="require('../../static/image/menu/' + e.path + '.png')" alt="">
<view class="menu-name">{{e.title}}</view>
</view>
</view>
</view>
<view v-if="show === true" class="sec_menu_wraper">
<view class="sec_menu_w">
<view class="menu-item" v-for="(e, i) in secM" :key="i" @click="toPage2(e)">
<view class="sec_menu-col_inner">
<view class="menu-name menu-name_inner">{{e.title}}</view>
</view> </view>
</view> </view>
</view> </view>
<view class="cancel"> <view class="zd-row relative jcflexstart tabs_wrap">
<view class="iconfont cancel_icon" @tap="show = false"></view> <view class="zd-col-6 tab_active" :style="{'left': (menuList1.length > 0 && menuList2.length > 0 && tab === 2) ? '25%' : '0'}">
<view class="tab_line_active"></view>
</view>
<view v-if="menuList1.length > 0" class="zd-col-6 tab_item" :class="{'tab_item_active': tab === 1}" @tap="changeTab(1)">一期</view>
<view v-if="menuList2.length > 0" class="zd-col-6 tab_item" :class="{'tab_item_active': tab === 2}" @tap="changeTab(2)">二期</view>
</view>
<view class="zd_home_wrapper">
<view class="menu-wrap">
<view class="menu-item" v-for="(e, i) in menuList" :key="i" @tap="toPage1(e)">
<image class="menu-img" :src="require('../../static/image/menu/' + e.path + '.png')" alt="">
<view class="menu-name">{{e.title}}</view>
</view>
</view>
</view> </view>
</view> </view>
<view class="sec_menu_wraper" :class="show ? 'popshow' : 'pophide'">
<view class="pop-title">{{title}}</view>
<view class="sec_menu_w">
<view class="sec_menu-item" :style="{'background-image': 'url(' + require('../../static/image/menu/' + icon + '.png') + ')'}" v-for="(e, i) in secM" :key="i" @click="toPage2(e)">
<view class="menu-name_inner" :class="'bgc_' + (i + 1)">{{e.title}}</view>
</view>
</view>
</view>
<view v-if="show" class="modal" @click.stop="show = false"></view>
</view> </view>
</template> </template>
<script> <script>
// import {authority} from '@/utils/getData2.js' import {allAuthority} from '@/utils/mork2.js'
import {authority} from '@/utils/mork2.js' import {authority} from '@/utils/getData2.js'
export default { export default {
data() { data() {
return { return {
userName: '',
rf_menu0: [],
rf_menu1: [],
menuList: [], menuList: [],
menuList1: [],
menuList2: [],
show: false, show: false,
secM: [] secM: [],
icon: '',
title: '',
tab: this.$store.getters.navTab
}; };
}, },
created () { created () {
this._authority() if (this.$store.getters.userInfo) {
this.userName = JSON.parse(this.$store.getters.userInfo).username
}
this._allAuthority()
}, },
methods: { methods: {
// async _authority () {
// let res = await authority()
// if (res.code === '1') {
// if (res.result.hasOwnProperty('rf_menu0')) {
// this.menuList1 = [...res.result.rf_menu0.sonTree]
// } else {
// this.tab = 2
// }
// if (res.result.hasOwnProperty('rf_menu1')) {
// this.menuList2 = [...res.result.rf_menu1.sonTree]
// } else {
// this.tab = 1
// }
// if (this.tab === 2) {
// this.menuList = [...this.menuList2]
// } else {
// this.menuList = [...this.menuList1]
// }
// } else {
// uni.showToast({
// title: res.desc,
// icon: 'none'
// })
// }
// },
async _allAuthority () {
let res = await allAuthority()
this.rf_menu0 = res.result.rf_menu0.sonTree
this.rf_menu1 = res.result.rf_menu1.sonTree
this._authority()
},
async _authority () { async _authority () {
let res = await authority() let res = await authority()
if (res.code === '1') { if (res.code === '1') {
this.menuList = [...res.result.sonTree] if (res.result.hasOwnProperty('rf_menu0')) {
let arr = [...res.result.rf_menu0.sonTree]
let arr1 = this.rf_menu0.filter(item1 =>
arr.some(item2 => item2.title === item1.title)
)
arr1.map(e => {
let carr = []
arr.map(ele => {
if (ele.title === e.title) {
carr = ele.sonTree
}
})
let carr1 = e.sonTree.filter(item1 =>
carr.some(item2 => item2.title === item1.title)
)
e.sonTree = carr1
})
this.menuList1 = arr1
} else {
this.tab = 2
}
if (res.result.hasOwnProperty('rf_menu1')) {
let arr = [...res.result.rf_menu1.sonTree]
let arr1 = this.rf_menu1.filter(item1 =>
arr.some(item2 => item2.title === item1.title)
)
arr1.map(e => {
let carr = []
arr.map(ele => {
if (ele.title === e.title) {
carr = ele.sonTree
}
})
let carr1 = e.sonTree.filter(item1 =>
carr.some(item2 => item2.title === item1.title)
)
e.sonTree = carr1
})
this.menuList2 = arr1
} else {
this.tab = 1
}
if (this.tab === 2) {
this.menuList = [...this.menuList2]
} else {
this.menuList = [...this.menuList1]
}
} else { } else {
uni.showToast({ uni.showToast({
title: res.desc, title: res.desc,
icon: 'none' icon: 'none'
}) })
} }
},
changeTab (type) {
if (type === 1) {
this.menuList = [...this.menuList1]
this.tab = 1
} else {
this.menuList = [...this.menuList2]
this.tab = 2
}
this.$store.dispatch('setNavTab', type)
}, },
toPage1 (e) { toPage1 (e) {
if (e.sonTree.length > 0) { if (e.sonTree.length > 0) {
this.show = true this.show = true
this.secM = e.sonTree this.secM = e.sonTree
this.icon = e.path
this.title = e.title
} }
}, },
toPage2 (e) { toPage2 (e) {
@@ -85,19 +192,28 @@
<style lang="stylus" scoped> <style lang="stylus" scoped>
@import '../../common/style/mixin.styl'; @import '../../common/style/mixin.styl';
.zd_content
padding-top 0
.header .header
height 88rpx _fj(center)
_font(36rpx,88rpx,#333,,center) position fixed
.userInfo-wrap _wh(100%, calc(var(--status-bar-height) + 88rpx))
_fj() z-index 200
_wh(100%,160rpx) padding var(--status-bar-height) 20rpx 0 20rpx
background-color #f6f6f6
.page_name
_font(36rpx, 88rpx, #444,700,center)
.zd_content
padding-top calc(var(--status-bar-height) + 88rpx)
padding-bottom 20rpx
.userInfo_wrap
_wh(100%,173rpx)
padding 0 30rpx padding 0 30rpx
background-color $red background linear-gradient(to bottom, $red1, $red2)
_bis('../../static/image/info_bg.png',auto,100%,right,bottom)
border-radius 12rpx border-radius 12rpx
margin-bottom 20rpx margin-bottom 68rpx
.userInfo_content
_fj()
_wh(100%, 100%)
_bis('../../static/image/info_bg.png',auto,100%,right,bottom)
.userInfo .userInfo
_fj(,flex-start,column) _fj(,flex-start,column)
.p1 .p1
@@ -107,17 +223,26 @@
_font(26rpx,1,#fff) _font(26rpx,1,#fff)
.exit .exit
_fj() _fj()
height 47rpx height 48rpx
padding 0 15rpx padding 0 20rpx
border 1px solid #FF967C border 1px solid #FF967C
border-radius 20rpx border-radius 20rpx
.icon-exit .icon-exit
_wh(22rpx, 22rpx) _wh(22rpx, 22rpx)
_bis('../../static/image/exit.png',22rpx) _bis('../../static/image/exit.png',22rpx)
.exit-text .exit-text
_font(24rpx,47rpx,#fff,,right) _font(24rpx,48rpx,#fff,,right)
padding-left 10rpx padding-left 10rpx
.zd_home_wrapper
width 100%
background-color #fff
border-radius: 0 0 12rpx 12rpx;
padding: 24rpx 14rpx;
margin-bottom: 24rpx;
overflow-y auto
box-shadow 0 4rpx 4rpx 4rpx rgba(180, 182, 186, 0.4)
.menu-wrap .menu-wrap
_wh(100%, auto)
_fj(flex-start,flex-start,,wrap) _fj(flex-start,flex-start,,wrap)
align-content: flex-start align-content: flex-start
.menu-item .menu-item
@@ -125,54 +250,117 @@
flex-direction column flex-direction column
_wh(30%, auto) _wh(30%, auto)
margin-bottom 40rpx margin-bottom 40rpx
_font(26rpx, 60rpx,#e74f1a,,center) _font(26rpx, 28rpx,#e74f1a,,center)
&:nth-child(3n+2) &:nth-child(3n+2)
margin-left 5% margin-left 5%
margin-right 5% margin-right 5%
::v-deep .menu-img ::v-deep .menu-img
_wh(100%, auto) _wh(100%, auto)
margin-bottom 16rpx
img img
position relative position relative
opacity 1 opacity 1
_wh(55%, auto) _wh(55%, auto)
background-color: #f3f5f8
box-shadow 8rpx 6rpx 10rpx 0px rgba(0,0,0,0.1)
padding 16rpx
border-radius 50%
margin 0 auto 0.2rpx margin 0 auto 0.2rpx
.menu-name .menu-name
_font(28rpx, 38rpx, #444,,center) _font(28rpx, 30rpx, #444,,center)
.sec_menu_wraper .sec_menu_wraper
position fixed position fixed
top 0 bottom 0
left 0
width 100%
background-color #f4f5f5
box-shadow 0 -8px 16px 0 rgba(28,31,33,.1)
border-top-left-radius 20rpx
border-top-right-radius 20rpx
z-index 2017
transition all .3s
.modal
position fixed
bottom 0
left 0 left 0
_wh(100%, 100%) _wh(100%, 100%)
background-color rgba(0, 0, 0, .9) background-color rgba(0,0,0,0.8)
z-index 2017 z-index 2010
flex-direction column
.sec_menu_w .sec_menu_w
_fj() width calc(100% - 76rpx)
_wh(100%, calc(100% - 100rpx)) margin 30rpx auto 60rpx auto
padding 0 24rpx _fj(flex-start)
flex-wrap wrap flex-wrap wrap
align-content center .sec_menu-item
&::after _wh(30%, 120rpx)
content '' margin-bottom 20rpx
display block border-radius 10rpx
_wh(30%,0) background-size 40% auto
.sec_menu-col background-position right 90%
background-color transparent background-repeat no-repeat
border none &:nth-child(3n+2)
height auto margin-left 5%
.sec_menu-col_inner margin-right 5%
_fj(center)
_wh(160rpx, 160rpx)
border-radius 50%
background-color $yellow
margin 0 auto
.menu-name_inner .menu-name_inner
color #fff _wh(100%, 100%)
padding 0 20rpx _fj(center)
_font(28rpx, 30rpx, #fff, 700, center)
border-radius 10rpx
padding 10rpx
overflow hidden
.pop-title
margin 60rpx 38rpx 0 38rpx
_font(30rpx, 60rpx, #000,700,center)
.cancel .cancel
_wh(100%, 100rpx) _wh(calc(100% - 76rpx), 100rpx)
padding 0 24rpx margin 0 auto
overflow hidden padding 20rpx 0
background-color rgba(255, 255, 255, .3) overflow hidden
box-shadow 0 1rpx 4rpx 0 rgba(160,160,160,0.9) border-bottom 1px solid #c5c6c7
.bgc_1, .bgc_6
background linear-gradient(to right, rgba(73,102,255,0.8) 0%, rgba(117,142,255,0.8) 100%)
.bgc_2, .bgc_7
background linear-gradient(to right, rgba(254, 168, 20,0.8) 0%, rgba(255, 177, 1,0.8) 100%)
.bgc_3, .bgc_8
background linear-gradient(to right, rgba(0, 228, 153,0.8) 0%, rgba(0, 241, 197,0.8) 100%)
.bgc_4, .bgc_9
background linear-gradient(to right, rgba(162, 86, 171,0.8) 0%, rgba(183,120,190,0.8) 100%)
.bgc_5, .bgc_10
background linear-gradient(to right, rgba(146, 94, 52,0.8) 0%, rgba(162, 116, 79,0.8) 100%)
.tabs_wrap
border-radius 20rpx 20rpx 0 0
background-color #ecedef
margin-top 40rpx
.tab_item
z-index 1
_font(26rpx, 60rpx, #666,,center)
.tab_active
position absolute
bottom -4rpx
height 90rpx
border-radius 20rpx 20rpx 0 0
background-color #fff
box-shadow -4rpx -4rpx 4rpx rgba(180, 182, 186, 0.4)
// box-shadow -3px -3px 3px rgba(28,31,33,.1)
.tab_item_active
font-size 30rpx
color #000
font-weight 700
.tab_line_active
position absolute
left calc(50% - 30rpx)
bottom 0
_wh(60rpx, 6rpx)
background-color $blue
&:before
position absolute
top -6rpx
left 50%
transform translateX(-50%)
content ''
width: 0;
height: 0;
border-left: 6rpx solid transparent;
border-right: 6rpx solid transparent;
border-bottom: 6rpx solid $blue
</style> </style>