feat: 优化订单详情滚动交互

This commit is contained in:
duanshuwen 2025-10-05 11:54:09 +08:00
parent 9cc7b48d36
commit e58ded9b84
5 changed files with 112 additions and 111 deletions

View File

@ -1,7 +1,10 @@
<template> <template>
<view :class="navBarClass" :style="navBarStyle"> <view :class="navBarClass" :style="navBarStyle">
<!-- 状态栏占位 --> <!-- 状态栏占位 -->
<view :style="{ height: statusBarHeight + 'px' }" v-if="!hideStatusBar"></view> <view
:style="{ height: statusBarHeight + 'px' }"
v-if="!hideStatusBar"
></view>
<!-- 导航栏内容 --> <!-- 导航栏内容 -->
<view class="nav-bar-content" :style="{ height: navBarHeight + 'px' }"> <view class="nav-bar-content" :style="{ height: navBarHeight + 'px' }">
@ -13,7 +16,9 @@
<!-- 中间标题区域 --> <!-- 中间标题区域 -->
<view :class="['nav-bar-center', `nav-bar-center--${titleAlign}`]"> <view :class="['nav-bar-center', `nav-bar-center--${titleAlign}`]">
<slot name="title"> <slot name="title">
<text class="nav-bar-title" :style="{ color: titleColor }">{{ title }}</text> <text class="nav-bar-title" :style="{ color: titleColor }">{{
title
}}</text>
</slot> </slot>
</view> </view>
@ -26,106 +31,112 @@
</template> </template>
<script setup> <script setup>
import { computed, onMounted, ref } from 'vue' import { computed, onMounted, ref } from "vue";
// props // props
const props = defineProps({ const props = defineProps({
// //
title: { title: {
type: String, type: String,
default: '' default: "",
}, },
// //
fixed: { fixed: {
type: Boolean, type: Boolean,
default: false default: false,
},
//
shadow: {
type: Boolean,
default: true,
}, },
// //
showBack: { showBack: {
type: Boolean, type: Boolean,
default: true default: true,
}, },
// //
backgroundColor: { backgroundColor: {
type: String, type: String,
default: '#ffffff' default: "#ffffff",
}, },
// //
titleColor: { titleColor: {
type: String, type: String,
default: '#333333' default: "#333333",
}, },
// //
backIconColor: { backIconColor: {
type: String, type: String,
default: '#333333' default: "#333333",
}, },
// //
hideStatusBar: { hideStatusBar: {
type: Boolean, type: Boolean,
default: false default: false,
}, },
// z-index // z-index
zIndex: { zIndex: {
type: Number, type: Number,
default: 999 default: 999,
}, },
// //
titleAlign: { titleAlign: {
type: String, type: String,
default: 'center', // 'center' | 'left' default: "center", // 'center' | 'left'
validator: (value) => ['center', 'left'].includes(value) validator: (value) => ["center", "left"].includes(value),
} },
}) });
// emits // emits
const emit = defineEmits(['back']) const emit = defineEmits(["back"]);
// //
const statusBarHeight = ref(0) const statusBarHeight = ref(0);
const navBarHeight = ref(44) // const navBarHeight = ref(44); //
// //
onMounted(() => { onMounted(() => {
const systemInfo = uni.getSystemInfoSync() const systemInfo = uni.getSystemInfoSync();
statusBarHeight.value = systemInfo.statusBarHeight || 0 statusBarHeight.value = systemInfo.statusBarHeight || 0;
// //
if (systemInfo.platform === 'ios') { if (systemInfo.platform === "ios") {
navBarHeight.value = 44 navBarHeight.value = 44;
} else { } else {
navBarHeight.value = 48 navBarHeight.value = 48;
} }
}) });
// //
const navBarClass = computed(() => { const navBarClass = computed(() => {
return [ return [
'top-nav-bar', "top-nav-bar",
{ {
'top-nav-bar--fixed': props.fixed "top-nav-bar--fixed": props.fixed,
} "has-shadow": props.shadow,
] },
}) ];
});
// //
const navBarStyle = computed(() => { const navBarStyle = computed(() => {
return { return {
backgroundColor: props.backgroundColor, backgroundColor: props.backgroundColor,
zIndex: props.zIndex zIndex: props.zIndex,
} };
}) });
// //
const handleBack = () => { const handleBack = () => {
emit('back') emit("back");
// back // back
if (!emit('back')) { if (!emit("back")) {
uni.navigateBack({ uni.navigateBack({
delta: 1 delta: 1,
}) });
}
} }
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -2,7 +2,10 @@
.top-nav-bar { .top-nav-bar {
width: 100%; width: 100%;
background-color: #ffffff; background-color: #ffffff;
&.has-shadow {
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1); box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}
&--fixed { &--fixed {
position: fixed; position: fixed;
@ -44,6 +47,7 @@
.nav-bar-center { .nav-bar-center {
flex: 1; flex: 1;
height: 30px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;

View File

@ -134,48 +134,8 @@ $transition-normal: 0.3s ease;
margin-top: $spacing-large; margin-top: $spacing-large;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
transition: all $transition-normal;
letter-spacing: 0.5px; letter-spacing: 0.5px;
// 按钮波纹效果
&::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 0;
height: 0;
background: rgba(255, 255, 255, 0.3);
border-radius: 50%;
transform: translate(-50%, -50%);
transition: width 0.6s, height 0.6s;
}
&:hover {
background: linear-gradient(
135deg,
$button-hover-color 0%,
color.scale($button-hover-color, $lightness: -11.9%) 100%
);
transform: translateY(-2px);
box-shadow: 0 4px 16px rgba($button-color, 0.4);
&::before {
width: 300px;
height: 300px;
}
}
&:active {
transform: translateY(-1px);
box-shadow: 0 2px 8px rgba($button-color, 0.3);
}
&:focus {
outline: none;
box-shadow: 0 0 0 3px rgba($button-color, 0.3);
}
&:disabled { &:disabled {
background: $button-disabled-color; background: $button-disabled-color;
cursor: not-allowed; cursor: not-allowed;

View File

@ -113,9 +113,9 @@ const commodityPurchaseInstruction = computed(() => {
}); });
// //
const show = () => popupRef.value.open(); const show = () => popupRef.value && popupRef.value.open();
const hide = () => popupRef.value.close(); const hide = () => popupRef.value && popupRef.value.close();
// modelValue // modelValue
watch( watch(

View File

@ -1,7 +1,18 @@
<template> <template>
<view class="order-detail-wrapper"> <view class="order-detail-page">
<uni-icons type="left" size="20" color="#fff" @click="goBack" /> <TopNavBar
titleAlign="center"
:backgroundColor="backgroundColor"
:backIconColor="backIconColor"
:shadow="shadow"
fixed
>
<template #title>
{{ title }}
</template>
</TopNavBar>
<view class="order-detail-wrapper">
<OrderStatusInfo :orderData="orderData" /> <OrderStatusInfo :orderData="orderData" />
<OrderQrcode <OrderQrcode
v-if="orderData.orderStatus === '2'" v-if="orderData.orderStatus === '2'"
@ -21,12 +32,14 @@
@confirm="handleRefundConfirm" @confirm="handleRefundConfirm"
/> />
</view> </view>
</view>
</template> </template>
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import { onLoad } from "@dcloudio/uni-app"; import { onLoad, onPageScroll } from "@dcloudio/uni-app";
import { userOrderDetail, orderRefund } from "@/request/api/OrderApi"; import { userOrderDetail, orderRefund } from "@/request/api/OrderApi";
import TopNavBar from "@/components/TopNavBar/index.vue";
import OrderQrcode from "./components/OrderQrcode/index.vue"; import OrderQrcode from "./components/OrderQrcode/index.vue";
import OrderStatusInfo from "./components/OrderStatusInfo/index.vue"; import OrderStatusInfo from "./components/OrderStatusInfo/index.vue";
import GoodsInfo from "./components/GoodsInfo/index.vue"; import GoodsInfo from "./components/GoodsInfo/index.vue";
@ -45,12 +58,25 @@ onLoad(async ({ orderId }) => {
console.log(res); console.log(res);
}); });
// //
const goBack = () => { const backgroundColor = ref("transparent");
uni.navigateBack({ const backIconColor = ref("#fff");
delta: 1, const title = ref("");
const shadow = ref(false);
onPageScroll(({ scrollTop }) => {
//
if (scrollTop <= 0) {
backgroundColor.value = "transparent";
backIconColor.value = "#fff";
title.value = "";
shadow.value = false;
} else {
backgroundColor.value = "#ffffff";
backIconColor.value = "#333333";
title.value = "订单详情";
shadow.value = true;
}
}); });
};
// 退 // 退
const showRefundPopup = () => { const showRefundPopup = () => {