Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mocp-uniapp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pangchong
mocp-uniapp
Commits
56994ef9
Commit
56994ef9
authored
May 15, 2024
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 菜单开发
parent
1cf7fc9f
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
129 additions
and
50 deletions
+129
-50
src/components/custom-button/custom-button.vue
+5
-1
src/components/custom-page/custom-page.vue
+31
-3
src/pages/login/constants/index.compositions.js
+0
-0
src/pages/login/constants/index.functionals.js
+0
-0
src/pages/login/constants/index.scss
+0
-0
src/pages/login/index.vue
+3
-3
src/pages/panel/app-center/index.vue
+18
-10
src/pages/panel/components/menu-item.vue
+35
-2
src/pages/panel/constants/data.config.js
+32
-15
src/pages/panel/index.vue
+5
-16
No files found.
src/components/custom-button/custom-button.vue
View file @
56994ef9
...
...
@@ -49,6 +49,9 @@ const getSize = computed(() => {
if
(
ps
.
size
==
'small'
)
{
return
56
+
'rpx'
}
if
(
ps
.
size
==
'medium'
)
{
return
72
+
'rpx'
}
if
(
ps
.
size
==
'large'
)
{
return
88
+
'rpx'
}
...
...
@@ -56,11 +59,12 @@ const getSize = computed(() => {
</
script
>
<
style
lang=
"scss"
scoped
>
.global-button
{
padding
:
0
32
rpx
;
padding
:
0
16
rpx
;
margin
:
0
;
height
:
v-bind
(
getSize
);
line-height
:
v-bind
(
getSize
);
font-size
:
28
rpx
;
border-radius
:
52
rpx
;
&.primary
{
background-color
:
$
uni-color-primary
;
color
:
#fff
;
...
...
src/components/custom-
navbar/custom-navbar
.vue
→
src/components/custom-
page/custom-page
.vue
View file @
56994ef9
<
template
>
<view
class=
"page-wrap"
>
<view
:style=
"
{ paddingTop: safeAreaInsets?.top + 'px' }">
<uni-nav-bar
:title=
"title"
:border=
"false"
:backgroundColor=
"backgroundColor"
:color=
"color"
left-icon=
"left"
>
<uni-nav-bar
:title=
"title"
:border=
"false"
:backgroundColor=
"backgroundColor"
:color=
"color"
left-icon=
"left"
:leftWidth=
"leftWidth"
:rightWidth=
"rightWidth"
>
<template
#
default
>
<slot
name=
"default"
></slot>
</
template
>
<
template
#
left
>
<slot
name=
"left"
></slot>
</
template
>
...
...
@@ -9,6 +13,10 @@
</
template
>
</uni-nav-bar>
</view>
<view
class=
"page-content"
:style=
"{ height: `calc(100% - 44px - ${safeAreaInsets?.top + 'px'})` }"
>
<slot
name=
"content"
></slot>
</view>
</view>
</template>
<
script
setup
>
...
...
@@ -24,10 +32,30 @@ const ps = defineProps({
backgroundColor
:
{
type
:
String
,
default
:
'#f7f8fa'
},
leftWidth
:
{
type
:
Number
,
default
:
120
},
rightWidth
:
{
type
:
Number
,
default
:
120
}
})
// 获取屏幕边界到安全区域距离
const
{
safeAreaInsets
}
=
uni
.
getSystemInfoSync
()
</
script
>
<
style
lang=
"scss"
scoped
></
style
>
<
style
lang=
"scss"
scoped
>
.page-wrap
{
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
:deep(.uni-navbar__header-btns)
{
width
:
auto
;
}
.page-content
{
flex
:
auto
;
overflow-y
:
auto
;
}
}
</
style
>
src/pages/login/index.compositions.js
→
src/pages/login/
constants/
index.compositions.js
View file @
56994ef9
File moved
src/pages/login/index.functionals.js
→
src/pages/login/
constants/
index.functionals.js
View file @
56994ef9
File moved
src/pages/login/index.scss
→
src/pages/login/
constants/
index.scss
View file @
56994ef9
File moved
src/pages/login/index.vue
View file @
56994ef9
...
...
@@ -25,9 +25,9 @@ import { loginApi } from '@/api/user'
import
{
debounce
}
from
'lodash'
import
message
from
'@/utils/message'
import
{
loginCode
,
loginForm
,
rules
}
from
'./index.compositions'
import
{
loginCode
,
loginForm
,
rules
}
from
'./
constants/
index.compositions'
//获取验证码
import
{
getGifCaptcha
}
from
'./index.functionals'
import
{
getGifCaptcha
}
from
'./
constants/
index.functionals'
watch
(
()
=>
loginForm
.
username
,
...
...
@@ -52,5 +52,5 @@ const handleLogin = async () => {
</
script
>
<
style
lang=
"scss"
>
@import
"index.scss"
;
@import
'./constants/index.scss'
;
</
style
>
src/pages/panel/app-center/index.vue
View file @
56994ef9
<
template
>
<custom-
navbar
title=
"应用中心"
>
<custom-
page
title=
"应用中心"
>
<template
#
left
>
<uni-icons
type=
"left"
size=
"16"
></uni-icons>
<view
v-if=
"isEdit"
@
tap=
"isEdit = false"
>
取消
</view>
<uni-icons
type=
"left"
size=
"16"
@
tap=
"goBack"
v-else
></uni-icons>
</
template
>
<
template
#
right
>
<custom-button
type=
"primary"
size=
"small"
>
保存
</custom-button>
<custom-button
type=
"primary"
size=
"small"
v-if=
"isEdit"
>
保存
</custom-button>
</
template
>
</custom-navbar
>
<
template
#
content
>
<view
class=
"content"
>
<view
class=
"card"
>
<view
class=
"card-title"
>
<view
class=
"card-title-txt"
>
首页应用
</view>
<custom-button
type=
"primary"
size=
"small"
class=
"card-title-button
"
>
编辑
</custom-button>
<custom-button
type=
"primary"
size=
"small"
@
tap=
"isEdit = true
"
>
编辑
</custom-button>
</view>
<view
class=
"menu-list"
>
<menu-item
class=
"menu-item"
v-for=
"item in menuList"
:data=
"item"
:key=
"item.id
"
></menu-item>
<menu-item
class=
"menu-item"
v-for=
"item in menuList"
:data=
"item"
:key=
"item.id"
:type=
"isEdit ? 'minus' : 'default'
"
></menu-item>
</view>
</view>
<view
class=
"card"
>
...
...
@@ -22,15 +23,25 @@
<view
class=
"card-title-txt"
>
全部应用
</view>
</view>
<view
class=
"menu-list"
>
<menu-item
class=
"menu-item"
v-for=
"item in menuList"
:data=
"item"
:key=
"item.id
"
></menu-item>
<menu-item
class=
"menu-item"
v-for=
"item in menuList"
:data=
"item"
:key=
"item.id"
:type=
"isEdit ? 'plus' : 'default'
"
></menu-item>
</view>
</view>
</view>
</
template
>
</custom-page>
</template>
<
script
setup
>
import
{
ref
}
from
'vue'
import
MenuItem
from
'../components/menu-item.vue'
import
{
menuList
}
from
'../constants/data.config'
const
isEdit
=
ref
(
false
)
//返回
const
goBack
=
()
=>
{
uni
.
navigateBack
()
}
</
script
>
<
style
lang=
"scss"
scoped
>
.content
{
...
...
@@ -49,9 +60,6 @@ import { menuList } from '../constants/data.config'
font-size
:
34
rpx
;
color
:
#1d2129
;
}
.card-title-button
{
border-radius
:
52
rpx
;
}
}
.menu-list
{
display
:
flex
;
...
...
src/pages/panel/components/menu-item.vue
View file @
56994ef9
<
template
>
<view
class=
"menu-item"
>
<uni-badge
class=
"uni-badge-left-margin"
:text=
"data.count"
absolute=
"rightTop"
size=
"small"
:offset=
"[3, 3]
"
>
<view
class=
"menu-item"
v-if=
"type == 'default'"
>
<uni-badge
:text=
"getText"
absolute=
"rightTop"
size=
"small"
:offset=
"[3, 3]"
:customStyle=
"customStyle
"
>
<image
:src=
"getUrl"
/>
</uni-badge>
<text>
{{
data
.
name
}}
</text>
</view>
<template
v-else
>
<uni-badge
:text=
"getText"
absolute=
"rightTop"
size=
"small"
:offset=
"[15, 15]"
:customStyle=
"customStyle"
>
<view
class=
"menu-item"
>
<image
:src=
"getUrl"
/>
<text>
{{
data
.
name
}}
</text>
</view>
</uni-badge>
</
template
>
</template>
<
script
setup
>
...
...
@@ -16,11 +24,36 @@ const ps = defineProps({
default
:
function
()
{
return
{}
}
},
type
:
{
type
:
String
,
default
:
'default'
}
})
const
getUrl
=
computed
(()
=>
{
return
'/static/panel/'
+
ps
.
data
.
icon
+
'.png'
})
const
getText
=
computed
(()
=>
{
if
(
ps
.
type
==
'default'
)
{
return
ps
.
data
.
count
}
if
(
ps
.
type
==
'minus'
)
{
return
'-'
}
if
(
ps
.
type
==
'plus'
)
{
return
'+'
}
return
ps
.
data
.
count
})
const
customStyle
=
computed
(()
=>
{
if
(
ps
.
type
==
'minus'
)
{
return
{
background
:
'#C8C8C8'
}
}
if
(
ps
.
type
==
'plus'
)
{
return
{
background
:
'#165DFF'
}
}
return
{}
})
</
script
>
<
style
lang=
"scss"
scoped
>
.menu-item
{
...
...
src/pages/panel/constants/data.config.js
View file @
56994ef9
import
{
ref
}
from
'vue'
import
{
computed
,
ref
}
from
'vue'
export
const
menuList
=
ref
([
{
id
:
1
,
name
:
'信息通报'
,
icon
:
'xxtb'
,
group
:
'技术支援'
,
count
:
0
,
sort
:
0
},
{
id
:
2
,
name
:
'机队状态'
,
icon
:
'jdzt'
,
group
:
'技术支援'
,
count
:
0
,
sort
:
0
},
{
id
:
3
,
name
:
'支援申请'
,
icon
:
'zysq'
,
group
:
'技术支援'
,
count
:
0
,
sort
:
0
},
{
id
:
4
,
name
:
'工作指令'
,
icon
:
'gzzl'
,
group
:
'技术支援'
,
count
:
0
,
sort
:
0
},
{
id
:
5
,
name
:
'技术评估'
,
icon
:
'jspg'
,
group
:
'技术支援'
,
count
:
0
,
sort
:
0
},
{
id
:
6
,
name
:
'运行调查'
,
icon
:
'yxdc'
,
group
:
'运行管理'
,
count
:
0
,
sort
:
0
},
{
id
:
7
,
name
:
'运行决策'
,
icon
:
'yxjc'
,
group
:
'运行管理'
,
count
:
0
,
sort
:
0
},
{
id
:
8
,
name
:
'布置工作'
,
icon
:
'bzgz'
,
group
:
'运行管理'
,
count
:
0
,
sort
:
0
},
{
id
:
9
,
name
:
'航站管理'
,
icon
:
'hzgl'
,
group
:
'航站管理'
,
count
:
0
,
sort
:
0
},
{
id
:
10
,
name
:
'协议单位'
,
icon
:
'xydw'
,
group
:
'航站管理'
,
count
:
0
,
sort
:
0
},
{
id
:
11
,
name
:
'不正常事件'
,
icon
:
'bzcsj'
,
group
:
'运行品质'
,
count
:
0
,
sort
:
0
},
{
id
:
12
,
name
:
'考核记录'
,
icon
:
'khjl'
,
group
:
'运行品质'
,
count
:
0
,
sort
:
0
}
])
//全部菜单
export
const
menuList
=
[
{
id
:
1
,
name
:
'信息通报'
,
icon
:
'xxtb'
,
group
:
'技术支援'
,
count
:
12
,
home
:
true
},
{
id
:
2
,
name
:
'机队状态'
,
icon
:
'jdzt'
,
group
:
'技术支援'
,
count
:
0
,
home
:
true
},
{
id
:
3
,
name
:
'支援申请'
,
icon
:
'zysq'
,
group
:
'技术支援'
,
count
:
0
,
home
:
true
},
{
id
:
4
,
name
:
'工作指令'
,
icon
:
'gzzl'
,
group
:
'技术支援'
,
count
:
0
,
home
:
true
},
{
id
:
5
,
name
:
'技术评估'
,
icon
:
'jspg'
,
group
:
'技术支援'
,
count
:
0
,
home
:
true
},
{
id
:
6
,
name
:
'运行调查'
,
icon
:
'yxdc'
,
group
:
'运行管理'
,
count
:
0
,
home
:
true
},
{
id
:
7
,
name
:
'运行决策'
,
icon
:
'yxjc'
,
group
:
'运行管理'
,
count
:
0
,
home
:
true
},
{
id
:
8
,
name
:
'布置工作'
,
icon
:
'bzgz'
,
group
:
'运行管理'
,
count
:
0
,
home
:
true
},
{
id
:
9
,
name
:
'航站管理'
,
icon
:
'hzgl'
,
group
:
'航站管理'
,
count
:
0
,
home
:
true
},
{
id
:
10
,
name
:
'协议单位'
,
icon
:
'xydw'
,
group
:
'航站管理'
,
count
:
0
,
home
:
true
},
{
id
:
11
,
name
:
'不正常事件'
,
icon
:
'bzcsj'
,
group
:
'运行品质'
,
count
:
0
,
home
:
true
},
{
id
:
12
,
name
:
'考核记录'
,
icon
:
'khjl'
,
group
:
'运行品质'
,
count
:
0
,
home
:
true
}
]
//获取首页菜单
export
const
menuListHome
=
computed
(()
=>
{
return
menuList
.
filter
((
item
)
=>
item
.
home
)
})
//获取分组菜单
export
const
menuListGroup
=
computed
(()
=>
{
return
menuList
.
reduce
((
groups
,
item
)
=>
{
// 如果该组不存在,则创建一个新组
if
(
!
groups
[
item
.
group
])
{
groups
[
item
.
group
]
=
[]
}
// 将当前项添加到对应的组中
groups
[
item
.
group
].
push
(
item
)
return
groups
},
{})
})
src/pages/panel/index.vue
View file @
56994ef9
...
...
@@ -62,7 +62,7 @@
<scroll-view
class=
"tab-content"
scroll-y=
"true"
>
<view
class=
"tab-content-item"
v-if=
"activeIndex == 0"
>
<view
class=
"menu-list"
>
<menu-item
class=
"menu-item"
v-for=
"item in menuList"
:data=
"item"
:key=
"item.id"
@
tap=
"goAppCenter"
></menu-item>
<menu-item
class=
"menu-item"
v-for=
"item in menuList
Home
"
:data=
"item"
:key=
"item.id"
@
tap=
"goAppCenter"
></menu-item>
</view>
</view>
<view
class=
"tab-content-item"
v-if=
"activeIndex == 1"
>
...
...
@@ -81,27 +81,16 @@
</template>
<
script
setup
>
import
{
computed
,
ref
}
from
'vue'
import
{
ref
}
from
'vue'
import
MenuItem
from
'./components/menu-item.vue'
import
{
menuList
}
from
'./constants/data.config'
import
{
menuList
Home
,
menuListGroup
}
from
'./constants/data.config'
// 获取屏幕边界到安全区域距离
const
{
safeAreaInsets
}
=
uni
.
getSystemInfoSync
()
//分类
const
tabNav
=
ref
([
'常用'
,
'分组'
])
const
activeIndex
=
ref
(
0
)
//获取分组数据
const
menuListGroup
=
computed
(()
=>
{
return
menuList
.
value
.
reduce
((
groups
,
item
)
=>
{
// 如果该组不存在,则创建一个新组
if
(
!
groups
[
item
.
group
])
{
groups
[
item
.
group
]
=
[]
}
// 将当前项添加到对应的组中
groups
[
item
.
group
].
push
(
item
)
return
groups
},
{})
})
//跳转应用中心
const
goAppCenter
=
()
=>
{
uni
.
navigateTo
({
url
:
'/pages/panel/app-center/index'
})
...
...
@@ -189,7 +178,7 @@ const goAppCenter = () => {
}
}
.content
{
border-radius
:
38
rpx
;
border-radius
:
38
rpx
38
rpx
0
0
;
background
:
#fff
;
padding-top
:
32
rpx
;
display
:
flex
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment