jufubao-base 1.0.157-beta2 → 1.0.157-beta4

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,3 +1,4 @@
1
+ <script src="JfbBasePosterBigSmallMixin.js"></script>
1
2
  <template>
2
3
  <view
3
4
  class="jfb-base-poster-big-small"
@@ -10,9 +11,7 @@
10
11
  :class="{ editx: isEditx && active }"
11
12
  v-if="isEditx && active"
12
13
  >
13
- <view class="jfb-base-poster-big-small__edit-icon" @click="delEdit"
14
- >删除</view
15
- >
14
+ <view class="jfb-base-poster-big-small__edit-icon" @click="delEdit">删除</view>
16
15
  </view>
17
16
  <!-- #endif -->
18
17
  <view class="jfb-base-poster-big-small__body">
@@ -22,6 +21,7 @@
22
21
  margin: margin,
23
22
  flexDirection: position === 1 ? 'row' : 'row-reverse',
24
23
  }"
24
+ v-if="isShowAd"
25
25
  >
26
26
  <view
27
27
  v-if="isCarousel === 1"
@@ -60,6 +60,26 @@
60
60
  :mode="dot_type"
61
61
  :dots-styles="dotStyleData"
62
62
  >
63
+ <!--#ifdef MP-WEIXIN-->
64
+ <swiper
65
+ :style="{width: bigWidth + 'rpx', height: bigHeight + 'rpx'}"
66
+ :indicator-dots="false"
67
+ :autoplay="carouselTime>0"
68
+ :interval="carouselTime"
69
+ :duration="500"
70
+ :current="current"
71
+ circular
72
+ @animationfinish="handleBigAnimationfinish"
73
+ >
74
+ <swiper-item v-for="(item,index) in bigList" :key="index" @click.stop="handleClick(item)">
75
+ <image
76
+ :style="{borderRadius: radius + 'rpx',width: bigWidth + 'rpx',height: bigHeight + 'rpx',}"
77
+ :src="item['image_url']"
78
+ mode="aspectFill"></image>
79
+ </swiper-item>
80
+ </swiper>
81
+ <!--#endif-->
82
+ <!--#ifdef H5-->
63
83
  <xd-swiper
64
84
  :indicator-dots="false"
65
85
  :list="bigList"
@@ -71,15 +91,10 @@
71
91
  @animationfinish="handleBigAnimationfinish"
72
92
  >
73
93
  <template slot-scope="{ item, index }">
74
- <image
75
- :style="{
76
- borderRadius: radius + 'rpx',
77
- }"
78
- :src="item['image_url']"
79
- mode="aspectFill"
80
- ></image>
94
+ <image :style="{borderRadius: radius + 'rpx',}" :src="item['image_url']" mode="aspectFill"></image>
81
95
  </template>
82
96
  </xd-swiper>
97
+ <!--#endif-->
83
98
  </xd-swiper-dot>
84
99
  <view v-if="isPreview" class="carousel-mask"></view>
85
100
  </view>
@@ -112,7 +127,7 @@
112
127
  }"
113
128
  :src="topList[0].image_url"
114
129
  mode="aspectFill"
115
- ></image> </view
130
+ ></image></view
116
131
  ></view>
117
132
  <view
118
133
  v-else
@@ -129,6 +144,26 @@
129
144
  :mode="top_dot_type"
130
145
  :dots-styles="topDotStyleData"
131
146
  >
147
+ <!--#ifdef MP-WEIXIN-->
148
+ <swiper
149
+ :style="{width: bigWidth + 'rpx', height: smallHeight + 'rpx'}"
150
+ :indicator-dots="false"
151
+ :autoplay="topCarouselTime>0"
152
+ :interval="topCarouselTime"
153
+ :duration="500"
154
+ :current="current"
155
+ circular
156
+ @animationfinish="handleBigAnimationfinish"
157
+ >
158
+ <swiper-item v-for="(item,index) in topList" :key="index" @click.stop="handleClick(item)">
159
+ <image
160
+ :style="{borderRadius: radius + 'rpx',width: bigWidth + 'rpx',height: smallHeight + 'rpx',}"
161
+ :src="item['image_url']"
162
+ mode="aspectFill"></image>
163
+ </swiper-item>
164
+ </swiper>
165
+ <!--#endif-->
166
+ <!--#ifdef H5-->
132
167
  <xd-swiper
133
168
  :indicator-dots="false"
134
169
  :list="topList"
@@ -140,17 +175,11 @@
140
175
  @animationfinish="handleTopAnimationfinish"
141
176
  >
142
177
  <template slot-scope="{ item, index }">
143
- <image
144
- :style="{
145
- borderRadius: topRadius + 'rpx',
146
- }"
147
- :src="item['image_url']"
148
- mode="aspectFill"
149
- ></image>
178
+ <image :style="{borderRadius: topRadius + 'rpx',}" :src="item['image_url']" mode="aspectFill"></image>
150
179
  </template>
151
180
  </xd-swiper>
181
+ <!--#endif-->
152
182
  </xd-swiper-dot>
153
-
154
183
  <view v-if="isPreview" class="carousel-mask"></view>
155
184
  </view>
156
185
  </view>
@@ -193,6 +222,26 @@
193
222
  :mode="bottom_dot_type"
194
223
  :dots-styles="bottomDotStyleData"
195
224
  >
225
+ <!--#ifdef MP-WEIXIN-->
226
+ <swiper
227
+ :style="{width: bigWidth + 'rpx', height: smallHeight + 'rpx'}"
228
+ :indicator-dots="false"
229
+ :autoplay="bottomCarouselTime>0"
230
+ :interval="bottomCarouselTime"
231
+ :duration="500"
232
+ :current="current"
233
+ circular
234
+ @animationfinish="handleBigAnimationfinish"
235
+ >
236
+ <swiper-item v-for="(item,index) in bottomList" :key="index" @click.stop="handleClick(item)">
237
+ <image
238
+ :style="{borderRadius: radius + 'rpx',width: bigWidth + 'rpx',height: smallHeight + 'rpx',}"
239
+ :src="item['image_url']"
240
+ mode="aspectFill"></image>
241
+ </swiper-item>
242
+ </swiper>
243
+ <!--#endif-->
244
+ <!--#ifdef H5-->
196
245
  <xd-swiper
197
246
  :indicator-dots="false"
198
247
  :list="bottomList"
@@ -213,8 +262,8 @@
213
262
  ></image>
214
263
  </template>
215
264
  </xd-swiper>
265
+ <!--#endif-->
216
266
  </xd-swiper-dot>
217
-
218
267
  <view v-if="isPreview" class="carousel-mask"></view>
219
268
  </view>
220
269
  </view>
@@ -246,6 +295,7 @@ export default {
246
295
  mixins: [componentsMixins, extsMixins, JfbBasePosterBigSmallMixin],
247
296
  data() {
248
297
  return {
298
+ params:{},
249
299
  height: 0, //组件高度
250
300
  mS: {
251
301
  top: 0,
@@ -280,6 +330,7 @@ export default {
280
330
  //大图
281
331
  current: 0,
282
332
  carouselTime: 5, //轮播图轮播周期
333
+
283
334
  bigList: [],
284
335
  number: null,
285
336
  dot_type: "dot",
@@ -295,6 +346,7 @@ export default {
295
346
  bottomRadius: 0, //小图上圆角
296
347
  bottomCurrent: 0, //小图上
297
348
  bottomIsCarousel: 1,
349
+ bottomCarouselTime:0,
298
350
 
299
351
  //小图上
300
352
  topList: [],
@@ -304,6 +356,7 @@ export default {
304
356
  topCurrent: 0, //小图上
305
357
  topIsCarousel: 1,
306
358
  smallHeight: 0,
359
+ topCarouselTime:0,
307
360
 
308
361
  timer: null,
309
362
 
@@ -467,6 +520,10 @@ export default {
467
520
  };
468
521
  return style[this.bottom_dot_type];
469
522
  },
523
+ isShowAd(){
524
+ if(this.bigList.length === 0 && this.topList.length === 0 && this.bottomList.length === 0 ) return false
525
+ return true
526
+ },
470
527
  },
471
528
  watch: {
472
529
  container(value,oloValue) {
@@ -499,6 +556,9 @@ export default {
499
556
  if (res.list.length === 0 && this.isPreview) {
500
557
  res.list = this.getTestData("big");
501
558
  }
559
+
560
+ res.list = this.filterItem(res.list);
561
+
502
562
  //将res.list中的image_url替换为服务地址
503
563
  this.bigList =
504
564
  res.list &&
@@ -513,6 +573,7 @@ export default {
513
573
  .catch((error) => {
514
574
  console.error(error);
515
575
  });
576
+
516
577
  //获取小图上列表
517
578
  jfbRootExec("getListPosterContent", {
518
579
  vm: this,
@@ -527,6 +588,9 @@ export default {
527
588
  if (res.list.length === 0 && this.isPreview) {
528
589
  res.list = this.getTestData("top");
529
590
  }
591
+
592
+ res.list = this.filterItem(res.list);
593
+
530
594
  //将res.list中的image_url替换为服务地址
531
595
  this.topList =
532
596
  res.list &&
@@ -541,6 +605,7 @@ export default {
541
605
  .catch((error) => {
542
606
  console.error(error);
543
607
  });
608
+
544
609
  //获取小图下列表
545
610
  jfbRootExec("getListPosterContent", {
546
611
  vm: this,
@@ -555,6 +620,9 @@ export default {
555
620
  if (res.list.length === 0 && this.isPreview) {
556
621
  res.list = this.getTestData("bottom");
557
622
  }
623
+
624
+ res.list = this.filterItem(res.list);
625
+
558
626
  //将res.list中的image_url替换为服务地址
559
627
  this.bottomList =
560
628
  res.list &&
@@ -579,65 +647,136 @@ export default {
579
647
  handleBottomAnimationfinish(e) {
580
648
  this.bottomCurrent = e.detail.current;
581
649
  },
650
+
651
+ /**
652
+ * @description 过滤不可以用
653
+ * 当前项目未H5时,过滤所有小程序应用
654
+ * 当前项目未小程序时,过滤所有非当前小程序应用
655
+ * 站外地址直接返回
656
+ * 站内地址未选值直接返回
657
+ * 预览模式全过
658
+ */
659
+ filterItem(list = []){
660
+ let content = list.filter(item=>{
661
+ //预览模式
662
+ if( this.$configProject.isPreview) return true;
663
+
664
+ //非内部应用
665
+ if(item.redirect_type !== 'INN') return true
666
+
667
+ //没有配置链接
668
+ if(!item.redirect_data) return true;
669
+
670
+ //内部应用
671
+ else {
672
+ let redirect_data;
673
+ try {
674
+ redirect_data = JSON.parse(item.redirect_data);
675
+ if(!item['app_type']) item['app_type']= 'h5';
676
+
677
+ //#ifdef H5
678
+ return item['app_type'] !== 'wxmp';
679
+ //#endif
680
+
681
+ //#ifdef MP-WEIXIN
682
+ let actDir = this.$parent.projectAttr.deploy_dir;
683
+ let dir = this.getPathDir(redirect_data.page);
684
+ if(item['app_type'] === 'wxmp'){
685
+ return actDir === dir;
686
+ }
687
+ else if(item['app_type'] === 'h5') return true;
688
+ else return true
689
+ //#endif
690
+ }
691
+ catch (e) {
692
+ return true
693
+ }
694
+ }
695
+ });
696
+ console.warn(`PostersList:${JSON.stringify(content.map(item=>`${item.app_type}:${item.content_name}:${item.redirect_data}`), null,2)}`)
697
+ return content;
698
+
699
+ },
700
+
701
+ getPathDir(pathDir){
702
+ if(pathDir.indexOf('@site_domain@/') === 0) {
703
+ return pathDir.replace('@site_domain@/','').split('/')[0]
704
+ }
705
+ return ''
706
+ },
707
+
582
708
  handleClick(item) {
709
+ if(!item.redirect_data) {
710
+ console.warn(`未配置链接地址: ${item.redirect_data}`);
711
+ console.error(`未配置链接地址: ${item.redirect_data}`);
712
+ return
713
+ }
714
+
583
715
  //内部链接跳转地址
584
- if (item.redirect_type === "INN") {
716
+ if (item.redirect_type === 'INN') {
585
717
  try {
586
718
  let url = JSON.parse(item.redirect_data);
587
- let params = "";
588
- if (item["redirect_params"]) params = `?${item["redirect_params"]}`;
589
- this.$xdUniHelper.navigateTo({
590
- url: url.page + params,
591
- });
719
+ let params = '';
720
+ if(url.page) {
721
+ if (item['redirect_params']) params = `?${item['redirect_params']}`;
722
+ this.$xdUniHelper.navigateTo({url: url.page + params})
723
+ }
724
+ else {
725
+ console.error(`应用链接配置错误: ${url.page}`)
726
+ }
592
727
  } catch (e) {
593
- console.error(e);
728
+ console.error(`应用链接配置错误: ${item.redirect_data}`)
594
729
  }
595
730
  }
596
731
 
597
732
  //外部链接
598
- if (item.redirect_type === "URL") {
733
+ if (item.redirect_type === 'URL') {
599
734
  let reg = /^(http:\/\/|https:\/\/|\/\/)+.+$/;
600
735
  //#ifdef MP-WEIXIN
601
736
  try {
602
737
  let url = JSON.parse(item.redirect_data);
603
- if (reg.test(url.url) && this.$configProject.extras.webview) {
604
- console.warn(`广告跳转外站: ${url.url}`);
605
- this.$xdUniHelper.navigateTo({
606
- url: `${
607
- this.$configProject.extras.webview
608
- }?seatUrl=${Base64.encodeURI(url.url)}`,
609
- });
738
+ if (reg.test(url.url)) {
739
+ console.warn(`广告跳转外站: ${url.url}`)
740
+ this.$xdUniHelper.navigateTo(url);
610
741
  } else {
611
- throw Error("地址错误");
742
+ console.error(`广告跳转外站配置错误: ${url.url}`)
612
743
  }
613
744
  } catch (e) {
614
- console.error(e);
745
+ console.error(`广告跳转外站配置错误: ${item.redirect_data}`)
615
746
  }
616
747
  //#endif
617
748
  //#ifdef H5
618
749
  try {
619
750
  let url = JSON.parse(item.redirect_data);
620
751
  console.warn(`广告跳转外站: ${url.url}`);
621
- this.$xdUniHelper.navigateTo(url)
752
+ this.$xdUniHelper.redirectTo(url, false)
622
753
  } catch (e) {
623
- console.error(e);
754
+ console.error(`广告跳转外站配置错误: ${item.redirect_data}`)
624
755
  }
625
756
  //#endif
757
+
758
+ }
759
+
760
+ //无跳转地址
761
+ if(item.redirect_type === 'EMP') {
762
+ console.warn(`无跳转地址`);
626
763
  }
627
764
  },
765
+
766
+
628
767
  getTestData(type) {
629
768
  let width;
630
769
  let height;
631
770
  // 根据type参数,设置width和height
632
- if (type == "big") {
771
+ if (type === "big") {
633
772
  width = this.bigWidth;
634
773
  height = this.bigHeight;
635
774
  }
636
- if (type == "top") {
775
+ if (type === "top") {
637
776
  width = this.bigWidth;
638
777
  height = this.smallHeight;
639
778
  }
640
- if (type == "bottom") {
779
+ if (type === "bottom") {
641
780
  width = this.bigWidth;
642
781
  height = this.smallHeight;
643
782
  }
@@ -658,6 +797,7 @@ export default {
658
797
  // 返回临时数组
659
798
  return temp;
660
799
  },
800
+
661
801
  /**
662
802
  * @description 监听事件变化
663
803
  * @param container {object} 业务组件对象自己
@@ -744,6 +884,7 @@ export default {
744
884
  getContainerPropsValue(container, "content.bottomCarouselTime", 5)
745
885
  ) * 1000;
746
886
  },
887
+
747
888
  onJfbUpdate(data) {
748
889
  this.onJfbLoad(this.params);
749
890
  }
@@ -122,50 +122,120 @@
122
122
  this.init(this.container);
123
123
  },
124
124
  methods: {
125
- handleClick(item){
125
+ /**
126
+ * @description 过滤不可以用
127
+ * 当前项目未H5时,过滤所有小程序应用
128
+ * 当前项目未小程序时,过滤所有非当前小程序应用
129
+ * 站外地址直接返回
130
+ * 站内地址未选值直接返回
131
+ * 预览模式全过
132
+ */
133
+ filterItem(list){
134
+ let content = list.filter(item=>{
135
+ //预览模式
136
+ if( this.$configProject.isPreview) return true;
137
+
138
+ //非内部应用
139
+ if(item.redirect_type !== 'INN') return true
140
+
141
+ //没有配置链接
142
+ if(!item.redirect_data) return true;
143
+
144
+ //内部应用
145
+ else {
146
+ let redirect_data;
147
+ try {
148
+ redirect_data = JSON.parse(item.redirect_data);
149
+ if(!item['app_type']) item['app_type']= 'h5';
150
+
151
+ //#ifdef H5
152
+ return item['app_type'] !== 'wxmp';
153
+ //#endif
154
+
155
+ //#ifdef MP-WEIXIN
156
+ let actDir = this.projectAttr.deploy_dir;
157
+ let dir = this.getPathDir(redirect_data.page);
158
+ if(item['app_type'] === 'wxmp'){
159
+ return actDir === dir;
160
+ }
161
+ else if(item['app_type'] === 'h5') return true;
162
+ else return true
163
+ //#endif
164
+ }
165
+ catch (e) {
166
+ return true
167
+ }
168
+ }
169
+ });
170
+ console.warn(`PostTypeList:${JSON.stringify(content.map(item=>`${item.app_type}:${item.content_name}:${item.redirect_data}`), null,2)}`)
171
+ return content;
172
+
173
+ },
174
+
175
+ getPathDir(pathDir){
176
+ if(pathDir.indexOf('@site_domain@/') === 0) {
177
+ return pathDir.replace('@site_domain@/','').split('/')[0]
178
+ }
179
+ return ''
180
+ },
181
+
182
+
183
+ handleClick(item) {
184
+ if(!item.redirect_data) {
185
+ console.warn(`未配置链接地址: ${item.redirect_data}`);
186
+ console.error(`未配置链接地址: ${item.redirect_data}`);
187
+ return
188
+ }
189
+
126
190
  //内部链接跳转地址
127
- if(item.redirect_type === 'INN') {
128
- try{
191
+ if (item.redirect_type === 'INN') {
192
+ try {
129
193
  let url = JSON.parse(item.redirect_data);
130
194
  let params = '';
131
- if(item['redirect_params']) params = `?${item['redirect_params']}`;
132
- this.$xdUniHelper.navigateTo({
133
- url: url.page + params
134
- })
135
- }catch (e) {
136
- console.error(e)
195
+ if(url.page) {
196
+ if (item['redirect_params']) params = `?${item['redirect_params']}`;
197
+ this.$xdUniHelper.navigateTo({url: url.page + params})
198
+ }
199
+ else {
200
+ console.error(`应用链接配置错误: ${url.page}`)
201
+ }
202
+ } catch (e) {
203
+ console.error(`应用链接配置错误: ${item.redirect_data}`)
137
204
  }
138
205
  }
139
206
 
140
207
  //外部链接
141
- if(item.redirect_type === 'URL') {
208
+ if (item.redirect_type === 'URL') {
142
209
  let reg = /^(http:\/\/|https:\/\/|\/\/)+.+$/;
143
210
  //#ifdef MP-WEIXIN
144
211
  try {
145
212
  let url = JSON.parse(item.redirect_data);
146
- if(reg.test(url.url) && this.$configProject.extras.webview) {
213
+ if (reg.test(url.url)) {
147
214
  console.warn(`广告跳转外站: ${url.url}`)
148
- this.$xdUniHelper.navigateTo({
149
- url: `${this.$configProject.extras.webview}?seatUrl=${Base64.encodeURI(url.url)}`
150
- });
215
+ this.$xdUniHelper.navigateTo(url);
151
216
  } else {
152
- throw Error('地址错误')
217
+ console.error(`广告跳转外站配置错误: ${url.url}`)
153
218
  }
154
219
  } catch (e) {
155
- console.error(e)
220
+ console.error(`广告跳转外站配置错误: ${item.redirect_data}`)
156
221
  }
157
222
  //#endif
158
223
  //#ifdef H5
159
224
  try {
160
225
  let url = JSON.parse(item.redirect_data);
161
226
  console.warn(`广告跳转外站: ${url.url}`);
162
- this.$xdUniHelper.navigateTo(url)
227
+ this.$xdUniHelper.redirectTo(url, false)
163
228
  } catch (e) {
164
- console.error(e)
229
+ console.error(`广告跳转外站配置错误: ${item.redirect_data}`)
165
230
  }
166
231
  //#endif
167
232
 
168
233
  }
234
+
235
+ //无跳转地址
236
+ if(item.redirect_type === 'EMP') {
237
+ console.warn(`无跳转地址`);
238
+ }
169
239
  },
170
240
 
171
241
  getTestData() {
@@ -212,8 +282,7 @@
212
282
  }
213
283
  }
214
284
 
215
-
216
- this.list = list;
285
+ this.list = this.filterItem(list);
217
286
  this.noData = this.list.length === 0;
218
287
  })
219
288
  .catch(error => {