Commit 7acbf9b9 by chenwq1

refactor: 优化组件结构和样式以提升用户体验

- 在 BackPress 组件中移除多余的宽度属性,简化弹窗样式
- 在 MessageBox 组件中增强宽度计算逻辑,确保在不同屏幕下的适应性
- 在 ToolBox 组件中调整弹窗结构,移除冗余元素,提升可读性
- 在 BoutiqueLandscape 和 Equity 组件中重构滑动逻辑,使用原生 swiper 组件,优化图片展示和交互
1 parent 65ae4a86
<!-- 退出弹框 --> <!-- 退出弹框 -->
<template> <template>
<MessageBox :popupW="704" ref="finishRef" :content="finishContene" :isFooter="false"> <MessageBox ref="finishRef" :content="finishContene" :isFooter="false">
<view class="footer"> <view class="footer">
<view class="footer-btn confirm flex" @click="$emit('openStep')"> <view class="footer-btn confirm flex" @click="$emit('openStep')">
<template v-if="finishDoneText"> <template v-if="finishDoneText">
......
<template> <template>
<un-popup :mode="position" <un-popup :mode="position"
:show="visible" :show="visible"
:z-index="zIndex"> :z-index="zIndex"
>
<view class="tips-wrapper" <view class="tips-wrapper"
:class="[{'radius': position === 'center'}]" :class="[{'radius': position === 'center'}]"
:style="popupStyle"> :style="popupStyle">
...@@ -107,16 +108,39 @@ const emit = defineEmits(["close", ...@@ -107,16 +108,39 @@ const emit = defineEmits(["close",
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
const popupRef= ref(null); const popupRef= ref(null);
const popupStyle = computed(() => { const popupStyle = computed(() => {
const hasExplicitW = props.popupW != null && props.popupW > 0;
const isCenter = props.position === "center";
const style: UTSJSONObject = { const style: UTSJSONObject = {
width: props.popupW != null && props.popupW > 0 ? `${props.popupW}px` : "100%",
minHeight: props.popupH != null && props.popupH > 0 ? `${props.popupH}px` : "100%", minHeight: props.popupH != null && props.popupH > 0 ? `${props.popupH}px` : "100%",
maxHeight: props.maxHeight != null && props.maxHeight > 0 ? `${props.maxHeight}px` : "100%" maxHeight: props.maxHeight != null && props.maxHeight > 0 ? `${props.maxHeight}px` : "100%"
}; };
if (hasExplicitW) {
let wPx = props.popupW as number;
if (isCenter) {
const info = uni.getWindowInfo();
const winW = info.windowWidth > 0 ? info.windowWidth : 375;
const capPx = Math.floor(winW * 0.85);
wPx = wPx < capPx ? wPx : capPx;
style.alignSelf = "center";
}
if (props.maxWidth != null && props.maxWidth > 0) {
wPx = wPx < props.maxWidth ? wPx : props.maxWidth;
}
style.width = `${wPx}px`;
} else if (isCenter) {
const info = uni.getWindowInfo();
const winW = info.windowWidth > 0 ? info.windowWidth : 375;
const capPx = Math.floor(winW * 0.85);
const maxCap = props.maxWidth != null && props.maxWidth > 0 ? props.maxWidth : 360;
const wPx = capPx < maxCap ? capPx : maxCap;
style.width = `${wPx}px`;
style.alignSelf = "center";
} else {
style.width = "100%";
if (props.maxWidth != null && props.maxWidth > 0) { if (props.maxWidth != null && props.maxWidth > 0) {
style.maxWidth = `${props.maxWidth}px`; style.maxWidth = `${props.maxWidth}px`;
} }
}
return style; return style;
}); });
......
<template> <template>
<view class="tool-box" :style="toolBoxVars"> <view class="tool-box" :style="toolBoxVars">
<un-popup :show="show" :mode="isLandscapeMode ? 'right' : 'bottom'" :round="isLandscapeMode ? 0 : 20" @close="hide"> <un-popup :show="show" :mode="isLandscapeMode ? 'right' : 'bottom'" :round="isLandscapeMode ? 0 : 20" @close="hide" :closeable="true" >
<view class="list-wrapper" :class="isLandscapeMode ? 'landscape-wrapper' : 'portrait-wrapper'"> <view class="list-wrapper" :class="isLandscapeMode ? 'landscape-wrapper' : 'portrait-wrapper'">
<view class="panel-head"> <!-- <view class="panel-head">
<view class="panel-close" @click="hide"> <view class="panel-close" @click="hide">
<text class="panel-close-text">×</text> <text class="panel-close-text">×</text>
</view> </view>
</view> </view> -->
<scroll-view class="panel-body" <view class="panel-body">
:style="scrollContainerStyle"
scroll-y="true">
<view class="section-title">快捷操作</view> <view class="section-title">快捷操作</view>
<view class="fixed-group"> <view class="fixed-group">
<view class="action-grid"> <view class="action-grid">
...@@ -57,7 +55,7 @@ ...@@ -57,7 +55,7 @@
</view> </view>
</view> </view>
</view> </view>
</scroll-view> </view>
</view> </view>
</un-popup> </un-popup>
...@@ -528,8 +526,9 @@ defineExpose({ ...@@ -528,8 +526,9 @@ defineExpose({
padding: var(--fab-panel-padding-v) var(--fab-panel-padding-h); padding: var(--fab-panel-padding-v) var(--fab-panel-padding-h);
margin-bottom: 0; margin-bottom: 0;
align-items: stretch; align-items: stretch;
border-radius: 20px;
background: linear-gradient(145deg, rgba(30, 36, 48, 0.95), rgba(42, 50, 66, 0.92)); background: linear-gradient(145deg, rgba(30, 36, 48, 0.95), rgba(42, 50, 66, 0.92));
width: var(--panel-width); width: 100%;
height: 100%; /* 撑满侧边栏高度 */ height: 100%; /* 撑满侧边栏高度 */
} }
......
...@@ -10,20 +10,30 @@ ...@@ -10,20 +10,30 @@
<view v-if="logic.loadComplete.value" class="swiper-custom-wrap"> <view v-if="logic.loadComplete.value" class="swiper-custom-wrap">
<view v-if="logic.packageList.value.length > 0" class="swiper-custom-content"> <view v-if="logic.packageList.value.length > 0" class="swiper-custom-content">
<view class="package-swiper-stack"> <view class="package-swiper-stack">
<un-swiper <swiper
class="package-swiper" class="package-swiper"
:list="packageSwiperUrls" :indicator-dots="false"
:indicator="false"
:autoplay="false" :autoplay="false"
:circular="logic.packageList.value.length > 1" :circular="logic.packageList.value.length > 1"
:current="logic.currentSwiperIndex.value" :current="logic.currentSwiperIndex.value"
imgMode="aspectFill"
height="100%"
radius="0"
bgColor="transparent"
@change="onPackageSwiperChange" @change="onPackageSwiperChange"
@click="onPackageSwiperClick" >
<swiper-item
v-for="(url, i) in packageSwiperUrls"
:key="i"
>
<view
class="package-swiper-slide"
@tap="onPackageSlideTap(i)"
>
<image
class="package-swiper-img"
:src="url"
mode="aspectFill"
/> />
</view>
</swiper-item>
</swiper>
<view v-if="hasCurrentPackageOverlay" class="package-swiper-overlay"> <view v-if="hasCurrentPackageOverlay" class="package-swiper-overlay">
<view class="swiper-name"> <view class="swiper-name">
{{ overlayGet("name") }} {{ overlayGet("name") }}
...@@ -233,8 +243,8 @@ function toDetail(index: number): void { ...@@ -233,8 +243,8 @@ function toDetail(index: number): void {
} }
} }
function onPackageSwiperClick(e: any): void { function onPackageSlideTap(index: number): void {
toDetail(parsePackageSwiperIndex(e)); toDetail(index);
} }
function toDetailCurrent(): void { function toDetailCurrent(): void {
...@@ -290,6 +300,19 @@ defineExpose({ ...@@ -290,6 +300,19 @@ defineExpose({
height: 100%; height: 100%;
} }
.package-swiper-slide {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.package-swiper-img {
width: 100%;
flex: 1;
min-height: 0;
}
.package-swiper-overlay { .package-swiper-overlay {
position: absolute; position: absolute;
left: 0; left: 0;
......
...@@ -9,22 +9,33 @@ ...@@ -9,22 +9,33 @@
<view v-if="loadComplete" class="swiper-custom-wrap"> <view v-if="loadComplete" class="swiper-custom-wrap">
<view v-if="moduleList.length > 0" class="swiper-custom-content"> <view v-if="moduleList.length > 0" class="swiper-custom-content">
<view class="equity-swiper-stack"> <view class="equity-swiper-stack">
<un-swiper <!-- 原生 swiper:uview un-swiper 为加密 .vue,在 uni-app x 下易无法渲染图片 -->
<swiper
class="equity-swiper" class="equity-swiper"
:list="equitySwiperUrls" :indicator-dots="false"
:indicator="false"
:autoplay="moduleList.length > 1" :autoplay="moduleList.length > 1"
:circular="moduleList.length > 1" :circular="moduleList.length > 1"
:interval="5000" :interval="5000"
:duration="400" :duration="400"
:current="currentSwiperIndex" :current="currentSwiperIndex"
imgMode="aspectFill"
height="100%"
radius="0"
bgColor="transparent"
@change="onSwiperChange" @change="onSwiperChange"
@click="onEquitySwiperClick" >
<swiper-item
v-for="(url, i) in equitySwiperUrls"
:key="i"
>
<view
class="equity-swiper-slide"
@tap="onEquitySlideTap(i)"
>
<image
class="equity-swiper-img"
:src="url"
mode="aspectFill"
/> />
</view>
</swiper-item>
</swiper>
<view v-if="hasEquityOverlay()" class="equity-swiper-overlay"> <view v-if="hasEquityOverlay()" class="equity-swiper-overlay">
<text class="swiper-name"> <text class="swiper-name">
{{ equityOverlayName() }} {{ equityOverlayName() }}
...@@ -412,11 +423,10 @@ function onSwiperChange(e: any): void { ...@@ -412,11 +423,10 @@ function onSwiperChange(e: any): void {
currentSwiperIndex.value = parseSwiperEventIndex(e); currentSwiperIndex.value = parseSwiperEventIndex(e);
} }
function onEquitySwiperClick(e: any): void { function onEquitySlideTap(index: number): void {
const i = parseSwiperEventIndex(e);
const list = moduleList.value; const list = moduleList.value;
if (i >= 0 && i < list.length) { if (index >= 0 && index < list.length) {
toPreview(list[i]); toPreview(list[index]);
} }
} }
async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promise<void> { async function getSoure(brandIdList: number[], subBrandIdList: number[]): Promise<void> {
...@@ -604,6 +614,19 @@ onShow(() => { ...@@ -604,6 +614,19 @@ onShow(() => {
height: 100%; height: 100%;
} }
.equity-swiper-slide {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
.equity-swiper-img {
width: 100%;
flex: 1;
min-height: 0;
}
.equity-swiper-overlay { .equity-swiper-overlay {
position: absolute; position: absolute;
left: 0; left: 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!