Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
liyeyun
Project
Project
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
cfld-frontend
liyeyun
Commits
9b2e4ce5
Commit
9b2e4ce5
authored
Dec 01, 2023
by
王玉鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 主图组件开发中
parent
69cb1dc6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
103 additions
and
3 deletions
+103
-3
components.d.ts
components.d.ts
+1
-0
image-left.png
src/assets/images/image-left.png
+0
-0
image-right.png
src/assets/images/image-right.png
+0
-0
ImageList.vue
src/components/common/ImageList.vue
+89
-0
DetailMain.vue
src/components/detail/DetailMain.vue
+13
-3
No files found.
components.d.ts
View file @
9b2e4ce5
...
...
@@ -21,6 +21,7 @@ declare module 'vue' {
ElMenuItem
:
typeof
import
(
'element-plus/es'
)[
'ElMenuItem'
]
ElPagination
:
typeof
import
(
'element-plus/es'
)[
'ElPagination'
]
ElSubMenu
:
typeof
import
(
'element-plus/es'
)[
'ElSubMenu'
]
ImageList
:
typeof
import
(
'./src/components/common/ImageList.vue'
)[
'default'
]
ListInfo
:
typeof
import
(
'./src/components/list/ListInfo.vue'
)[
'default'
]
ListPagination
:
typeof
import
(
'./src/components/list/ListPagination.vue'
)[
'default'
]
MiniListItem
:
typeof
import
(
'./src/components/detail/MiniListItem.vue'
)[
'default'
]
...
...
src/assets/images/image-left.png
0 → 100644
View file @
9b2e4ce5
972 Bytes
src/assets/images/image-right.png
0 → 100644
View file @
9b2e4ce5
980 Bytes
src/components/common/ImageList.vue
0 → 100644
View file @
9b2e4ce5
<
template
>
<div
v-if=
"images.length"
class=
"w-[455px]"
>
<div
class=
"w-full"
>
<img
class=
"h-[342px] w-full"
:src=
"currentImage"
/>
</div>
<div
class=
"relative mt-[13px]"
>
<div
class=
"flex space-x-[10px] overflow-x-hidden"
>
<div
v-for=
"(image, index) of images"
:key=
"index"
class=
"flex-none"
>
<img
ref=
"imgRef"
class=
"h-[72px] w-[90px] cursor-pointer"
:src=
"image"
@
click=
"changeIndex(index)"
/>
</div>
</div>
<div
class=
"image-icon-bg__left absolute left-0 top-0 flex h-[72px] w-[46px] cursor-pointer items-center"
@
click=
"changeIndex(currentIndex - 1)"
>
<img
class=
"ml-1 h-[30px] w-[30px]"
src=
"@/assets/images/image-left.png"
/>
</div>
<div
class=
"image-icon-bg__right absolute right-0 top-0 flex h-[72px] w-[46px] cursor-pointer items-center"
@
click=
"changeIndex(currentIndex + 1)"
>
<img
class=
"mr-1 h-[30px] w-[30px]"
src=
"@/assets/images/image-right.png"
/>
</div>
</div>
</div>
</
template
>
<
script
setup
lang=
"ts"
>
import
{
computed
,
ref
,
watch
}
from
'vue'
;
const
props
=
withDefaults
(
defineProps
<
{
images
:
string
[];
}
>
(),
{
images
:
()
=>
[],
},
);
const
currentIndex
=
ref
(
0
);
const
imgRef
=
ref
<
null
|
HTMLImageElement
[]
>
(
null
);
/** 当前选中图片 */
const
currentImage
=
computed
(()
=>
{
return
props
.
images
[
currentIndex
.
value
];
});
const
handleScroll
=
(
index
:
number
)
=>
{
const
el
=
imgRef
.
value
?.[
index
];
if
(
el
)
{
el
.
scrollIntoView
({
behavior
:
'smooth'
,
block
:
'nearest'
,
inline
:
'center'
,
});
}
};
watch
(
currentIndex
,
(
val
)
=>
{
handleScroll
(
val
);
});
const
changeIndex
=
(
index
:
number
)
=>
{
const
max
=
props
.
images
.
length
-
1
;
let
i
=
index
;
if
(
index
<
0
)
{
i
=
0
;
}
else
if
(
index
>
max
)
{
i
=
max
;
}
currentIndex
.
value
=
i
;
};
</
script
>
<
style
lang=
"scss"
>
.image-icon-bg
{
&
__left
{
background
:
linear-gradient
(
90deg
,
rgba
(
255
,
255
,
255
,
0
.6
)
0%
,
rgba
(
255
,
255
,
255
,
0
)
100%
);
}
&
__right
{
background
:
linear-gradient
(
270deg
,
rgba
(
255
,
255
,
255
,
0
.6
)
0%
,
rgba
(
255
,
255
,
255
,
0
)
100%
);
}
}
</
style
>
src/components/detail/DetailMain.vue
View file @
9b2e4ce5
...
...
@@ -27,7 +27,7 @@
</div>
</div>
</div>
<div
class=
"mt-5
flex
py-5"
>
<div
class=
"mt-5 py-5"
>
<div
class=
"flex h-10 items-center"
>
<div
class=
"font-yahei text-[32px] font-bold leading-10 text-[#333333]"
>
{{
detail
.
name
}}
...
...
@@ -43,8 +43,16 @@
</div>
</div>
</div>
<div>
<img
src=
""
alt=
""
/>
<div
class=
"mt-4"
>
<ImageList
:images=
"[
...detail.imgUrlList,
...detail.imgUrlList,
...detail.imgUrlList,
...detail.imgUrlList,
...detail.imgUrlList,
]"
></ImageList>
</div>
<div>
<slot></slot>
...
...
@@ -57,6 +65,7 @@
import
{
useItemStatus
}
from
'@/composable/useItemStatus.ts'
;
import
{
AuthStatus
,
DetailType
}
from
'@/types/enum.ts'
;
import
{
computed
}
from
'vue'
;
import
ImageList
from
'@/components/common/ImageList.vue'
;
export
interface
HeaderDetail
{
name
:
string
;
...
...
@@ -64,6 +73,7 @@ export interface HeaderDetail {
statusName
?:
string
;
isSuper
?:
number
;
isSuperName
?:
string
;
imgUrlList
:
string
[];
}
const
props
=
withDefaults
(
...
...
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