jufubao-base 1.0.63-beta2 → 1.0.63-beta201

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,465 @@
1
+ <template>
2
+ <view
3
+ class="jfb-base-poster"
4
+ @click="handleEditxSelect"
5
+ :class="{ editx : isEditx && active }"
6
+ >
7
+ <!--#ifdef H5-->
8
+ <view
9
+ class="jfb-base-poster__edit"
10
+ :class="{ editx : isEditx && active }"
11
+ v-if="isEditx && active"
12
+ >
13
+ <view class="jfb-base-poster__edit-icon" @click="delEdit">删除</view>
14
+ </view>
15
+ <!-- #endif -->
16
+ <view
17
+ class="jfb-base-poster__body"
18
+ v-if="noData"
19
+ :style="{
20
+ margin: margin
21
+ }
22
+ ">
23
+ <!--一分屏-->
24
+ <template v-if="posterType === '1'">
25
+ <view
26
+ v-if="isCarousel === false"
27
+ class="jfb-base-poster__one notCarousel"
28
+ :style="{
29
+ width: width + 'rpx',
30
+ height: height + 'rpx',
31
+ borderRadius: (posterType === '1' ? radius: 0) + 'rpx',
32
+ }"
33
+ >
34
+ <view @click="handleClick(info[0])">
35
+ <image
36
+ :style="{
37
+ width: width + 'rpx',
38
+ height: height + 'rpx'
39
+ }"
40
+ :src="info[0].image_url"
41
+ mode="aspectFill"
42
+ ></image>
43
+ </view>
44
+ </view>
45
+ <view
46
+ v-else
47
+ class="jfb-base-poster__one carousel"
48
+ :style="{
49
+ width: width + 'rpx',
50
+ height: height + 'rpx',
51
+ borderRadius: (posterType === '1' ? radius: 0) + 'rpx',
52
+ }"
53
+ >
54
+ <xd-swiper-dot
55
+ :current="current"
56
+ :info="info"
57
+ field="content_name"
58
+ :mode="mode"
59
+ :dots-styles="dotStyleData"
60
+ >
61
+ <xd-swiper
62
+ :indicator-dots="false"
63
+ :list="info"
64
+ :current="current"
65
+ :width=" width + 'rpx'"
66
+ :height="height + 'rpx'"
67
+ @onClickItem="handleClick"
68
+ @animationfinish="handleAnimationfinish"
69
+ >
70
+ <template slot-scope="{ item, index}">
71
+ <image :src="item['image_url']" mode="aspectFill"></image>
72
+ </template>
73
+ </xd-swiper>
74
+ </xd-swiper-dot>
75
+
76
+ <view v-if="isPreview" class="carousel-mask"></view>
77
+ </view>
78
+ </template>
79
+ <!--一分屏-->
80
+ <more-screen
81
+ v-if="posterType !== '1'"
82
+ :config="getConfig"
83
+ :content="info"
84
+ ></more-screen>
85
+ </view>
86
+ </view>
87
+ </template>
88
+
89
+ <script>
90
+ const color = require('color');
91
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
92
+ import { jfbRootExec } from "@/utils/xd.event";
93
+ import JfbBaseVideoMixin from "./JfbBaseVideoMixin";
94
+ import componentsMixins from "@/mixins/componentsMixins";
95
+ import extsMixins from "@/mixins/extsMixins"
96
+ import { getContainerPropsValue } from "@/utils/xd.base";
97
+ import getServiceUrl from '@/common/getServiceUrl'
98
+ import XdImage from "@/components/XdImage/XdImage";
99
+ import XdSwiper from "@/components/XdSwiper/XdSwiper";
100
+ import MoreScreen from "./MoreScreen";
101
+ import XdSwiperDot from "./XdSwiperDot";
102
+
103
+ export default {
104
+ name: "JfbBaseVideo",
105
+ components: {
106
+ XdFontIcon,
107
+ XdImage,
108
+ XdSwiper,
109
+ MoreScreen,
110
+ XdSwiperDot
111
+ },
112
+ mixins: [componentsMixins,extsMixins,JfbBaseVideoMixin],
113
+ data() {
114
+ return {
115
+ selfMask: true,
116
+ params: {},
117
+
118
+ //Swiper 配置
119
+ mode:'round', //default 、round 、nav 、dot, indexes
120
+ current: 0,
121
+ poster: null,
122
+ posterPosition: null,
123
+ posterType: '1',//分屏模式
124
+ showType: '', //广告显示方式
125
+ isCarousel: true, //是否轮播图
126
+ carouselTime: 5,//轮播图轮播周期
127
+ useNumber: null, //广告使用张数
128
+ height: 0, //广告高度
129
+ width: 0, //广告高度
130
+ padding: 0, //广告内容之间间距
131
+ rows: 1, //四分屏起作用
132
+ radius: 0,
133
+ timer: null,
134
+ info: [],
135
+ mS: {
136
+ top: 0,
137
+ bottom: 0,
138
+ left: 0,
139
+ right: 0
140
+ },
141
+ isPreview: false,
142
+ noData:false,
143
+
144
+ test: {
145
+ "content_id": "KpBbUKdj4aBejwe7Fh1ki",
146
+ "position_id": "QCk3PmoyQmOWRP1SxnYR3",
147
+ "partner_id": 0,
148
+ "site_id": "",
149
+ "content_name": "测试.",
150
+ "image_url": "//dummyimage.com/200x200",
151
+ "redirect_type": "EMP",
152
+ "redirect_type_name": "无链接",
153
+ "redirect_data": "",
154
+ "sort": "",
155
+ "status": "",
156
+ "start_time": "",
157
+ "end_time": "",
158
+ "op_user_id": "",
159
+ "created_time": 0,
160
+ "updated_time": 0
161
+ }
162
+ }
163
+ },
164
+ computed: {
165
+ getConfig(){
166
+ let cell = this.posterType === '2' ? 2: (this.posterType === '3' ? 3: 4);
167
+ let spacing = Math.floor((cell - 1) * this.padding * this.$rpxNum);
168
+ let viewWidth = uni.getSystemInfoSync().safeArea.width - ((this.mS.right || 0) + (this.mS.left || 0)) * this.$rpxNum - spacing;
169
+ if(this.$configProject.isPreview) viewWidth -= 2;
170
+ let width = Math.floor(viewWidth / cell);
171
+ let height = this.height * width / this.width;
172
+ return {
173
+ mode: this.getMode,
174
+ dotStyleData: this.dotStyleData,
175
+ poster: this.poster,
176
+ showType: this.showType,
177
+ isCarousel: this.isCarousel,
178
+ carouselTime: this.carouselTime,
179
+ radius: this.radius,
180
+ padding: this.padding,
181
+ rows: this.rows,
182
+ cell,
183
+ height,
184
+ width
185
+ }
186
+ },
187
+ margin(){
188
+ return `${this.mS.top||0}rpx ${this.mS.right||0}rpx ${this.mS.bottom||0}rpx ${this.mS.left||0}rpx`
189
+ },
190
+ getMode(){
191
+ let mode = this.mode;
192
+ if (this.posterType !== '1') {
193
+ if (this.mode === 'nav'
194
+ || this.mode === 'indexes') {
195
+ mode = 'dot'
196
+ }
197
+ }
198
+ return mode;
199
+ },
200
+ dotStyleData(){
201
+ let alpha = 1;
202
+ if(this.posterType === '1') alpha = 0.6;
203
+
204
+ let selectedColor = `rgba(${color(this.mainColor).alpha(alpha).array().join(',')})`;
205
+ console.log('selectedColor',selectedColor, this.mode, this.posterType);
206
+ let style = {
207
+ dot: {
208
+ backgroundColor: 'rgba(166,166,166,.5)',
209
+ border: '0px rgba(166,166,166,.5) solid',
210
+ color: '#fff',
211
+ selectedBackgroundColor: selectedColor,
212
+ selectedBorder: `0px this.mainColor solid`
213
+ },
214
+ default: {
215
+ width: 16,
216
+ backgroundColor: 'rgba(200,200,200,.45)',
217
+ border: '1px rgba(200,200,200,.45) solid',
218
+ color: '#fff',
219
+ selectedBackgroundColor: selectedColor,
220
+ selectedBorder: `1px this.mainColor solid`
221
+ },
222
+ round: {
223
+ backgroundColor: 'rgba(166,166,166,.5)',
224
+ border: '0px rgba(166,166,166,.5) solid',
225
+ color: '#fff',
226
+ selectedBackgroundColor: selectedColor,
227
+ selectedBorder: `0px this.mainColor solid`
228
+ },
229
+ nav: {
230
+ backgroundColor: 'rgba(0,0,0,.5)',
231
+ border: '1px rgba(0,0,0,.5) solid',
232
+ color: '#fff',
233
+ selectedBackgroundColor: 'rgba(255, 255, 255, 1)',
234
+ selectedBorder: '1px rgba(255, 255, 255 1) solid'
235
+ },
236
+ indexes: {
237
+ backgroundColor: 'rgba(0,0,0,.5)',
238
+ border: '0px rgba(0,0,0,.5) solid',
239
+ color: '#aaa',
240
+ selectedBackgroundColor: 'rgba(0,0,0,.8)',
241
+ selectedBorder: '0px rgba(0,0,0,.8) solid',
242
+ selectedColor: '#fff',
243
+ }
244
+ }
245
+ if(this.posterType !== '1') {
246
+ if(this.mode === 'nav'
247
+ || this.mode === 'indexes') {
248
+ this.mode = 'dot'
249
+ }
250
+ }
251
+ return style[this.mode]
252
+ },
253
+ },
254
+ watch: {
255
+ container(value) {
256
+ this.init(value);
257
+ if(this.timer) clearTimeout(this.timer);
258
+ this.timer = setTimeout(()=>{
259
+ if (this.$configProject['isPreview']) this.onJfbLoad()
260
+ }, 400)
261
+ }
262
+ },
263
+ created() {
264
+ this.init(this.container);
265
+ this.isPreview = this.$configProject.isPreview;
266
+ },
267
+ methods: {
268
+ getTestData(){
269
+ let temp = [];
270
+ for (let i = 0; i< this.useNumber; i++) {
271
+ let item = this.$xdUniHelper.cloneDeep(this.test);
272
+ item.content_id = i;
273
+ item.content_name = item.content_name + i;
274
+ item.image_url = `//dummyimage.com/${this.width}x${this.height}`;
275
+ temp.push(item)
276
+ }
277
+ return temp
278
+ },
279
+ handleAnimationfinish(e) {
280
+ this.current = e.detail.current;
281
+ },
282
+ handleClick(item) {
283
+ //内部链接跳转地址
284
+ if (item.redirect_type === 'INN') {
285
+ try {
286
+ let url = JSON.parse(item.redirect_data);
287
+ let params = '';
288
+ if (item['redirect_params']) params = `?${item['redirect_params']}`;
289
+ this.$xdUniHelper.navigateTo({
290
+ url: url.page + params
291
+ })
292
+ } catch (e) {
293
+ console.error(e)
294
+ }
295
+ }
296
+
297
+ //外部链接
298
+ if (item.redirect_type === 'URL') {
299
+ let reg = /^(http:\/\/|https:\/\/|\/\/)+.+$/;
300
+ //#ifdef MP-WEIXIN
301
+ try {
302
+ let url = JSON.parse(item.redirect_data);
303
+ if (reg.test(url.url) && this.$configProject.extras.webview) {
304
+ console.warn(`广告跳转外站: ${url.url}`)
305
+ this.$xdUniHelper.navigateTo({
306
+ url: `${this.$configProject.extras.webview}?seatUrl=${Base64.encodeURI(url.url)}`
307
+ });
308
+ } else {
309
+ throw Error('地址错误')
310
+ }
311
+ } catch (e) {
312
+ console.error(e)
313
+ }
314
+ //#endif
315
+ //#ifdef H5
316
+ try {
317
+ let url = JSON.parse(item.redirect_data);
318
+ if (reg.test(url.url)) {
319
+ console.warn(`广告跳转外站: ${url.url}`);
320
+ window.location.href = url.url;
321
+ } else {
322
+ throw Error('地址错误')
323
+ }
324
+ } catch (e) {
325
+ console.error(e)
326
+ }
327
+ //#endif
328
+
329
+ }
330
+ },
331
+ handleImage(list){
332
+ return list.map(item => {
333
+ return {
334
+ ...item,
335
+ image_url: getServiceUrl(item.image_url)
336
+ }
337
+ })
338
+ },
339
+ handleOne(list){
340
+ this.info = this.handleImage(list);
341
+ },
342
+
343
+ getDefualtValue(key){
344
+ if (key === 'margin') {
345
+ return {top: 0, bottom: 0, left: 0, right: 0}
346
+ }
347
+ },
348
+
349
+ /**
350
+ * @description 监听事件变化
351
+ * @param container {object} 业务组件对象自己
352
+ */
353
+ init(container) {
354
+ this.poster = getContainerPropsValue(container, 'content.poster', {size:{width: 750, height: 160}, type: '1'});
355
+ if (this.poster.type) {
356
+ this.posterType = this.poster.type
357
+ }
358
+ if(this.poster.position) {
359
+ this.posterPosition = this.poster.position
360
+ }
361
+ this.radius = getContainerPropsValue(container, 'content.radius', 0);
362
+ this.padding = getContainerPropsValue(container, 'content.padding', 0);
363
+ this.rows = getContainerPropsValue(container, 'content.rows', 1);
364
+ this.mS = getContainerPropsValue(container, 'content.margin', this.getDefualtValue('margin'));
365
+
366
+ //content
367
+ this.mode = getContainerPropsValue(container, 'content.dot_type', 'dot');
368
+ this.isCarousel = getContainerPropsValue(container, 'content.isCarousel', 1) === 2;
369
+ this.carouselTime = Number(getContainerPropsValue(container, 'content.carouselTime', 5)) * 1000;
370
+ this.useNumber = getContainerPropsValue(container, 'content.number', 1);
371
+
372
+ if(this.poster.size) {
373
+ this.width = this.poster.size.width;
374
+ this.height = this.poster.size.height;
375
+ }
376
+ },
377
+
378
+ onJfbLoad(options) {
379
+ this.params = options;
380
+ jfbRootExec('getListPosterContent', {
381
+ vm: this,
382
+ data: {
383
+ page_id: this.pageAttr['page_id'], //页面ID
384
+ container_id: this.containerId, //组件ID
385
+ page_size: this.useNumber //可以不传
386
+ },
387
+ })
388
+ .then(res => {
389
+ if(res.list.length === 0 && this.isPreview) {
390
+ res.list = this.getTestData();
391
+ }
392
+
393
+ if (this.posterType === '1') this.handleOne(res.list);
394
+ if (this.posterType === '2') this.handleOne(res.list);
395
+ if (this.posterType === '3') this.handleOne(res.list);
396
+ if (this.posterType === '4') this.handleOne(res.list);
397
+ if(this.$configProject.isPreview) this.noData = true;
398
+ else this.noData = res.list.length > 0;
399
+ })
400
+ .catch(error => {
401
+ console.error(error)
402
+ })
403
+ },
404
+
405
+ onJfbUpdate(data) {
406
+ this.onJfbLoad(this.params);
407
+ }
408
+
409
+
410
+ }
411
+ }
412
+
413
+ </script>
414
+
415
+ <style scoped lang="less">
416
+ @import "./JfbBasePosterLess.less";
417
+
418
+ .jfb-base-video {
419
+ &__body{
420
+ box-sizing: border-box;
421
+ overflow: hidden;
422
+ justify-content: center;
423
+ align-items: center;
424
+ display: flex;
425
+ }
426
+ &__one.notCarousel {
427
+ position: relative;
428
+ box-sizing: border-box;
429
+ display: flex;
430
+ justify-content: center;
431
+ align-items: center;
432
+ overflow: hidden;
433
+
434
+
435
+ & > view {
436
+ width: 100%;
437
+ height: 100%;
438
+ box-sizing: border-box;
439
+
440
+ & > image {
441
+
442
+ }
443
+ }
444
+ }
445
+
446
+ &__one.carousel {
447
+ position: relative;
448
+ box-sizing: border-box;
449
+ display: flex;
450
+ justify-content: center;
451
+ align-items: center;
452
+ overflow: hidden;
453
+
454
+ & .carousel-mask {
455
+ position: absolute;
456
+ left: 0;
457
+ right: 0;
458
+ top: 0;
459
+ bottom: 0;
460
+ background: rgba(0,0,0,0);
461
+ }
462
+ }
463
+
464
+ }
465
+ </style>
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @desc 获取绝对路径完整地址
3
+ * @param @path
4
+ **/
5
+ //例如:https://image.jufubao.cn/20220501010108/image/bg/default_gonghui_bg.png
6
+ @basePath: 'business/';
7
+ @doMain: '//sandbox-img.jufubao.cn/';
8
+
9
+ .getBusinessImageUrl(@path, @size: 'size8') {
10
+ @url: "@{doMain}@{basePath}@{path}?x-oss-process=style/@{size}";
11
+ background-image: url(@url);
12
+ }
13
+
14
+ //start
15
+ .jfb-base-video {
16
+ border: 1px dashed rgba(0, 0, 0, 0);
17
+ box-sizing: border-box;
18
+ min-height: unit(100, rpx);
19
+
20
+ &__body{
21
+ position: relative;
22
+ overflow: hidden;
23
+ z-index: 2
24
+ }
25
+
26
+ &.editx {
27
+ position: relative;
28
+ border: 1px dashed blue;
29
+ box-sizing: border-box;
30
+ z-index: 3
31
+
32
+ }
33
+
34
+ &:hover {
35
+ border: 1px dashed blue;
36
+ }
37
+
38
+ &.noBorder {
39
+ border-color: rgba(0,0,0,0);
40
+ border-width: 0;
41
+ }
42
+
43
+
44
+ &__edit {
45
+ cursor: pointer;
46
+ position: absolute;
47
+ right: unit(0, rpx);
48
+ top: unit(-52, rpx);
49
+ height: unit(50, rpx);
50
+ line-height: unit(50, rpx);
51
+ display: flex;
52
+ justify-content: center;
53
+ align-items: center;
54
+ background: rgba(0, 0, 0, .6);
55
+ border-radius: unit(10, rpx);
56
+ box-shadow: 0 0 10px rbga(0, 0, 0, 0.3);
57
+ color: #fff;
58
+ font-size: unit(22, rpx);
59
+
60
+ &-icon{
61
+ padding: 0 unit(20, rpx);
62
+ }
63
+
64
+ &.editx {
65
+ box-sizing: border-box;
66
+
67
+ }
68
+ }
69
+ }
70
+ //end
71
+
72
+
73
+ /**notPreview**/
74
+ .jfb-base-video {
75
+ &:before {
76
+ content: " ";
77
+ display: table;
78
+ }
79
+ }
80
+ /**endNotPreview**/
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+
4
+ //@AttrImport
5
+ import Attr from "./Attr";
6
+ //@EndAttrImport
7
+
8
+
9
+ export default {
10
+ data() {
11
+ return {
12
+ //#ifdef H5
13
+
14
+ //@AttrData
15
+ Attr:{}, //对外开发编辑属性
16
+ //@EndAttrData
17
+
18
+ // #endif
19
+ cssRoot: 'jfb-base-video'
20
+ }
21
+ },
22
+ created() {
23
+
24
+ //@AttrDataCreated
25
+ this.Attr = this.$xdUniHelper.customClone(Attr);
26
+ //@EndAttrDataCreated
27
+
28
+
29
+ },
30
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ aaaa: {}
5
+ }