jufubao-takeorder 1.0.1

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 (50) hide show
  1. package/README.md +27 -0
  2. package/commands.js +84 -0
  3. package/commands.update.change.js +176 -0
  4. package/file.config.js +16 -0
  5. package/get.package.path.js +22 -0
  6. package/get.package.path.js.tpl +22 -0
  7. package/package.json +122 -0
  8. package/src/CreateClientID.js +16 -0
  9. package/src/ICONS.js +1148 -0
  10. package/src/appParams.js +1 -0
  11. package/src/common/authorize.js +261 -0
  12. package/src/common/getBusinessImageUrl.js +39 -0
  13. package/src/common/getServiceUrl.js +38 -0
  14. package/src/common/paysdk/jweixin.js +98 -0
  15. package/src/components/CusCouponChose/CusCouponChose.vue +1024 -0
  16. package/src/components/CusCouponItem/CusCouponItem.vue +298 -0
  17. package/src/components/CusEnter/CusEnter.vue +368 -0
  18. package/src/components/CusListItem/CusListItem.vue +141 -0
  19. package/src/components/CusPoster/CusPoster.vue +167 -0
  20. package/src/components/CusPoster/CusSwiperDot.vue +234 -0
  21. package/src/components/CusPrice/CusPrice.vue +383 -0
  22. package/src/components/CusProduct/CusProduct.vue +763 -0
  23. package/src/components/CusShops/CusShops.vue +717 -0
  24. package/src/components/CusSwiperDot/CusSwiperDot.vue +234 -0
  25. package/src/components/CusTab/CusTab.vue +544 -0
  26. package/src/components/CusVideo/CusVideo.vue +170 -0
  27. package/src/components/CusVipList/CusVipList.vue +169 -0
  28. package/src/config.app.plus.js +6 -0
  29. package/src/config.h5.js +13 -0
  30. package/src/config.mp.weixin.js +13 -0
  31. package/src/config.project.js +15 -0
  32. package/src/get.package.path.js +22 -0
  33. package/src/mixins/cardListMixins.js +187 -0
  34. package/src/mixins/colorCardMixins.js +122 -0
  35. package/src/mixins/componentsMixins.js +900 -0
  36. package/src/mixins/extsMixins.js +3 -0
  37. package/src/mixins/locationMixins.js +119 -0
  38. package/src/mixins/newLocaltionMixins.js +754 -0
  39. package/src/mixins/openDebuggerMixins.js +74 -0
  40. package/src/mixins/pageEditx.js +347 -0
  41. package/src/mixins/pageEvent.js +311 -0
  42. package/src/mixins/pageMain.js +120 -0
  43. package/src/mixins/pageUitls.js +738 -0
  44. package/src/mixins/posterMixins.js +122 -0
  45. package/src/mixins/scrollListFixedHeigthMixins.js +174 -0
  46. package/src/mocks.js +4 -0
  47. package/src/oss.config.js +17 -0
  48. package/src/settings.js +244 -0
  49. package/src/staticVersion.js +3 -0
  50. package/src/xd.less +196 -0
@@ -0,0 +1,900 @@
1
+ 'use strict';
2
+
3
+ import {getContainerFnPropsValue, getContainerPropsValue,isWechat} from "@/utils/xd.base";
4
+ import {mapActions,mapState, mapMutations} from "vuex";
5
+ import helper from "@/utils/helper";
6
+ import store from "@/store/index";
7
+ import getServiceUrl from "@/common/getServiceUrl"
8
+
9
+
10
+ export default {
11
+ props: {
12
+ /**
13
+ * @description 插件在页面中到唯一ID
14
+ */
15
+ cid: {
16
+ type: null | String | Number,
17
+ default: null,
18
+ },
19
+ /**
20
+ * @description 业务插件相关数据集合
21
+ */
22
+ container: {
23
+ type: Object,
24
+ default() {
25
+ return {}
26
+ }
27
+ },
28
+ /**
29
+ * @description 页面框架属性
30
+ */
31
+ layoutInfo: {
32
+ type: Object,
33
+ default() {
34
+ return {}
35
+ }
36
+ },
37
+ /**
38
+ * @description 页面属性
39
+ */
40
+ pageAttr: {
41
+ type: Object,
42
+ default() {
43
+ return {}
44
+ }
45
+ },
46
+ /**
47
+ * @description 业务插件元素属性(插件管理时候填写属性)
48
+ */
49
+ componentAttr: {
50
+ type: Object | Array,
51
+ default() {
52
+ return {}
53
+ }
54
+ },
55
+ /**
56
+ * @description 业务插件所属插件库属性(业务插件库)
57
+ */
58
+ appAttr: {
59
+ type: Object | Array,
60
+ default() {
61
+ return {}
62
+ }
63
+ },
64
+ /**
65
+ * @description 项目配置
66
+ */
67
+ settings: {
68
+ type: Object,
69
+ default() {
70
+ return {}
71
+ }
72
+ },
73
+ /**
74
+ * @description 业务插件库所用风格属性
75
+ */
76
+ styles: {
77
+ type: Object || null,
78
+ default() {
79
+ return {}
80
+ }
81
+ },
82
+ /**
83
+ * @description 项目配置文件
84
+ */
85
+ projectAttr: {
86
+ type: Object || null,
87
+ default() {
88
+ return {}
89
+ }
90
+ },
91
+
92
+ /**
93
+ * @description 是否进行本地插件调试模式
94
+ */
95
+ noBorder: {
96
+ type: Boolean,
97
+ default: false
98
+ },
99
+ },
100
+ data(){
101
+ return {
102
+ containerId: null, //容器ID
103
+
104
+ //#ifdef H5
105
+ active: false, //是否选择当前状态
106
+ isEditx: true, //当前为Editx模式
107
+ edit: false, //是否开启编辑模式
108
+ // #endif
109
+
110
+ //风格键
111
+ mainColor: '',
112
+ successColor: '',
113
+ warningColor: '',
114
+ subMainColor: '',
115
+ infoColor: '',
116
+ defaultColor: '',
117
+ dangerColor: '',
118
+ mainGradient: '',
119
+ subGradient: '',
120
+
121
+ //test
122
+ posterTest:{
123
+ "content_id": "KpBbUKdj4aBejwe7Fh1ki",
124
+ "position_id": "QCk3PmoyQmOWRP1SxnYR3",
125
+ "partner_id": 0,
126
+ "site_id": "",
127
+ "content_name": "测试.",
128
+ "image_url": "//dummyimage.com/200x200",
129
+ "redirect_type": "EMP",
130
+ "redirect_type_name": "无链接",
131
+ "redirect_data": "",
132
+ "sort": "",
133
+ "status": "",
134
+ "start_time": "",
135
+ "end_time": "",
136
+ "op_user_id": "",
137
+ "created_time": 0,
138
+ "updated_time": 0
139
+ }
140
+ }
141
+ },
142
+
143
+ destroyed() {
144
+ console.warn('componentsMixins.destroyed.my(timeer|timer)');
145
+ if (this.timeer && typeof this.timeer === "number") {
146
+ clearTimeout(this.timeer);
147
+ console.warn('componentsMixins.destroyed.my.timeer');
148
+ }
149
+ if (this.timer && typeof this.timer === "number") {
150
+ clearTimeout(this.timer);
151
+ console.warn('componentsMixins.destroyed.my.timer');
152
+ }
153
+
154
+ //卸载页面
155
+ if(typeof this.onJfbUnload === "function") {
156
+ console.warn('componentsMixins.destroyed.exec.onJfbUnload');
157
+ this.onJfbUnload()
158
+ }
159
+
160
+ },
161
+
162
+ created(){
163
+ let tag = '';
164
+ if (this.$vnode && this.$vnode.tag) tag = this.$vnode.tag;
165
+ this.$xdLog.setProject('App.components.start', `App.components.vnode.name.${tag}`);
166
+
167
+ //设置插件cid
168
+ if (this.cid) {
169
+ this.containerId = this.cid;
170
+ } else {
171
+ this.containerId = this.$xdUniHelper.randomChar(20);
172
+ }
173
+
174
+ //保存到vuex
175
+ this.setStyleCommon(this.styles);
176
+
177
+ //初始化风格
178
+ this.initThemesToData();
179
+
180
+
181
+ //#ifdef H5
182
+ //监听用户点击状态显示虚框
183
+ XdBus.addEvent('select', ({containerId}) => {
184
+ this.active = containerId === this.containerId;
185
+ });
186
+
187
+ //业务面板选中插件操作
188
+ XdBus.addEvent('onBoardSelect', ({containerId}) => {
189
+ if (containerId === this.containerId) {
190
+ this.handleEditxSelect()
191
+ }
192
+ });
193
+
194
+ //面板刷新页面功能
195
+ XdBus.addEvent('onUpdateView', (data) => {
196
+ if (data.container_id === this.containerId) {
197
+ if (typeof this['onJfbUpdate'] === 'function') {
198
+ this['onJfbUpdate'](data);
199
+ }
200
+ }
201
+ });
202
+
203
+ // #endif
204
+ },
205
+
206
+ //#ifdef H5
207
+ mounted() {
208
+ let that = this;
209
+ this.autoHideMask();
210
+
211
+ //调试模式设置值
212
+ let zIndex = 4;
213
+ if(this['hideMask'] === true) zIndex = -1;
214
+ if(this['closeMask'] === true) zIndex = -1;
215
+ if(this['closeMask'] === false) zIndex = 4;
216
+
217
+ //生产元素
218
+ if(this.$configProject.isPreview) {
219
+ if(zIndex ===-1) {
220
+ this.$nextTick(()=>{
221
+ setTimeout(()=>{
222
+ let r = document.getElementsByClassName(this.cssRoot);
223
+ let len = r.length;
224
+ for (let i=0; i < len; i++) {
225
+ let el = r.item(i);
226
+ if(!el.hasAttribute('close-mask')) {
227
+ el.setAttribute('close-mask', '1');
228
+ for(let k=0; k < 4;k++) {
229
+ let span = document.createElement('span');
230
+ span.className = 'xd-preview-line xd-preview-line-' + k;
231
+ el.appendChild(span);
232
+ }
233
+ }
234
+ }
235
+
236
+ }, 50)
237
+ })
238
+ }
239
+
240
+ }
241
+
242
+ if (this.$configProject.isPreview && this.selfMask !== true ) {
243
+ //启动关闭
244
+ if(this['closeMask'] === true) {
245
+ return;
246
+ }
247
+
248
+ function handle() {
249
+ let elx = that.$el.getElementsByClassName(`${that.cssRoot}__body`);
250
+ if (elx.length === 0) {
251
+ setTimeout(() => {
252
+ handle()
253
+ }, 50)
254
+ }
255
+ else {
256
+ let len = elx.length;
257
+ for (let i = 0; i < len; i++) {
258
+ if (!elx.item(i).classList.contains('isGPreview')) {
259
+ elx.item(i).classList.add("isGPreview");
260
+ }
261
+ }
262
+ }
263
+ }
264
+ this.$nextTick(()=>{
265
+ setTimeout(()=>{
266
+ handle();
267
+ },200)
268
+ });
269
+ }
270
+
271
+ //模式不显示虚线
272
+ if(this.$configProject.type === 'test'
273
+ && this.$configProject.NODE_ENV === 'development'
274
+ && this.$configProject.viewType === 'pack'
275
+ ){
276
+ this.isEditx = false;
277
+ }
278
+
279
+ },
280
+ // #endif
281
+
282
+ computed:{
283
+ ...mapState({
284
+ pageNamespace: state=> state.pageBusinessCode,
285
+ })
286
+ },
287
+
288
+ watch:{
289
+ active(val){
290
+ if(this.$configProject.isPreview && val) this.autoHideMask();
291
+ },
292
+ },
293
+
294
+ methods:{
295
+ ...mapActions(['setXNamespace','setStyleCommon']),
296
+ ...mapMutations(['setCurrentStyle']),
297
+
298
+ /**
299
+ * @description 自动生成调试模式
300
+ */
301
+ autoHideMask(){
302
+ if(this.$configProject.isPreview && this.hideMask === true){
303
+ this.$nextTick(()=>{
304
+ setTimeout(()=>{
305
+ let className = this.$el.classList;
306
+ if(!className.contains('gHideMask')) {
307
+ className.add("gHideMask")
308
+ }
309
+ },200)
310
+
311
+ })
312
+ }
313
+ },
314
+
315
+ /**
316
+ * @description 检查是否同域名
317
+ * @param url
318
+ * @param dir {String} 部署目录
319
+ * @returns {*}
320
+ */
321
+ //#ifdef H5
322
+ getSameSiteAndDomain(url, dir) {
323
+ let regDir = new RegExp(`^/${dir}/\.*$`);
324
+ let host = window.location.host;
325
+ let pages = this.$xdUniHelper.parseURL(url);
326
+
327
+ //域名相同并且部署目录相同
328
+ if (host === pages.host && regDir.test(pages.path)) {
329
+ return pages.relative;
330
+ }
331
+ return url;
332
+ },
333
+ // #endif
334
+
335
+ setNameSpace(options){
336
+ this.xnamespace = this.xnamespace || this.pageNamespace;
337
+ if(!this.xnamespace && !this.$configProject.isPreview){
338
+ this.$xdAlert({content: '未设置业务编码',type:'error'});
339
+ throw new Error('请配置业务编码')
340
+ }
341
+ this.setXNamespace(this.xnamespace)
342
+ },
343
+
344
+ /**
345
+ * @description 自动计算列数的宽和间距 (父节点需要设置110%)不兼容微信小程序(废弃)
346
+ * @param index {number} 当前索引值
347
+ * @param cell {number} 当前索引值
348
+ * @param jfbSpacing {number}
349
+ * @returns {{marginRight: string, overflow: string, width: string, marginTop: string}}
350
+ */
351
+ itemStyle(index, cell, jfbSpacing ) {
352
+ if(this.$xdUniHelper.checkVarType(jfbSpacing) === 'string') jfbSpacing = Number(jfbSpacing);
353
+ let maxW = 100 / cell;
354
+ let padding = Math.floor(this.$rpxNum * jfbSpacing + this.$rpxNum * (jfbSpacing / cell))
355
+ return {
356
+ marginTop: jfbSpacing + 'rpx',
357
+ marginRight: (index + 1) % cell === 0 ? '0' : jfbSpacing + 'rpx',
358
+ width: `calc(${maxW}vw - ${padding}px)`,
359
+ overflow: 'hidden'
360
+ };
361
+ },
362
+
363
+
364
+
365
+ /**
366
+ * @description 获取吸顶样式
367
+ * @param options {Object} 样式参数
368
+ * @param options.top
369
+ * @param options.left
370
+ * @param options.bottom
371
+ * @param options.right
372
+ * @param options.paddingBottom 距离底部距离(paddingBottom和height选其一即可)
373
+ * @param options.height 距离底部距离(paddingBottom和height选其一即可)
374
+ * @param options.zIndex
375
+ * @param type {String} 吸顶类型 其值:bottom/top
376
+ * @param fixed {Boolean} 是否吸顶或者占位
377
+ * @return {String}
378
+ */
379
+ fixedStyle(options = {}, type = 'bottom', fixed = true) {
380
+ let paddingBottom = options.paddingBottom || options.height || 0;
381
+ if (options.paddingBottom) delete options.paddingBottom;
382
+ if (options.height) delete options.height;
383
+ let obj = Object.assign({}, {
384
+ top: 0, left: 0, right: 0, bottom: 0, zIndex: 100,
385
+ }, options);
386
+ if (!fixed) {
387
+ let padding = (this.layoutInfo.bottomHeight + this.layoutInfo.footerHeight + paddingBottom) * this.$rpxNum;
388
+ let sy = `padding-bottom:calc(${padding}px + constant(safe-area-inset-bottom));`;
389
+ sy = `${style}; padding-bottom:calc(${padding}px + env(safe-area-inset-bottom));`;
390
+ return sy;
391
+ }
392
+
393
+ let style = 'position: fixed';
394
+ style = `${style};left:${obj.left}rpx`;
395
+ style = `${style};right:${obj.right}rpx`;
396
+ style = `${style};z-index:${obj.zIndex}`;
397
+ if (type === 'bottom') {
398
+ let padding = (this.layoutInfo.bottomHeight + this.layoutInfo.footerHeight + paddingBottom) * this.$rpxNum;
399
+ style = `${style}; padding-bottom:calc(${padding}px + constant(safe-area-inset-bottom));`;
400
+ style = `${style}; padding-bottom:calc(${padding}px + env(safe-area-inset-bottom));`;
401
+ style = `${style};bottom:0;`;
402
+ }
403
+ if (type === 'top') {
404
+ style = `${style};top:${obj.top}rpx`;
405
+ }
406
+ return style;
407
+ },
408
+
409
+
410
+ /**
411
+ * 检查插件是否加载成功
412
+ */
413
+ onCheck() {},
414
+
415
+ /***
416
+ * @description 业务组件风格map到data中
417
+ */
418
+ initThemesToData() {
419
+ let current = {};
420
+ Object.keys(this.styles).map(key => {
421
+ let k = key.replace('$', '');
422
+ if (this[k] !== undefined){
423
+ this[k] = this.styles[key];
424
+ current[k] = this.styles[key];
425
+ }
426
+ });
427
+ this.setCurrentStyle(helper.cloneDeep(current))
428
+ },
429
+
430
+ /**
431
+ * @description 其子级插件获取当前插件的业务组件风格列表
432
+ * @returns {*}
433
+ */
434
+ getParentThemes() {
435
+ return this.styles;
436
+ },
437
+
438
+ //#ifdef H5
439
+ /**
440
+ * @description 点击删除操作按钮
441
+ */
442
+ delEdit() {
443
+ if(this.isReferenceTemplate) return;
444
+ XdBus.send('onDelPackage', {
445
+ containerId: this.containerId,
446
+ componentAtrr: this.componentAtrr,
447
+ cid: this.cid,
448
+ container: this.container
449
+ })
450
+ },
451
+ //#endif
452
+
453
+ /**
454
+ * @description 点击选择插件显示边框
455
+ */
456
+ handleEditxSelect() {
457
+ //加载本地业务插件库
458
+ if (this.noBorder) return;
459
+
460
+ //#ifdef H5
461
+ if (this.active) return;
462
+ this.active = true;
463
+ let AttrObj = this.$xdUniHelper.checkVarType(this.Attr) === 'object' ?
464
+ this.$xdUniHelper.customClone(this.Attr) : {style: [], advanced: [], content: []};
465
+
466
+ //设置已绑定数据
467
+ Object.keys(AttrObj).map(type => {
468
+ //配置的是方法
469
+ if (type === 'style' || type === 'advanced' || type === 'content') {
470
+ if (typeof AttrObj[type] === "function") {
471
+ let params = getContainerFnPropsValue(this.container, `${type}`);
472
+ let Attr = this.$xdUniHelper.customClone(this.Attr);
473
+ AttrObj[type] = Attr[type](params);
474
+ AttrObj[`${type}.isFn`] = true;
475
+ AttrObj[`${type}.Fn`] = Attr[type];
476
+ } else {
477
+ AttrObj[type].map(item => {
478
+ if (item.value !== undefined) item.value = getContainerPropsValue(this.container, `${type}.${item.valueKey}`, item.value);
479
+ if (item.defaultValue !== undefined) item.defaultValue = getContainerPropsValue(this.container, `${type}.${item.valueKey}`, item.value);
480
+ });
481
+ AttrObj[`${type}.isFn`] = false;
482
+ }
483
+ }
484
+ });
485
+
486
+ //发送点击组件事件
487
+ XdBus.send('onSelectPackage', {
488
+ containerId: this.containerId,
489
+ Attr: this.$xdUniHelper.customClone(AttrObj),
490
+ container: this.$xdUniHelper.cloneDeep(this.container)
491
+ });
492
+
493
+ //绑定选中插件事件
494
+ XdBus.message('select', {
495
+ containerId: this.containerId,
496
+ })
497
+ //#endif
498
+ },
499
+
500
+ /**
501
+ * @description 判断是否有值并返回默认值
502
+ * @param value {Number} 判断的值
503
+ * @param dValue {Number} 默认值
504
+ * @return {number}
505
+ */
506
+ checkValue(value, dValue = 0){
507
+ if(value === undefined || value === '' || value === null) return dValue;
508
+ return Number(value || 0);
509
+ },
510
+
511
+ /**
512
+ * @description 获取图片链接
513
+ * @param image {Object} 图片对象
514
+ * @return {string}
515
+ */
516
+ getBgImage(image = {}){
517
+ let bg = 'none';
518
+ if(this.$xdUniHelper.checkVarType(image) === 'object') {
519
+ if(!this.$xdUniHelper.isEmpty(image)) {
520
+ return `url(${getServiceUrl(image.url)})`
521
+ }
522
+ }
523
+ return bg
524
+ },
525
+
526
+ /**
527
+ * @description 阴影样式生成
528
+ * @param defaultObj {Object} 默认值
529
+ * @param newObj {Object} 新组件对象
530
+ * @return {string} 例如:`0,0,10rpx,rgba(0,0,0,0)`
531
+ */
532
+ getXdShadow(defaultObj, newObj){
533
+ if(newObj.type === 'N' || this.$xdUniHelper.isEmpty(newObj)) return `0 0 0 rgba(0,0,0,0)`;
534
+ return this.getXdBorder(defaultObj,newObj,'shadow')
535
+ },
536
+
537
+ /**
538
+ * @description 边框样式生成
539
+ * @param defaultObj {Object} 默认值
540
+ * @param newObj {Object} 新组件对象
541
+ * @param type {string} border/shadow
542
+ * @return {string} 例如:`2rpx solid rgba(0,0,0,0)`
543
+ */
544
+ getXdBorder(defaultObj, newObj, type='border'){
545
+ //使用默认值
546
+ if(newObj.type ==='D'){
547
+ if(type === 'border') return `${defaultObj.width}rpx ${defaultObj.style} ${defaultObj.color}`;
548
+ return `0 0 ${defaultObj.width}rpx ${defaultObj.color}`;
549
+ }
550
+ if(newObj.type === 'N' || this.$xdUniHelper.isEmpty(newObj)) return `0`;
551
+ let width = defaultObj.width;
552
+ let color = defaultObj.color;
553
+ let style = defaultObj.style || 'solid';
554
+ let value = newObj.value || {};
555
+ if(value.width) width = value.width;
556
+ if(value.color) color = value.color;
557
+ if(value.style) style = value.style;
558
+ if(type === 'border') return `${width}rpx ${style} ${color}`
559
+ return `0 0 ${width}rpx ${color}`;
560
+ },
561
+
562
+ /**
563
+ * @description 兼容新老border与shadow组件数据
564
+ * @param newObj {Object} 新对象border与shadow
565
+ * @param oldObj {Object} 新对象border与shadow
566
+ * @param oldObj.width {Number}老border与shadow的宽度字段
567
+ * @param oldObj.color {String} 老border与shadow的颜色字段
568
+ * @param oldObj.style {String|undefined} 老border样式默认值:solid
569
+ * @param type {String}
570
+ * @return {string} 例如:`2rpx solid rgba(0,0,0,0)`
571
+ */
572
+ getBorderCompatibleOldStyle(newObj={}, oldObj={}, type='border'){
573
+ let contWidth = 0;
574
+ let contColor = 'rgba(0.0.0.0)';
575
+ let contrStyle = 'solid';
576
+
577
+ if(oldObj.type === 'Y') {
578
+ if(oldObj.width !== undefined) contWidth = oldObj.width;
579
+ if(oldObj.color !== undefined) contColor = oldObj.color;
580
+ }
581
+ if(newObj.type === 'Y') {
582
+ let value = newObj.value || {};
583
+ if(value.color) contColor = value.color;
584
+ if(value.style) contrStyle = value.style;
585
+ if(value.width) contWidth = value.width;
586
+ }
587
+
588
+ if(type === 'border'){
589
+ if(oldObj.type === 'N' && newObj.type === 'N') return 0;
590
+ return `${contWidth}rpx ${contrStyle} ${contColor}`
591
+ }
592
+ return `0 0 ${contWidth}rpx ${contColor}` ;
593
+ },
594
+
595
+ /**
596
+ * @description 兼容新老border与shadow组件数据
597
+ * @param newShadow {Object} 新对象border与shadow
598
+ * @param oldShadow {Object} 新对象border与shadow
599
+ * @param oldShadow.width {Number}老border与shadow的宽度字段
600
+ * @param oldShadow.color {String} 老border与shadow的颜色字段
601
+ * @return {string} 例如:`0,0,10rpx,rgba(0,0,0,1)`
602
+ */
603
+ getShadowCompatibleOldStyle(newShadow={},oldShadow={}){
604
+ return this.getBorderCompatibleOldStyle(newShadow,oldShadow, 'shadow')
605
+ },
606
+
607
+ /**
608
+ * @description 获取边框或投影宽度值
609
+ * @param newObj {Object} border|shadow
610
+ * @param width {number|string} 老模式宽
611
+ * @param type {string} 老模式宽是否启用 Y/N
612
+ * @return {number}
613
+ */
614
+ getBorOrShWidth(newObj={}, {width, type}) {
615
+ let tempWidth = 0;
616
+ if(type === 'Y' && width !== undefined) tempWidth = width;
617
+ if(newObj.type === 'Y') {
618
+ let value = newObj.value || {};
619
+ if(value.width !== undefined) tempWidth = value.width;
620
+ }
621
+ return Number(tempWidth);
622
+ },
623
+
624
+ /**
625
+ * @description 解析切换元素属性方法
626
+ * @param newObj
627
+ * @param fontSize {String} 默认字体大小, 格式:24rpx
628
+ * @param lineHeight {Number} 默认行高 格式:30
629
+ * @param color {String} 默认颜色
630
+ * @param bgColor {String} 默认背景色
631
+ * @param fontWeight {String} 字体粗线
632
+ * @param gradientColor {String} 渐变色 参考:https://www.colorzilla.com/gradient-editor/
633
+ * @param type {String} 获取样式类型: ''=>获取普通样式 act=>获取选中样式
634
+ * @return {{}}
635
+ */
636
+ getFontAndBgcStyle(newObj, {fontSize, lineHeight, color, bgColor, fontWeight,gradientColor},type='' ){
637
+ let temp = {};
638
+ let colorKey = 'color',
639
+ fontSizeKey='fontSize',
640
+ lineHeightKey = 'lineHeight',
641
+ fontWeightKey = 'fontWeight',
642
+ bgColorKey = 'bgColor',
643
+ gradientColorKey = 'gradientColor';
644
+ if(type === 'act') {
645
+ colorKey = `actColor`;
646
+ fontSizeKey='actFontSize';
647
+ lineHeightKey = 'actLineHeight';
648
+ fontWeightKey = 'actFontWeight';
649
+ bgColorKey = 'actBgColor';
650
+ gradientColorKey = 'actGradientColor';
651
+ }
652
+ if(newObj[colorKey] || color) temp['color'] = newObj[colorKey] || color;
653
+ if(newObj[fontSizeKey] || color) temp['fontSize'] = newObj[fontSizeKey] || fontSize;
654
+ if(newObj[lineHeightKey] || lineHeight) temp['lineHeight'] = (newObj[lineHeightKey] || lineHeight) + 'rpx';
655
+ if(newObj[fontWeightKey] || fontWeight) temp['fontWeight'] = newObj[fontWeightKey] || fontWeight;
656
+ if(newObj[bgColorKey] || bgColor) temp['backgroundColor'] = newObj[bgColorKey] || bgColor;
657
+ if(newObj[gradientColorKey] || gradientColor) temp['backgroundImage'] = newObj[gradientColorKey] || gradientColor;
658
+ return temp;
659
+
660
+ },
661
+
662
+ /**
663
+ * @description 获取margin或者padding的值
664
+ * @param marAndPadding {Object}
665
+ * @param defVale {Object|number} 格式:10 或者 {top:10, left:10, right: 10, bottom:10}
666
+ * @return {string} 例如:`10rpx 10rpx 10rpx 10rpx`
667
+ */
668
+ getMarginAndPadding(marAndPadding, defVale){
669
+ let top = 0, left=0,bottom=0,right=0;
670
+ if(typeof defVale === 'number') {
671
+ top=defVale;
672
+ left=defVale;
673
+ bottom=defVale;
674
+ right=defVale;
675
+ }
676
+ if(this.$xdUniHelper.checkVarType(defVale) === 'object') {
677
+ if(defVale.top !== undefined) top = defVale.top;
678
+ if(defVale.right !== undefined) right = defVale.right;
679
+ if(defVale.bottom !== undefined) bottom = defVale.bottom;
680
+ if(defVale.left !== undefined) left = defVale.left;
681
+ }
682
+ let str = `${this.checkValue(marAndPadding.top, top)}rpx`;
683
+ str = `${str} ${this.checkValue(marAndPadding.right, right)}rpx`;
684
+ str = `${str} ${this.checkValue(marAndPadding.bottom, bottom)}rpx`;
685
+ str = `${str} ${this.checkValue(marAndPadding.left, left)}rpx`;
686
+ return str
687
+ },
688
+
689
+ /**
690
+ * @description 获取margin和padding的上下或者左右值的和
691
+ * @param obj {Object} margin或者padding的值
692
+ * @param type {string} RL|TB
693
+ * @param defValue {Object|number} 格式:10 或者 {top:10, left:10, right: 10, bottom:10}
694
+ * @return {number}
695
+ */
696
+ getPMValue(obj = {},type='RL', defValue) {
697
+ if(this.$xdUniHelper.checkVarType(obj) !== 'object') obj = {};
698
+ let top = 0,right=0,bottom=0,left=0;
699
+ if(typeof defValue === 'number') {
700
+ top = right = left = bottom = defValue;
701
+ }
702
+ else if(this.$xdUniHelper.checkVarType(obj) === 'object') {
703
+ if(typeof defValue.top === "number") top = defValue.top;
704
+ if(typeof defValue.right === "number") right = defValue.right;
705
+ if(typeof defValue.bottom === "number") bottom = defValue.bottom;
706
+ if(typeof defValue.left === "number") left = defValue.left;
707
+ }
708
+ if(type === 'RL') {
709
+ return this.checkValue(obj.left,left) + this.checkValue(obj.right,right);
710
+ }
711
+ return this.checkValue(obj.bottom,bottom) + this.checkValue(obj.top,top);
712
+ },
713
+
714
+ /**
715
+ * @description 获取商品显示规则
716
+ * @param container
717
+ * @return {{isAddCart: *, isShowDiscount: *, isPrice: *, is_show_brand: *, showActivityPrice: *, isShowTag: *, differ: *}}
718
+ */
719
+ getProductConfig(container){
720
+ let is_show_brand = getContainerPropsValue(container, "content.is_show_brand", "N");
721
+ let isPrice = getContainerPropsValue(container, "content.isPrice", "Y");
722
+ let isShowDiscount = getContainerPropsValue(container, "content.isShowDiscount", "Y");
723
+ let differ = getContainerPropsValue(container, "content.differ", 1);
724
+ let showActivityPrice = getContainerPropsValue(container, "content.showActivityPrice", "N");
725
+ let isShowTag = getContainerPropsValue(container, "content.isShowTag", "Y");
726
+ let isAddCart = getContainerPropsValue(container, "content.isAddCart", "N");
727
+ return {
728
+ isShowDiscount: isShowDiscount,
729
+ isPrice: isPrice,
730
+ isAddCart: isAddCart,
731
+ is_show_brand: is_show_brand,
732
+ showActivityPrice:showActivityPrice,
733
+ isShowTag : isShowTag,
734
+ differ: differ,
735
+ }
736
+ },
737
+
738
+ getUrlCallback(path){
739
+ if(this.inCallbackUrlOrg) {
740
+ if(path.indexOf('?') === -1) path = `${path}?inCallback=${this.inCallbackUrlOrg}`;
741
+ else path = `${path}&inCallback=${this.inCallbackUrlOrg}`;
742
+ }
743
+ return path
744
+ },
745
+
746
+ baiduTogcj(bd_lng, bd_lat) {//坐标第转换
747
+ const x_PI = 3.14159265358979324 * 3000.0 / 180.0;
748
+ const x = bd_lng - 0.0065;
749
+ const y = bd_lat - 0.006;
750
+ const z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI);
751
+ const theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI);
752
+ const gg_lng = z * Math.cos(theta);
753
+ const gg_lat = z * Math.sin(theta);
754
+ return [gg_lng, gg_lat]
755
+ },
756
+
757
+
758
+ //#ifdef H5
759
+ webChatEnvOpenLocation({latitude,longitude,name, address}, cb){
760
+ store.dispatch('getH5WxAuthorize',{jsApiList: ['openLocation', 'getLocation']})
761
+ .then(({jwxSDK})=>{
762
+ let zb = this.baiduTogcj(latitude, longitude)
763
+ jwxSDK.openLocation({
764
+ latitude: zb[0],
765
+ longitude:zb[1],
766
+ name: name || '我的位置',
767
+ address: address||'',
768
+ scale: 15,
769
+ infoUrl: ''
770
+ });
771
+ })
772
+ .catch(err=>{
773
+ console.error(err)
774
+ this.$xdAlert({
775
+ content:'暂时不支持唤起APP导航功能',
776
+ time:5000,
777
+ })
778
+ })
779
+ },
780
+ //#endif
781
+
782
+ /**
783
+ * @description 启动导航功能
784
+ * @param latitude {string|number}
785
+ * @param longitude {string|number}
786
+ * @param name {string} 地点名称
787
+ * @param address {string} 地点详细地址
788
+ * @param cb {Function} 成功回调方法
789
+ */
790
+ handleOpenLocation({latitude,longitude, name, address}, cb){
791
+ //latitude = latitude||39.961521814959795;
792
+ //longitude = longitude || 116.84499635227222
793
+
794
+ if(typeof latitude === 'string') latitude = Number(latitude);
795
+ if(typeof longitude === 'string') longitude = Number(longitude);
796
+
797
+ //#ifdef MP-WEIXIN
798
+ let zb = this.baiduTogcj(latitude, longitude);
799
+ uni.openLocation({
800
+ latitude: zb[0],
801
+ longitude: zb[1],
802
+ name: name || '我的位置',
803
+ scale: 15,
804
+ address: address ||'',
805
+ success: function () {
806
+ if(typeof cb === 'function') {
807
+ cb();
808
+ }
809
+ console.log('success');
810
+ }
811
+ });
812
+ //#endif
813
+ //#ifdef H5
814
+ if(isWechat()) this.webChatEnvOpenLocation({latitude,longitude, name, address}, cb);
815
+ else {
816
+ let params = '';
817
+ params = `${params}&location=${latitude},${longitude}`;
818
+ params = `${params}&title=${encodeURIComponent(name)}`;
819
+ params = `${params}&content=${encodeURIComponent(address)}&output=html&zoom=15`;
820
+ window.location.href = `http://api.map.baidu.com/marker?${params}`;
821
+ }
822
+ //#endif
823
+ },
824
+
825
+ getUrlHasSpStrDIR(pathDir){
826
+ if(pathDir.indexOf('@site_domain@/') === 0) {
827
+ return pathDir.replace('@site_domain@/','').split('/')[0]
828
+ }
829
+ return ''
830
+ },
831
+
832
+ /**
833
+ * @description 判断站内设置的地址是否可以进行跳转
834
+ * 当前项目为H5时,过滤所有小程序应用
835
+ * 当前项目为小程序时,过滤所有非当前小程序应用
836
+ * 站外地址直接返回
837
+ * 站内地址未选值直接返回
838
+ * 预览模式全过
839
+ * @param url {string} json数据
840
+ * @return {null|string}
841
+ */
842
+ checkUrlIsValid(url){
843
+ let projectAttr = this.$root.projectAttr;
844
+ //url = '{"dir":"wtxsaas","host":"sandbox-website-05.jufubao.cn","path":"\/main\/order\/detail","appType":"h5","site_id":"17928cc37788be02","site_url":"https:\/\/sandbox-website-05.jufubao.cn\/wtxsaas\/main\/order\/detail","frontPath":"\/wtxsaas\/main\/order\/detail","fixed_business_code":""}'
845
+ //数据为空
846
+ if(url === '' || url === null || url === undefined) return null;
847
+ try {
848
+ let redirect_data = JSON.parse(url);
849
+ //兼容数据
850
+ if(redirect_data.app) redirect_data = redirect_data.app;
851
+ //兼容老数据
852
+ if(!redirect_data['appType']) redirect_data['appType']= 'h5';
853
+ //#ifdef H5
854
+
855
+ //H5 -> MP
856
+ if(redirect_data['appType'] === 'wxmp'){
857
+ //todo 待支持H5跳转到小程序
858
+ return null;
859
+ }
860
+ else {
861
+ //相同H5应用
862
+ if(redirect_data.dir === projectAttr.deploy_dir) {
863
+ return redirect_data.path
864
+ }
865
+ //不相同H5应用
866
+ else {
867
+ return `//${projectAttr.host}${redirect_data.frontPath}`
868
+ }
869
+ }
870
+ //#endif
871
+
872
+ //#ifdef MP-WEIXIN
873
+ let dir = redirect_data.dir;
874
+ if(redirect_data['appType'] === 'wxmp'){
875
+ //相同小程序应用
876
+ if(projectAttr.deploy_dir === dir) return redirect_data.path;
877
+
878
+ //MP -> MP
879
+ else{
880
+ //todo 待支持微信小程序跳转微信小程序
881
+ return null;
882
+ }
883
+ }
884
+ else if(redirect_data['appType'] === 'h5'){
885
+ return `https://${projectAttr.host}${redirect_data.frontPath}`
886
+ }
887
+ //其他情况
888
+ else {
889
+ return null;
890
+ }
891
+ //#endif
892
+ }
893
+ catch (e){
894
+ console.error(e);
895
+ return null;
896
+ }
897
+ },
898
+ }
899
+ }
900
+