yy-dymini-pop-bottom 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/package.json +36 -0
- package/pop-bottom-confirm.js +70 -0
- package/pop-bottom-confirm.json +4 -0
- package/pop-bottom-confirm.ttml +19 -0
- package/pop-bottom-confirm.ttss +142 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# yy-dymini-pop-center
|
|
2
|
+
抖音小程序轻量级居中确认弹出框自定义组件,无需额外依赖,开箱即用。
|
|
3
|
+
|
|
4
|
+
## 🌟 特性
|
|
5
|
+
- 原生小程序语法,兼容所有抖音小程序基础库
|
|
6
|
+
- 支持自定义标题、内容
|
|
7
|
+
- 提供确认/取消回调,支持遮罩关闭
|
|
8
|
+
- 样式简洁美观,可自定义修改
|
|
9
|
+
|
|
10
|
+
## 📦 安装
|
|
11
|
+
在你的抖音小程序项目根目录执行:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install yy-dymini-pop-center --save
|
|
15
|
+
or
|
|
16
|
+
yarn add yy-dymini-pop-center
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## 抖音小程序(必读)
|
|
20
|
+
- 抖音小程序目前不支持通过 npm 包目录直接引用组件,
|
|
21
|
+
- 必须显式指向组件文件路径。
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"usingComponents": {
|
|
26
|
+
"pop-center-confirm": "/miniprogram_npm/yy-dymini-pop-center/pop-center-confirm"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yy-dymini-pop-bottom",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "抖音小程序-底部确认弹出框自定义组件",
|
|
5
|
+
"main": "pop-bottom-confirm.js",
|
|
6
|
+
"miniprogram": ".",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"douyin",
|
|
9
|
+
"miniProgram",
|
|
10
|
+
"抖音小程序",
|
|
11
|
+
"confirm",
|
|
12
|
+
"modal",
|
|
13
|
+
"弹出框"
|
|
14
|
+
],
|
|
15
|
+
"author": "Allen.ge <gyjshow@163.com>",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "",
|
|
19
|
+
"url": ""
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": ""
|
|
23
|
+
},
|
|
24
|
+
"homepage": "",
|
|
25
|
+
"private": false,
|
|
26
|
+
"files": [
|
|
27
|
+
"pop-bottom-confirm.js",
|
|
28
|
+
"pop-bottom-confirm.json",
|
|
29
|
+
"pop-bottom-confirm.ttml",
|
|
30
|
+
"pop-bottom-confirm.ttss",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//底部操作 确认弹窗
|
|
2
|
+
Component({
|
|
3
|
+
properties: {
|
|
4
|
+
visible: { // 控制显示/隐藏
|
|
5
|
+
type: Boolean,
|
|
6
|
+
value: false,
|
|
7
|
+
observer(newVal) {
|
|
8
|
+
// 同步控制动画类,避免异步延迟
|
|
9
|
+
this.setData({
|
|
10
|
+
show: newVal
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
zindex: {
|
|
15
|
+
type: Number,
|
|
16
|
+
value: 999
|
|
17
|
+
},
|
|
18
|
+
title: {
|
|
19
|
+
type: String,
|
|
20
|
+
value: ''
|
|
21
|
+
}, // 弹窗标题
|
|
22
|
+
message: {
|
|
23
|
+
type: String,
|
|
24
|
+
value: ''
|
|
25
|
+
}, // 弹窗内容
|
|
26
|
+
cancelText: {
|
|
27
|
+
type: String,
|
|
28
|
+
value: '取消'
|
|
29
|
+
}, // 取消按钮文本
|
|
30
|
+
confirmText: {
|
|
31
|
+
type: String,
|
|
32
|
+
value: '确认'
|
|
33
|
+
}, // 确认按钮文本
|
|
34
|
+
showClose: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
value: true
|
|
37
|
+
}, // 是否显示关闭按钮
|
|
38
|
+
showCancel: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
value: true
|
|
41
|
+
}, // 是否显示取消按钮
|
|
42
|
+
hideFooter: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
value: false
|
|
45
|
+
}, // 是否隐藏底部按钮
|
|
46
|
+
maskCloseable: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
value: true
|
|
49
|
+
} // 遮罩点击是否关闭
|
|
50
|
+
},
|
|
51
|
+
data: {
|
|
52
|
+
show: false // 内部维护显示状态,避免异步延迟
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
// 关闭弹窗:通知页面
|
|
56
|
+
onClose() {
|
|
57
|
+
this.triggerEvent('close');
|
|
58
|
+
},
|
|
59
|
+
// 确认按钮:拼接业务参数透传给页面
|
|
60
|
+
onConfirm(e) {
|
|
61
|
+
const baseParams = e.detail || {};
|
|
62
|
+
const bizParams = {
|
|
63
|
+
message: this.data.message,
|
|
64
|
+
...baseParams
|
|
65
|
+
};
|
|
66
|
+
this.triggerEvent('confirm', bizParams);
|
|
67
|
+
this.triggerEvent('close'); // 确认后关闭弹窗
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!-- 遮罩层:全屏,控制显示/隐藏 -->
|
|
2
|
+
<view class="view-mask {{visible ? 'show' : ''}}" style="z-index: {{zindex}};" bindtap="onMaskClick">
|
|
3
|
+
<!-- 弹窗主体:固定在底部,宽度100% -->
|
|
4
|
+
<view class="view-content" catchtap="stopPropagation">
|
|
5
|
+
<!-- 标题区:可选 -->
|
|
6
|
+
<view class="popup-title">
|
|
7
|
+
{{title}}
|
|
8
|
+
</view>
|
|
9
|
+
<view tt:if="{{showClose}}" class="popup-close" bindtap="onClose">×</view>
|
|
10
|
+
<!-- 内容 -->
|
|
11
|
+
<view class="popup-msg">{{message}}</view>
|
|
12
|
+
|
|
13
|
+
<!-- 底部按钮区:可选 -->
|
|
14
|
+
<view class="popup-footer" tt:if="{{!hideFooter}}">
|
|
15
|
+
<button class="btn cancel" bindtap="onClose" tt:if="{{showCancel}}">{{cancelText}}</button>
|
|
16
|
+
<button class="btn confirm" bindtap="onConfirm">{{confirmText}}</button>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* 遮罩层:全屏、透明、不可点击(初始状态) */
|
|
2
|
+
.view-mask {
|
|
3
|
+
position: fixed;
|
|
4
|
+
top: 0;
|
|
5
|
+
left: 0;
|
|
6
|
+
right: 0;
|
|
7
|
+
bottom: 0;
|
|
8
|
+
background: rgba(0, 0, 0, 0.45);
|
|
9
|
+
opacity: 0;
|
|
10
|
+
pointer-events: none;
|
|
11
|
+
transition: opacity 0.3s ease;
|
|
12
|
+
/* z-index: 999; */
|
|
13
|
+
/* z-index层级值 调用的时候传入,默认是999; */
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* 遮罩显示:不透明+可点击 */
|
|
17
|
+
.view-mask.show {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
pointer-events: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* 弹窗主体:固定底部,初始滑出屏幕 */
|
|
23
|
+
.view-content {
|
|
24
|
+
position: fixed;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
left: 0;
|
|
27
|
+
right: 0;
|
|
28
|
+
|
|
29
|
+
background: #ffffff;
|
|
30
|
+
|
|
31
|
+
border-top-left-radius: 30rpx;
|
|
32
|
+
border-top-right-radius: 30rpx;
|
|
33
|
+
|
|
34
|
+
padding: 40rpx 40rpx 80rpx;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
/* 初始状态:滑出屏幕底部 */
|
|
37
|
+
transform: translateY(100%);
|
|
38
|
+
transition: transform 0.3s ease-out;
|
|
39
|
+
/* 滑动动画更丝滑 */
|
|
40
|
+
min-height: 200rpx;
|
|
41
|
+
/* 固定最小高度,适配内容 */
|
|
42
|
+
height: auto;
|
|
43
|
+
/* 自适应内容高度 */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/* 弹窗显示:滑入屏幕 */
|
|
47
|
+
.view-mask.show .view-content {
|
|
48
|
+
transform: translateY(0);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* 通用样式:适配抖音规范 */
|
|
52
|
+
.popup-title {
|
|
53
|
+
font-size: 32rpx;
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
text-align: center;
|
|
56
|
+
margin-bottom: 20rpx;
|
|
57
|
+
position: relative;
|
|
58
|
+
/* 关闭按钮定位 */
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.popup-msg {
|
|
62
|
+
font-size: 32rpx;
|
|
63
|
+
color: #232832;
|
|
64
|
+
text-align: center;
|
|
65
|
+
margin: 60rpx 0;
|
|
66
|
+
|
|
67
|
+
/* background-color: #333333; */
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
.popup-close {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
right: 0;
|
|
75
|
+
font-size: 36rpx;
|
|
76
|
+
color: #999;
|
|
77
|
+
/* background-color: #232832; */
|
|
78
|
+
padding: 20rpx 30rpx 30rpx 60rpx
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.popup-footer {
|
|
82
|
+
display: flex;
|
|
83
|
+
margin-top: 100rpx;
|
|
84
|
+
gap: 60rpx;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/* 核心重置:只解决伪元素遮挡+原生外观问题(必写) */
|
|
90
|
+
button {
|
|
91
|
+
-webkit-appearance: none !important;
|
|
92
|
+
/* 去掉原生外观(关键) */
|
|
93
|
+
appearance: none !important;
|
|
94
|
+
border: none !important;
|
|
95
|
+
/* 清空默认边框 */
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
button::after {
|
|
99
|
+
content: none !important;
|
|
100
|
+
/* 直接移除遮挡的伪元素(核心) */
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.btn {
|
|
104
|
+
flex: 1;
|
|
105
|
+
height: 80rpx;
|
|
106
|
+
line-height: 80rpx;
|
|
107
|
+
border-radius: 40rpx;
|
|
108
|
+
border: none;
|
|
109
|
+
font-size: 30rpx;
|
|
110
|
+
padding: 0;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.cancel {
|
|
114
|
+
background: #FFFFFF;
|
|
115
|
+
color: #333333;
|
|
116
|
+
border: 2rpx solid #D1D1D6 !important;
|
|
117
|
+
/* transition: background-color 0.1s; */
|
|
118
|
+
|
|
119
|
+
/* box-shadow: 0 0 0 rgba(0, 0, 0, 0);
|
|
120
|
+
transition: box-shadow 0.1s; */
|
|
121
|
+
/* 按压 */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.cancel:active {
|
|
125
|
+
background-color: #f5f5f5;
|
|
126
|
+
|
|
127
|
+
/* box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.2); */
|
|
128
|
+
/* 按压 */
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.confirm {
|
|
132
|
+
background: linear-gradient(180deg, #FF8684 0%, #CB6DF3 100%);
|
|
133
|
+
color: #ffffff;
|
|
134
|
+
font-weight: 600;
|
|
135
|
+
|
|
136
|
+
background: linear-gradient(180deg, #FF8684 0%, #CB6DF3 100%);
|
|
137
|
+
transition: opacity 0.15s;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.confirm:active {
|
|
141
|
+
opacity: 0.65;
|
|
142
|
+
}
|