jufubao-mall 2.0.33 → 2.0.35-beta1

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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/src/components/CusCouponChose/CusCouponChose.vue +10 -13
  3. package/src/components/CusEnter/CusEnter.vue +9 -1
  4. package/src/components/CusListItem/CusListItem.vue +141 -0
  5. package/src/components/CusPoster/CusPoster.vue +17 -62
  6. package/src/components/CusPrice/CusPrice.vue +391 -0
  7. package/src/components/CusProduct/CusProduct.vue +576 -184
  8. package/src/components/CusShops/CusShops.vue +409 -209
  9. package/src/components/CusTab/CusTab.vue +159 -22
  10. package/src/components/CusVipList/CusVipList.vue +169 -0
  11. package/src/components/JfbMallConfirm/Api.js +1 -1
  12. package/src/components/JfbMallConfirm/Attr.js +167 -453
  13. package/src/components/JfbMallConfirm/JfbMallConfirm.vue +362 -162
  14. package/src/components/JfbMallConfirm/Mock.js +61 -43
  15. package/src/components/JfbMallConfirm/XdAddrDefault.vue +26 -13
  16. package/src/components/JfbMallConfirm/XdAddrOld.vue +9 -7
  17. package/src/components/JfbMallConfirm/XdListItem.vue +10 -2
  18. package/src/components/JfbMallConfirm/cusAttr/advanced.js +91 -0
  19. package/src/components/JfbMallConfirm/cusAttr/content.js +355 -0
  20. package/src/components/JfbMallConfirm/cusAttr/style.js +628 -0
  21. package/src/components/JfbMallConfirm/shopList.vue +84 -42
  22. package/src/components/JfbMallNetworkMedia/Api.js +94 -0
  23. package/src/components/JfbMallNetworkMedia/Attr.js +20 -0
  24. package/src/components/JfbMallNetworkMedia/JfbMallNetworkMedia.vue +1167 -0
  25. package/src/components/JfbMallNetworkMedia/JfbMallNetworkMediaLess.less +80 -0
  26. package/src/components/JfbMallNetworkMedia/JfbMallNetworkMediaMixin.js +30 -0
  27. package/src/components/JfbMallNetworkMedia/Mock.js +372 -0
  28. package/src/components/JfbMallNetworkMedia/cusAttr/advanced.js +60 -0
  29. package/src/components/JfbMallNetworkMedia/cusAttr/content.js +230 -0
  30. package/src/components/JfbMallNetworkMedia/cusAttr/font.js +123 -0
  31. package/src/components/JfbMallNetworkMedia/cusAttr/icon.js +257 -0
  32. package/src/components/JfbMallNetworkMedia/cusAttr/style.js +12 -0
  33. package/src/components/JfbMallProductInfo/cusAttr/content.js +2 -0
  34. package/src/components/JfbMallProductList/JfbMallProductList.vue +7 -1
  35. package/src/components/JfbMallProductList/XdCateV1.vue +0 -1
  36. package/src/components/SkeProduct/SkeProduct.vue +88 -3
@@ -0,0 +1,1167 @@
1
+ <template>
2
+ <view
3
+ class="jfb-mall-network-media"
4
+ @click="handleEditxSelect"
5
+ :class="{ editx : isEditx && active }"
6
+ >
7
+ <!--#ifdef H5-->
8
+ <view
9
+ class="jfb-mall-network-media__edit"
10
+ :class="{ editx : isEditx && active }"
11
+ v-if="isEditx && active"
12
+ >
13
+ <view class="jfb-mall-network-media__edit-icon" @click.stop="delEdit">
14
+ <xd-font-icon icon="iconshanchu-01" color="#fff" size="30"></xd-font-icon>
15
+ </view>
16
+ </view>
17
+ <!-- #endif -->
18
+ <view class="jfb-mall-network-media__body" :style="[gCompStyle]">
19
+ <view class="media-tab" v-if="cateOneList.length > 0">
20
+ <view class="media-tab-hold" :style="[holdTabStyleComp]" v-if="!isPreview"></view>
21
+ <view class="media-tab-cont" :style="[tabStyleComp]" :class="{isPreview:isPreview}">
22
+ <cus-tab
23
+ class="xd-tab"
24
+ item-padding="0 16rpx"
25
+ :bg-color="tabStyleComp.backgroundColor"
26
+ :scroll-with-animation="true"
27
+ :height="104"
28
+ :tab-index="oneCateIndex"
29
+ :spacing="fontSp"
30
+ :list="cateOneList"
31
+ :line-bottom="lineBottom"
32
+ :footer-style="navStyle"
33
+ :no-border="false"
34
+ :color="titleStyle.color"
35
+ :act-color="titleStyle.actColor"
36
+ :font-size="titleStyle.fontSize"
37
+ :act-font-size="titleStyle.actFontSize"
38
+ :font-weight="titleStyle.fontWeight"
39
+ :act-font-weight="titleStyle.actFontWeight"
40
+ :bgc-color="titleStyle.bgColor"
41
+ :act-bgc-color="titleStyle.actBgColor"
42
+ @onTab="handleCate"
43
+ ></cus-tab>
44
+ </view>
45
+ </view>
46
+ <view class="media-two" v-if="cateTwoList.length > 0" :style="[twoTabStyleComp]">
47
+ <scroll-view
48
+ :scroll-x="true"
49
+ :scroll-into-view="twoViewId"
50
+ :scroll-with-animation="true"
51
+ >
52
+ <view class="media-two-box">
53
+ <view
54
+ @click="handleCate(item)"
55
+ class="media-two-item"
56
+ :class="{active: item.category_id === twoCateId}"
57
+ v-for="item in cateTwoList"
58
+ :key="item.category_id"
59
+ :id="`index-${item.category_id}`"
60
+ :style="[twoTabStyleItemComp]"
61
+ >
62
+ <view :style="[twoCateId === item.category_id?twoTabActIconComp:twoTabIconComp,subTitleInIcon]">
63
+ <view>
64
+ <image :src="item.category_icon" :alt="item.category_name"></image>
65
+ </view>
66
+ </view>
67
+ <view class="media-two-name-hold"></view>
68
+ <view :style="[twoCateId === item.category_id?twoTabActNameComp:twoTabNameComp]">{{item.category_name}}</view>
69
+ <view v-if="twoCateId === item.category_id">
70
+ <image :src="triangleIcon"></image>
71
+ </view>
72
+ </view>
73
+ </view>
74
+ </scroll-view>
75
+ </view>
76
+ <view class="media-content" v-if="hasProducts === 'Y'">
77
+ <view class="media-input" v-if="blessingData.length > 0">
78
+ <view
79
+ class="media-input-item"
80
+ v-for="item in blessingData"
81
+ :key="item.id"
82
+ >
83
+ <input
84
+ :maxlength="item.struct.maxlength||16"
85
+ :minlength="item.struct.minlength||0"
86
+ v-model="item.data"
87
+ placeholder-style="color: #ccc"
88
+ :placeholder="item.value || item.struct.placeholder" />
89
+ <view
90
+ class="media-input-tip"
91
+ v-if="item.struct && item.struct.explain"
92
+ >{{item.struct.explain}}</view>
93
+ </view>
94
+ </view>
95
+ <view class="media-three" v-if="cateThreeList.length > 0">
96
+ <scroll-view
97
+ :scroll-x="true"
98
+ :scroll-into-view="threeViewId"
99
+ :scroll-with-animation="true"
100
+ >
101
+ <view class="media-three-box">
102
+ <view
103
+ @click="handleCate(item)"
104
+ class="media-three-item"
105
+ :class="{active: item.category_id === threeCateId}"
106
+ v-for="item in cateThreeList"
107
+ :key="item.category_id"
108
+ :id="`index-${item.category_id}`"
109
+ >
110
+ <view>{{item.category_name}}</view>
111
+ <view v-if="threeCateId === item.category_id"></view>
112
+ </view>
113
+ </view>
114
+ </scroll-view>
115
+ </view>
116
+ <view class="media-product" v-if="productList && productList.length > 0">
117
+ <view
118
+ class="media-product-item"
119
+ v-for="item in productList"
120
+ :key="item.product_id"
121
+ :class="{active: item.product_id === productId}"
122
+ @click="handleSelectProduct(item.product_id, item.shopId)"
123
+ :style="[productStyleComp]"
124
+ >
125
+ <view>{{item.list_title}}</view>
126
+ <view>
127
+ <cus-price type="two" :is-plus="isPlus" :show-price="item['show_prices']" ></cus-price>
128
+ </view>
129
+ <view v-if="item.product_id === productId"></view>
130
+ </view>
131
+ </view>
132
+ <view class="media-product-nodata" v-if="productList && productList.length === 0">
133
+ <xd-no-data
134
+ icon-type="product"
135
+ :scale-size="2"
136
+ height="100%"
137
+ >当前暂无商品</xd-no-data>
138
+ </view>
139
+ <view class="media-detail" v-if="prodcutInfo">
140
+ <view>商品详情</view>
141
+ <view>
142
+ <xd-content-xss :key="prodcutContKey" v-if="prodcutInfo" :html="prodcutInfo"></xd-content-xss>
143
+ </view>
144
+ </view>
145
+ </view>
146
+ <view
147
+ class="media-no-data"
148
+ v-if="hasProducts === 'N'"
149
+ :style="[noDataCompStyle]"
150
+ >
151
+ <xd-no-data icon-type="product" :scale-size="2" height="100%">当前暂无商品</xd-no-data>
152
+ </view>
153
+ <view style="height: 120rpx"></view>
154
+ <view class="media-btn" :style="mediaBtnComp">
155
+ <view>
156
+ <view class="media-btn-index" @click="handleIndex">
157
+ <view v-if="showIndex === 'Y'"><xd-font-icon :icon="showIndexIcon" color="#999"></xd-font-icon></view>
158
+ <view v-if="showIndex === 'Y'">首页</view>
159
+ </view>
160
+ <view>
161
+ <xd-button
162
+ v-if="isSubmitStatus"
163
+ @click="handleSubmit"
164
+ type="primary"
165
+ size="small"
166
+ width="200rpx"
167
+ >{{nowBuyText}}</xd-button>
168
+ <xd-button
169
+ v-else
170
+ disabled
171
+ type="primary"
172
+ size="small"
173
+ width="200rpx"
174
+ >{{nowBuyText}}</xd-button>
175
+ </view>
176
+ </view>
177
+ </view>
178
+ </view>
179
+ </view>
180
+ </template>
181
+
182
+ <script>
183
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon";
184
+ import XdNoData from "@/components/XdNoData/XdNoData.vue";
185
+ import XdContentXss from "@/components/XdContentXss/XdContentXss.vue";
186
+ import XdUnit from "@/components/XdUnit/XdUnit.vue";
187
+ import CusPrice from "@/components/CusPrice/CusPrice.vue";
188
+ import XdButton from "@/components/XdButton/XdButton.vue";
189
+ import { jfbRootExec } from "@/utils/xd.event";
190
+ import JfbMallNetworkMediaMixin from "./JfbMallNetworkMediaMixin";
191
+ import {gCPVal, getContainerPropsValue} from "@/utils/xd.base";
192
+ import componentsMixins from "@/mixins/componentsMixins";
193
+ import extsMixins from "@/mixins/extsMixins";
194
+ import {Base64} from "js-base64";
195
+ import CusTab from "@/components/CusTab/CusTab.vue";
196
+ import getServiceUrl from "@/common/getServiceUrl";
197
+ import Color from "color";
198
+
199
+ export default {
200
+ name: "JfbMallNetworkMedia",
201
+ components: {
202
+ CusTab,
203
+ XdFontIcon,
204
+ XdContentXss,
205
+ XdUnit,
206
+ XdButton,
207
+ XdNoData,
208
+ CusPrice
209
+ },
210
+ mixins: [
211
+ componentsMixins, extsMixins, JfbMallNetworkMediaMixin
212
+ ],
213
+ computed:{
214
+ productStyleComp(){
215
+ return {
216
+ height: this.isShowDiscount === 'Y' ? '182rpx':'140rpx'
217
+ }
218
+ },
219
+ noDataCompStyle(){
220
+ let other = 104;//一级高度
221
+ if(this.cateTwoList.length > 0) other += 190 //二级分类高度
222
+ other += 80 //底部缝隙高度
223
+ other += 120 //底部高度
224
+ other += 32;
225
+ if(this.cateThreeList.length === 0) other -= 80
226
+ return {
227
+ height: `calc(${this.layoutInfo.bodyMinHeightPx}px - ${other* this.$rpxNum}px)`
228
+ }
229
+ },
230
+ holdTabStyleComp(){
231
+ return {
232
+ backgroundColor: this.titleBgColor,
233
+ height: '56rpx',
234
+ padding: '24rpx'
235
+ }
236
+ },
237
+ tabStyleComp(){
238
+ let top = 0;
239
+ if(!this.isPreview) top = this.layoutInfo.top;
240
+ return {
241
+ backgroundColor: this.titleBgColor,
242
+ top: top + 'rpx',
243
+ }
244
+ },
245
+ gCompStyle(){
246
+ return {
247
+ '--g-comp-radius': this.gStyleValue.radius * this.$rpxNum + 'px',
248
+ '--g-comp-style-radius-w': parseInt(this['subTitleRadius']) * this.$rpxNum + 'px'
249
+ }
250
+ },
251
+ isSubmitStatus(){
252
+ if(!this.isCanBuy) return false;
253
+ //为空不检查是否直接购买
254
+ if(this.blessingData.length === 0) return true
255
+
256
+ //有值根据后台数据返回是否需要检查是否购买
257
+ let flag = true;
258
+ this.blessingData.map(item=>{
259
+ if(item.struct && item.struct.required) {
260
+ if(!item.data) flag = false
261
+ }
262
+ });
263
+ return flag;
264
+ },
265
+ mediaBtnComp() {
266
+ return this.fixedStyle({ paddingBottom: 0, zIndex: 110 });
267
+ },
268
+ twoTabStyleComp(){
269
+ return {
270
+ backgroundColor: this.level2BgcColor
271
+ }
272
+ },
273
+ twoTabStyleItemComp(){
274
+ return {
275
+ marginRight: this.iconImageSp + 'rpx',
276
+ }
277
+ },
278
+
279
+ twoTabNameComp(){
280
+ let {color, fontSize, fontWeight,bgColor} = this.level2Name;
281
+ return {color, fontSize, fontWeight, backgroundColor: bgColor}
282
+ },
283
+ twoTabActNameComp(){
284
+ let {actColor, actFontSize, actFontWeight, actBgColor} = this.level2Name;
285
+ return {color:actColor, fontSize:actFontSize, fontWeight:actFontWeight,backgroundColor: actBgColor}
286
+ },
287
+
288
+ twoTabIconComp(){
289
+ let style = { borderRadius: this['subTitleRadius']}
290
+ let border = 0;
291
+ if(typeof this['subTitleIconBorder'] === 'string' && this['subTitleIconBorder']) {
292
+ border = this['subTitleIconBorder'].split(' ')[0];
293
+ }
294
+ style['border'] = `${border} solid rgba(255,255,255,0.01)`;
295
+ return style
296
+ },
297
+ twoTabActIconComp(){
298
+ let style = { borderRadius: this['subTitleRadius']}
299
+ style['border'] = this['subTitleIconBorder'];
300
+ return style
301
+ },
302
+ subTitleInIcon(){
303
+ let {iconWdith, iconBgColor} = this
304
+ return {
305
+ width: iconWdith + 'rpx',
306
+ height: iconWdith + 'rpx',
307
+ backgroundColor: iconBgColor
308
+ }
309
+ },
310
+ },
311
+ data() {
312
+ return {
313
+ isPreview: false,
314
+ closeMask: true,
315
+ triangleIcon:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAeCAYAAABXNvynAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEASURBVFiFzZVBEYMwEEWZKkACUuKglYCESsABEiKhEpBQCZFQCa+HkhYYIBR22bwjh+XNn92folAAqDXmqgA4oLP22Azg+VBauyQBKn401j5JBukCPK19kgCBMU76HxepQX0zVJPPV6n54sykC/DK8viAekY23+MDuhXhYO03on8oUjhrzy+JdCN5vHwb080nZeabIc+UWW+GJWpL4X/SjQQsehm475CNtGfLVjvTHeLOFPYHZeGs1WDfoS3htWUlVmFKoyncCcvqSQONkqy8NMcq7FxpZI9MV9pAdr80+jub4sGWngZKoDWWjQSgWpN1yPfsUQJwmxPtTLXSePq03xLWohge5x8uAAAAAElFTkSuQmCC',
316
+ searchTimer:null,//搜索关键字截流
317
+ cateOneList: [],
318
+ cateTwoList:[],
319
+ cateThreeList:[],
320
+ productList:null,
321
+ productListOrg:[], //商品原生数据【预览模式使用】
322
+ parentId:0,
323
+ hasProducts: 'UNDEF', //是否有数据 'Y'=>有数据 N=>无 UNDEF=>未熟初始化
324
+ page_size: 51,
325
+ page_token: '1',
326
+ isPlus: false,
327
+
328
+ //内容
329
+ nowBuyText:'立即充值',
330
+ showIndex:'N', //是否展示首页链接
331
+ showIndexIcon:'iconshouye1',//首页图标样式
332
+ lineBottom:12, //分类样式距离底部距离
333
+ navStyle:'line-6-8-s',
334
+
335
+ //提交数据
336
+ productId: -1,//商品id
337
+ oneCateId:-1, //一级分类
338
+ oneCateIndex:0, //组件要求传入选中数据记录索引值
339
+ oneViewId:-1, //二级分类进入效果
340
+ twoCateId:-1, //二级分类
341
+ twoViewId:'', //二级分类进入效果
342
+ threeCateId: -1, //三级分类ID
343
+ threeViewId:'',
344
+
345
+
346
+ //划线价格
347
+ isShowDiscount:'N',//是否展示划线价格
348
+ differ:10,
349
+ isCanBuy: false, //是否可以购买
350
+
351
+
352
+ //地址栏参数
353
+ addressPid: '',
354
+ addressTwoId:'',
355
+
356
+ //内容
357
+ prodcutInfo:'',
358
+ prodcutContKey:'prodcutContKey',
359
+
360
+ //表单配置信息
361
+ blessingData: [],
362
+ weixinBtnBug: false,
363
+
364
+ //一级菜单
365
+ titleBgColor:'', //背景颜色
366
+ titleStyle:{}, //文字样式
367
+ fontSp:1,//间距
368
+
369
+ //二级导航
370
+ level2BgcColor:'#f8f8f8',
371
+ iconImageSp:16,//间距
372
+ level2Name:{},
373
+ subTitleRadius:'40rpx', //圆角
374
+ subTitleIconBorder:0, //边框样式
375
+ iconBgColor:'', //背景颜色
376
+ iconWdith: 96, //icon大小
377
+
378
+ //
379
+ productInfoPath:null
380
+
381
+ }
382
+ },
383
+ watch: {
384
+ container(value, oldValue) {
385
+ if (JSON.stringify(value) === JSON.stringify(oldValue)) return;
386
+ if (this.$configProject['isPreview']) this.init(value)
387
+ },
388
+ isShowDiscount(){
389
+ this.productList = this.filterProdcutData(this.productListOrg);
390
+ }
391
+ },
392
+ created() {
393
+ this.isPreview = this.$configProject['isPreview'];
394
+ this.init(this.container);
395
+ },
396
+ methods: {
397
+ async onJfbLoad(options) {
398
+ this.setNameSpace(options);
399
+ //参数设置
400
+ if(options.pid) this.addressPid = Number(options.pid);
401
+ if(options.cateId) this.addressTwoId = Number(options.cateId);
402
+ if(this.$configProject['isPreview']) {
403
+ this.addressPid = 157696
404
+ }
405
+ await this.getCategoryList();
406
+ },
407
+
408
+
409
+ /**
410
+ * @description 监听事件变化
411
+ * @param container {object} 业务组件对象自己
412
+ */
413
+ init(container) {
414
+ let categoryParentType = gCPVal(container, 'categoryParentType', 'root');
415
+ if(categoryParentType === 'root') this.parentId = 0;
416
+ else {
417
+ let categoryParent = gCPVal(container, 'categoryParent', '');
418
+ if(!categoryParent) this.parentId = 0;
419
+ else this.parentId = categoryParent;
420
+ }
421
+
422
+ this.xnamespace = gCPVal(container, 'xnamespace', this.projectAttr.business_code||this.xnamespace);
423
+ this.showIndex = gCPVal(container, 'showIndex', 'Y');
424
+ this.nowBuyText = gCPVal(container, 'nowBuyText', '立即充值');
425
+ let showIndexIcon = 'iconshouye1';
426
+ this.showIndex = gCPVal(container, 'showIndex', 'Y');
427
+ if(this.showIndex === 'Y') {
428
+ showIndexIcon = gCPVal(container, 'showIndexIcon', 'iconshouye1');
429
+ }
430
+ this.showIndexIcon = showIndexIcon;
431
+
432
+ this.isShowDiscount = gCPVal(container,'isShowDiscount', 'Y');
433
+ this.differ = gCPVal(container,'differ', 0);
434
+ this.navStyle = gCPVal(container, 'navStyle', 'line-6-8-s');
435
+
436
+ //一级分类
437
+ this.titleBgColor = gCPVal(container, 'titleBgColor', '#fff',{sKey:'titleBgColorStatus', fields:['titleBgColor']});
438
+ let defTitleStyle = {
439
+ color:'#333',
440
+ actColor: this.navStyle === 'tags'?'#fff':this.mainColor,
441
+ fontSize: '28',
442
+ actFontSize: '28',
443
+ fontWeight:'400',
444
+ actFontWeight: '400',
445
+ bgColor: this.navStyle === 'tags'?'rgba(0,0,0,0)':'#f8f8f8',
446
+ actBgColor: this.navStyle === 'tags'?this.mainColor: 'rgba(0,0,0,0)'
447
+ }
448
+ this.titleStyle = gCPVal(container, 'titleStyle', [defTitleStyle],{sKey:'titleStyleStatus', fields:['titleStyle','titleColor'],isMerge: true});
449
+ this.fontSp = gCPVal(container, 'fontSp', [16],{sKey:'fontSpSpStatus', fields:['fontSp']});
450
+
451
+
452
+ //二级分类
453
+ this.level2BgcColor = gCPVal(container, 'level2BgcColor', ['#f8f8f8'],{sKey:'level2BgcColorStatus', fields:['level2BgcColor']});
454
+ this.level2Name = gCPVal(container, 'level2Name', [{
455
+ fontSize: '24',
456
+ actFontSize: '24',
457
+ color: '#333',
458
+ actColor:this.mainColor,
459
+ bgColor:'rgba(0,0,0,0)',
460
+ actBgColor:'rgba(0,0,0,0)',
461
+ fontWeight: '400',
462
+ actFontWeight: '400',
463
+ }],{sKey:'level2NameStatus', fields:['level2Name','level2Color'],isMerge: true});
464
+ this.subTitleIconBorder = gCPVal(container, 'subTitleIconBorder', [{style:'solid', width: '2', color: this.mainColor}], {isBorder:true});
465
+ this.iconWdith = gCPVal(container, 'iconWdith', [96],{sKey:'iconWdithStatus', fields:['iconWdith']});
466
+ this.iconImageSp = gCPVal(container, 'iconImageSp', [16],{sKey:'iconImageSpStatus', fields:['iconImageSp']});
467
+ this.iconBgColor = gCPVal(container, 'iconBgColor', [100],{sKey:'iconBgColorStatus', fields:['iconBgColor']});
468
+ let defTitleRadius = 40*Number(this.iconWdith)/96 + 'rpx';
469
+ this.subTitleRadius = gCPVal(container, 'subTitleRadius', [defTitleRadius],{sKey:'subTitleRadiusStatus', fields:['subTitleRadius']})||0;
470
+
471
+
472
+ //高级
473
+ this.productInfoPath = gCPVal(container, "productInfoPath", {value: ""}).value;
474
+ },
475
+
476
+ //====分类数据=========
477
+ clearStatus(level){
478
+ if(level === 1) {
479
+ this.threeCateId = -1;
480
+ this.twoCateId = -1;
481
+
482
+ }
483
+ if(level === 2) {
484
+ this.threeCateId = -1
485
+ }
486
+ this.twoViewId = '';
487
+ this.threeViewId = ''
488
+ this.productList = null;
489
+ this.prodcutInfo = '';
490
+ this.productId = -1
491
+ this.shopId = -1;
492
+
493
+ },
494
+ getCategoryList(){
495
+ return new Promise((resolve)=>{
496
+ let params = {
497
+ xnamespace: this.xnamespace,
498
+ root_category_id: this.parentId,
499
+ level: 3,
500
+ };
501
+ jfbRootExec("getMallMediaCategoryTree", {
502
+ vm: this,
503
+ data: params
504
+ })
505
+ .then(res => {
506
+ //设置条件
507
+ this.cateOneList = res.items
508
+ .filter(item=>item.children.length > 0)
509
+ .map((item,index) => {
510
+ item['name'] = item.category_name;
511
+ item['id'] = item.category_id;
512
+ item['level'] = 1;
513
+ //页面传参中的一级分类否分存在
514
+ if(this.addressPid && Number(this.addressPid) === item.category_id) {
515
+ this.oneCateIndex = index;
516
+ }
517
+ item['category_icon'] = getServiceUrl(item['category_icon'], 'size3');
518
+
519
+ //二级分类
520
+ item.children = item.children.map(child => {
521
+ child['category_icon'] = getServiceUrl(child['category_icon'], 'size3');
522
+ child['level'] = 2;
523
+
524
+ //三级分类
525
+ if(child.children && child.children.length > 0) {
526
+ child.children = child.children.map(three=>{
527
+ three['category_icon'] = getServiceUrl(three['category_icon'], 'size3');
528
+ three['level'] = 3;
529
+ return three
530
+ })
531
+ }
532
+
533
+ return child;
534
+ });
535
+ return item;
536
+ });
537
+
538
+ //第一次操作
539
+ if(this.cateOneList.length > 0) {
540
+ if(this.addressPid) {
541
+ let curItemIndex = this.cateOneList.findIndex(item=>item.id === this.addressPid);
542
+ if(curItemIndex === -1) this.handleCate(this.cateOneList[0]);
543
+ else this.handleCate(this.cateOneList[curItemIndex ])
544
+ }
545
+ else this.handleCate(this.cateOneList[0]);
546
+ }
547
+
548
+ resolve()
549
+ })
550
+ .catch(err => {
551
+ this.$xdLog.catch(err);
552
+ resolve()
553
+ })
554
+ })
555
+ },
556
+ handleCate(cate){
557
+
558
+ let {level} = cate;
559
+ let idsMap = {
560
+ "1": "oneCateId",
561
+ "2": "twoCateId",
562
+ "3": "threeCateId"
563
+ }
564
+ let listMap = {
565
+ "1": "cateOneList",
566
+ "2": "cateTwoList",
567
+ "3": "cateThreeList"
568
+ }
569
+ let addressMap = {
570
+ "1": "addressPid",
571
+ "2": "addressTwoId",
572
+ }
573
+ let viewToMap = {
574
+ "2": 'twoViewId',
575
+ "3" : "threeViewId"
576
+ };
577
+ let curCateIdKey = idsMap[level];
578
+
579
+ //点击为相同分类
580
+ if(this[curCateIdKey] === cate.category_id) return;
581
+
582
+ //设置当前分类ID
583
+ this[curCateIdKey] = cate.category_id;
584
+
585
+ //使用动画
586
+ if(viewToMap[level]) {
587
+ setTimeout(()=>{
588
+ this[viewToMap[level]] = `index-${this[curCateIdKey]}`;
589
+ },100)
590
+ }
591
+
592
+
593
+ //层级小于三级处理
594
+ if(cate.level < 3) {
595
+ this.clearStatus(level);
596
+ let nextCateListKey = listMap[level+1];
597
+ this[nextCateListKey] = cate.children;
598
+
599
+ //有子级自动触发点击事件(操作第一个记录)
600
+ if(cate.children.length > 0) {
601
+ let nextCateKey = addressMap[level + 1];
602
+ //下一级为二级分类处理
603
+ if(nextCateKey !== undefined) {
604
+ if(this[nextCateKey]) {
605
+ let curItemIndex = cate.children.findIndex(item=>item.category_id === this[nextCateKey]);
606
+ if(curItemIndex === -1) this.handleCate(cate.children[0]);
607
+ else {
608
+ let item = cate.children[curItemIndex]
609
+ let nextViewToKey = viewToMap[level + 1];
610
+ this.$nextTick(()=>{
611
+ if(nextViewToKey) {
612
+ this[nextViewToKey] = `index-${item.category_id}`;
613
+ }
614
+ })
615
+
616
+ this.handleCate(item);
617
+ }
618
+ }
619
+
620
+ //无值使用第一个
621
+ else this.handleCate(cate.children[0]);
622
+ }
623
+ //下一级为三级分类处理
624
+ else {
625
+ if(cate.children.length >0) this.handleCate(cate.children[0]);
626
+ else this.getProductInfo();
627
+ }
628
+
629
+ }
630
+ //无数据
631
+ else this.getProductInfo();
632
+ }
633
+
634
+ //第三级分类处理
635
+ else {
636
+ //有子级自动触发点击事件(操作第一个记录)
637
+ this.getProductInfo(cate);
638
+ }
639
+
640
+ },
641
+ getProductInfo(item = null){
642
+ if(item === null) {
643
+ this.prodcutInfo = '';
644
+ this.hasProducts = 'N';
645
+ }
646
+ else {
647
+ this.hasProducts = 'Y';
648
+ this.getList(item);
649
+ }
650
+ },
651
+ //====分类数据=========
652
+
653
+ //==商品相关操作=======
654
+ async handleProductOperate(){
655
+ await this.getProductContent(this.productId);
656
+ await this.getProductBtns(this.productId);
657
+ await this.getProductForm(this.productId);
658
+ this.$xdHideLoading();
659
+ },
660
+
661
+ handleSelectProduct(i){
662
+ if(i === this.productId) return
663
+ this.productId = i;
664
+ this.$xdShowLoading({});
665
+ this.handleProductOperate()
666
+ },
667
+
668
+ getProductBtns(product_id){
669
+ return new Promise((resolve)=>{
670
+ jfbRootExec("getMallMediaProductBuyButton", {
671
+ vm: this,
672
+ data: {
673
+ product_id,
674
+ xnamespace: this.xnamespace,
675
+ }
676
+ }).then(res=>{
677
+ let isCanBuyItem = res['buttons'].filter(item=>{
678
+ return item.code === 'buy-now' && item.enabled === true;
679
+ });
680
+ this.isCanBuy = isCanBuyItem.length > 0;
681
+ resolve();
682
+ }).catch(err=>{
683
+ this.isCanBuy = false
684
+ resolve();
685
+ })
686
+ })
687
+
688
+ },
689
+
690
+ getProductForm(product_id){
691
+ return new Promise((resolve)=>{
692
+ jfbRootExec("getMallMediaProductForm", {
693
+ vm: this,
694
+ data: {
695
+ product_id,
696
+ xnamespace: this.xnamespace,
697
+ }
698
+ }).then(res=>{
699
+ this.blessingData = res['form_data']||[];
700
+ resolve()
701
+ }).catch(err=>{
702
+ this.blessingData = [];
703
+ console.error(err);
704
+ resolve()
705
+ })
706
+ })
707
+
708
+ },
709
+
710
+ getProductContent(product_id){
711
+ return new Promise((resolve)=>{
712
+ jfbRootExec("getMallMediaProductContent", {
713
+ vm: this,
714
+ data: {
715
+ product_id,
716
+ xnamespace: this.xnamespace,
717
+ }
718
+ }).then(res=>{
719
+ this.prodcutInfo = res.content;
720
+ this.prodcutContKey = Date.now();
721
+ resolve()
722
+ }).catch(err=>{
723
+ this.prodcutInfo = '';
724
+ this.prodcutContKey = Date.now();
725
+ resolve()
726
+ })
727
+ })
728
+
729
+ },
730
+
731
+ filterProdcutData(list = []){
732
+ return this.$xdUniHelper.cloneDeep(list)
733
+ .filter(item=>item.status === 'ok')
734
+ .map(item=>{
735
+ if(this.isShowDiscount === 'N') {
736
+ item['show_prices'] = item['show_prices'].filter(it=>{
737
+ return it.t !== 'U'
738
+ })
739
+ }
740
+ return item;
741
+ });
742
+ },
743
+
744
+ getList(cate){
745
+ let data = {
746
+ xnamespace: this.xnamespace,
747
+ page_token: this.page_token,
748
+ page_size: this.page_size,
749
+ custom_category_id: cate.category_id,
750
+ is_remove_same_prefix_name: 'Y'
751
+ }
752
+
753
+ //设置是否展示划线价格
754
+ if(this.isShowDiscount==='Y') data.is_show_uprice = this.$xdUniHelper.multiplyFloatNumber(this.differ,100)
755
+ else data.is_show_uprice = -1
756
+ this.$xdShowLoading({});
757
+ jfbRootExec("getMallMediaProductList", {
758
+ vm: this,
759
+ data: data
760
+ }).then(res=>{
761
+ this.productListOrg = this.$xdUniHelper.cloneDeep(res.list);
762
+ this.productList = this.filterProdcutData(res.list);
763
+
764
+ //获取内容
765
+ if(this.productList.length > 0) {
766
+ let item = this.productList[0];
767
+ this.productId = item.product_id;
768
+ this.handleProductOperate()
769
+ }
770
+ else {
771
+ this.$xdHideLoading();
772
+ this.blessingData = [];
773
+ this.prodcutInfo = '';
774
+ }
775
+
776
+ }).catch(err=>{
777
+ this.$xdHideLoading();
778
+ this.productList = [ ]
779
+ this.prodcutInfo = '';
780
+ })
781
+ },
782
+ //==商品相关操作=======
783
+
784
+ handleSubmit(){
785
+ if(this.$configProject['isPreview']) return;
786
+ let params = {
787
+ namespace: this.xnamespace,
788
+ product: {
789
+ product_id: this.productId,
790
+ num: 1,
791
+ product_sku_id: 0,
792
+ }
793
+ }
794
+ this.$xdShowLoading({});
795
+ jfbRootExec("nowMallMediaBuyPay", {
796
+ vm: this,
797
+ data: params
798
+ }).then(res => {
799
+ this.$xdHideLoading();
800
+ if(!this.productInfoPath) console.warn('参数为空')
801
+ if(this.$configProject['isPreview'] || !this.productInfoPath) return;
802
+ this.$nextTick(() => {
803
+ let data = {...this.getFromData(),order_id: res.cart_order_id};
804
+ let dataStr = this.$xdUniHelper.jsonToParams(data);
805
+ this.$xdUniHelper.navigateTo({
806
+ url: this.productInfoPath + `?${dataStr}`
807
+ })
808
+ })
809
+ }).catch((err) => {
810
+ this.$xdHideLoading()
811
+ this.$xdLog.catch(err);
812
+ })
813
+ },
814
+ getFromData(){
815
+ //无form数据
816
+ if(this.blessingData.length === 0) return {};
817
+ let params = { product_id: this.productId}
818
+ this.blessingData.map(item=>{
819
+ params[item.id] = item['data'];
820
+ });
821
+ console.warn(JSON.stringify(params));
822
+ return {
823
+ blessing: Base64.encodeURI(JSON.stringify(params))
824
+ }
825
+ },
826
+
827
+ handleIndex(){
828
+ if(this.$configProject['isPreview'] || this.showIndex === 'N') return;
829
+ this.$xdUniHelper.redirectTo({
830
+ url: this.$settings.index
831
+ },false)
832
+ },
833
+
834
+ onJfbBack(options) {
835
+ console.log('event.onJfbBack', options)
836
+ },
837
+
838
+ onJfbCustomEvent({action, data}){
839
+ if(action === 'baseHeader@search'){
840
+ if(this.searchTimer) {
841
+ clearTimeout(this.searchTimer);
842
+ this.searchTimer = null;
843
+ }
844
+ this.searchTimer = setTimeout(()=>{
845
+ this.keyword = data;
846
+ this.getList();
847
+ },1000)
848
+ }
849
+ },
850
+ }
851
+ }
852
+
853
+ </script>
854
+
855
+ <style scoped lang="less">
856
+ @import "./JfbMallNetworkMediaLess.less";
857
+
858
+ .jfb-mall-network-media {
859
+ &__body{
860
+ .media-tab {
861
+ position: relative;
862
+ z-index: 1;
863
+ &-cont {
864
+ position: fixed;
865
+ left:0;
866
+ right: 0;
867
+
868
+ &.isPreview {
869
+ position: relative;
870
+ }
871
+ }
872
+ }
873
+ .media-two {
874
+ &-box {
875
+ display: flex;
876
+ justify-content: flex-start;
877
+ white-space: nowrap;
878
+ padding: 16rpx 0 30rpx 32rpx;
879
+ }
880
+ &-item {
881
+ margin-right: 16rpx;
882
+ padding: 0 16rpx 0;
883
+ position: relative;
884
+
885
+ & > view:first-child {
886
+ width: 96rpx;
887
+ height: 96rpx;
888
+ display: flex;
889
+ justify-content: center;
890
+ align-items: center;
891
+
892
+ & > view {
893
+ width: 100%;
894
+ height: 100%;
895
+ border-radius: var(--g-comp-style-radius-w);
896
+ overflow: hidden;
897
+ box-sizing: border-box;
898
+ border: 2rpx solid #fff;
899
+ }
900
+
901
+ & image {
902
+ max-width:100%;
903
+ max-height: 100%;
904
+ }
905
+ }
906
+ & > view:nth-child(3) {
907
+ position: absolute;
908
+ left: 0;
909
+ right: 0;
910
+ max-width: calc(100% + 32rpx);
911
+ bottom: 0;
912
+ overflow: hidden;
913
+ font-size: 24rpx;
914
+ word-break: break-all;
915
+ white-space: wrap;
916
+ font-weight: 400;
917
+ text-align: center;
918
+ height: 40rpx;
919
+ line-height: 40rpx;
920
+ border-radius: 30rpx;
921
+ }
922
+ & > view:nth-child(4) {
923
+ width: 42rpx;
924
+ height: 30rpx;
925
+ position: absolute;
926
+ bottom: -32rpx;
927
+ left: 50%;
928
+ transform: translateX(-50%);
929
+ display: flex;
930
+ justify-content: flex-start;
931
+ align-items: flex-start;
932
+ & > image {
933
+ width: 100%;
934
+ height: 100%;
935
+ }
936
+ }
937
+ &:last-child {
938
+ margin-right: 0;
939
+ }
940
+
941
+ }
942
+
943
+ &-name-hold {
944
+ height: 40rpx;
945
+ line-height: 40rpx;
946
+ margin-top: 8rpx;
947
+ }
948
+ }
949
+
950
+
951
+
952
+ .media-content {
953
+ margin: 0 16rpx 16rpx;
954
+ position: relative;
955
+ z-index: 0;
956
+ }
957
+
958
+ .media-no-data {
959
+ margin: 0 16rpx 16rpx;
960
+ background-color: #fff;
961
+ border-radius: 16rpx;
962
+ }
963
+
964
+ .media-input {
965
+ border-radius: 16rpx;
966
+ background: rgba(255, 255, 255, 1);
967
+ padding: 24rpx;
968
+
969
+ &-tip {
970
+ color: var(--g-theme-dangerColor);
971
+ line-height: 30rpx;
972
+ font-size: 24rpx;
973
+ margin-top: 16rpx;
974
+ }
975
+ &-item {
976
+ margin-bottom: 32rpx;
977
+ &:last-child {
978
+ margin-bottom: 0;
979
+ }
980
+
981
+ & > input {
982
+ padding: 20rpx;
983
+ background-color: #fff;
984
+ border: 1px solid #ccc;
985
+ height: 40rpx;
986
+ line-height: 40rpx;
987
+ border-radius: 16rpx;
988
+ font-size: 28rpx;
989
+ }
990
+
991
+ }
992
+ }
993
+
994
+ .media-three {
995
+ &-box {
996
+ display: flex;
997
+ justify-content: space-between;
998
+ white-space: nowrap;
999
+ min-width: fit-content;
1000
+ box-sizing: border-box;
1001
+ padding: 24rpx 0;
1002
+ }
1003
+ &-item {
1004
+ flex-shrink: 0;
1005
+ flex: 1;
1006
+ text-align: center;
1007
+ height: 56rpx;
1008
+ line-height: 56rpx;
1009
+ font-size: 28rpx;
1010
+ font-weight: 500;
1011
+ color: #999;
1012
+ position: relative;
1013
+ margin-right: 48rpx;
1014
+
1015
+ &:last-child {
1016
+ margin-right: 0;
1017
+ }
1018
+
1019
+ & > view:first-child {
1020
+ line-height: 56rpx;
1021
+ }
1022
+ & > view:nth-child(2) {
1023
+ background-color: var(--g-theme-mainColor);
1024
+ height: 6rpx;
1025
+ width: 60rpx;
1026
+ position: absolute;
1027
+ left: 50%;
1028
+ bottom: 0;
1029
+ transform: translateX(-50%);
1030
+ border-radius: 6rpx;
1031
+ }
1032
+
1033
+ &.active {
1034
+ & > view:first-child {
1035
+ color: #333;
1036
+ }
1037
+ }
1038
+
1039
+ }
1040
+ }
1041
+ .media-product-nodata {
1042
+ padding: 24rpx;
1043
+ border-radius: var(--g-comp-radius);
1044
+ overflow: hidden;
1045
+ background: rgba(255, 255, 255, 1);
1046
+ margin-bottom: 24rpx;
1047
+ height: 700rpx;
1048
+ }
1049
+ .media-product {
1050
+ padding: 24rpx;
1051
+ border-radius: var(--g-comp-radius);
1052
+ overflow: hidden;
1053
+ background: rgba(255, 255, 255, 1);
1054
+ margin-bottom: 24rpx;
1055
+ display: flex;
1056
+ justify-content: flex-start;
1057
+ align-content: center;
1058
+ align-items: center;
1059
+ flex-flow: wrap;
1060
+
1061
+
1062
+
1063
+ &-item {
1064
+ width: calc((100% - 48rpx)/3);
1065
+ flex-shrink: 0;
1066
+ margin-right: 24rpx;
1067
+ box-sizing: border-box;
1068
+ padding: 16rpx;
1069
+ border-radius: 16rpx;
1070
+ background: linear-gradient(135deg, #FFFFFF 0%, #F5F5F5 100%);
1071
+ box-shadow: 0 0 8rpx rgba(0,0,0,.1);
1072
+ margin-top:24rpx;
1073
+ position:relative;
1074
+
1075
+ &:nth-child(1),&:nth-child(2),&:nth-child(3) {
1076
+ margin-top: 0;
1077
+ }
1078
+
1079
+ &.active {
1080
+ & > view:nth-child(3) {
1081
+ position: absolute;
1082
+ left: 0;
1083
+ right: 0;
1084
+ top:0;
1085
+ bottom:0;
1086
+ border: 6rpx solid var(--g-theme-mainColor);
1087
+ border-radius: 16rpx;
1088
+ }
1089
+ }
1090
+
1091
+ & > view:first-child {
1092
+ font-size: 28rpx;
1093
+ color: #333;
1094
+ height: 40rpx;
1095
+ line-height: 40rpx;
1096
+ overflow: hidden;
1097
+ margin-bottom: 16rpx;
1098
+ word-break: break-all;
1099
+ word-wrap: break-word;
1100
+ white-space: pre-line;
1101
+ }
1102
+
1103
+ &:nth-child(3n) {
1104
+ margin-right: 0;
1105
+ }
1106
+ }
1107
+
1108
+ }
1109
+
1110
+ .media-detail {
1111
+ border-radius: var(--g-comp-radius);
1112
+ overflow: hidden;
1113
+ background: rgba(255, 255, 255, 1);
1114
+ & > view:first-child {
1115
+ padding: 0 24rpx;
1116
+ line-height: 76rpx;
1117
+ font-size: 28rpx;
1118
+ height: 76rpx;
1119
+ color: #333;
1120
+ border-bottom: 1px solid #f8f8f8;
1121
+ }
1122
+ & > view:nth-child(2) {
1123
+ padding: 24rpx;
1124
+ /deep/ img{
1125
+ max-width: 100% !important;
1126
+ height: auto !important;
1127
+ }
1128
+ /deep/ *{
1129
+ max-width: 100% !important;
1130
+ }
1131
+ }
1132
+ }
1133
+
1134
+ .media-btn {
1135
+ position: fixed;
1136
+ bottom: 0;
1137
+ left: 0;
1138
+ background: #fff;
1139
+ z-index: 1;
1140
+
1141
+ & > view {
1142
+ padding: 16rpx 32rpx;
1143
+ height: 84rpx;
1144
+ display: flex;
1145
+ justify-content: space-between;
1146
+ align-items: center;
1147
+ font-size: unit(28, rpx);
1148
+ }
1149
+
1150
+ &-index {
1151
+ display: flex;
1152
+ justify-content: flex-start;
1153
+ align-items: center;
1154
+ flex-flow: wrap;
1155
+ width: 60rpx;
1156
+ & > view {
1157
+ width: 100%;
1158
+ flex-shrink: 0;
1159
+ text-align: center;
1160
+ font-size: 24rpx;
1161
+ color: #999;
1162
+ }
1163
+ }
1164
+ }
1165
+ }
1166
+ }
1167
+ </style>