jufubao-base 1.0.237 → 1.0.238-beta67

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.
@@ -261,22 +261,12 @@
261
261
  return this.getNoData();
262
262
  },
263
263
  menuBoxStyle(){
264
- let padding = `${this.checkValue(this.menuPadding.top, 20)}rpx`;
265
- padding = `${padding} ${this.checkValue(this.menuPadding.right, 20)}rpx`;
266
- padding = `${padding} ${this.checkValue(this.menuPadding.bottom, 20)}rpx`;
267
- padding = `${padding} ${this.checkValue(this.menuPadding.left, 20)}rpx`;
268
-
269
264
  return this.styleObjectToString({
270
- // background: this.formBgColor,
271
- padding: padding,
265
+ padding: this.getMarginAndPadding(this.menuPadding,20),
272
266
  })
273
267
  },
274
268
  menuItemBoxPadding(){
275
- let padding = `${this.checkValue(this.menuBtnPadding.top, 20)}rpx`;
276
- padding = `${padding} ${this.checkValue(this.menuBtnPadding.right, 20)}rpx`;
277
- padding = `${padding} ${this.checkValue(this.menuBtnPadding.bottom, 20)}rpx`;
278
- padding = `${padding} ${this.checkValue(this.menuBtnPadding.left, 20)}rpx`;
279
- return padding;
269
+ return this.getMarginAndPadding(this.menuBtnPadding, 20)
280
270
  },
281
271
  menuItemStyle(){
282
272
  let styleObj = {
@@ -308,11 +298,7 @@
308
298
  return this.styleObjectToString(styleActiveObj)
309
299
  },
310
300
  bindCardBtnPadding(){
311
- let padding = `${this.checkValue(this.cardBtnPadding.top, 20)}rpx`;
312
- padding = `${padding} ${this.checkValue(this.cardBtnPadding.right, 20)}rpx`;
313
- padding = `${padding} ${this.checkValue(this.cardBtnPadding.bottom, 20)}rpx`;
314
- padding = `${padding} ${this.checkValue(this.cardBtnPadding.left, 20)}rpx`;
315
- return padding;
301
+ return this.getMarginAndPadding(this.cardBtnPadding,20)
316
302
  },
317
303
  bindCardBtnOther(){
318
304
  return {
@@ -325,7 +311,7 @@
325
311
  },
326
312
  bindCardBtnStyle(){
327
313
  let styleObj = {
328
- color: this.cardBtnTextStyle['color'] || '#333',
314
+ color: this.cardBtnTextStyle['color'] || '#fff',
329
315
  background: this.cardBtnTextStyle['bgColor'] || '#fff',
330
316
  fontSize: this.cardBtnTextStyle['fontSize'] || '30rpx',
331
317
  fontWeight: this.cardBtnTextStyle['fontWeight'] || 'normal',
@@ -334,7 +320,7 @@
334
320
  return this.styleObjectToString(styleObj)
335
321
  },
336
322
  bindCardActiveStyle(){
337
- let defaultTextColor = '#ff5a39';
323
+ let defaultTextColor = '#333';
338
324
  let styleActiveObj = {
339
325
  color: this.cardBtnTextStyle['actColor'] || defaultTextColor,
340
326
  background: this.cardBtnTextStyle['actBgColor'] || '#fff',
@@ -345,11 +331,7 @@
345
331
  return this.styleObjectToString(styleActiveObj)
346
332
  },
347
333
  couponBtnPadding(){
348
- let padding = `${this.checkValue(this.couponUseBtnPadding.top, 20)}rpx`;
349
- padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.right, 20)}rpx`;
350
- padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.bottom, 20)}rpx`;
351
- padding = `${padding} ${this.checkValue(this.couponUseBtnPadding.left, 20)}rpx`;
352
- return padding;
334
+ return this.getMarginAndPadding(this.couponUseBtnPadding,20);
353
335
  },
354
336
  couponBtnStyle(){
355
337
  let styleObj = {
@@ -405,13 +387,9 @@
405
387
  }
406
388
  if(this.cardImageMode) image['backgroundSize'] = this.cardImageMode;
407
389
 
408
- let padding = `${this.checkValue(this.cardPadding.top, 20)}rpx`;
409
- padding = `${padding} ${this.checkValue(this.cardPadding.right, 20)}rpx`;
410
- padding = `${padding} ${this.checkValue(this.cardPadding.bottom, 20)}rpx`;
411
- padding = `${padding} ${this.checkValue(this.cardPadding.left, 20)}rpx`;
412
390
  return this.styleObjectToString({
413
391
  ...image,
414
- padding: padding,
392
+ padding: this.getMarginAndPadding(this.cardPadding, 20),
415
393
  borderRadius: this.cardRadius + 'rpx',
416
394
  border: border,
417
395
  boxShadow: boxShadow,
@@ -420,13 +398,8 @@
420
398
  })
421
399
  },
422
400
  listBoxStyle(){
423
- let padding = `${this.checkValue(this.cardListPadding.top, 20)}rpx`;
424
- padding = `${padding} ${this.checkValue(this.cardListPadding.right, 20)}rpx`;
425
- padding = `${padding} ${this.checkValue(this.cardListPadding.bottom, 20)}rpx`;
426
- padding = `${padding} ${this.checkValue(this.cardListPadding.left, 20)}rpx`;
427
-
428
401
  return this.styleObjectToString({
429
- padding: padding,
402
+ padding: this.getMarginAndPadding(this.cardListPadding, 20),
430
403
  })
431
404
  },
432
405
  getCouponBgImage(){
@@ -455,22 +428,13 @@
455
428
  })
456
429
  },
457
430
  noticeWrapBoxStyle(){
458
- let padding = `${this.checkValue(this.noticeMargin.top, 20)}rpx`;
459
- padding = `${padding} ${this.checkValue(this.noticeMargin.right, 20)}rpx`;
460
- padding = `${padding} ${this.checkValue(this.noticeMargin.bottom, 20)}rpx`;
461
- padding = `${padding} ${this.checkValue(this.noticeMargin.left, 20)}rpx`;
462
-
463
431
  return this.styleObjectToString({
464
- padding: padding,
432
+ padding: this.getMarginAndPadding(this.noticeMargin, 20),
465
433
  })
466
434
  },
467
435
  noticeBoxStyle(){
468
- let padding = `${this.checkValue(this.noticePadding.top, 20)}rpx`;
469
- padding = `${padding} ${this.checkValue(this.noticePadding.right, 20)}rpx`;
470
- padding = `${padding} ${this.checkValue(this.noticePadding.bottom, 20)}rpx`;
471
- padding = `${padding} ${this.checkValue(this.noticePadding.left, 20)}rpx`;
472
436
  return this.styleObjectToString({
473
- padding: padding,
437
+ padding: this.getMarginAndPadding(this.noticePadding, 20),
474
438
  background: this.noticeBgColor
475
439
  })
476
440
  },
@@ -608,7 +572,7 @@
608
572
  }
609
573
  if(this.cardBtnTextStyle){
610
574
  if(!this.cardBtnTextStyle.actBgColor){
611
- this.cardBtnTextStyle.actBgColor = this.mainColor;
575
+ this.cardBtnTextStyle.actBgColor = this.infoColor;
612
576
  }
613
577
  if(!this.cardBtnTextStyle.bgColor){
614
578
  this.cardBtnTextStyle.bgColor = this.mainColor;
@@ -0,0 +1,187 @@
1
+ 'use strict';
2
+ import {mapMutations, mapState} from "vuex";
3
+
4
+ export default {
5
+ data() {
6
+ return {
7
+ ajaxCardList: null, //接口返回原始数据
8
+
9
+ //卡券列表
10
+ cardOrgList:[], //原始数据
11
+ cardList:null, //计算后的卡列表
12
+ cardPageNum: 0, //当前页面
13
+ cardPageLen: 10, //每页获取数据调试
14
+ cardComputedList:[], //当前获取的数据列表
15
+ cardLoading: false, //加载状态值设置
16
+ cardNextTop: 0, //计算到每一个节点的距离顶部Top值
17
+ contentStatus: false, //内容框是否已经进行过计算距离顶部Top值状态
18
+ hasContent: true, //是否可以进行继续加载状态
19
+ cardIndex: 0,
20
+
21
+ //转换按钮
22
+ hasChangeStatus: false,//是否有转换按钮
23
+
24
+ cardItemEntry: '//img.jufubao.cn/component/card/card_item_entry.png?v1=11',
25
+ cardItem: '//img.jufubao.cn/component/card/card_item.png?v1=11',
26
+
27
+ showStatus:false,
28
+
29
+ }
30
+ },
31
+ computed:{
32
+ ...mapState(['srollPreview'])
33
+ },
34
+ created(){
35
+ this.setSrollPreview({
36
+ pageWindowPrevStart: 0,
37
+ pageWindowPrevEnd: uni.getSystemInfoSync().safeArea.height,
38
+ });
39
+ this.showStatus = true;
40
+ },
41
+
42
+
43
+ methods:{
44
+ ...mapMutations(['setSrollPreview']),
45
+
46
+ onJfbHide(){
47
+ this.showStatus = false;
48
+ },
49
+
50
+ onJfbShow(options){
51
+ this.showStatus = true;
52
+ this.clearDefault();
53
+ this.onJfbLoad(options);
54
+ },
55
+
56
+ setCardItemShow({height , top},index){
57
+
58
+ //预览模式只获取10条
59
+ if(this.$configProject.isPreview) {
60
+ //console.log(this.cardPageLen, index, this.cardPageLen > index)
61
+ return this.cardPageLen > index;
62
+ }
63
+
64
+ //打包模式
65
+ let fiexd = 50;
66
+ let boxTop = top + height + fiexd;
67
+ let boxBottom = top - (fiexd);
68
+ let {pageWindowPrevStart, pageWindowPrevEnd} = this.srollPreview;
69
+
70
+ //console.log(height,top,pageWindowPrevStart,pageWindowPrevEnd)
71
+ return boxTop > pageWindowPrevStart && boxBottom < pageWindowPrevEnd;
72
+ },
73
+
74
+ getBoxTop(){
75
+ return new Promise((resolve, reject)=>{
76
+ const query = uni.createSelectorQuery().in(this);
77
+ query.select('.card-content').boundingClientRect(data=>{
78
+ this.cardNextTop = data.top;
79
+ this.contentStatus = true;
80
+ resolve();
81
+ }).exec()
82
+ })
83
+
84
+ },
85
+
86
+ async handleCardComputed(paddingBottom=30){
87
+ this.$xdShowLoading({});
88
+ if(this.contentStatus === false) await this.getBoxTop();
89
+ this.$nextTick(()=>{
90
+ const query = uni.createSelectorQuery().in(this);
91
+ query.selectAll('.computed-box').boundingClientRect(data => {
92
+ let arr = data.map(item=>{
93
+ let card = this.cardComputedList.filter(it=>{
94
+ return item.dataset.card === it.card_number;
95
+ })[0];
96
+ card['height'] = item.height;
97
+ card['top'] = this.cardNextTop;
98
+ card['index'] = this.cardIndex;
99
+ this.cardNextTop = this.cardNextTop + card['height'] + (paddingBottom * this.$rpxNum);
100
+ this.cardIndex++;
101
+ return card
102
+ });
103
+ this.cardList = (this.cardList||[]).concat(arr);
104
+ this.$xdHideLoading();
105
+ }).exec();
106
+ })
107
+ },
108
+
109
+ handleCardInit(cardList,type,paddingBottom =30){
110
+ let newCardList = this.$xdUniHelper.cloneDeep(cardList);
111
+ let validCardList = this.getCardGroupItem(newCardList.list.filter((item) => {
112
+ // 判断type是否为'is_valid'
113
+ if (type === 'is_valid') {
114
+ // 如果是,则返回item.is_transfering是否不等于'Y'
115
+ return item[type] === 'Y' && item.is_transfering !== 'Y';
116
+ } else if(type === 'is_exchange') {
117
+ // 如果是,则返回item.is_transfering是否不等于'Y'
118
+ return item[type] === 'Y' && item.is_transfering !== 'Y';
119
+ } else {
120
+ // 否则,返回item[type]是否等于'Y'
121
+ return item[type] === 'Y';
122
+ }
123
+ }), newCardList['site_entry_settings']).map((item,index)=>{
124
+ item['index'] = index;
125
+ return item
126
+ });
127
+ console.log(validCardList,'validCardListvalidCardList');
128
+
129
+
130
+ this.cardOrgList = this.$xdUniHelper.cloneDeep(validCardList);
131
+ console.warn(`cardOrgList:${this.cardOrgList.length}`)
132
+ this.cardComputedList = this.$xdUniHelper.cloneDeep(this.cardOrgList).slice(this.cardPageNum,this.cardPageLen);
133
+ if(this.cardComputedList.length < this.cardPageLen) {
134
+ this.hasContent = false;
135
+ }
136
+ this.handleCardComputed(paddingBottom).then().catch();
137
+ },
138
+
139
+ onJfbScroll({e}){
140
+ if(this.showStatus) {
141
+ this.setSrollPreview({
142
+ pageWindowPrevStart: e.scrollTop,
143
+ pageWindowPrevEnd:e.scrollTop + uni.getSystemInfoSync().safeArea.height
144
+ })
145
+ }
146
+ },
147
+
148
+ onJfbReachBottom(){
149
+ //加载在不处理,无下一页不处理,当前也为0不处理
150
+ if(this.cardLoading || !this.hasContent || this.cardPageNum === 0) return;
151
+ this.cardLoading = true;
152
+ this.$xdShowLoading({});
153
+ this.$nextTick(()=>{
154
+ setTimeout(()=>{
155
+ this.cardLoading = false;
156
+ this.$xdHideLoading();
157
+ this.cardComputedList = this.$xdUniHelper.cloneDeep(this.cardOrgList).slice(
158
+ this.cardPageNum*this.cardPageLen,
159
+ this.cardPageNum*this.cardPageLen + this.cardPageLen
160
+ );
161
+ this.handleCardComputed().then().catch();
162
+ if(this.cardComputedList.length < this.cardPageLen) {
163
+ this.hasContent = false;
164
+ }
165
+ this.cardPageNum++;
166
+ },500)
167
+ })
168
+
169
+ },
170
+
171
+ clearDefault(){
172
+ this.cardOrgList = [];
173
+ this.cardList = null;
174
+ this.cardPageNum = 0;
175
+ this.cardComputedList = [];
176
+ this.cardLoading = false;
177
+ this.cardNextTop = 0;
178
+ this.contentStatus = false;
179
+ this.hasContent = true;
180
+ this.cardIndex = 0;
181
+ this.ajaxCardList = null;
182
+ //this.hasChangeStatus = false;
183
+ }
184
+ }
185
+ }
186
+
187
+
@@ -40,7 +40,7 @@ export default {
40
40
  let support = [];
41
41
  codes.map(bus => {
42
42
  allEntry.map(it => {
43
- it['image_url'] = getServiceUrl(it['image_url'])
43
+ it['image_url'] = getServiceUrl(it['image_url'],'size2')
44
44
  if (bus === it['business_code']) {
45
45
  support.push(it);
46
46
  }
@@ -117,6 +117,74 @@ export default {
117
117
  },
118
118
  getNoData(){
119
119
  return this.colorObj.nodata
120
- }
120
+ },
121
+ /**
122
+ * @description 单业务自动跳转功能
123
+ * @param entry {Array} 业务链接信息
124
+ */
125
+ handleOneBussClick(entry){
126
+ debugger
127
+ if (this.$configProject['isPreview']) return;
128
+
129
+ //登陆成功,有回调地址返回回调地址
130
+ if(this.inCallbackUrlOrg) {
131
+ this.$xdUniHelper.redirectTo({
132
+ url:this.inCallback
133
+ }, false);
134
+ return;
135
+ }
136
+
137
+ const {dir, path, host, appType} = entry['redirect_data'];
138
+ let regHttp = /^(\/\/|http:\/\/|https:\/\/).+$/;
139
+ let regSp = /(-apiuri\/v)/;
140
+
141
+ if(!appType) entry.redirect_data.appType = 'h5';
142
+ let nsp = Base64.encodeURI(JSON.stringify({business_code: entry['business_code']}));
143
+
144
+ //外站配置地址
145
+ if(entry.redirect_type === 'URL') {
146
+ if(regHttp.test(entry.redirect_data['path']) || regSp.test(entry.redirect_data['path'])) {
147
+ let urlPath = entry.redirect_data['path'];
148
+ if(urlPath.indexOf('?') === -1) urlPath = `${urlPath}?x-common=${nsp}&vs=${new Date().getTime()}`;
149
+ else urlPath = `${urlPath}&x-common=${nsp}&vs=${new Date().getTime()}`;
150
+ this.$xdUniHelper.redirectTo({
151
+ url:urlPath
152
+ }, false)
153
+ }
154
+ else {
155
+ console.error(`配置错误:${entry.redirect_data['path']}`);
156
+ throw new Error(`配置错误:${entry.redirect_data['path']}`)
157
+ }
158
+ return
159
+ }
160
+
161
+ //站内应用处理
162
+ let jumpUrl = path;
163
+ let cardPathStr = '';
164
+ const {deploy_dir} = this.projectAttr;
165
+ if(host === this.projectAttr.host && deploy_dir !== dir){
166
+ jumpUrl = `//${host}/${dir}${path}`;
167
+ //#ifdef MP-WEIXIN
168
+ jumpUrl = `https:${jumpUrl}`;
169
+ //#endif
170
+ }
171
+
172
+ //#ifdef MP-WEIXIN
173
+ //获取自定义卡券登录地址(微信小程序跳转到H5平台起作用)
174
+ if(entry.redirect_data.appType === 'h5') {
175
+ const custom_redirect_data = this.$xdUniHelper.checkVarType(entry['custom_redirect_data']) === 'object'?entry['custom_redirect_data']:{};
176
+ const cardPathObject = this.getCardPath(custom_redirect_data);
177
+ if(cardPathObject !== null) {
178
+ const {cardPath, cardSelf} =cardPathObject
179
+ if(cardPath) cardPathStr = `&card-login=${encodeURIComponent(cardPath)}&cardSelf=${cardSelf}`
180
+ }
181
+ }
182
+ //#endif
183
+
184
+ jumpUrl = `${jumpUrl}?x-common=${nsp}&vs=${new Date().getTime()}${cardPathStr}`;
185
+ console.warn(`entry.path:${jumpUrl}`);
186
+ if(regHttp.test(jumpUrl)) this.$xdUniHelper.redirectTo({url:jumpUrl}, false)
187
+ else this.$xdUniHelper.navigateTo({url:jumpUrl}, false)
188
+ },
121
189
  }
122
190
  }
@@ -5,6 +5,7 @@ import {mapActions,mapState, mapMutations} from "vuex";
5
5
  import helper from "@/utils/helper";
6
6
  import store from "@/store/index";
7
7
  import getServiceUrl from "@/common/getServiceUrl"
8
+ import {parsePath} from "@/utils/linkUrl";
8
9
 
9
10
 
10
11
  export default {
@@ -735,6 +736,7 @@ export default {
735
736
  let showActivityPrice = getContainerPropsValue(container, "content.showActivityPrice", "N");
736
737
  let isShowTag = getContainerPropsValue(container, "content.isShowTag", "Y");
737
738
  let isAddCart = getContainerPropsValue(container, "content.isAddCart", "N");
739
+ let showFreeShipping = getContainerPropsValue(container, "content.showFreeShipping", "N");
738
740
  return {
739
741
  isShowDiscount: isShowDiscount,
740
742
  isPrice: isPrice,
@@ -743,6 +745,7 @@ export default {
743
745
  showActivityPrice:showActivityPrice,
744
746
  isShowTag : isShowTag,
745
747
  differ: differ,
748
+ showFreeShipping: showFreeShipping
746
749
  }
747
750
  },
748
751
 
@@ -907,30 +910,55 @@ export default {
907
910
  }
908
911
  },
909
912
 
910
- handleH5ToMP(app_id,url,params){
911
- debugger
913
+ getProductTagsParams(conf=null,data={}){
914
+ var temp = [];
915
+ let defaultValue = {
916
+ isShowTag:"market",
917
+ showActivityPrice:"flashsale",
918
+ showTag: "market",
919
+ }
920
+ try{
921
+ if(conf) {
922
+ conf = JSON.parse(conf).value;
923
+ conf={
924
+ ...defaultValue,
925
+ ...conf,
926
+ }
927
+ Object.keys(data).map(key=>{
928
+ if(data[key] === 'Y') {
929
+ temp.push(conf[key]);
930
+ }
931
+ })
932
+ }
933
+ else {
934
+ temp = [];
935
+ }
936
+ }catch(e){
937
+ temp = []
938
+ }
939
+ return temp
940
+ },
941
+ getProductTagsKeys(conf=null,container,type='productList'){
942
+ let defaultValue
943
+ if(type==='productList' ){
944
+ defaultValue = ["isShowTag","showActivityPrice"]
945
+ } else {
946
+ defaultValue = ["showTag","showActivityPrice"]
947
+ }
948
+ try{
949
+ if(conf) conf = JSON.parse(conf).keys;
950
+ else conf = []
951
+ }catch(e){
952
+ conf = []
953
+ }
954
+ conf = conf.concat(defaultValue)
955
+ let tagList = {}
956
+ conf.map(item=>{
957
+ tagList[item] = getContainerPropsValue(container, `content.${item}`, "N");
958
+ })
959
+ return tagList
912
960
  },
913
961
 
914
- handleMpToMP(app_id,url,params){
915
-
916
- },
917
- /**
918
- * @description 处理站点应用内部跳转微信小程序处理
919
- * @param code {string} 站点内部微信小程序aopen_app_code
920
- * @param type {string} h5|wxmp
921
- * @param url {string} 内部链接地址
922
- * @param params {string} 自定义参数 例如:id=1&cid=1234
923
- */
924
- codeForGetAppId(code, type, url,params){
925
- this.wxCodeForGetAppId({app_code: code})
926
- .then(app_id=>{
927
- if(type === 'h5') this.handleH5ToMP(app_id,url, params || '');
928
- if(type === 'wxmp') this.handleMpToMP( app_id, url, params || '')
929
- })
930
- .catch(err=>{
931
- console.error(err)
932
- })
933
- }
934
962
  }
935
963
  }
936
964
 
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+ import {mapActions, mapMutations} from 'vuex';
3
+ import storage from "@/common/storage";
4
+
5
+ export default {
6
+ data() {
7
+ return {
8
+ locationStatus: false,
9
+ currentLocationCity: 'jfb_current_ajax_location_city',
10
+ useSelectCity: 'xd_user_current_access_city',
11
+ timeoutLocationTime: null,
12
+ timeoutLocationStatus: false,
13
+ }
14
+ },
15
+
16
+ destroyed() {
17
+ if(this.timeoutLocationTime) {
18
+ clearTimeout(this.timeoutLocationTime)
19
+ this.timeoutLocationTime = null;
20
+ }
21
+ },
22
+
23
+ methods: {
24
+ ...mapActions(['getAllCityList']),
25
+ ...mapActions('wxAuthorize', [
26
+ 'getLoadingCityInfoByLocationLv4'
27
+ ]),
28
+ ...mapMutations(['setCityInfo']),
29
+
30
+ async getCityInfoByLocation(options, cb) {
31
+ try {
32
+ this.$xdLog.setProject('Layout.getCity.start.open.in', {
33
+ time: new Date().getTime(),
34
+ timeString: new Date().toLocaleString(),
35
+ ...options
36
+ });
37
+ let locationInfo = await this.getLoadingCityInfoByLocationLv4(options);
38
+ storage.set('console_Layout.getCity.done',locationInfo)
39
+ this.$xdLog.setProject('Layout.getCity.done', {
40
+ time: new Date().getTime(),
41
+ timeString: new Date().toLocaleString(),
42
+ ...locationInfo
43
+ });
44
+ cb(locationInfo);
45
+ } catch (e) {
46
+ storage.set('aaa_Layout.getCity.fail',1)
47
+ this.$xdLog.setProject('Layout.getCity.fail', {
48
+ time: new Date().getTime(),
49
+ timeString: new Date().toLocaleString(),
50
+ ...this.$settings.defaultCity
51
+ });
52
+ cb({data: this.$settings.defaultCity})
53
+ }
54
+ },
55
+
56
+ setDefaultCityData(defaultCity, local){
57
+ if(!defaultCity.isDefault){
58
+ storage.set(this.currentLocationCity, defaultCity, .5);
59
+ }
60
+ //用户首次定位成功设置系统自动给用户选中一个城市
61
+ if (!storage.get(this.useSelectCity)) {
62
+ this.setCityInfo(defaultCity)
63
+ }
64
+ },
65
+
66
+ timeoutLocation(location){
67
+ this.timeoutLocationTime = setTimeout(()=>{
68
+ this.setDefaultCityData(this.$settings.defaultCity);
69
+ this.$xdLog.setProject('Layout.getCity.timeout.5s', {
70
+ time: new Date().getTime(),
71
+ timeString: new Date().toLocaleString(),
72
+ ...this.$settings.defaultCity,
73
+ ...location
74
+ });
75
+ this.locationStatus = true;
76
+ this.timeoutLocationStatus = true;
77
+ }, 3000)
78
+ },
79
+
80
+ handleLocationDone(location) {
81
+ this.$xdLog.setProject('Layout.getCity.start', {
82
+ time: new Date().getTime(),
83
+ timeString: new Date().toLocaleString(),
84
+ statue:this.locationStatus,
85
+ ...location
86
+ });
87
+
88
+ //从缓存定位到的城市
89
+ if(storage.get(this.currentLocationCity)) {
90
+ this.locationStatus = true;
91
+ return;
92
+ }
93
+
94
+ //通过接口获取定位城市信息
95
+ this.$xdLog.setProject('Layout.getCity.start.send', {
96
+ time: new Date().getTime(),
97
+ timeString: new Date().toLocaleString(),
98
+ });
99
+
100
+ this.getCityInfoByLocation(location, (res)=>{
101
+ if (this.timeoutLocationStatus) return;
102
+ this.setDefaultCityData(res.data);
103
+ this.$xdLog.setProject('Layout.location.done', {
104
+ time: new Date().getTime(),
105
+ timeString: new Date().toLocaleString(),
106
+ });
107
+ if(this.timeoutLocationTime) {
108
+ clearTimeout(this.timeoutLocationTime);
109
+ this.timeoutLocationTime = null;
110
+ this.timeoutLocationStatus = false;
111
+ }
112
+
113
+ this.locationStatus = true;
114
+ });
115
+
116
+ this.timeoutLocation(location);
117
+ },
118
+ }
119
+ }