Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 07aed763
authored
Apr 25, 2025
by
杨明
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
图片适应
1 parent
94dba41e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
84 deletions
pages/boutique/preview.vue
pages/common/imgPreview.vue
pages/boutique/preview.vue
View file @
07aed76
<
template
>
<view
class=
"popup-box"
v-if=
"popupShow"
>
<view
class=
"popup-box"
v-if=
"popupShow"
>
<view
class=
"nav-bar"
>
<view
class=
"back"
@
click=
"back"
>
<uni-icons
type=
"left"
:size=
"20"
color=
"#fff"
></uni-icons>
<view
class=
"back"
@
click=
"back"
>
<uni-icons
type=
"left"
:size=
"20"
color=
"#fff"
></uni-icons>
</view>
<view
class=
"title"
>
{{
title
}}
</view>
</view>
<view
class=
"popup-body"
>
<video
ref=
"videoPlayer"
:src=
"detailUrl"
controls
v-if=
"sourceType == 2"
></video>
<view
class=
"img-detail"
v-else
>
<image
@
click=
"back"
:src=
"detailUrl"
:style=
"
{ width: width + 'px' }"
/>
<video
ref=
"videoPlayer"
:src=
"detailUrl"
controls
v-if=
"sourceType == 2"
></video>
<view
class=
"img-detail"
v-else
>
<image
@
click=
"back"
:src=
"detailUrl"
mode=
"heightFix"
/>
</view>
</view>
</view>
...
...
@@ -46,7 +24,6 @@ export default {
},
data
()
{
return
{
width
:
0
,
title
:
''
,
sourceType
:
''
,
detailUrl
:
''
...
...
@@ -80,19 +57,6 @@ export default {
this
.
title
=
tabName
this
.
sourceType
=
sourceType
this
.
detailUrl
=
detailUrl
const
_this
=
this
uni
.
getImageInfo
({
src
:
detailUrl
,
// 替换为你的图片路径
success
(
img
)
{
uni
.
createSelectorQuery
().
select
(
'.img-detail'
).
boundingClientRect
(
function
(
rect
)
{
_this
.
width
=
rect
.
height
*
img
.
height
/
img
.
width
}).
exec
();
},
fail
:
function
(
error
)
{
console
.
error
(
'获取图片信息失败:'
,
error
);
}
});
},
back
()
{
if
(
this
.
isComponents
)
this
.
$emit
(
'previewBack'
)
...
...
@@ -143,7 +107,7 @@ export default {
height
:
100%
;
text-align
:
center
;
image
{
height
:
100%
;
height
:
calc
(
100vh
-
#{
toRpx
(
200
)}
)
;
width
:
auto
;
}
}
...
...
pages/common/imgPreview.vue
View file @
07aed76
<
template
>
<view
class=
"popup-box"
v-if=
"popupShow"
>
<view
class=
"popup-box"
v-if=
"popupShow"
>
<view
class=
"nav-bar"
>
<view
class=
"back"
@
click=
"back"
>
<uni-icons
type=
"left"
:size=
"20"
color=
"#fff"
></uni-icons>
<view
class=
"back"
@
click=
"back"
>
<uni-icons
type=
"left"
:size=
"20"
color=
"#fff"
></uni-icons>
</view>
<view
class=
"title"
>
{{
title
}}
</view>
</view>
<view
class=
"popup-body"
>
<video
ref=
"videoPlayer"
:src=
"detailUrl"
controls
v-if=
"sourceType == 2"
></video>
<view
class=
"img-detail"
v-else
>
<image
@
click=
"back"
:src=
"detailUrl"
:style=
"
{ width: width + 'px' }"
/>
<video
ref=
"videoPlayer"
:src=
"detailUrl"
controls
v-if=
"sourceType == 2"
></video>
<view
class=
"img-detail"
v-else
>
<image
@
click=
"back"
:src=
"detailUrl"
mode=
"heightFix"
/>
</view>
</view>
</view>
...
...
@@ -81,19 +59,19 @@ export default {
this
.
title
=
tabName
this
.
sourceType
=
sourceType
this
.
detailUrl
=
detailUrl
const
_this
=
this
uni
.
getImageInfo
({
src
:
detailUrl
,
// 替换为你的图片路径
success
(
img
)
{
uni
.
createSelectorQuery
().
select
(
'.img-detail'
).
boundingClientRect
(
function
(
rect
)
{
_this
.
width
=
rect
.
height
*
img
.
height
/
img
.
width
}).
exec
();
//
const _this = this
//
uni.getImageInfo({
//
src: detailUrl, // 替换为你的图片路径
//
success (img) {
//
uni.createSelectorQuery().select('.img-detail').boundingClientRect(function (rect) {
//
_this.width = rect.height * img.height / img.width
//
}).exec();
},
fail
:
function
(
error
)
{
console
.
error
(
'获取图片信息失败:'
,
error
);
}
});
//
},
//
fail: function (error) {
//
console.error('获取图片信息失败:', error);
//
}
//
});
},
back
()
{
if
(
this
.
isComponents
)
this
.
$emit
(
'previewBack'
)
...
...
@@ -144,7 +122,7 @@ export default {
height
:
100%
;
text-align
:
center
;
image
{
height
:
100%
;
height
:
calc
(
100%
-
#{
toRpx
(
200
)}
)
;
width
:
auto
;
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment