效果預覽
彈出的內容
src\pages\goods\components\ServicePanel.vue
<script setup lang="ts">
// 子組件調父組件的方法
const emit = defineEmits<{(event: 'close'): void
}>()
</script><template><view class="service-panel"><!-- 關閉按鈕 --><text class="close icon-close" @tap="emit('close')"></text><!-- 標題 --><view class="title">服務說明</view><!-- 內容 --><view class="content"><view class="item"><view class="dt">無憂退貨</view><view class="dd">自收到商品之日起30天內,可在線申請無憂退貨服務(食品等特殊商品除外)</view></view><view class="item"><view class="dt">快速退款</view><view class="dd">收到退貨包裹并確認無誤后,將在48小時內辦理退款,退款將原路返回,不同銀行處理時間不同,預計1-5個工作日到賬</view></view><view class="item"><view class="dt">滿88元免郵費</view><view class="dd">單筆訂單金額(不含運費)滿88元可免郵費,不滿88元, 單筆訂單收取10元郵費</view></view></view></view>
</template><style lang="scss">
.service-panel {padding: 0 30rpx;border-radius: 10rpx 10rpx 0 0;position: relative;background-color: #fff;
}.title {line-height: 1;padding: 40rpx 0;text-align: center;font-size: 32rpx;font-weight: normal;border-bottom: 1rpx solid #ddd;color: #444;
}.close {position: absolute;right: 24rpx;top: 24rpx;
}.content {padding: 20rpx 20rpx 100rpx 20rpx;.item {margin-top: 20rpx;}.dt {margin-bottom: 10rpx;font-size: 28rpx;color: #333;font-weight: 500;position: relative;&::before {content: '';width: 10rpx;height: 10rpx;border-radius: 50%;background-color: #eaeaea;transform: translateY(-50%);position: absolute;top: 50%;left: -20rpx;}}.dd {line-height: 1.6;font-size: 26rpx;color: #999;}
}
</style>
頁面導入并使用
import ServicePanel from './components/ServicePanel.vue'// uni-ui 彈出層組件 ref
const popup = ref<{open: (type?: UniHelper.UniPopupType) => voidclose: () => void
}>()const openPopup = () => {// 打開彈出層popup.value?.open()
}
<view @tap="openPopup('service')" class="item arrow"><text class="label">服務</text><text class="text ellipsis"> 無憂退 快速退款 免費包郵 </text>
</view>
<!-- uni-ui 彈出層 -->
<uni-popup ref="popup" type="bottom" background-color="#fff"><ServicePanel @close="popup?.close()" />
</uni-popup>