jufubao-forms 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.
- package/README.md +27 -0
- package/commands.js +84 -0
- package/commands.update.change.js +176 -0
- package/file.config.js +16 -0
- package/get.package.path.js +22 -0
- package/get.package.path.js.tpl +22 -0
- package/package.json +119 -0
- package/src/CreateClientID.js +16 -0
- package/src/ICONS.js +1148 -0
- package/src/common/authorize.js +261 -0
- package/src/common/getBusinessImageUrl.js +39 -0
- package/src/common/getServiceUrl.js +38 -0
- package/src/common/paysdk/jweixin.js +98 -0
- package/src/components/CusCouponChose/CusCouponChose.vue +1024 -0
- package/src/components/CusCouponItem/CusCouponItem.vue +298 -0
- package/src/components/CusEnter/CusEnter.vue +333 -0
- package/src/components/CusPoster/CusPoster.vue +213 -0
- package/src/components/CusPoster/CusSwiperDot.vue +234 -0
- package/src/components/CusProduct/CusProduct.vue +362 -0
- package/src/components/CusSwiperDot/CusSwiperDot.vue +234 -0
- package/src/components/CusTab/CusTab.vue +411 -0
- package/src/components/CusVideo/CusVideo.vue +170 -0
- package/src/components/JfbFormsDynamicForm/Api.js +66 -0
- package/src/components/JfbFormsDynamicForm/Attr.js +35 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicForm.vue +767 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormLess.less +79 -0
- package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormMixin.js +30 -0
- package/src/components/JfbFormsDynamicForm/Mock.js +194 -0
- package/src/components/JfbFormsDynamicForm/XdFormDate.vue +71 -0
- package/src/components/JfbFormsDynamicForm/ld-select/ld-select.vue +329 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar-item.vue +177 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar.vue +930 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/en.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/index.js +8 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hans.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hant.json +22 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/time-picker.vue +934 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/uni-datetime-picker.vue +1042 -0
- package/src/components/JfbFormsDynamicForm/uni-datetime-picker/util.js +403 -0
- package/src/components/JfbFormsList/Api.js +20 -0
- package/src/components/JfbFormsList/Attr.js +70 -0
- package/src/components/JfbFormsList/JfbFormsList.vue +228 -0
- package/src/components/JfbFormsList/JfbFormsListLess.less +79 -0
- package/src/components/JfbFormsList/JfbFormsListMixin.js +30 -0
- package/src/components/JfbFormsList/Mock.js +38 -0
- package/src/components/JfbFormsQuestionAndAnswer/Api.js +43 -0
- package/src/components/JfbFormsQuestionAndAnswer/Attr.js +14 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswer.vue +506 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerLess.less +79 -0
- package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerMixin.js +30 -0
- package/src/components/JfbFormsQuestionAndAnswer/Mock.js +144 -0
- package/src/components/SkeProduct/SkeProduct.vue +241 -0
- package/src/config.app.plus.js +6 -0
- package/src/config.h5.js +13 -0
- package/src/config.mp.weixin.js +13 -0
- package/src/config.project.js +15 -0
- package/src/mixins/cardListMixins.js +187 -0
- package/src/mixins/colorCardMixins.js +122 -0
- package/src/mixins/componentsMixins.js +900 -0
- package/src/mixins/extsMixins.js +3 -0
- package/src/mixins/locationMixins.js +119 -0
- package/src/mixins/newLocaltionMixins.js +754 -0
- package/src/mixins/openDebuggerMixins.js +74 -0
- package/src/mixins/pageEditx.js +347 -0
- package/src/mixins/pageEvent.js +311 -0
- package/src/mixins/pageMain.js +120 -0
- package/src/mixins/pageUitls.js +738 -0
- package/src/mixins/posterMixins.js +122 -0
- package/src/mixins/scrollListFixedHeigthMixins.js +174 -0
- package/src/mocks.js +4 -0
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
import { mapState, mapActions} from 'vuex';
|
|
4
|
+
import {JfbEvent} from "@/utils/xd.event";
|
|
5
|
+
import {Base64} from 'js-base64'
|
|
6
|
+
import {parsePath} from "@/utils/linkUrl";
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
AttrToTargetValues,
|
|
10
|
+
getContainerPropsValue,
|
|
11
|
+
baseCloneDeep,
|
|
12
|
+
} from "@/utils/xd.base";
|
|
13
|
+
import getServiceUrl from "@/common/getServiceUrl";
|
|
14
|
+
import {isGiftPreview} from "@/common/CheckGiftIsPreview";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
computed: {
|
|
18
|
+
...mapState(['siteInfo', 'jfbAuthorize', 'webThemes', 'xnamespace', 'brandInfo']),
|
|
19
|
+
},
|
|
20
|
+
watch: {
|
|
21
|
+
webThemes: {
|
|
22
|
+
immediate: true,
|
|
23
|
+
handler(value) {
|
|
24
|
+
if (value) this.themesList = value
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
data(){
|
|
29
|
+
return {
|
|
30
|
+
themesList: {}, //保存所有业务组件使用风格列表
|
|
31
|
+
titleDefaultCount: 0, //设置标题时候计数器,最大查找uni-page-head__title样式名称次数
|
|
32
|
+
pageHeadersInfo:null, //页面headers信息
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
...mapActions(['loginCardMock','setPagesBusinessCode','setPagesParams']),
|
|
37
|
+
|
|
38
|
+
getPropsParse(data){
|
|
39
|
+
if(typeof data === 'string') {
|
|
40
|
+
if(data === '') return {};
|
|
41
|
+
try{
|
|
42
|
+
return JSON.parse(data);
|
|
43
|
+
}
|
|
44
|
+
catch (e){
|
|
45
|
+
return {}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {}
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
transformToData(containers){
|
|
52
|
+
return containers.map(item=>{
|
|
53
|
+
let props = item.component.props;
|
|
54
|
+
const style = this.getPropsParse(props.style);
|
|
55
|
+
const content = this.getPropsParse(props.content);
|
|
56
|
+
const advanced = this.getPropsParse(props.advanced);
|
|
57
|
+
const refContent = this.getPropsParse(props['ref_content']);
|
|
58
|
+
const propsContent = Object.assign({},style,advanced,content,refContent);
|
|
59
|
+
item.component.props['content'] = JSON.stringify(propsContent);
|
|
60
|
+
return item;
|
|
61
|
+
})
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @description Container数据转化
|
|
66
|
+
* @param containers {Array} 使用业务插件数据
|
|
67
|
+
* @return {Object}
|
|
68
|
+
*/
|
|
69
|
+
getContainerGroup(containers) {
|
|
70
|
+
//转换数据格式
|
|
71
|
+
containers = this.transformToData(containers);
|
|
72
|
+
let temp = {
|
|
73
|
+
topHeight: 0,
|
|
74
|
+
bottomHeight: 0,
|
|
75
|
+
footerHeight: 0,
|
|
76
|
+
tops: [],
|
|
77
|
+
bottoms: [],
|
|
78
|
+
bodys: [],
|
|
79
|
+
footers: [],
|
|
80
|
+
};
|
|
81
|
+
let refs = [];
|
|
82
|
+
containers.map(item => {
|
|
83
|
+
item['refreshKey'] = this.$xdUniHelper.randomChar(20);
|
|
84
|
+
if(!item.hidden) refs.push(item['container_id']);
|
|
85
|
+
let fixed = 'body';
|
|
86
|
+
let height = 0;
|
|
87
|
+
item['component']['attrs'] = AttrToTargetValues(item['component']['attrs']);
|
|
88
|
+
item['component']['attrs'].map(it => {
|
|
89
|
+
if (it['key'] === 'fixed') {
|
|
90
|
+
fixed = it['value'];
|
|
91
|
+
}
|
|
92
|
+
if (it['key'] === 'height') {
|
|
93
|
+
height = it['value'];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
switch (fixed) {
|
|
97
|
+
case 'top':
|
|
98
|
+
temp.tops.push(item);
|
|
99
|
+
if (!item.hidden) temp.topHeight += height;
|
|
100
|
+
break;
|
|
101
|
+
case 'bottom':
|
|
102
|
+
temp.bottoms.push(item);
|
|
103
|
+
if (!item.hidden) temp.bottomHeight += height;
|
|
104
|
+
break;
|
|
105
|
+
case 'footer':
|
|
106
|
+
temp.footers.push(item);
|
|
107
|
+
if (!item.hidden) temp.footerHeight += height;
|
|
108
|
+
break;
|
|
109
|
+
default:
|
|
110
|
+
temp.bodys.push(item);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
this.refs = refs;
|
|
114
|
+
return temp;
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
setPageTitle(){
|
|
118
|
+
// #ifdef MP-WEIXIN
|
|
119
|
+
uni.setNavigationBarTitle({
|
|
120
|
+
title: this.pageAttr.title
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// #endif
|
|
124
|
+
|
|
125
|
+
// #ifdef H5
|
|
126
|
+
if (this.$configProject.type === 'food') {
|
|
127
|
+
let xd = getApp().globalData.$xd;
|
|
128
|
+
if (xd && xd.brandInfo && xd.brandInfo.name) {
|
|
129
|
+
document.title = xd.brandInfo.name;
|
|
130
|
+
this.setH5Title(this.pageAttr.title);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (this.projectAttr['site_name'] || this.projectAttr['seo_title']) {
|
|
135
|
+
document.title = this.projectAttr['seo_title'] || this.projectAttr['site_name'];
|
|
136
|
+
}
|
|
137
|
+
this.setH5Title(this.pageAttr.title);
|
|
138
|
+
}
|
|
139
|
+
// #endif
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
getMockCard(){
|
|
143
|
+
let pagae = this.$xdUniHelper.parseURL();
|
|
144
|
+
let card = pagae.params['x-test'];
|
|
145
|
+
if (card) {
|
|
146
|
+
let reg = /^(card_)[a-zA-Z0-9\-_]{8,}$/;
|
|
147
|
+
if (reg.test(card)) {
|
|
148
|
+
return card.split('_')[1];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return ''
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
getSpPath(dir , path ){
|
|
155
|
+
let reg = /@site_domain@/;
|
|
156
|
+
if(!reg.test(path)) return `/${dir}${path}`;
|
|
157
|
+
else return path.replace(reg, '');
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* @description 只处理H5端(小程序端无法控制链接参数)
|
|
162
|
+
* @return {boolean}
|
|
163
|
+
*/
|
|
164
|
+
checkMockCard(){
|
|
165
|
+
let login_entry = this.projectAttr.login_entry || this.$configProject.login_entry;
|
|
166
|
+
let card_entry = this.projectAttr.card_entry || this.$configProject.card_entry;
|
|
167
|
+
// #ifdef H5
|
|
168
|
+
let pages = this.$xdUniHelper.parseURL();
|
|
169
|
+
let userLogin = this.getSpPath(this.projectAttr.deploy_dir, login_entry);
|
|
170
|
+
let cardLogin = this.getSpPath(this.projectAttr.deploy_dir, card_entry);
|
|
171
|
+
|
|
172
|
+
//登陆页面和卡登陆页面不启用
|
|
173
|
+
if(pages.path === userLogin || pages.path === cardLogin) {
|
|
174
|
+
return false
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let card = pages.params['x-test'];
|
|
178
|
+
if(card) {
|
|
179
|
+
let reg = /^(card_)[a-zA-Z0-9\-_]+$/;
|
|
180
|
+
if(reg.test(card)) return true
|
|
181
|
+
}
|
|
182
|
+
// #endif
|
|
183
|
+
return false;
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
setBusinessCodeSave(options, pages){
|
|
187
|
+
let business_code = '';
|
|
188
|
+
let getType = ''
|
|
189
|
+
|
|
190
|
+
//地址栏中参数传递
|
|
191
|
+
if (!business_code && options['xnamespace']){
|
|
192
|
+
getType = '地址栏中参数传递业务线'
|
|
193
|
+
business_code = options['xnamespace'];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//页面中获取参数
|
|
197
|
+
if (!business_code && pages['is_business_code']){
|
|
198
|
+
business_code = pages['is_business_code'];
|
|
199
|
+
getType = '页面pages.json文件中获取业务线'
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
//文件目录中获取
|
|
203
|
+
//todo
|
|
204
|
+
//getType = '页面JSON文件中获取业务线'
|
|
205
|
+
|
|
206
|
+
//项目文件中获取
|
|
207
|
+
if(!business_code && (this.brandInfo && this.brandInfo.business_code)){
|
|
208
|
+
getType = '项目应用project.json文件中获取业务线'
|
|
209
|
+
business_code = this.brandInfo.business_code;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//地址栏中获取特定参数
|
|
213
|
+
if(!business_code && options['x-common']) {
|
|
214
|
+
let decodeParams = Base64.decode(options['x-common']);
|
|
215
|
+
try {
|
|
216
|
+
let params = JSON.parse(decodeParams);
|
|
217
|
+
if (params.business_code){
|
|
218
|
+
business_code = params.business_code;
|
|
219
|
+
getType = '地址栏中获取全局特殊参数(x-common)中获取业务线'
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
this.setPagesBusinessCode(business_code);
|
|
227
|
+
console.warn(`获取业务线方式:${getType}`)
|
|
228
|
+
return business_code;
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @description 检查地址是否为登陆页面
|
|
233
|
+
* @param type
|
|
234
|
+
* @returns {boolean}
|
|
235
|
+
*/
|
|
236
|
+
checkPathIsLoginAndOrCard(type = 'card'){
|
|
237
|
+
//包含: /$dir/xxx/xxx/xxx或者/pages/index/index
|
|
238
|
+
let pages = this.$xdUniHelper.parseURL();
|
|
239
|
+
let login_entry = this.projectAttr.login_entry || this.$configProject.login_entry;
|
|
240
|
+
let card_entry = this.projectAttr.card_entry || this.$configProject.card_entry;
|
|
241
|
+
|
|
242
|
+
// #ifdef H5
|
|
243
|
+
let userLogin = this.getSpPath(this.projectAttr.deploy_dir, login_entry);
|
|
244
|
+
let cardLogin = this.getSpPath(this.projectAttr.deploy_dir,card_entry);
|
|
245
|
+
if (type === 'card') return pages.path === cardLogin;
|
|
246
|
+
if (type === 'login') return pages.path === userLogin;
|
|
247
|
+
// #endif
|
|
248
|
+
// #ifdef MP-WEIXIN
|
|
249
|
+
let loginObj = parsePath(login_entry);
|
|
250
|
+
let cardObj = parsePath(card_entry);
|
|
251
|
+
if (type === 'card') return cardObj.isSameApp && pages.path === cardObj.url;
|
|
252
|
+
if (type === 'login') return loginObj.isSameApp && pages.path === loginObj.url;
|
|
253
|
+
// #endif
|
|
254
|
+
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @description 当用户登陆当前卡不支持当前业务线时候
|
|
259
|
+
*/
|
|
260
|
+
toCardIndex(){
|
|
261
|
+
let page = this.$xdUniHelper.parseURL();
|
|
262
|
+
let {inCallback} = page.params;
|
|
263
|
+
if(inCallback) {
|
|
264
|
+
try{
|
|
265
|
+
inCallback = Base64.decode(inCallback);
|
|
266
|
+
let regIndex = /^.*(toIndex)$/;
|
|
267
|
+
if(regIndex.test(inCallback)) {
|
|
268
|
+
this.$xdUniHelper.redirectTo({url: this.$settings.index}, false, true)
|
|
269
|
+
}
|
|
270
|
+
}catch (e) {
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
setContainersLogs(containers){
|
|
278
|
+
if(containers && containers.length > 0) {
|
|
279
|
+
let log = containers.map(item=>{
|
|
280
|
+
return item.component['component_name']
|
|
281
|
+
});
|
|
282
|
+
this.$xdLog.setProject('App.containers', log.join('_'));
|
|
283
|
+
}
|
|
284
|
+
else this.$xdLog.setProject('App.containers', 'no.containers');
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
getUID(token){
|
|
288
|
+
let arr = token.split('.');
|
|
289
|
+
try {
|
|
290
|
+
let uid = JSON.parse(Base64.decode(arr[1]));
|
|
291
|
+
return uid['csrf_user_id'];
|
|
292
|
+
}catch (e) {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @description 设置页面公共参数
|
|
299
|
+
* @param pages
|
|
300
|
+
* @param bussCode
|
|
301
|
+
*/
|
|
302
|
+
setCommonPagesParams(pages, bussCode){
|
|
303
|
+
let isPagesUseBussCode = false;
|
|
304
|
+
if(pages.features && this.$xdUniHelper.checkVarType(pages.features) === 'array') {
|
|
305
|
+
pages.features.map(item=>{
|
|
306
|
+
if(item === 'business_limit') isPagesUseBussCode = true;
|
|
307
|
+
})
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
let folderCustomLoginEntry = '';
|
|
311
|
+
this.setPagesParams({
|
|
312
|
+
pagesParams: {
|
|
313
|
+
xnamespace:bussCode,
|
|
314
|
+
custom_login_entry: pages['is_login_entry'] || folderCustomLoginEntry || '',
|
|
315
|
+
isPagesUseBussCode: isPagesUseBussCode,
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
},
|
|
319
|
+
|
|
320
|
+
init(options){
|
|
321
|
+
this.settings = this.$settings;
|
|
322
|
+
this.site_id = this.brandInfo.site_id;
|
|
323
|
+
this.projectAttr = this.brandInfo;
|
|
324
|
+
|
|
325
|
+
//第一次上班日志
|
|
326
|
+
this.$xdLog.setProject('App.pages.init', 'pages.init');
|
|
327
|
+
|
|
328
|
+
//预览模式设置页面ID
|
|
329
|
+
if (this.$configProject.isPreview === true) {
|
|
330
|
+
let {page_id} = this.$xdUniHelper.parseURL().params;
|
|
331
|
+
if (!page_id) throw new Error('请设置页面ID');
|
|
332
|
+
this.pageAttr['page_id'] = page_id;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
//当用户登陆当前卡不支持当前业务线时候(选择去换业务线)
|
|
337
|
+
this.toCardIndex();
|
|
338
|
+
|
|
339
|
+
//获取用户信息
|
|
340
|
+
this.getPageAttr(this.page_id)
|
|
341
|
+
.then(async (res) => {
|
|
342
|
+
|
|
343
|
+
//configs.template_type
|
|
344
|
+
// 模板类型 1=克隆 2=软链 3=原创模板
|
|
345
|
+
if(res.configs['template_type']) {
|
|
346
|
+
this.isReferenceTemplate = res.configs['template_type'] === 2
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
//设置页面信息
|
|
350
|
+
this.pageAttr = {...this.pageAttr, ...this.parsePageConfig(res)};
|
|
351
|
+
if (this.pageAttr['config']) this.pageAttr['configs'] = this.pageAttr['config'];
|
|
352
|
+
|
|
353
|
+
//预览模式设置topBar属性
|
|
354
|
+
if (this.$configProject.isPreview) {
|
|
355
|
+
this.setPreviewSetPageConfig(this.pageAttr.is_bar_custom === 'custom');
|
|
356
|
+
} else this.setPageConfig(this.pageAttr);
|
|
357
|
+
|
|
358
|
+
//计算页面插件信息
|
|
359
|
+
this.setContainersLogs(res['containers'])
|
|
360
|
+
this.containers = this.getContainerGroup(res['containers']);
|
|
361
|
+
|
|
362
|
+
//检查是否为成功页面
|
|
363
|
+
this.isSpecialPages = this.checkSpecialPages(res['containers']);
|
|
364
|
+
|
|
365
|
+
//保存页面headers变量
|
|
366
|
+
if (res['headers']) {
|
|
367
|
+
this.setPagesHeader(res['headers']);
|
|
368
|
+
this.pageHeadersInfo = this.$xdUniHelper.cloneDeep(res['headers'])
|
|
369
|
+
}
|
|
370
|
+
else{
|
|
371
|
+
this.setPagesHeader({});
|
|
372
|
+
this.pageHeadersInfo = {};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
//保存页面权限
|
|
376
|
+
if (res['permission']) this.setPagesPermission(res['permission']);
|
|
377
|
+
else this.setPagesPermission({can_card: false, can_sign: false});
|
|
378
|
+
this.loadStatus = true;
|
|
379
|
+
|
|
380
|
+
//设置业务线
|
|
381
|
+
const bussCode = this.setBusinessCodeSave(this.$xdUniHelper.parseURL().params, this.pageAttr);
|
|
382
|
+
|
|
383
|
+
//保存页面参数和地址参数
|
|
384
|
+
this.setCommonPagesParams(this.pageAttr, bussCode)
|
|
385
|
+
this.$xdLog.setProject('App.user.card.start', 'pages.check.userAndCard.start');
|
|
386
|
+
|
|
387
|
+
//礼包预览使用免登陆模式(H5模式)
|
|
388
|
+
// #ifdef H5
|
|
389
|
+
if(isGiftPreview()){
|
|
390
|
+
this.handleDoneLoad()
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
// #endif
|
|
394
|
+
|
|
395
|
+
//检查用户是否登录
|
|
396
|
+
if (!await this.checkLoginAndCardLogin(res.permission['can_sign'])) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
//登陆测试卡
|
|
401
|
+
if(this.checkMockCard()) {
|
|
402
|
+
if(this.getMockCard()){
|
|
403
|
+
let mock = await this.loginCardMock({card_number: this.getMockCard()});
|
|
404
|
+
if (!mock.status) {
|
|
405
|
+
this.$xdAlert({
|
|
406
|
+
content: (mock.message && mock.message.data && mock.message.data.message) ?
|
|
407
|
+
mock.message.data.message:
|
|
408
|
+
'当前登陆的卡券或服务不可用,请重试!',
|
|
409
|
+
width: '60vw',
|
|
410
|
+
time: 3000
|
|
411
|
+
})
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
else{
|
|
416
|
+
this.$xdAlert({
|
|
417
|
+
content: '请输入正确券号,请重试!',
|
|
418
|
+
width: '60vw',
|
|
419
|
+
time: 3000
|
|
420
|
+
})
|
|
421
|
+
return
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
//正常卡登陆
|
|
426
|
+
else{
|
|
427
|
+
//检查用户卡是否登录
|
|
428
|
+
if (!await this.checkLoginAndCardLogin(res.permission['can_card'], 'card')) {
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
this.$xdLog.setProject('App.user.card.done', 'pages.check.userAndCard.done');
|
|
434
|
+
if(this.jfbAuthorize.getToken('user') !== null) {
|
|
435
|
+
this.$xdLog.setConfig(this.getUID(this.jfbAuthorize.getToken('user')))
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
this.handleDoneLoad()
|
|
439
|
+
|
|
440
|
+
})
|
|
441
|
+
.catch(err=>{
|
|
442
|
+
console.error(err)
|
|
443
|
+
this.$xdLog.catch(err)
|
|
444
|
+
});
|
|
445
|
+
},
|
|
446
|
+
|
|
447
|
+
handleDoneLoad(){
|
|
448
|
+
|
|
449
|
+
//用户状态已经检查完成
|
|
450
|
+
this.isCheckAuth = true;
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
//设置标题
|
|
454
|
+
this.setPageTitle();
|
|
455
|
+
this.isCheckAuth = true;
|
|
456
|
+
|
|
457
|
+
//执行onload事件
|
|
458
|
+
this.$xdLog.setProject(`App.getPages`, 'App.getPages.done');
|
|
459
|
+
this.onInitLoad();
|
|
460
|
+
},
|
|
461
|
+
|
|
462
|
+
checkSpecialPages(containers=[]){
|
|
463
|
+
let flag = false;
|
|
464
|
+
let packArrays = ['JfbBaseSuccess'];
|
|
465
|
+
if(containers instanceof Array) {
|
|
466
|
+
containers.map(item=>{
|
|
467
|
+
if(packArrays.includes(item.component['component_name'])) {
|
|
468
|
+
flag = true;
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
}
|
|
472
|
+
return flag
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* @description 获取页面信息
|
|
477
|
+
* @returns {{pageAttr: *, projectAttr: *, pagePackConfig: *}}
|
|
478
|
+
*/
|
|
479
|
+
getPageAllInfo(){
|
|
480
|
+
return {
|
|
481
|
+
pageAttr: this.pageAttr,
|
|
482
|
+
projectAttr: this.projectAttr,
|
|
483
|
+
pagePackConfig: this.pagePackConfig
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @description 预览模式设置页面属性
|
|
489
|
+
* @param type {Object} 导航模式 (false|true)false=>系统 true => 自定义
|
|
490
|
+
*/
|
|
491
|
+
setPreviewSetPageConfig(type) {
|
|
492
|
+
if (type) {
|
|
493
|
+
this.pageAttr['showBar'] = this.pageAttr['is_bar'] || false;
|
|
494
|
+
this.pageAttr['backgroundImage'] = this.pageAttr.configs['background_image'] || 'none';
|
|
495
|
+
this.pageAttr['showBack'] = this.pageAttr['is_back'] || false;
|
|
496
|
+
this.pageAttr['isUseBgImage'] = !(this.pageAttr['is_use_bar_show_bg'] || false);
|
|
497
|
+
} else {
|
|
498
|
+
this.pageAttr['showBar'] = true;
|
|
499
|
+
this.pageAttr['backgroundImage'] = this.pageAttr.configs['background_image'] || 'none';
|
|
500
|
+
this.pageAttr.isUseBgImage = false;
|
|
501
|
+
this.pageAttr.showBack = false;
|
|
502
|
+
}
|
|
503
|
+
this.pageAttr['navigationStyleIsCustom'] = type;
|
|
504
|
+
|
|
505
|
+
//导航颜色
|
|
506
|
+
if(!type) this.pageAttr['barColor'] = this.pageAttr['is_bar_default_tc'] || this.$configProject.extras['top_bar_text_color'] || 'black';
|
|
507
|
+
else this.pageAttr['barColor'] = this.pageAttr['is_bar_custom_tc'] || this.$configProject.extras['top_bar_text_color'] || 'black';
|
|
508
|
+
this.pageAttr['background'] = this.pageAttr.configs['background_color'] || this.$configProject.extras.bgc || 'none';
|
|
509
|
+
this.pageAttr['barBgColor'] = '';
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
//h5使用渐变色
|
|
513
|
+
let templateBgcGradient = '';
|
|
514
|
+
let pageBgcGradient = '';
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
//#ifdef H5
|
|
518
|
+
if(type) {
|
|
519
|
+
if (this.$configProject.extras['bgc_gradient']) {
|
|
520
|
+
templateBgcGradient = this.$configProject.extras['bgc_gradient']
|
|
521
|
+
}
|
|
522
|
+
if (this.pageAttr['is_bar_bgc_gradient']) {
|
|
523
|
+
pageBgcGradient = this.pageAttr['is_bar_bgc_gradient']
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
//#endif
|
|
527
|
+
|
|
528
|
+
this.pageAttr['barBackground'] = templateBgcGradient || pageBgcGradient ||
|
|
529
|
+
this.pageAttr.is_bar_bgc || this.$configProject.extras.top_bar_color
|
|
530
|
+
|| '#f8f8f8';
|
|
531
|
+
|
|
532
|
+
},
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* @description 解析页面configs数据
|
|
536
|
+
* @param res {Object} 页面数据
|
|
537
|
+
*/
|
|
538
|
+
parsePageConfig(res) {
|
|
539
|
+
if (res.configs.background_image) res.configs.background_image = getServiceUrl(res.configs.background_image);
|
|
540
|
+
if (res.configs.parameters &&
|
|
541
|
+
this.$xdUniHelper.checkVarType(res.configs.parameters) === 'array'
|
|
542
|
+
) {
|
|
543
|
+
res.configs.parameters = AttrToTargetValues(res.configs['parameters']);
|
|
544
|
+
res.configs.parameters.map(item => {
|
|
545
|
+
res[item['key']] = item.value
|
|
546
|
+
})
|
|
547
|
+
} else res.configs.parameters = {};
|
|
548
|
+
return res;
|
|
549
|
+
},
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* @description 设置标题
|
|
553
|
+
*/
|
|
554
|
+
|
|
555
|
+
setH5Title(title) {
|
|
556
|
+
if (this.titleDefaultCount > 20) return;
|
|
557
|
+
let titleElx = document.getElementsByClassName('uni-page-head__title').item(0);
|
|
558
|
+
if (titleElx) {
|
|
559
|
+
titleElx.innerHTML = title;
|
|
560
|
+
} else setTimeout(() => {
|
|
561
|
+
this.titleDefaultCount++;
|
|
562
|
+
this.setH5Title(title);
|
|
563
|
+
}, 50);
|
|
564
|
+
},
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* @description 获取站点信息
|
|
568
|
+
*/
|
|
569
|
+
getSiteAttr() {
|
|
570
|
+
return this.siteInfo;
|
|
571
|
+
},
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @description 检查是否登陆
|
|
575
|
+
* @param permission {Boolean} 是否检查登陆
|
|
576
|
+
* @param type {String} 检查类型 login=用户登陆 card=>正常用户卡登陆 card_mock=>自动卡登陆
|
|
577
|
+
* @param isAutoJump {Boolean} 是否启动自动跳转到登陆或者卡登陆页面
|
|
578
|
+
*/
|
|
579
|
+
checkLoginAndCardLogin(permission, type = 'login', isAutoJump = true) {
|
|
580
|
+
return new Promise((resolve) => {
|
|
581
|
+
|
|
582
|
+
//检查用户是否已经登录
|
|
583
|
+
if (type === 'login') {
|
|
584
|
+
if (permission) {
|
|
585
|
+
|
|
586
|
+
//status=true 免登或者已登陆 status=false 未登陆
|
|
587
|
+
this.jfbAuthorize.checkUserLogin(permission, this, isAutoJump)
|
|
588
|
+
.then(status => {
|
|
589
|
+
resolve(status)
|
|
590
|
+
})
|
|
591
|
+
.catch(status => {
|
|
592
|
+
console.error(status)
|
|
593
|
+
resolve(false)
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
//用户免登陆
|
|
598
|
+
else resolve(true)
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
//检查用户是否已经登录消费卡
|
|
602
|
+
if (type === 'card') {
|
|
603
|
+
if (permission) {
|
|
604
|
+
|
|
605
|
+
//已登陆卡
|
|
606
|
+
if (this.jfbAuthorize.checkCardLogin(permission, this, isAutoJump)) {
|
|
607
|
+
resolve(true)
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
//未登陆卡
|
|
611
|
+
else resolve(false)
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
//免登陆卡
|
|
615
|
+
else resolve(true)
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
//自动卡登陆
|
|
619
|
+
if (type === 'card_mock') {
|
|
620
|
+
if (this.jfbAuthorize.checkCardLogin(permission, this, false)) {
|
|
621
|
+
resolve(true)
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
//未登陆卡
|
|
625
|
+
else resolve(false)
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
})
|
|
629
|
+
},
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* @description 获取业务插件风格配置
|
|
634
|
+
* @param appid {String} 业务插件所在插件应用id
|
|
635
|
+
*/
|
|
636
|
+
getStyles(appid) {
|
|
637
|
+
function getGradient(data){
|
|
638
|
+
try{
|
|
639
|
+
let {list,deg} = JSON.parse(data);
|
|
640
|
+
if (list.length === 0) return '';
|
|
641
|
+
if (list.length === 1) return list[0].color;
|
|
642
|
+
let color = list.map(item => {
|
|
643
|
+
return `${item.color} ${item.percentage}%`;
|
|
644
|
+
});
|
|
645
|
+
return `linear-gradient(${deg}deg,${color.join(',')})`;
|
|
646
|
+
}
|
|
647
|
+
catch (e) {
|
|
648
|
+
return ''
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
let theme = {};
|
|
653
|
+
(this.themesList[appid] || this.$webSetting.defaultTheme).map(item => {
|
|
654
|
+
if(item['key'] === '$mainGradient' || item['key'] === '$subGradient' ) {
|
|
655
|
+
theme[item['key']] = getGradient(item.value)
|
|
656
|
+
}else{
|
|
657
|
+
theme[item['key']] = item.value;
|
|
658
|
+
}
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
//设置默认值
|
|
662
|
+
if (!theme['$mainGradient']) theme['$mainGradient'] = theme['$mainColor'];
|
|
663
|
+
if (!theme['$subGradient']) theme['$subGradient'] = theme['$subMainColor'] || theme['$mainColor'];
|
|
664
|
+
|
|
665
|
+
return theme;
|
|
666
|
+
},
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* @description
|
|
670
|
+
* @param page {Object} 页面对象
|
|
671
|
+
*/
|
|
672
|
+
setPageConfig(page = {}) {
|
|
673
|
+
const handle = (data, key) => {
|
|
674
|
+
if (this.$xdUniHelper.isEmpty(data)) return null;
|
|
675
|
+
let temp = {};
|
|
676
|
+
data.map(item => {
|
|
677
|
+
temp[item['key']] = item['value'];
|
|
678
|
+
});
|
|
679
|
+
|
|
680
|
+
if (temp[key] !== undefined) return temp[key];
|
|
681
|
+
else return null;
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
let pageTemp = {};
|
|
685
|
+
const configs = page['configs'];
|
|
686
|
+
let parameters = {};
|
|
687
|
+
if (configs['parameters']) parameters = configs['parameters'];
|
|
688
|
+
|
|
689
|
+
//页面名称
|
|
690
|
+
if (page['title']) pageTemp['title'] = page['title'];
|
|
691
|
+
|
|
692
|
+
//是否显示返回按钮
|
|
693
|
+
if (handle(parameters, "is_back") !== null) pageTemp['showBack'] = handle(parameters, "is_back");
|
|
694
|
+
|
|
695
|
+
//背景是否仅仅顶部导航显示
|
|
696
|
+
if (handle(parameters, "is_use_bar_show_bg") !== null) pageTemp['isUseBgImage'] = !handle(parameters, "is_use_bar_show_bg");
|
|
697
|
+
|
|
698
|
+
//是否显示顶部导航
|
|
699
|
+
if (handle(parameters, "is_bar") !== null) pageTemp['showBar'] = handle(parameters, "is_bar");
|
|
700
|
+
|
|
701
|
+
//背景图片
|
|
702
|
+
if (configs['background_image']) {
|
|
703
|
+
pageTemp['backgroundImage'] = getServiceUrl(configs['background_image']);
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
//背景颜色
|
|
707
|
+
if (configs['background_color']) pageTemp['background'] = configs['background_color'];
|
|
708
|
+
|
|
709
|
+
//非自定义模式直接隐藏自定义topBar
|
|
710
|
+
if (this.pagePackConfig.navigationStyle === 'default') {
|
|
711
|
+
pageTemp['showBar'] = false
|
|
712
|
+
}
|
|
713
|
+
this.pageAttr = Object.assign({}, this.$xdUniHelper.cloneDeep(this.pageAttr), page, pageTemp);
|
|
714
|
+
|
|
715
|
+
//设置自定义导航导航背景色
|
|
716
|
+
if(this.pageAttr['is_bar_custom'] === 'custom') {
|
|
717
|
+
let templateBgcGradient = '', pageBgcGradient='';
|
|
718
|
+
|
|
719
|
+
//#ifdef H5
|
|
720
|
+
if (this.$configProject.extras['bgc_gradient']) {
|
|
721
|
+
templateBgcGradient = this.$configProject.extras['bgc_gradient']
|
|
722
|
+
}
|
|
723
|
+
if (this.pageAttr['is_bar_bgc_gradient']) {
|
|
724
|
+
pageBgcGradient = this.pageAttr['is_bar_bgc_gradient']
|
|
725
|
+
}
|
|
726
|
+
//#endif
|
|
727
|
+
this.pageAttr['barBackground'] = templateBgcGradient || pageBgcGradient
|
|
728
|
+
|| this.pageAttr.is_bar_bgc || this.$configProject.extras.top_bar_color
|
|
729
|
+
|| '#f8f8f8';
|
|
730
|
+
this.pageAttr['barColor'] = this.pageAttr['is_bar_custom_tc'] || this.$configProject.extras['top_bar_text_color'] || 'black';
|
|
731
|
+
}
|
|
732
|
+
this.pageAttr['navigationStyleIsCustom'] = this.pageAttr['is_bar_custom'] === 'custom';
|
|
733
|
+
},
|
|
734
|
+
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
|