uview-plus组件库全面升级更新,订单结算判断支付方式是否可用代码调整,公众号关注二维码修改

This commit is contained in:
2025-10-21 10:44:31 +08:00
parent 5d98b7efc2
commit 5f3a307fec
395 changed files with 31264 additions and 2477 deletions

View File

@@ -21,9 +21,13 @@ export default {
safeAreaInsetBottom: true,
safeAreaInsetTop: false,
closeIconPos: 'top-right',
round: 0,
round: '20px',
zoom: true,
bgColor: '',
overlayOpacity: 0.5
overlayOpacity: 0.5,
pageInline: false,
touchable: false,
minHeight: '200px',
maxHeight: '600px'
}
}

View File

@@ -76,6 +76,26 @@ export const props = defineMixin({
overlayOpacity: {
type: [Number, String],
default: () => defProps.popup.overlayOpacity
}
},
// 是否页面内展示
pageInline:{
type: Boolean,
default: () => defProps.popup.pageInline
},
// 是否页开启手势滑动
touchable:{
type: Boolean,
default: () => defProps.popup.touchable
},
// 手势滑动最小高度
minHeight:{
type: [String],
default: () => defProps.popup.minHeight
},
// 手势滑动最大高度
maxHeight:{
type: [String],
default: () => defProps.popup.maxHeight
}
}
})

View File

@@ -1,7 +1,15 @@
<template>
<view class="u-popup" :class="[customClass]">
<view class="u-popup" :class="[customClass]"
:style="{width: show == false ? '0px' : '',
height: show == false ? '0px' : ''}">
<view class="u-popup__trigger">
<slot name="trigger">
</slot>
<view @click="open"
class="u-popup__trigger__cover"></view>
</view>
<u-overlay
:show="show"
:show="show && pageInline == false"
@click="overlayClick"
v-if="overlay"
:zIndex="zIndex"
@@ -10,9 +18,11 @@
:opacity="overlayOpacity"
></u-overlay>
<u-transition
:show="show"
class="u-popup__content—transition"
:style="contentStyleWrap"
:show="pageInline ? true : show"
:customStyle="transitionStyle"
:mode="position"
:mode="pageInline ? 'none' : position"
:duration="duration"
@afterEnter="afterEnter"
@click="clickHandler"
@@ -25,6 +35,18 @@
@touchmove.stop.prevent="noop"
>
<u-status-bar v-if="safeAreaInsetTop"></u-status-bar>
<!-- 增加触摸区域用于处理手势 -->
<view
v-if="touchable && mode === 'bottom'"
class="u-popup__content__touch-area"
@touchstart="onTouchStart"
@touchmove="onTouchMove"
@touchend="onTouchEnd"
@touchcancel="onTouchEnd"
>
<!-- iOS风格的横条指示器 -->
<view class="u-popup__content__indicator"></view>
</view>
<slot></slot>
<view
v-if="closeable"
@@ -34,15 +56,16 @@
hover-class="u-popup__content__close--hover"
hover-stay-time="150"
>
<u-icon
<up-icon
name="close"
color="#909399"
size="18"
bold
></u-icon>
></up-icon>
</view>
<u-safe-bottom v-if="safeAreaInsetBottom"></u-safe-bottom>
</view>
<slot name="bottom"></slot>
</u-transition>
</view>
</template>
@@ -69,8 +92,12 @@
* @property {Boolean} safeAreaInsetBottom 是否为iPhoneX留出底部安全距离 (默认 true
* @property {Boolean} safeAreaInsetTop 是否留出顶部安全距离(状态栏高度) (默认 false
* @property {String} closeIconPos 自定义关闭图标位置(默认 'top-right'
* @property {String | Number} round 圆角值(默认 0
* @property {String | Number} round 圆角值(默认 20px
* @property {String } bgColor 背景色值(默认 ''
* @property {Boolean} zoom 当mode=center时 是否开启缩放(默认 true
* @property {Boolean} touchable 是否开启底部弹窗手势功能(默认 false
* @property {String} minHeight 最小高度单位任意数值默认为px默认 '200px'
* @property {String} maxHeight 最大高度单位任意数值默认为px默认 '80%'
* @property {Object} customStyle 组件的样式,对象形式
* @event {Function} open 弹出层打开
* @event {Function} close 弹出层收起
@@ -81,7 +108,13 @@
mixins: [mpMixin, mixin, props],
data() {
return {
overlayDuration: this.duration + 50
overlayDuration: this.duration + 50,
// 触摸相关数据
touchStartY: 0,
touchStartHeight: 0,
isTouching: false,
// 当前弹窗高度
currentHeight: 'auto'
}
},
watch: {
@@ -97,10 +130,12 @@
computed: {
transitionStyle() {
const style = {
zIndex: this.zIndex,
position: 'fixed',
display: 'flex',
}
if (!this.pageInline) {
style.zIndex = this.zIndex
style.position = 'fixed'
}
style[this.mode] = 0
if (this.mode === 'left') {
return deepMerge(style, {
@@ -133,6 +168,23 @@
})
}
},
contentStyleWrap() {
const style = {}
// 处理手势滑动时的高度变化
if (this.mode === 'bottom' && this.touchable) {
if (this.currentHeight !== 'auto') {
style.height = this.currentHeight
}
if (this.maxHeight) {
style.maxHeight = addUnit(this.maxHeight)
}
if (this.minHeight) {
style.minHeight = addUnit(this.minHeight)
}
}
return style;
},
contentStyle() {
const style = {}
// 通过设备信息的safeAreaInsets值来判断是否需要预留顶部状态栏和底部安全局的位置
@@ -159,6 +211,7 @@
style.borderRadius = value
}
}
return deepMerge(style, addStyle(this.customStyle))
},
position() {
@@ -188,6 +241,9 @@
this.$emit('close')
}
},
open(e) {
this.$emit('update:show', true)
},
close(e) {
this.$emit('update:show', false)
this.$emit('close')
@@ -227,19 +283,82 @@
this.retryComputedComponentRect(grandChild)
}
}
}
},
// #endif
// 触摸开始
onTouchStart(e) {
if (!this.touchable || this.mode !== 'bottom') return;
this.isTouching = true;
this.touchStartY = e.touches[0].clientY;
// 保存当前高度
this.touchStartHeight = this.$el.querySelector('.u-popup__content—transition').offsetHeight;
},
// 触摸移动
onTouchMove(e) {
if (!this.isTouching || !this.touchable || this.mode !== 'bottom') return;
const touchY = e.touches[0].clientY;
const deltaY = touchY - this.touchStartY;
// 只处理向上滑动(减小高度)和向下滑动(增加高度)
if (deltaY !== 0) {
const newHeight = this.touchStartHeight - deltaY;
const minHeight = parseFloat(addUnit(this.minHeight)) || 200;
const maxHeight = this.maxHeight ?
(this.maxHeight.toString().includes('%') ?
getWindowInfo().windowHeight * (parseFloat(this.maxHeight) / 100) :
parseFloat(addUnit(this.maxHeight))) :
getWindowInfo().windowHeight * 0.8;
// 限制高度在最小值和最大值之间
if (newHeight >= minHeight && newHeight <= maxHeight) {
this.currentHeight = newHeight + 'px';
}
}
// 阻止默认滚动行为
e.preventDefault();
},
// 触摸结束
onTouchEnd(e) {
if (!this.isTouching || !this.touchable || this.mode !== 'bottom') return;
this.isTouching = false;
const touchY = e.changedTouches[0].clientY;
const deltaY = touchY - this.touchStartY;
const velocity = Math.abs(deltaY) / (e.timeStamp - e.changedTouches[0].timestamp); // 简单的速度计算
// 快速向下滑动时关闭弹窗
if (deltaY > 100 || (deltaY > 30 && velocity > 0.5)) {
this.close();
} else {
// 恢复到自适应高度
// this.currentHeight = 'auto';
}
}
}
}
</script>
<style lang="scss" scoped>
@import "../../libs/css/components.scss";
$u-popup-flex:1 !default;
$u-popup-content-background-color: #fff !default;
.u-popup {
flex: $u-popup-flex;
&__trigger {
position: relative;
&__cover {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
}
&__content {
background-color: $u-popup-content-background-color;
@@ -279,6 +398,27 @@
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
&__touch-area {
// position: absolute;
top: 0;
left: 0;
right: 0;
height: 42rpx;
z-index: 10;
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: center;
align-items: center;
}
&__indicator {
width: 100px;
height: 5px;
border-radius: 100px;
background-color: #c0c4cc;
}
&__close {
position: absolute;
@@ -309,4 +449,4 @@
}
}
}
</style>
</style>