@bi-nova/ui-weapp 1.1.1-beta.202605161224

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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "component": true
3
+ }
@@ -0,0 +1,74 @@
1
+ <view
2
+ wx:if="{{visible && (isWechatAd || hasCustomMedia)}}"
3
+ class="bi-splash-ad {{showPiP ? 'bi-splash-ad--pip' : ''}} {{pipAnimating ? 'bi-splash-ad--pip-animating' : ''}}"
4
+ style="z-index: {{zIndex}};"
5
+ >
6
+ <!-- 微信模板广告 -->
7
+ <view wx:if="{{isWechatAd}}" class="bi-splash-ad__popup">
8
+ <view class="bi-splash-ad__media-wrapper {{showPiP ? 'bi-splash-ad__media-wrapper--pip' : ''}}">
9
+ <ad-custom
10
+ wx:if="{{visible}}"
11
+ class="bi-splash-ad__wechat-unit"
12
+ unit-id="{{unitId}}"
13
+ bind:load="handleLoad"
14
+ bind:error="handleError"
15
+ bind:close="handleWechatClose"
16
+ />
17
+ </view>
18
+ </view>
19
+
20
+ <!-- 自定义广告 -->
21
+ <view wx:elif="{{mediaUrl}}" class="bi-splash-ad__popup">
22
+ <view class="bi-splash-ad__media-shell" bindtap="handleAction">
23
+ <image
24
+ wx:if="{{isImage}}"
25
+ class="bi-splash-ad__media bi-splash-ad__media--background"
26
+ src="{{mediaUrl}}"
27
+ mode="aspectFill"
28
+ bindload="handleCustomLoad"
29
+ binderror="handleCustomMediaError"
30
+ />
31
+ <block wx:else>
32
+ <image
33
+ class="bi-splash-ad__media bi-splash-ad__media--background"
34
+ src="{{posterUrl}}"
35
+ mode="aspectFill"
36
+ />
37
+ <video
38
+ class="bi-splash-ad__video {{adSpec === 1 ? 'bi-splash-ad__video--landscape' : ''}}"
39
+ src="{{mediaUrl}}"
40
+ poster="{{posterUrl}}"
41
+ autoplay="{{true}}"
42
+ muted="{{customAd.muted !== false}}"
43
+ loop="{{true}}"
44
+ object-fit="cover"
45
+ show-center-play-btn="{{false}}"
46
+ show-play-btn="{{false}}"
47
+ controls="{{false}}"
48
+ bindloadedmetadata="handleCustomLoad"
49
+ binderror="handleCustomMediaError"
50
+ />
51
+ </block>
52
+
53
+ <view wx:if="{{showPiP}}" class="bi-splash-ad__pip-mask"></view>
54
+
55
+ <view wx:if="{{!showPiP}}" class="bi-splash-ad__badge" style="{{badgeStyle}}">{{adBadgeText}}</view>
56
+
57
+ <view wx:if="{{customAd && (customAd.title || (!showPiP && (customAd.description || customAd.buttonText)))}}" class="bi-splash-ad__content" style="{{contentStyle}}">
58
+ <text wx:if="{{customAd.title}}" class="bi-splash-ad__title">{{customAd.title}}</text>
59
+ <text wx:if="{{!showPiP && customAd.description}}" class="bi-splash-ad__description">{{customAd.description}}</text>
60
+ <button wx:if="{{!showPiP && customAd.buttonText}}" class="bi-splash-ad__action">{{customAd.buttonText}}</button>
61
+ </view>
62
+ </view>
63
+ </view>
64
+
65
+ <view wx:if="{{showPiP}}" class="bi-splash-ad__pip-close" bindtap="handlePiPClose">
66
+ <view class="bi-splash-ad__pip-close-text">关闭</view>
67
+ </view>
68
+
69
+ <view wx:if="{{!showPiP}}" class="bi-splash-ad__skip" style="{{skipStyle}}" bindtap="handleSkip">
70
+ <text>{{remainingSeconds}}s</text>
71
+ <view class="bi-splash-ad__skip-divider"></view>
72
+ <text class="bi-splash-ad__skip-text">跳过</text>
73
+ </view>
74
+ </view>
@@ -0,0 +1,257 @@
1
+ .bi-splash-ad {
2
+ position: fixed;
3
+ inset: 0;
4
+ transform: scale(1);
5
+ transform-origin: right bottom;
6
+ }
7
+
8
+ .bi-splash-ad__popup {
9
+ position: relative;
10
+ width: 100vw;
11
+ height: 100vh;
12
+ z-index: 10;
13
+ background-color: #000000;
14
+ box-sizing: border-box;
15
+ display: flex;
16
+ flex-direction: column;
17
+ justify-content: center;
18
+ align-items: center;
19
+ border-radius: 0;
20
+ overflow: hidden;
21
+ transition: all 0.28s ease-in-out;
22
+ }
23
+
24
+ .bi-splash-ad__media-wrapper {
25
+ position: relative;
26
+ width: 100vw;
27
+ height: 100vh;
28
+ }
29
+
30
+ .bi-splash-ad__media-wrapper--pip {
31
+ width: 100vw;
32
+ height: 100vh;
33
+ }
34
+
35
+ .bi-splash-ad__wechat-unit {
36
+ position: relative;
37
+ display: block;
38
+ width: 100vw;
39
+ max-height: 100vh;
40
+ }
41
+
42
+ .bi-splash-ad__media-shell {
43
+ position: relative;
44
+ width: 100%;
45
+ height: 100%;
46
+ }
47
+
48
+ .bi-splash-ad__media {
49
+ width: 100%;
50
+ height: 100%;
51
+ }
52
+
53
+ .bi-splash-ad__media--background {
54
+ display: block;
55
+ }
56
+
57
+ .bi-splash-ad__video {
58
+ position: absolute;
59
+ z-index: 2;
60
+ top: 0;
61
+ left: 0;
62
+ width: 100vw;
63
+ height: 100vh;
64
+ }
65
+
66
+ .bi-splash-ad__video--landscape {
67
+ top: 50%;
68
+ left: 50%;
69
+ width: 100vw;
70
+ max-width: 100vw;
71
+ height: 500rpx;
72
+ transform: translate(-50%, -50%);
73
+ }
74
+
75
+ .bi-splash-ad__content {
76
+ position: absolute;
77
+ left: 40rpx;
78
+ right: 40rpx;
79
+ bottom: 84rpx;
80
+ z-index: 3;
81
+ padding: 28rpx;
82
+ border-radius: 24rpx;
83
+ background: linear-gradient(180deg, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.76));
84
+ color: #ffffff;
85
+ box-sizing: border-box;
86
+ }
87
+
88
+ .bi-splash-ad__badge {
89
+ position: absolute;
90
+ right: 32rpx;
91
+ bottom: 130rpx;
92
+ z-index: 3;
93
+ min-width: 72rpx;
94
+ height: 38rpx;
95
+ padding: 0 12rpx;
96
+ box-sizing: border-box;
97
+ border-radius: 19rpx;
98
+ background: rgba(0, 0, 0, 0.52);
99
+ color: #ffffff;
100
+ font-size: 20rpx;
101
+ line-height: 38rpx;
102
+ text-align: center;
103
+ }
104
+
105
+ .bi-splash-ad__title {
106
+ display: block;
107
+ margin-bottom: 12rpx;
108
+ font-size: 36rpx;
109
+ font-weight: 600;
110
+ line-height: 1.4;
111
+ }
112
+
113
+ .bi-splash-ad__description {
114
+ display: block;
115
+ margin-bottom: 20rpx;
116
+ font-size: 26rpx;
117
+ line-height: 1.6;
118
+ }
119
+
120
+ .bi-splash-ad__action {
121
+ width: 100%;
122
+ min-height: 0;
123
+ padding: 18rpx 24rpx;
124
+ border: none;
125
+ border-radius: 16rpx;
126
+ background: linear-gradient(135deg, #1677ff, #0f52ba);
127
+ color: #ffffff;
128
+ font-size: 26rpx;
129
+ line-height: 1.4;
130
+ }
131
+
132
+ .bi-splash-ad__action::after {
133
+ display: none;
134
+ }
135
+
136
+ .bi-splash-ad__skip {
137
+ z-index: 99;
138
+ position: absolute;
139
+ display: flex;
140
+ align-items: center;
141
+ justify-content: center;
142
+ padding: 0 22rpx;
143
+ min-width: 148rpx;
144
+ height: 64rpx;
145
+ box-sizing: border-box;
146
+ background: transparent;
147
+ border: 1px solid rgba(255, 255, 255, 0.3);
148
+ border-radius: 32rpx;
149
+ font-weight: 400;
150
+ font-size: 24rpx;
151
+ color: #fff;
152
+ white-space: nowrap;
153
+ }
154
+
155
+ .bi-splash-ad__skip-divider {
156
+ width: 1rpx;
157
+ height: 24rpx;
158
+ margin: 0 12rpx;
159
+ background: rgba(255, 255, 255, 0.3);
160
+ }
161
+
162
+ .bi-splash-ad__skip-text {
163
+ line-height: 24rpx;
164
+ }
165
+
166
+ .bi-splash-ad--pip {
167
+ top: auto;
168
+ left: auto;
169
+ right: 24rpx;
170
+ bottom: 24rpx;
171
+ width: 240rpx;
172
+ height: 320rpx;
173
+ border-radius: 24rpx;
174
+ overflow: hidden;
175
+ box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.28);
176
+ }
177
+
178
+ .bi-splash-ad--pip-animating {
179
+ animation: bi-splash-ad-pip-scale 0.28s ease-in-out forwards;
180
+ }
181
+
182
+ .bi-splash-ad--pip .bi-splash-ad__popup {
183
+ width: 240rpx;
184
+ height: 320rpx;
185
+ border-radius: 24rpx;
186
+ }
187
+
188
+ .bi-splash-ad--pip .bi-splash-ad__content {
189
+ left: 16rpx;
190
+ right: 16rpx;
191
+ bottom: 16rpx;
192
+ padding: 16rpx;
193
+ border-radius: 18rpx;
194
+ }
195
+
196
+ .bi-splash-ad--pip .bi-splash-ad__badge {
197
+ display: none;
198
+ }
199
+
200
+ .bi-splash-ad--pip .bi-splash-ad__title {
201
+ margin-bottom: 8rpx;
202
+ font-size: 24rpx;
203
+ }
204
+
205
+ .bi-splash-ad__pip-mask {
206
+ position: absolute;
207
+ inset: 0;
208
+ z-index: 1;
209
+ }
210
+
211
+ .bi-splash-ad__pip-close {
212
+ width: 300rpx;
213
+ height: 250rpx;
214
+ position: absolute;
215
+ right: 0;
216
+ top: 0;
217
+ z-index: 10;
218
+ display: flex;
219
+ align-items: flex-start;
220
+ justify-content: flex-end;
221
+ box-sizing: border-box;
222
+ }
223
+
224
+ .bi-splash-ad__pip-close-text {
225
+ width: 200rpx;
226
+ height: 110rpx;
227
+ line-height: 110rpx;
228
+ background: rgba(255, 255, 255, 0.9);
229
+ border-radius: 60rpx;
230
+ font-size: 60rpx;
231
+ color: #222222;
232
+ display: flex;
233
+ align-items: center;
234
+ justify-content: center;
235
+ white-space: nowrap;
236
+ margin: 20rpx 20rpx 0 0;
237
+ }
238
+
239
+ @keyframes bi-splash-ad-pip-scale {
240
+ 0% {
241
+ right: 0;
242
+ bottom: 0;
243
+ width: 100vw;
244
+ height: 100vh;
245
+ transform: scale(1);
246
+ border-radius: 0;
247
+ }
248
+
249
+ 100% {
250
+ right: 24rpx;
251
+ bottom: 24rpx;
252
+ width: 240rpx;
253
+ height: 320rpx;
254
+ transform: scale(1);
255
+ border-radius: 24rpx;
256
+ }
257
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @Description Weapp 广告组件公共工具方法
3
+ * @Author wutao
4
+ * @Date 2026-04-17
5
+ * @LastEditors wutao
6
+ * @LastEditTime 2026-04-17
7
+ */
8
+
9
+ /**
10
+ * 获取跳转目标类型
11
+ * @param {Record<string, any> | null | undefined} customAd 自定义广告数据
12
+ * @returns {'miniProgram' | 'internal' | 'web' | 'none'}
13
+ */
14
+ function getNavigationType(customAd) {
15
+ if (!customAd) return 'none'
16
+
17
+ if (customAd.appId || customAd.miniProgramAppId || customAd.jumpAppId) {
18
+ return 'miniProgram'
19
+ }
20
+
21
+ if (customAd.path || customAd.pagePath || customAd.jumpPath || customAd.targetUrl) {
22
+ return 'internal'
23
+ }
24
+
25
+ if (customAd.url || customAd.webUrl || customAd.h5Url) {
26
+ return 'web'
27
+ }
28
+
29
+ return 'none'
30
+ }
31
+
32
+ /**
33
+ * 获取小程序跳转 appId
34
+ * @param {Record<string, any> | null | undefined} customAd 自定义广告数据
35
+ * @returns {string}
36
+ */
37
+ function getNavigationAppId(customAd) {
38
+ if (!customAd) return ''
39
+ return customAd.appId || customAd.miniProgramAppId || customAd.jumpAppId || ''
40
+ }
41
+
42
+ /**
43
+ * 获取跳转路径
44
+ * @param {Record<string, any> | null | undefined} customAd 自定义广告数据
45
+ * @returns {string}
46
+ */
47
+ function getNavigationPath(customAd) {
48
+ if (!customAd) return ''
49
+ return customAd.path || customAd.pagePath || customAd.jumpPath || customAd.targetUrl || ''
50
+ }
51
+
52
+ /**
53
+ * 获取 Web 跳转地址
54
+ * @param {Record<string, any> | null | undefined} customAd 自定义广告数据
55
+ * @returns {string}
56
+ */
57
+ function getWebUrl(customAd) {
58
+ if (!customAd) return ''
59
+ return customAd.url || customAd.webUrl || customAd.h5Url || ''
60
+ }
61
+
62
+ /**
63
+ * 执行自定义广告跳转
64
+ * @param {Object} options 跳转参数
65
+ * @param {Record<string, any> | null | undefined} options.customAd 自定义广告数据
66
+ * @param {Record<string, any>} options.actionDetail 点击事件载荷
67
+ * @param {(detail: Record<string, any>) => void} options.onOpenWebview 打开 WebView 回调
68
+ * @param {(detail: Record<string, any>) => void} options.onError 错误回调
69
+ * @param {(provider: 'wechat' | 'custom', event?: Record<string, any> | null, extraDetail?: Record<string, any>) => Record<string, any>} options.resolveEventDetail 事件合并方法
70
+ * @param {string} options.miniProgramErrorCode 小程序跳转失败错误码
71
+ * @param {string} options.navigateErrorCode 内部页面跳转失败错误码
72
+ * @returns {void}
73
+ */
74
+ function navigateCustomAd(options) {
75
+ const {
76
+ customAd,
77
+ actionDetail,
78
+ onOpenWebview,
79
+ onError,
80
+ resolveEventDetail,
81
+ miniProgramErrorCode,
82
+ navigateErrorCode
83
+ } = options
84
+
85
+ if (!customAd) return
86
+
87
+ const targetType = getNavigationType(customAd)
88
+ const appId = getNavigationAppId(customAd)
89
+ const path = getNavigationPath(customAd)
90
+ const webUrl = getWebUrl(customAd)
91
+
92
+ if (targetType === 'miniProgram' && appId) {
93
+ if (typeof wx.navigateToMiniProgram !== 'function') return
94
+
95
+ wx.navigateToMiniProgram({
96
+ appId,
97
+ path: path || '',
98
+ fail: (error) => {
99
+ onError({
100
+ ...resolveEventDetail(actionDetail.provider, null),
101
+ errCode: miniProgramErrorCode,
102
+ errMsg: error.errMsg || '跳转到其他小程序失败'
103
+ })
104
+ }
105
+ })
106
+ return
107
+ }
108
+
109
+ if (targetType === 'internal' && path) {
110
+ if (typeof wx.navigateTo !== 'function') return
111
+
112
+ wx.navigateTo({
113
+ url: path,
114
+ fail: (error) => {
115
+ onError({
116
+ ...resolveEventDetail(actionDetail.provider, null),
117
+ errCode: navigateErrorCode,
118
+ errMsg: error.errMsg || '页面跳转失败'
119
+ })
120
+ }
121
+ })
122
+ return
123
+ }
124
+
125
+ if (targetType === 'web' && webUrl) {
126
+ onOpenWebview({
127
+ ...actionDetail,
128
+ url: webUrl
129
+ })
130
+ }
131
+ }
132
+
133
+ module.exports = {
134
+ getNavigationType,
135
+ getNavigationAppId,
136
+ getNavigationPath,
137
+ getWebUrl,
138
+ navigateCustomAd
139
+ }
@@ -0,0 +1,17 @@
1
+ Component({
2
+ externalClasses: ['bi-ad-card-button-class'],
3
+ properties: {
4
+ image: { type: String, value: '' },
5
+ title: { type: String, value: '广告' },
6
+ description: { type: String, value: '广告说明文字' },
7
+ buttonText: { type: String, value: '立即查看' }
8
+ },
9
+ methods: {
10
+ onClose() {
11
+ this.triggerEvent('close')
12
+ },
13
+ onAction() {
14
+ this.triggerEvent('action')
15
+ }
16
+ }
17
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "externalClasses": ["bi-ad-card-button-class"]
4
+ }
@@ -0,0 +1,8 @@
1
+ <view class="bi-ad-card">
2
+ <button class="bi-ad-card__close" aria-label="关闭" bindtap="onClose">&times;</button>
3
+ <image class="bi-ad-card__image" src="{{image}}" mode="aspectFill" />
4
+ <view class="bi-ad-card__content">
5
+ <text class="bi-ad-card__description">{{description}}</text>
6
+ <button class="bi-ad-card__button bi-ad-card-button-class" bindtap="onAction">{{buttonText}}</button>
7
+ </view>
8
+ </view>