jufubao-third 1.0.0-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.
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ export default {
4
+ "type": "build",
5
+ "NODE_ENV": "production",
6
+ "UNI_PLATFORM": "mp-weixin",
7
+ "platform": "mp.weixin",
8
+ "viewType": "preview",
9
+ "isPreview": true,
10
+ "server": "server",
11
+ "copypack": null,
12
+ "fileDir": "resource"
13
+ }
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ //#ifdef H5
4
+ import config from "@/config.h5";
5
+ //#endif
6
+
7
+ //#ifdef MP-WEIXIN
8
+ import config from "@/config.mp.weixin";
9
+ //#endif
10
+
11
+ //#ifdef APP-PLUS
12
+ import config from "@/config.app.plus";
13
+ //#endif
14
+
15
+ export default config;
@@ -0,0 +1,416 @@
1
+ 'use strict';
2
+
3
+ import {getContainerFnPropsValue, getContainerPropsValue} from "@/utils/xd.base";
4
+ import {Base64} from 'js-base64';
5
+ import {mapActions,mapState} from "vuex";
6
+ import helper from "@/utils/helper";
7
+
8
+ export default {
9
+ props: {
10
+ /**
11
+ * @description 插件在页面中到唯一ID
12
+ */
13
+ cid: {
14
+ type: null | String | Number,
15
+ default: null,
16
+ },
17
+ /**
18
+ * @description 业务插件相关数据集合
19
+ */
20
+ container: {
21
+ type: Object,
22
+ default() {
23
+ return {}
24
+ }
25
+ },
26
+ /**
27
+ * @description 页面框架属性
28
+ */
29
+ layoutInfo: {
30
+ type: Object,
31
+ default() {
32
+ return {}
33
+ }
34
+ },
35
+ /**
36
+ * @description 页面属性
37
+ */
38
+ pageAttr: {
39
+ type: Object,
40
+ default() {
41
+ return {}
42
+ }
43
+ },
44
+ /**
45
+ * @description 业务插件元素属性(插件管理时候填写属性)
46
+ */
47
+ componentAttr: {
48
+ type: Object | Array,
49
+ default() {
50
+ return {}
51
+ }
52
+ },
53
+ /**
54
+ * @description 业务插件所属插件库属性(业务插件库)
55
+ */
56
+ appAttr: {
57
+ type: Object | Array,
58
+ default() {
59
+ return {}
60
+ }
61
+ },
62
+ /**
63
+ * @description 项目配置
64
+ */
65
+ settings: {
66
+ type: Object,
67
+ default() {
68
+ return {}
69
+ }
70
+ },
71
+ /**
72
+ * @description 业务插件库所用风格属性
73
+ */
74
+ styles: {
75
+ type: Object || null,
76
+ default() {
77
+ return {}
78
+ }
79
+ },
80
+ /**
81
+ * @description 项目配置文件
82
+ */
83
+ projectAttr: {
84
+ type: Object || null,
85
+ default() {
86
+ return {}
87
+ }
88
+ },
89
+
90
+ /**
91
+ * @description 是否进行本地插件调试模式
92
+ */
93
+ noBorder: {
94
+ type: Boolean,
95
+ default: false
96
+ },
97
+ },
98
+ data(){
99
+ return {
100
+ containerId: null, //容器ID
101
+
102
+ //#ifdef H5
103
+ active: false, //是否选择当前状态
104
+ isEditx: true, //当前为Editx模式
105
+ edit: false, //是否开启编辑模式
106
+ // #endif
107
+
108
+ //风格键
109
+ mainColor: '',
110
+ successColor: '',
111
+ warningColor: '',
112
+ subMainColor: '',
113
+ infoColor: '',
114
+ defaultColor: '',
115
+ dangerColor: '',
116
+ mainGradient: '',
117
+ subGradient: '',
118
+ }
119
+ },
120
+
121
+ destroyed() {
122
+ console.warn('componentsMixins.destroyed.my(timeer|timer)');
123
+ if (this.timeer && typeof this.timeer === "number") {
124
+ clearTimeout(this.timeer);
125
+ console.warn('componentsMixins.destroyed.my.timeer');
126
+ }
127
+ if (this.timer && typeof this.timer === "number") {
128
+ clearTimeout(this.timer);
129
+ console.warn('componentsMixins.destroyed.my.timer');
130
+ }
131
+
132
+ //卸载页面
133
+ if(typeof this.onJfbUnload === "function") {
134
+ console.warn('componentsMixins.destroyed.exec.onJfbUnload');
135
+ this.onJfbUnload()
136
+ }
137
+
138
+ },
139
+
140
+ created(){
141
+ let tag = '';
142
+ if (this.$vnode && this.$vnode.tag) tag = this.$vnode.tag
143
+ console.warn(`init.components._uid:${this._uid},vnode.name=${tag}`);
144
+
145
+ //设置插件cid
146
+ if (this.cid) {
147
+ this.containerId = this.cid;
148
+ } else {
149
+ this.containerId = this.$xdUniHelper.randomChar(20);
150
+ }
151
+
152
+ //保存到vuex
153
+ this.setStyleCommon(this);
154
+
155
+ //初始化风格
156
+ this.initThemesToData();
157
+
158
+
159
+ //#ifdef H5
160
+ //监听用户点击状态显示虚框
161
+ XdBus.addEvent('select', ({containerId}) => {
162
+ this.active = containerId === this.containerId;
163
+ });
164
+
165
+ //业务面板选中插件操作
166
+ XdBus.addEvent('onBoardSelect', ({containerId}) => {
167
+ if (containerId === this.containerId) {
168
+ this.handleEditxSelect()
169
+ }
170
+ });
171
+
172
+ //面板刷新页面功能
173
+ XdBus.addEvent('onUpdateView', (data) => {
174
+ if (data.container_id === this.containerId) {
175
+ if (typeof this['onJfbUpdate'] === 'function') {
176
+ this['onJfbUpdate'](data);
177
+ }
178
+ }
179
+ });
180
+
181
+ // #endif
182
+ },
183
+
184
+
185
+ //#ifdef H5
186
+ mounted() {
187
+ if (this.$configProject.isPreview && this.selfMask !== true) {
188
+ let that = this;
189
+ function handle() {
190
+ let className = `${that.cssRoot}__body-mask`;
191
+ if (document.getElementsByClassName(className).length === 0) {
192
+ let elx = document.getElementsByClassName(`${that.cssRoot}__body`);
193
+ if (elx.length === 0) {
194
+ setTimeout(() => {
195
+ handle()
196
+ }, 100)
197
+ } else {
198
+ const mask = document.createElement("div");
199
+ mask.className = 'jfb-mask';
200
+ mask.style.position = 'absolute';
201
+ mask.style.left = '0px';
202
+ mask.style.right = '0px';
203
+ mask.style.top = '0px';
204
+ mask.style.bottom = '0px';
205
+ mask.style.zIndex = 9999;
206
+ elx.item(0).appendChild(mask);
207
+ }
208
+ }
209
+ }
210
+ handle()
211
+ }
212
+ },
213
+ // #endif
214
+
215
+ computed:{
216
+ ...mapState({
217
+ storeXNamespace: state=> state.xnamespace
218
+ })
219
+ },
220
+
221
+ methods:{
222
+ ...mapActions(['setXNamespace','setStyleCommon']),
223
+
224
+ /**
225
+ * @description 检查是否同域名
226
+ * @param url
227
+ * @param dir {String} 部署目录
228
+ * @returns {*}
229
+ */
230
+ //#ifdef H5
231
+ getSameSiteAndDomain(url, dir) {
232
+ let regDir = new RegExp(`^/${dir}/\.*$`);
233
+ let host = window.location.host;
234
+ let pages = this.$xdUniHelper.parseURL(url);
235
+
236
+ //域名相同并且部署目录相同
237
+ if (host === pages.host && regDir.test(pages.path)) {
238
+ return pages.relative;
239
+ }
240
+ return url;
241
+ },
242
+ // #endif
243
+
244
+ setNameSpace(options){
245
+ //地址栏中获取参数
246
+ if (options['xnamespace']) this.xnamespace = options['xnamespace'];
247
+ //地址栏中获取特定参数
248
+ if (!this.xnamespace && options['x-common']) {
249
+ let decodeParams = Base64.decode(options['x-common']);
250
+ try {
251
+ let params = JSON.parse(decodeParams);
252
+ if (params.business_code) this.xnamespace = params.business_code;
253
+ } catch (e) {
254
+ this.$xdAlert({content: '配置业务参数无法解析'});
255
+ }
256
+ }
257
+ console.warn(`setNameSpace:${this.xnamespace}`);
258
+ if(!this.xnamespace && !this.$configProject.isPreview){
259
+ this.$xdAlert({content: '未设置业务编码',type:'error'});
260
+ throw new Error('请配置业务编码')
261
+ }
262
+
263
+ this.setXNamespace(this.xnamespace || this.projectAttr.business_code)
264
+
265
+ },
266
+
267
+ /**
268
+ * @description 自动计算列数的宽和间距 (父节点需要设置110%)
269
+ * @param index {number} 当前索引值
270
+ * @param cell {number} 当前索引值
271
+ * @param jfbSpacing {number}
272
+ * @returns {{marginRight: string, overflow: string, width: string, marginTop: string}}
273
+ */
274
+ itemStyle(index, cell, jfbSpacing ) {
275
+ if(this.$xdUniHelper.checkVarType(jfbSpacing) === 'string') jfbSpacing = Number(jfbSpacing);
276
+ let maxW = 100 / cell;
277
+ let padding = Math.floor(this.$rpxNum * jfbSpacing + this.$rpxNum * (jfbSpacing / cell))
278
+ return {
279
+ marginTop: jfbSpacing + 'rpx',
280
+ marginRight: (index + 1) % cell === 0 ? '0' : jfbSpacing + 'rpx',
281
+ width: `calc(${maxW}vw - ${padding}px)`,
282
+ overflow: 'hidden'
283
+ };
284
+ },
285
+
286
+ /**
287
+ * @description 获取吸顶样式
288
+ * @param options {Object} 样式参数
289
+ * @param options.top
290
+ * @param options.left
291
+ * @param options.bottom
292
+ * @param options.right
293
+ * @param options.paddingBottom 距离底部距离(paddingBottom和height选其一即可)
294
+ * @param options.height 距离底部距离(paddingBottom和height选其一即可)
295
+ * @param options.zIndex
296
+ * @param type {String} 吸顶类型 其值:bottom/top
297
+ * @param fixed {Boolean} 是否吸顶或者占位
298
+ * @return {String}
299
+ */
300
+ fixedStyle(options = {}, type = 'bottom', fixed = true) {
301
+ let paddingBottom = options.paddingBottom || options.height || 0;
302
+ if (options.paddingBottom) delete options.paddingBottom;
303
+ if (options.height) delete options.height;
304
+ let obj = Object.assign({}, {
305
+ top: 0, left: 0, right: 0, bottom: 0, zIndex: 100,
306
+ }, options);
307
+ if (!fixed) {
308
+ let padding = (this.layoutInfo.bottomHeight + this.layoutInfo.footerHeight + paddingBottom) * this.$rpxNum;
309
+ let sy = `padding-bottom:calc(${padding}px + constant(safe-area-inset-bottom));`;
310
+ sy = `${style}; padding-bottom:calc(${padding}px + env(safe-area-inset-bottom));`;
311
+ return sy;
312
+ }
313
+
314
+ let style = 'position: fixed';
315
+ style = `${style};left:${obj.left}rpx`;
316
+ style = `${style};right:${obj.right}rpx`;
317
+ style = `${style};z-index:${obj.zIndex}`;
318
+ if (type === 'bottom') {
319
+ let padding = (this.layoutInfo.bottomHeight + this.layoutInfo.footerHeight + paddingBottom) * this.$rpxNum;
320
+ style = `${style}; padding-bottom:calc(${padding}px + constant(safe-area-inset-bottom));`;
321
+ style = `${style}; padding-bottom:calc(${padding}px + env(safe-area-inset-bottom));`;
322
+ style = `${style};bottom:0;`;
323
+ }
324
+ if (type === 'top') {
325
+ style = `${style};top:${obj.top}rpx`;
326
+ }
327
+ return style;
328
+ },
329
+
330
+
331
+ /**
332
+ * 检查插件是否加载成功
333
+ */
334
+ onCheck() {},
335
+
336
+ /***
337
+ * @description 业务组件风格map到data中
338
+ */
339
+ initThemesToData() {
340
+ Object.keys(this.styles).map(key => {
341
+ let k = key.replace('$', '');
342
+ if (this[k] !== undefined) this[k] = this.styles[key];
343
+ });
344
+ },
345
+
346
+ /**
347
+ * @description 其子级插件获取当前插件的业务组件风格列表
348
+ * @returns {*}
349
+ */
350
+ getParentThemes() {
351
+ return this.styles;
352
+ },
353
+
354
+ //#ifdef H5
355
+ /**
356
+ * @description 点击删除操作按钮
357
+ */
358
+ delEdit() {
359
+ XdBus.send('onDelPackage', {
360
+ containerId: this.containerId,
361
+ componentAtrr: this.componentAtrr,
362
+ cid: this.cid,
363
+ container: this.container
364
+ })
365
+ },
366
+ //#endif
367
+
368
+ /**
369
+ * @description 点击选择插件显示边框
370
+ */
371
+ handleEditxSelect() {
372
+ //加载本地业务插件库
373
+ if (this.noBorder) return;
374
+
375
+ //#ifdef H5
376
+ if (this.active) return;
377
+ this.active = true;
378
+ let AttrObj = this.$xdUniHelper.checkVarType(this.Attr) === 'object' ?
379
+ this.$xdUniHelper.customClone(this.Attr) : {style: [], advanced: [], content: []};
380
+
381
+ //设置已绑定数据
382
+ Object.keys(AttrObj).map(type => {
383
+ //配置的是方法
384
+ if (type === 'style' || type === 'advanced' || type === 'content') {
385
+ if (typeof AttrObj[type] === "function") {
386
+ let params = getContainerFnPropsValue(this.container, `${type}`);
387
+ let Attr = this.$xdUniHelper.customClone(this.Attr);
388
+ AttrObj[type] = Attr[type](params);
389
+ AttrObj[`${type}.isFn`] = true;
390
+ AttrObj[`${type}.Fn`] = Attr[type];
391
+ } else {
392
+ AttrObj[type].map(item => {
393
+ if (item.value !== undefined) item.value = getContainerPropsValue(this.container, `${type}.${item.valueKey}`, item.value);
394
+ if (item.defaultValue !== undefined) item.defaultValue = getContainerPropsValue(this.container, `${type}.${item.valueKey}`, item.value);
395
+ });
396
+ AttrObj[`${type}.isFn`] = false;
397
+ }
398
+ }
399
+ });
400
+
401
+ //发送点击组件事件
402
+ XdBus.send('onSelectPackage', {
403
+ containerId: this.containerId,
404
+ Attr: this.$xdUniHelper.customClone(AttrObj),
405
+ container: this.$xdUniHelper.cloneDeep(this.container)
406
+ });
407
+
408
+ //绑定选中插件事件
409
+ XdBus.message('select', {
410
+ containerId: this.containerId,
411
+ })
412
+ //#endif
413
+ },
414
+ }
415
+ }
416
+
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+
3
+ export default {}
@@ -0,0 +1,35 @@
1
+ 'use strict';
2
+ import {mapActions} from 'vuex';
3
+
4
+ export default {
5
+ data() {
6
+ return {
7
+ locationStatus: false
8
+ }
9
+ },
10
+
11
+ methods: {
12
+ ...mapActions(['getAllCityList']),
13
+ ...mapActions('wxAuthorize', [
14
+ 'getLoadingCityInfoByLocationLv4'
15
+ ]),
16
+
17
+ //==开启定位============
18
+ async getCityInfoByLocation(options, cb) {
19
+ try {
20
+ let locationInfo = await this.getLoadingCityInfoByLocationLv4(options);
21
+ this.$xdLog.setProject('location.getCity.success', locationInfo);
22
+ cb(locationInfo);
23
+ } catch (e) {
24
+ this.$xdLog.setARMSCustomError('get_city_info_by_location_loading', this.$runtime.getErrorInfo(e));
25
+ this.$xdLog.setProject('location.getCity.fail', {data: this.$settings.defaultCity});
26
+ cb({data: this.$settings.defaultCity})
27
+ }
28
+ },
29
+
30
+ handleLocationDone(info) {
31
+ this.$xdLog.setProject('location.done', info);
32
+ this.locationStatus = true;
33
+ },
34
+ }
35
+ }