gxd-uni-library-editx 1.0.22 → 1.0.24
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/package.json
CHANGED
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
//微信参数
|
|
78
78
|
isWx: false,
|
|
79
79
|
time: 0,
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
location: {},
|
|
82
82
|
baiduCount: 0, //baidu API 加载次数
|
|
83
83
|
backed: false,
|
|
84
84
|
initBaidu: false,
|
|
85
85
|
uiBaiduAk: '',
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
failStatus: false,
|
|
88
88
|
timeStatus: null,
|
|
89
89
|
permanentSave: 'xd-user-permanent-location-config',
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
created() {
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
//#ifdef H5
|
|
97
97
|
//微信环境定位
|
|
98
98
|
if(isWechat()) {
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
this.init();
|
|
101
101
|
return
|
|
102
102
|
}
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
//百度定位
|
|
105
105
|
this.uiBaiduAk = this.baiduAk || this.$settings.baiduAk;
|
|
106
106
|
if(this.baidu){
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
this.init();
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
//默认
|
|
117
117
|
else{
|
|
118
118
|
this.init();
|
|
@@ -127,11 +127,11 @@
|
|
|
127
127
|
methods:{
|
|
128
128
|
...mapMutations(['setLocationInfo']),
|
|
129
129
|
...mapActions(['getH5WxAuthorize']),
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
getLocationData(){
|
|
132
132
|
return storage.get(this.locationStorageKey);
|
|
133
133
|
},
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
/**
|
|
136
136
|
* @description 火星转百度坐标
|
|
137
137
|
* @param lng
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
let PI = 3.1415926535897932384626;
|
|
144
144
|
let a = 6378245.0;
|
|
145
145
|
let ee = 0.00669342162296594323;
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
lat = +lat;
|
|
148
148
|
lng = +lng;
|
|
149
149
|
let z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
|
|
@@ -152,7 +152,7 @@
|
|
|
152
152
|
let bd_lat = z * Math.sin(theta) + 0.006;
|
|
153
153
|
return {longitude: bd_lng, latitude:bd_lat}
|
|
154
154
|
},
|
|
155
|
-
|
|
155
|
+
|
|
156
156
|
wxLocation(){
|
|
157
157
|
//被拒绝之后不在启动授权功能
|
|
158
158
|
if(storage.get(this.rejectSave) === true) {
|
|
@@ -164,12 +164,12 @@
|
|
|
164
164
|
this.handleBaiduInit(null);
|
|
165
165
|
return
|
|
166
166
|
}
|
|
167
|
-
|
|
167
|
+
|
|
168
168
|
//启动微信授权功能
|
|
169
169
|
this.getH5WxAuthorize({jsApiList: ['openLocation', 'getLocation']})
|
|
170
170
|
.then(({jwxSDK}) => {
|
|
171
171
|
this.$xdLog.setProject('Location.jwxSDK.init', 'Location.jwxSDK.init');
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
//pc端端微信环境直接返回
|
|
174
174
|
if(isPlatform().isPc ||
|
|
175
175
|
(jwxSDK && typeof jwxSDK.getLocation !== 'function')
|
|
@@ -181,7 +181,10 @@
|
|
|
181
181
|
this.handleBaiduInit(null);
|
|
182
182
|
return
|
|
183
183
|
}
|
|
184
|
-
|
|
184
|
+
|
|
185
|
+
let time = null;
|
|
186
|
+
let isReturn = false;
|
|
187
|
+
|
|
185
188
|
//手机端微信环境
|
|
186
189
|
jwxSDK.getLocation({
|
|
187
190
|
type: 'gcj02',
|
|
@@ -199,9 +202,23 @@
|
|
|
199
202
|
this.handleBaiduInit(this.location);
|
|
200
203
|
},
|
|
201
204
|
fail: (e) => {
|
|
205
|
+
|
|
206
|
+
//已超时返回
|
|
207
|
+
if(isReturn) {
|
|
208
|
+
time = null;
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
//比超时返回快
|
|
213
|
+
if(time) {
|
|
214
|
+
clearTimeout(time);
|
|
215
|
+
time=null;
|
|
216
|
+
}
|
|
217
|
+
|
|
202
218
|
this.$xdLog.setProject('Location.wx.api.fail', {
|
|
203
219
|
lng: null,
|
|
204
|
-
lat: null
|
|
220
|
+
lat: null,
|
|
221
|
+
error:e
|
|
205
222
|
});
|
|
206
223
|
this.handleBaiduInit(null)
|
|
207
224
|
},
|
|
@@ -214,6 +231,17 @@
|
|
|
214
231
|
this.handleBaiduInit(null)
|
|
215
232
|
}
|
|
216
233
|
});
|
|
234
|
+
|
|
235
|
+
//超时处理
|
|
236
|
+
time = setTimeout(()=>{
|
|
237
|
+
this.$xdLog.setProject('Location.wx.api.fail.timeout', {
|
|
238
|
+
lng: null,
|
|
239
|
+
lat: null,
|
|
240
|
+
error:'fail.timeout'
|
|
241
|
+
});
|
|
242
|
+
this.handleBaiduInit(null);
|
|
243
|
+
isReturn = true;
|
|
244
|
+
}, 5000)
|
|
217
245
|
})
|
|
218
246
|
.catch(res => {
|
|
219
247
|
this.$xdLog.setProject('Location.wx.jwxSDK.fail', {
|
|
@@ -223,7 +251,7 @@
|
|
|
223
251
|
this.handleBaiduInit(null)
|
|
224
252
|
});
|
|
225
253
|
},
|
|
226
|
-
|
|
254
|
+
|
|
227
255
|
/**
|
|
228
256
|
* @description 主要针对百度定位超时进行返回操作
|
|
229
257
|
*/
|
|
@@ -236,7 +264,7 @@
|
|
|
236
264
|
}, 10000)
|
|
237
265
|
}
|
|
238
266
|
},
|
|
239
|
-
|
|
267
|
+
|
|
240
268
|
init(){
|
|
241
269
|
if(this.getLocationData() !== null){
|
|
242
270
|
this.$xdLog.setProject('Location.cache', this.getLocationData());
|
|
@@ -252,7 +280,7 @@
|
|
|
252
280
|
}
|
|
253
281
|
return;
|
|
254
282
|
}
|
|
255
|
-
|
|
283
|
+
|
|
256
284
|
//百度定位
|
|
257
285
|
if(this.isWx === false) {
|
|
258
286
|
// 没有定位信息并且超时5秒
|
|
@@ -263,7 +291,7 @@
|
|
|
263
291
|
|
|
264
292
|
handleDone(){
|
|
265
293
|
this.setLocationInfo(this.location);
|
|
266
|
-
|
|
294
|
+
|
|
267
295
|
//超过5秒就不走这里的逻辑
|
|
268
296
|
if(this.failStatus === false) {
|
|
269
297
|
this.$xdLog.setProject('Location.done', this.location);
|
|
@@ -32,19 +32,17 @@
|
|
|
32
32
|
</view>
|
|
33
33
|
<view class="xd-dailog__body-btn" v-if="cancel || confirm">
|
|
34
34
|
<slot name="btn">
|
|
35
|
-
<view>
|
|
35
|
+
<view v-if="cancel">
|
|
36
36
|
<xd-button
|
|
37
|
-
v-if="cancel"
|
|
38
37
|
@click="handleConfirm('cancel')"
|
|
39
38
|
:type="cancelColorType"
|
|
40
39
|
size="medium"
|
|
41
40
|
:radius="btnRadius + 'rpx'"
|
|
42
41
|
>{{cancelText}}</xd-button>
|
|
43
42
|
</view>
|
|
44
|
-
<view>
|
|
43
|
+
<view v-if="confirm">
|
|
45
44
|
<xd-button
|
|
46
45
|
@click="handleConfirm('confirm')"
|
|
47
|
-
v-if="confirm"
|
|
48
46
|
:type="confirmColorType"
|
|
49
47
|
size="medium"
|
|
50
48
|
:radius="btnRadius + 'rpx'"
|
|
@@ -135,7 +133,7 @@
|
|
|
135
133
|
type: Number, //rpx
|
|
136
134
|
default: 10,
|
|
137
135
|
},
|
|
138
|
-
|
|
136
|
+
|
|
139
137
|
isAuto:{
|
|
140
138
|
type: Boolean,
|
|
141
139
|
default: false,
|
|
@@ -167,7 +165,7 @@
|
|
|
167
165
|
if(this.$configProject && this.$configProject.isPreview) {
|
|
168
166
|
this.isPreview = !this.isAuto && this.$configProject.isPreview
|
|
169
167
|
}
|
|
170
|
-
|
|
168
|
+
|
|
171
169
|
},
|
|
172
170
|
methods: {
|
|
173
171
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
:id="`tab-scroll__index-${index}`"
|
|
20
20
|
v-for="(item, index) in list"
|
|
21
21
|
:key="index"
|
|
22
|
-
:style="{color: activeIndex === index? styleMainColor: color}"
|
|
22
|
+
:style="{color: activeIndex === index? activeColor || styleMainColor: color}"
|
|
23
23
|
class="tab-scroll__item"
|
|
24
24
|
:class="{active:activeIndex === index}"
|
|
25
25
|
@click="clickTab(item, index)"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
<view
|
|
33
33
|
v-if="showFooterLine"
|
|
34
34
|
:style="{
|
|
35
|
-
background: activeIndex === index? styleMainColor: '',
|
|
35
|
+
background: activeIndex === index? activeColor || styleMainColor: '',
|
|
36
36
|
bottom: (lineBottom) + 'rpx'
|
|
37
37
|
}"
|
|
38
38
|
></view>
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
type: String,
|
|
104
104
|
default: '#333'
|
|
105
105
|
},
|
|
106
|
+
activeColor:{
|
|
107
|
+
type: String,
|
|
108
|
+
default: ''
|
|
109
|
+
},
|
|
106
110
|
bgColor: {
|
|
107
111
|
type: String,
|
|
108
112
|
default: '#fff'
|
|
@@ -143,7 +147,7 @@
|
|
|
143
147
|
async created() {
|
|
144
148
|
this.styleMainColor = await getParentsStyle(this.$parent, '$mainColor');
|
|
145
149
|
},
|
|
146
|
-
|
|
150
|
+
|
|
147
151
|
mounted(){
|
|
148
152
|
this.$nextTick(()=>{
|
|
149
153
|
this.toView = 'tab-scroll__index-0'
|
|
@@ -208,7 +212,7 @@
|
|
|
208
212
|
display: flex;
|
|
209
213
|
align-items: center;
|
|
210
214
|
align-content: center;
|
|
211
|
-
|
|
215
|
+
|
|
212
216
|
&.active {
|
|
213
217
|
color: @xd-base-color;
|
|
214
218
|
}
|
package/src/utils/xd.base.js
CHANGED
|
@@ -655,19 +655,23 @@ export function toProductDetail($vm, item, url, showCart = false) {
|
|
|
655
655
|
|
|
656
656
|
/**
|
|
657
657
|
* @description 获取图片信息
|
|
658
|
-
* @param src {
|
|
659
|
-
* @param height {
|
|
658
|
+
* @param src {string} 图片地址
|
|
659
|
+
* @param height {number} 默认高度
|
|
660
|
+
* @param margin {number} 像素
|
|
660
661
|
*/
|
|
661
|
-
export function getImageInfo(src, height = 100) {
|
|
662
|
+
export function getImageInfo(src, height = 100, margin = 0) {
|
|
662
663
|
return new Promise((resolve, reject) => {
|
|
663
664
|
uni.getImageInfo({
|
|
664
665
|
src,
|
|
665
666
|
complete:(image)=>{
|
|
666
|
-
console.log('getImageInfo', image)
|
|
667
667
|
if(image.errMsg === 'getImageInfo:ok') {
|
|
668
|
+
const system = uni.getSystemInfoSync()
|
|
669
|
+
const windowW = system.safeArea.width - Number(margin);
|
|
670
|
+
const windowH = Math.floor((image.height * windowW)/image.width);
|
|
671
|
+
console.log('getImageInfo', image,windowH)
|
|
668
672
|
resolve({
|
|
669
|
-
imgWidth:
|
|
670
|
-
imgHeight:
|
|
673
|
+
imgWidth: windowW,
|
|
674
|
+
imgHeight: windowH,
|
|
671
675
|
imgStatus: 'ok'
|
|
672
676
|
});
|
|
673
677
|
}
|