jufubao-base 1.0.63-beta203 → 1.0.63-beta205

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.
@@ -1,411 +1,139 @@
1
1
  <template>
2
2
  <view
3
- class="jfb-base-poster"
3
+ class="jfb-base-video"
4
4
  @click="handleEditxSelect"
5
5
  :class="{ editx : isEditx && active }"
6
6
  >
7
7
  <!--#ifdef H5-->
8
8
  <view
9
- class="jfb-base-poster__edit"
9
+ class="jfb-base-video__edit"
10
10
  :class="{ editx : isEditx && active }"
11
11
  v-if="isEditx && active"
12
12
  >
13
- <view class="jfb-base-poster__edit-icon" @click="delEdit">删除</view>
13
+ <view class="jfb-base-video__edit-icon" @click="delEdit">删除</view>
14
14
  </view>
15
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>
16
+ <view class="jfb-base-video__body">
17
+ <view class="float"></view>
18
+ <view class="video" v-if="video !== null">
19
+ <xd-video
20
+ :margin="margin"
21
+ :poster="videoSetting"
22
+ :video="video"
23
+ :radius="radius"
24
+ :pack-this="$vm"
25
+ ></xd-video>
26
+ </view>
85
27
  </view>
86
28
  </view>
87
29
  </template>
88
30
 
89
31
  <script>
90
32
  const color = require('color');
91
- import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
92
33
  import { jfbRootExec } from "@/utils/xd.event";
93
34
  import JfbBaseVideoMixin from "./JfbBaseVideoMixin";
94
35
  import componentsMixins from "@/mixins/componentsMixins";
95
36
  import extsMixins from "@/mixins/extsMixins"
96
37
  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";
38
+ import XdVideo from "./XdVideo.vue";
39
+
102
40
 
103
41
  export default {
104
42
  name: "JfbBaseVideo",
105
43
  components: {
106
- XdFontIcon,
107
- XdImage,
108
- XdSwiper,
109
- MoreScreen,
110
- XdSwiperDot
44
+ XdVideo
111
45
  },
112
46
  mixins: [componentsMixins,extsMixins,JfbBaseVideoMixin],
113
47
  data() {
114
48
  return {
115
49
  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
- }
50
+ page_size: 1,
51
+ options:{},
52
+
53
+ //data
54
+ video: null,
55
+ videoSetting: null,
56
+ margin:{},
57
+ radius:0,
58
+ $vm: {}
162
59
  }
163
60
  },
164
61
  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;
62
+ iconFont(){
63
+ if(this.autoplay === 'N') return 'iconplayright'
64
+ if(this.autoplay === 'E') return 'iconshibai';
65
+ if(this.autoplay === 'R') return 'iconplayreplay';
66
+ },
67
+ contentWidth(){
68
+ let border = 0;
69
+ if(this.isPreview) border = 2;
70
+ return 750 - (this.margin.left + this.margin.right + border);
71
+ },
72
+ contentHeight(){
73
+ let border = 0;
74
+ if(this.isPreview) border = 2;
75
+ let winWidth = 750 - ((this.margin.left||0) + (this.margin.right||0) + border);
76
+ return winWidth * this.height/this.width;
77
+ },
203
78
 
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
- },
79
+ outMargin(){
80
+ let margin = `${this.margin.top !== null ? this.margin.top : 0}rpx`;
81
+ margin = `${margin} ${this.margin.right !== null ? this.margin.right : 0}rpx`;
82
+ margin = `${margin} ${this.margin.bottom !== null ? this.margin.bottom :0}rpx`;
83
+ margin = `${margin} ${this.margin.left !== null ? this.margin.left : 0}rpx`;
84
+ return margin;
85
+ }
253
86
  },
254
87
  watch: {
255
88
  container(value) {
256
89
  this.init(value);
257
90
  if(this.timer) clearTimeout(this.timer);
258
91
  this.timer = setTimeout(()=>{
259
- if (this.$configProject['isPreview']) this.onJfbLoad()
92
+ if (this.$configProject['isPreview']) this.onJfbLoad(this.options)
260
93
  }, 400)
261
94
  }
262
95
  },
263
96
  created() {
264
- this.init(this.container);
97
+ this.$vm = this;
265
98
  this.isPreview = this.$configProject.isPreview;
99
+ this.init(this.container);
100
+
266
101
  },
267
102
  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
103
 
349
104
  /**
350
105
  * @description 监听事件变化
351
106
  * @param container {object} 业务组件对象自己
352
107
  */
353
108
  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
- }
109
+ this.videoSetting = getContainerPropsValue(container, 'content.video', {size:{width: 400, height: 300}, type: '1'});
110
+ this.margin = getContainerPropsValue(container, 'content.margin', {top:0, bottom:0, right:0, left: 0});
361
111
  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
112
  },
377
113
 
378
114
  onJfbLoad(options) {
379
- this.params = options;
115
+ this.options = options;
380
116
  jfbRootExec('getListPosterContent', {
381
117
  vm: this,
382
118
  data: {
383
119
  page_id: this.pageAttr['page_id'], //页面ID
384
120
  container_id: this.containerId, //组件ID
385
- page_size: this.useNumber //可以不传
121
+ page_size: this.page_size //可以不传
386
122
  },
387
123
  })
388
124
  .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;
125
+ if(res && res.list && res.list.length > 0) {
126
+ this.video = res.list[0];
127
+ }
399
128
  })
400
129
  .catch(error => {
401
- console.error(error)
130
+ this.$xdLog.catch(error)
402
131
  })
403
132
  },
404
133
 
405
- onJfbUpdate(data) {
406
- this.onJfbLoad(this.params);
407
- }
408
-
134
+ onJfbUpdate() {
135
+ this.onJfbLoad(this.options);
136
+ },
409
137
 
410
138
  }
411
139
  }
@@ -417,49 +145,15 @@
417
145
 
418
146
  .jfb-base-video {
419
147
  &__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
148
 
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;
149
+ }
453
150
 
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
- }
151
+ }
463
152
 
153
+ .float {
154
+ height: 1px;
155
+ width: 100%;
156
+ overflow: hidden;
464
157
  }
158
+
465
159
  </style>
@@ -1,5 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = {
4
- aaaa: {}
5
- }
3
+ module.exports = {}