gxd-uni-library-editx 1.0.77 → 1.0.79
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
|
@@ -101,7 +101,6 @@ export default {
|
|
|
101
101
|
return card
|
|
102
102
|
});
|
|
103
103
|
this.cardList = (this.cardList||[]).concat(arr);
|
|
104
|
-
this.cardPageNum++;
|
|
105
104
|
this.$xdHideLoading();
|
|
106
105
|
}).exec();
|
|
107
106
|
})
|
|
@@ -118,7 +117,8 @@ export default {
|
|
|
118
117
|
});
|
|
119
118
|
|
|
120
119
|
this.cardOrgList = this.$xdUniHelper.cloneDeep(validCardList);
|
|
121
|
-
|
|
120
|
+
console.warn(`cardOrgList:${this.cardOrgList.length}`)
|
|
121
|
+
this.cardComputedList = this.$xdUniHelper.cloneDeep(this.cardOrgList).slice(this.cardPageNum,this.cardPageLen);
|
|
122
122
|
if(this.cardComputedList.length < this.cardPageLen) {
|
|
123
123
|
this.hasContent = false;
|
|
124
124
|
}
|
|
@@ -143,7 +143,7 @@ export default {
|
|
|
143
143
|
setTimeout(()=>{
|
|
144
144
|
this.cardLoading = false;
|
|
145
145
|
this.$xdHideLoading();
|
|
146
|
-
this.cardComputedList = this.cardOrgList.slice(
|
|
146
|
+
this.cardComputedList = this.$xdUniHelper.cloneDeep(this.cardOrgList).slice(
|
|
147
147
|
this.cardPageNum*this.cardPageLen,
|
|
148
148
|
this.cardPageNum*this.cardPageLen + this.cardPageLen
|
|
149
149
|
);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
import helper from "@/utils/helper";
|
|
3
|
+
import {getJfbConfig,getColorBaseUrl} from "@/lib/conf.domain";
|
|
4
|
+
|
|
5
|
+
class XdNetwork {
|
|
6
|
+
constructor(){
|
|
7
|
+
this.eventObj = {
|
|
8
|
+
online: [],
|
|
9
|
+
offline: [],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//网络定义
|
|
13
|
+
this.status = {
|
|
14
|
+
strong: '',//0-230ms
|
|
15
|
+
normal: '',//230-750ms
|
|
16
|
+
low: '' //750-1400ms
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.init();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
addEvent(eventName, cb){
|
|
23
|
+
this.eventObj[eventName].push(cb);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
$mount(type){
|
|
28
|
+
let eventsFn = this.eventObj[type];
|
|
29
|
+
eventsFn.map(item=>{
|
|
30
|
+
item();
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleH5(){
|
|
35
|
+
let timer = null;
|
|
36
|
+
const handleOffline = () => {
|
|
37
|
+
if (timer) {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
timer = null;
|
|
40
|
+
}
|
|
41
|
+
timer = setTimeout(() => {
|
|
42
|
+
this.$mount('offline');
|
|
43
|
+
}, 100)
|
|
44
|
+
};
|
|
45
|
+
const handleOnline = () => {
|
|
46
|
+
if (timer) {
|
|
47
|
+
clearTimeout(timer);
|
|
48
|
+
timer = null;
|
|
49
|
+
}
|
|
50
|
+
timer = setTimeout(() => {
|
|
51
|
+
this.$mount('online');
|
|
52
|
+
}, 100)
|
|
53
|
+
};
|
|
54
|
+
if (window.addEventListener) {
|
|
55
|
+
window.addEventListener("offline", function () {
|
|
56
|
+
handleOffline();
|
|
57
|
+
}, true);
|
|
58
|
+
window.addEventListener("online", function () {
|
|
59
|
+
handleOnline();
|
|
60
|
+
}, true);
|
|
61
|
+
}
|
|
62
|
+
else if (window['attachEvent']) {
|
|
63
|
+
window['attachEvent']("onoffline", function () {
|
|
64
|
+
handleOffline();
|
|
65
|
+
});
|
|
66
|
+
window['attachEvent']("online", function () {
|
|
67
|
+
handleOnline();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
window.onoffline = function () {
|
|
72
|
+
handleOffline();
|
|
73
|
+
};
|
|
74
|
+
window.ononline = function () {
|
|
75
|
+
handleOnline();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
init(){
|
|
81
|
+
//#ifdef H5
|
|
82
|
+
this.handleH5();
|
|
83
|
+
// #endif
|
|
84
|
+
//#ifndef H5
|
|
85
|
+
uni.onNetworkStatusChange(({isConnected, networkType})=>{
|
|
86
|
+
uni.getNetworkType({
|
|
87
|
+
success: function (res) {
|
|
88
|
+
console.log('onNetworkStatusChange', isConnected, res.networkType)
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
// #endif
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
handleImage(image){
|
|
96
|
+
let time = new Date().getTime();
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
uni.getImageInfo({
|
|
99
|
+
src: `${image.path}?v=${time}`,
|
|
100
|
+
success:(res)=>{
|
|
101
|
+
let end = (new Date().getTime() - time)/1000;
|
|
102
|
+
resolve(helper.divisionFloatNumber(image.size, end));
|
|
103
|
+
},
|
|
104
|
+
fail:()=>{
|
|
105
|
+
reject(0)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
getNetworkEnv(paths=[]){
|
|
112
|
+
if(paths.length === 0) {
|
|
113
|
+
paths = [
|
|
114
|
+
{path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/10x10.png`, size:0.94},
|
|
115
|
+
{path: `${getColorBaseUrl(getJfbConfig('apiBasePath'))}/common/100x100.png`, size: 1.078},
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
let promiseArr= [];
|
|
119
|
+
paths.map(path=>{
|
|
120
|
+
promiseArr.push(this.handleImage(path));
|
|
121
|
+
});
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
Promise.all(promiseArr)
|
|
124
|
+
.then(res=>{
|
|
125
|
+
console.log(res)
|
|
126
|
+
resolve((res[0] + res[1])/2);
|
|
127
|
+
})
|
|
128
|
+
.catch()
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export default function () {
|
|
134
|
+
return new XdNetwork();
|
|
135
|
+
};
|