@10yun/cv-mobile-ui 0.5.58 → 0.5.60
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/libs/storage2.js +0 -10
- package/package.json +1 -1
- package/plugins/storage.js +200 -213
- package/plugins/uniMap.js +2 -2
- package/ui-cv/components/cv-geo-local/cv-geo-local.vue +35 -19
- package/ui-cv/components/cv-geo-region/cv-geo-region.vue +38 -14
- package/uview-plus/components/u-upload/file.js +1 -1
- package/uview-plus/components/u-upload/u-upload.vue +8 -1
- package/libs/storage3.js +0 -104
- package/other/tui-clipboard/tui-clipboard.js +0 -53
package/libs/storage2.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
/***
|
|
2
|
-
* title: storage.js
|
|
3
|
-
* Author: Gaby
|
|
4
|
-
* Email: xxx@126.com
|
|
5
|
-
* Time: 2022/6/1 17:30
|
|
6
|
-
* last: 2022/6/2 17:30
|
|
7
|
-
* Desc: 对存储的简单封装
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
import CryptoJS from 'crypto-js';
|
|
11
|
-
|
|
12
2
|
// 十六位十六进制数作为密钥
|
|
13
3
|
const SECRET_KEY = CryptoJS.enc.Utf8.parse('3333e6e143439161');
|
|
14
4
|
// 十六位十六进制数作为密钥偏移量
|
package/package.json
CHANGED
package/plugins/storage.js
CHANGED
|
@@ -1,279 +1,266 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* StorageClass
|
|
3
|
+
* ✔ local = 持久化缓存(内存 + storage)
|
|
4
|
+
* ✔ memory = 纯内存缓存
|
|
5
|
+
* ✔ 自动过期清理
|
|
6
|
+
* ✔ 内存加速(Map)
|
|
7
|
+
* ✔ 懒清理 + 启动清理
|
|
8
|
+
* ✔ 防止 KEYS_CACHE_FLAG 污染
|
|
4
9
|
*/
|
|
5
|
-
|
|
6
|
-
function get_data1(key, def) {
|
|
7
|
-
uni.getStorage({
|
|
8
|
-
key: key,
|
|
9
|
-
success: function (res) {
|
|
10
|
-
param.success(res.data || def);
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function get_data2(key, def) {
|
|
15
|
-
const value = uni.getStorageSync(key);
|
|
16
|
-
return value || def;
|
|
17
|
-
}
|
|
18
10
|
class StorageClass {
|
|
19
|
-
//实例化类时默认会执行构造函数
|
|
20
11
|
constructor(options = {}) {
|
|
21
12
|
this.config = Object.assign(
|
|
22
13
|
{
|
|
23
14
|
cache_keys: 'syCacheKeys',
|
|
15
|
+
expiration: 7 * 86400, // 60 * 60 * 24 * 7,// 默认7天
|
|
24
16
|
prefix: '',
|
|
25
17
|
suffix: ''
|
|
26
18
|
},
|
|
27
19
|
options
|
|
28
20
|
);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let fullCache = uni.getStorageSync(fullKey) || {};
|
|
39
|
-
fullCache[appendKey] = 1;
|
|
40
|
-
uni.setStorageSync(fullKey, fullCache);
|
|
21
|
+
|
|
22
|
+
this.KEYS_CACHE_FLAG = this.__getFullKeyName(this.config.cache_keys) || '___';
|
|
23
|
+
|
|
24
|
+
// 内存缓存层
|
|
25
|
+
this.cacheMap = new Map();
|
|
26
|
+
// 初始化加载持久化缓存
|
|
27
|
+
this.__initPersistentCache();
|
|
28
|
+
// 启动时先清一波
|
|
29
|
+
this.__autoExpiredTimeKey();
|
|
41
30
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
|
|
32
|
+
/* ================= 初始化 ================= */
|
|
33
|
+
|
|
34
|
+
__initPersistentCache() {
|
|
35
|
+
try {
|
|
36
|
+
const { keys } = uni.getStorageInfoSync();
|
|
37
|
+
keys.forEach((key) => {
|
|
38
|
+
// 过滤:只加载当前前缀 & 排除 key表
|
|
39
|
+
if (key.startsWith(this.config.prefix) && key !== this.KEYS_CACHE_FLAG) {
|
|
40
|
+
const val = uni.getStorageSync(key);
|
|
41
|
+
if (val !== '') {
|
|
42
|
+
this.cacheMap.set(key, val);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
/* ================= 基础 ================= */
|
|
49
|
+
|
|
50
|
+
// 获取带前缀后缀的真实key
|
|
51
|
+
__getFullKeyName(key) {
|
|
49
52
|
key = key || '';
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
if (config.suffix) {
|
|
55
|
-
key += config.suffix;
|
|
56
|
-
}
|
|
53
|
+
const { prefix, suffix } = this.config;
|
|
54
|
+
if (prefix) key = prefix + key;
|
|
55
|
+
if (suffix) key += suffix;
|
|
57
56
|
return key;
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
localDel(key) {
|
|
68
|
-
this.removeAsync(key);
|
|
69
|
-
this.removeSync(key);
|
|
70
|
-
}
|
|
71
|
-
updateKey(key) {
|
|
72
|
-
let allCacheKeys = this.getSync(this.KEYS_CACHE_FLAG) || {};
|
|
73
|
-
// 当前时间
|
|
74
|
-
let currTime = parseInt(new Date().getTime() / 1000);
|
|
75
|
-
allCacheKeys[key] = currTime + 60 * 60 * 24 * 7; // 7天
|
|
76
|
-
this.setSync(this.KEYS_CACHE_FLAG, allCacheKeys);
|
|
77
|
-
}
|
|
78
|
-
checkKey(key) {
|
|
79
|
-
// 所有缓存keys
|
|
80
|
-
let allCacheKeys = this.getSync(this.KEYS_CACHE_FLAG) || {};
|
|
81
|
-
// 缓存时间
|
|
82
|
-
let currCacheExpires = allCacheKeys[key] || 0;
|
|
83
|
-
if (currCacheExpires > 0) {
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
// 当前时间
|
|
87
|
-
let currTime = parseInt(new Date().getTime() / 1000);
|
|
88
|
-
// 当前缓存
|
|
89
|
-
let currCache = this.getSync(key) || null;
|
|
90
|
-
if (!currCache) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
console.log(currCache);
|
|
94
|
-
if (currCache.length == 0 || currTime > currCacheExpires) {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
58
|
+
// 判断key是否【未过期】
|
|
59
|
+
__getKeyTime(key) {
|
|
60
|
+
const allCacheKeys = uni.getStorageSync(this.KEYS_CACHE_FLAG) || {};
|
|
61
|
+
const deadTime = allCacheKeys[key] ? parseInt(allCacheKeys[key]) : 0;
|
|
62
|
+
if (deadTime === -1) return true; // 永久有效
|
|
63
|
+
const currTime = Math.floor(Date.now() / 1000); // 当前时间
|
|
64
|
+
return deadTime > currTime; // 未过期 = true
|
|
98
65
|
}
|
|
99
|
-
/**
|
|
100
|
-
* 设置缓存 - 异步
|
|
101
|
-
* @param {[type]} key [键名]
|
|
102
|
-
* @param {[type]} data [键值]
|
|
103
|
-
* @param {[type]} t [时间、单位秒]
|
|
104
|
-
* @使用方式 ==== 【设置缓存】
|
|
105
|
-
* string cache.put('k', 'string你好啊');
|
|
106
|
-
* json cache.put('k', { "b": "3" }, 2);
|
|
107
|
-
* array cache.put('k', [1, 2, 3]);
|
|
108
|
-
* boolean cache.put('k', true);
|
|
109
|
-
*/
|
|
110
66
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
uni.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
key: fullKey + '_time',
|
|
123
|
-
data: timestamp + t * 1000,
|
|
124
|
-
success: () => {}
|
|
125
|
-
});
|
|
67
|
+
// 更新key过期时间
|
|
68
|
+
__updateKeyTime(key, timeStamp = -1) {
|
|
69
|
+
const allCacheKeys = uni.getStorageSync(this.KEYS_CACHE_FLAG) || {};
|
|
70
|
+
const currTime = Math.floor(Date.now() / 1000); // 当前时间
|
|
71
|
+
const defaultExpire = Math.floor(this.config.expiration) || 7 * 86400;
|
|
72
|
+
if (timeStamp === -1) {
|
|
73
|
+
allCacheKeys[key] = -1; // 永久有效
|
|
74
|
+
} else if (timeStamp > 0) {
|
|
75
|
+
allCacheKeys[key] = currTime + Math.floor(timeStamp);
|
|
76
|
+
} else {
|
|
77
|
+
allCacheKeys[key] = currTime + defaultExpire; // 默认7天
|
|
126
78
|
}
|
|
127
|
-
this.
|
|
79
|
+
uni.setStorageSync(this.KEYS_CACHE_FLAG, allCacheKeys);
|
|
128
80
|
}
|
|
129
|
-
|
|
130
|
-
|
|
81
|
+
// 删除key的过期记录
|
|
82
|
+
__delKeyTime(key) {
|
|
83
|
+
const allCacheKeys = uni.getStorageSync(this.KEYS_CACHE_FLAG) || {};
|
|
84
|
+
delete allCacheKeys[key];
|
|
85
|
+
uni.setStorageSync(this.KEYS_CACHE_FLAG, allCacheKeys);
|
|
86
|
+
}
|
|
87
|
+
// 自动清理所有过期key(含内存)
|
|
88
|
+
__autoExpiredTimeKey() {
|
|
131
89
|
try {
|
|
132
|
-
uni.
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
90
|
+
const allCacheKeys = uni.getStorageSync(this.KEYS_CACHE_FLAG) || {};
|
|
91
|
+
const currTime = Math.floor(Date.now() / 1000);
|
|
92
|
+
let hasExpired = false;
|
|
93
|
+
|
|
94
|
+
// 遍历所有key,检查过期
|
|
95
|
+
for (const key in allCacheKeys) {
|
|
96
|
+
const deadTime = allCacheKeys[key];
|
|
97
|
+
if (deadTime === -1) continue; // 永久不过期
|
|
98
|
+
|
|
99
|
+
// 过期了
|
|
100
|
+
if (deadTime < currTime) {
|
|
101
|
+
const fullKey = this.__getFullKeyName(key);
|
|
102
|
+
uni.removeStorageSync(fullKey); // 删除缓存
|
|
103
|
+
this.cacheMap.delete(fullKey);
|
|
104
|
+
delete allCacheKeys[key]; // 删除过期记录
|
|
105
|
+
hasExpired = true;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 有过期才更新,避免无意义写入
|
|
110
|
+
if (hasExpired) {
|
|
111
|
+
uni.setStorageSync(this.KEYS_CACHE_FLAG, allCacheKeys);
|
|
137
112
|
}
|
|
138
|
-
this._setAllCache(fullKey);
|
|
139
113
|
} catch (e) {
|
|
140
|
-
console.error(e);
|
|
114
|
+
console.error('__autoExpiredTimeKey error:', e);
|
|
141
115
|
}
|
|
142
116
|
}
|
|
143
|
-
/**
|
|
144
|
-
* 获取缓存
|
|
145
|
-
* @param {[type]} key [键名]
|
|
146
|
-
* @param {[type]} def [获取为空时默认]
|
|
147
|
-
*
|
|
148
|
-
* @使用方式 ==== 【读取缓存】
|
|
149
|
-
* 默认值 cache.get('key')
|
|
150
|
-
* string cache.get('key', '你好')
|
|
151
|
-
* json cache.get('key', { "a": "1" })
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* 根据key获取数据缓存 - 异步
|
|
155
|
-
* @param {String} key
|
|
156
|
-
*/
|
|
157
|
-
getAsync(param) {
|
|
158
|
-
param = Object.assign({ def: '' }, param);
|
|
159
117
|
|
|
160
|
-
|
|
118
|
+
/* ================= 持久化缓存 ================= */
|
|
161
119
|
|
|
162
|
-
//先获取时间
|
|
163
|
-
var deadtime = 0;
|
|
164
|
-
uni.getStorage({
|
|
165
|
-
key: fullKey + '_time',
|
|
166
|
-
success: function (res) {
|
|
167
|
-
if (!res.data) {
|
|
168
|
-
get_data1(fullKey, param.success);
|
|
169
|
-
} else {
|
|
170
|
-
deadtime = parseInt(res.data);
|
|
171
|
-
let timestamp = parseInt(new Date().getTime());
|
|
172
|
-
if (deadtime > 0 && deadtime < timestamp) {
|
|
173
|
-
//过期了
|
|
174
|
-
param.success(def);
|
|
175
|
-
}
|
|
176
|
-
get_data1(fullKey, def);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
120
|
/**
|
|
182
|
-
*
|
|
183
|
-
* @param {String} key
|
|
121
|
+
* 获取缓存(内存优先,超快)
|
|
122
|
+
* @param {String} key 键名
|
|
123
|
+
* @param {String|Object|Array|Json|Boolean|Number} defValue 为空时默认值
|
|
124
|
+
* @使用方式 ==== 【读取缓存】
|
|
125
|
+
* 默认值 cache.localGet('key')
|
|
126
|
+
* string cache.localGet('key', '你好')
|
|
127
|
+
* json cache.localGet('key', { "a": "1" })
|
|
184
128
|
*/
|
|
185
|
-
|
|
186
|
-
let fullKey = this._getFullKey(key);
|
|
129
|
+
localGet(key, defValue = '') {
|
|
187
130
|
try {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let timestamp = parseInt(new Date().getTime());
|
|
194
|
-
if (deadtime > 0 && deadtime < timestamp) {
|
|
195
|
-
//过期了
|
|
196
|
-
return def;
|
|
197
|
-
}
|
|
198
|
-
return get_data2(fullKey, def);
|
|
131
|
+
this.__autoExpiredTimeKey();
|
|
132
|
+
const fullKey = this.__getFullKeyName(key);
|
|
133
|
+
// 先查内存优先
|
|
134
|
+
if (this.cacheMap.has(fullKey)) {
|
|
135
|
+
return this.cacheMap.get(fullKey);
|
|
199
136
|
}
|
|
137
|
+
// 过期判断
|
|
138
|
+
if (!this.__getKeyTime(key)) {
|
|
139
|
+
this.localDel(key);
|
|
140
|
+
return defValue;
|
|
141
|
+
}
|
|
142
|
+
// 查 storage
|
|
143
|
+
// JSON.parse(decodeURIComponent());
|
|
144
|
+
const data = uni.getStorageSync(fullKey);
|
|
145
|
+
// 回填内存
|
|
146
|
+
if (data !== '') {
|
|
147
|
+
this.cacheMap.set(fullKey, data);
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
return defValue;
|
|
200
151
|
} catch (e) {
|
|
201
|
-
console.error(e);
|
|
152
|
+
console.error('localGet error:', e);
|
|
153
|
+
return defValue;
|
|
202
154
|
}
|
|
203
155
|
}
|
|
204
156
|
/**
|
|
205
|
-
*
|
|
206
|
-
* @param
|
|
157
|
+
* 设置缓存(一定持久化)
|
|
158
|
+
* @param {String} key 键名
|
|
159
|
+
* @param {String|Object|Array|Json|Boolean|Number} value 键值
|
|
160
|
+
* @param {Number} timeStamp 时间(单位秒)
|
|
161
|
+
* @使用方式 ==== 【设置缓存】
|
|
162
|
+
* string cache.localSet('k', 'string你好啊');
|
|
163
|
+
* json cache.localSet('k', { "b": "3" }, 2);
|
|
164
|
+
* array cache.localSet('k', [1, 2, 3]);
|
|
165
|
+
* boolean cache.localSet('k', true);
|
|
207
166
|
*/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
fullKey = this.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
key: fullKey
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
this._removeAllCache(fullKey);
|
|
167
|
+
localSet(key, value = null, timeStamp = -1) {
|
|
168
|
+
try {
|
|
169
|
+
this.__autoExpiredTimeKey();
|
|
170
|
+
const fullKey = this.__getFullKeyName(key);
|
|
171
|
+
// encodeURIComponent(JSON.stringify())
|
|
172
|
+
// 写 storage
|
|
173
|
+
uni.setStorageSync(fullKey, value);
|
|
174
|
+
// 写入内存
|
|
175
|
+
this.cacheMap.set(fullKey, value);
|
|
221
176
|
|
|
222
|
-
|
|
223
|
-
key
|
|
224
|
-
|
|
225
|
-
|
|
177
|
+
// 设置过期
|
|
178
|
+
this.__updateKeyTime(key, timeStamp);
|
|
179
|
+
} catch (e) {
|
|
180
|
+
console.error('localSet error:', e);
|
|
181
|
+
}
|
|
226
182
|
}
|
|
227
183
|
/**
|
|
228
|
-
*
|
|
184
|
+
* 删除缓存
|
|
229
185
|
* @param {String} key
|
|
230
186
|
*/
|
|
231
|
-
|
|
232
|
-
let fullKey = this._getFullKey(key);
|
|
187
|
+
localDel(key) {
|
|
233
188
|
try {
|
|
189
|
+
this.__autoExpiredTimeKey();
|
|
190
|
+
const fullKey = this.__getFullKeyName(key);
|
|
234
191
|
uni.removeStorageSync(fullKey);
|
|
235
|
-
|
|
236
|
-
|
|
192
|
+
|
|
193
|
+
// 删除内存
|
|
194
|
+
this.cacheMap.delete(fullKey);
|
|
195
|
+
|
|
196
|
+
this.__delKeyTime(key);
|
|
237
197
|
} catch (e) {
|
|
238
|
-
console.error(e);
|
|
198
|
+
console.error('localDel error:', e);
|
|
239
199
|
}
|
|
240
200
|
}
|
|
241
201
|
/**
|
|
242
|
-
*
|
|
243
|
-
*/
|
|
244
|
-
clearAsync() {
|
|
245
|
-
uni.clearStorage();
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* 清除用户端所用缓存 - 同步
|
|
202
|
+
* 清空所有缓存
|
|
249
203
|
*/
|
|
250
|
-
|
|
204
|
+
localClear() {
|
|
251
205
|
try {
|
|
252
206
|
uni.clearStorageSync();
|
|
207
|
+
// 清空内存
|
|
208
|
+
this.cacheMap.clear();
|
|
253
209
|
} catch (e) {
|
|
254
|
-
console.error(e);
|
|
210
|
+
console.error('localClear error:', e);
|
|
255
211
|
}
|
|
256
212
|
}
|
|
257
213
|
/**
|
|
258
|
-
*
|
|
214
|
+
* 检查key是否有效(存在+未过期)
|
|
215
|
+
* @param {*} key
|
|
216
|
+
* @returns
|
|
259
217
|
*/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
218
|
+
localHas(key) {
|
|
219
|
+
this.__autoExpiredTimeKey();
|
|
220
|
+
if (!this.__getKeyTime(key)) return false;
|
|
221
|
+
const fullKey = this.__getFullKeyName(key);
|
|
222
|
+
|
|
223
|
+
if (this.cacheMap.has(fullKey)) return true;
|
|
224
|
+
return !!this.localGet(key);
|
|
266
225
|
}
|
|
267
226
|
/**
|
|
268
|
-
*
|
|
227
|
+
* 获取storage信息
|
|
269
228
|
*/
|
|
270
|
-
|
|
229
|
+
localInfo() {
|
|
271
230
|
try {
|
|
231
|
+
this.__autoExpiredTimeKey();
|
|
272
232
|
return uni.getStorageInfoSync();
|
|
273
233
|
} catch (e) {
|
|
274
|
-
console.
|
|
234
|
+
console.error('localInfo error:', e);
|
|
235
|
+
return null;
|
|
275
236
|
}
|
|
276
237
|
}
|
|
238
|
+
|
|
239
|
+
/* ================= 纯内存缓存 ================= */
|
|
240
|
+
|
|
241
|
+
memorySet(key, value) {
|
|
242
|
+
const fullKey = this.__getFullKeyName(key);
|
|
243
|
+
this.cacheMap.set(fullKey, value);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
memoryGet(key, defValue = '') {
|
|
247
|
+
const fullKey = this.__getFullKeyName(key);
|
|
248
|
+
return this.cacheMap.has(fullKey) ? this.cacheMap.get(fullKey) : defValue;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
memoryDel(key) {
|
|
252
|
+
const fullKey = this.__getFullKeyName(key);
|
|
253
|
+
this.cacheMap.delete(fullKey);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
memoryClear() {
|
|
257
|
+
this.cacheMap.clear();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
memoryHas(key) {
|
|
261
|
+
const fullKey = this.__getFullKeyName(key);
|
|
262
|
+
return this.cacheMap.has(fullKey);
|
|
263
|
+
}
|
|
277
264
|
}
|
|
265
|
+
|
|
278
266
|
export default StorageClass;
|
|
279
|
-
// export default
|
package/plugins/uniMap.js
CHANGED
|
@@ -34,8 +34,8 @@ export default class uniMap {
|
|
|
34
34
|
static openLocation(lat, lng) {
|
|
35
35
|
return new Promise((resolve, reject) => {
|
|
36
36
|
uni.openLocation({
|
|
37
|
-
latitude:
|
|
38
|
-
longitude:
|
|
37
|
+
latitude: lat,
|
|
38
|
+
longitude: lng,
|
|
39
39
|
success: function () {
|
|
40
40
|
resolve();
|
|
41
41
|
},
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
auto-height
|
|
12
12
|
/>
|
|
13
13
|
<view @tap="chooseLocation" class="cv-geo-local-button">
|
|
14
|
-
<cv-icons type="
|
|
14
|
+
<cv-icons type="geoLocateoutline" size="20" color="#999999" />
|
|
15
15
|
</view>
|
|
16
16
|
</view>
|
|
17
17
|
<view class="cv-geo-local-map" v-if="isShowMap">
|
|
18
18
|
<map
|
|
19
19
|
style="width: 100%; height: 170px"
|
|
20
|
-
:longitude="
|
|
21
|
-
:latitude="
|
|
20
|
+
:longitude="localLongitude"
|
|
21
|
+
:latitude="localLatitude"
|
|
22
22
|
:scale="localScale"
|
|
23
23
|
show-location
|
|
24
24
|
:markers="markers"
|
|
@@ -32,7 +32,7 @@ import mixin from '../../libs/mixin/mixin.js';
|
|
|
32
32
|
export default {
|
|
33
33
|
mixins: [mpMixin, mixin],
|
|
34
34
|
name: 'cvGeoLocal',
|
|
35
|
-
emits: ['input', 'update:modelValue', '
|
|
35
|
+
emits: ['input', 'update:modelValue', 'update:longitude', 'update:latitude'],
|
|
36
36
|
props: {
|
|
37
37
|
value: {
|
|
38
38
|
type: [Number, String],
|
|
@@ -42,6 +42,16 @@ export default {
|
|
|
42
42
|
type: [Number, String],
|
|
43
43
|
default: ''
|
|
44
44
|
},
|
|
45
|
+
// 经度
|
|
46
|
+
longitude: {
|
|
47
|
+
type: [Number, String],
|
|
48
|
+
default: ''
|
|
49
|
+
},
|
|
50
|
+
// 纬度
|
|
51
|
+
latitude: {
|
|
52
|
+
type: [Number, String],
|
|
53
|
+
default: ''
|
|
54
|
+
},
|
|
45
55
|
placeholder: {
|
|
46
56
|
type: [String],
|
|
47
57
|
default: '请输入定位地址'
|
|
@@ -83,7 +93,13 @@ export default {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
},
|
|
86
|
-
|
|
96
|
+
longitude(n) {
|
|
97
|
+
if (this.isShowMap) {
|
|
98
|
+
console.log('change:location');
|
|
99
|
+
this.initLocation();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
latitude(n) {
|
|
87
103
|
if (this.isShowMap) {
|
|
88
104
|
console.log('change:location');
|
|
89
105
|
this.initLocation();
|
|
@@ -111,10 +127,8 @@ export default {
|
|
|
111
127
|
markers: [],
|
|
112
128
|
//当前选择的位置
|
|
113
129
|
localScale: 14,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
latitude: 26.074286
|
|
117
|
-
},
|
|
130
|
+
localLongitude: 119.296411,
|
|
131
|
+
localLatitude: 26.074286,
|
|
118
132
|
parentObj: null
|
|
119
133
|
};
|
|
120
134
|
},
|
|
@@ -173,12 +187,12 @@ export default {
|
|
|
173
187
|
this.funcOnInput();
|
|
174
188
|
},
|
|
175
189
|
initLocation() {
|
|
176
|
-
if (this.
|
|
177
|
-
this.
|
|
190
|
+
if (this.longitude && this.latitude) {
|
|
191
|
+
this.localLongitude = this.longitude;
|
|
192
|
+
this.localLatitude = this.latitude;
|
|
178
193
|
}
|
|
179
|
-
console.log('--', this.map_location);
|
|
180
194
|
if (this.localVal) {
|
|
181
|
-
this.
|
|
195
|
+
this.localVal = this.localVal;
|
|
182
196
|
}
|
|
183
197
|
},
|
|
184
198
|
chooseLocation() {
|
|
@@ -188,9 +202,11 @@ export default {
|
|
|
188
202
|
console.log(res);
|
|
189
203
|
if (res.errMsg == 'chooseLocation:ok') {
|
|
190
204
|
this.localVal = res.address || '';
|
|
191
|
-
this.
|
|
205
|
+
this.localLongitude = res.longitude || '';
|
|
206
|
+
this.localLatitude = res.latitude || '';
|
|
192
207
|
this.localScale = 16;
|
|
193
|
-
this.$emit('
|
|
208
|
+
this.$emit('update:longitude', this.localLongitude);
|
|
209
|
+
this.$emit('update:latitude', this.localLatitude);
|
|
194
210
|
this.funcOnInput();
|
|
195
211
|
}
|
|
196
212
|
}
|
|
@@ -198,12 +214,11 @@ export default {
|
|
|
198
214
|
},
|
|
199
215
|
initMarkers() {
|
|
200
216
|
let markers = [];
|
|
201
|
-
let map_location = this.map_location;
|
|
202
217
|
markers.push({
|
|
203
|
-
latitude:
|
|
204
|
-
longitude:
|
|
218
|
+
latitude: this.localLatitude,
|
|
219
|
+
longitude: this.localLongitude,
|
|
205
220
|
callout: {
|
|
206
|
-
content:
|
|
221
|
+
content: this.localVal,
|
|
207
222
|
color: '#333333',
|
|
208
223
|
borderRadius: 5,
|
|
209
224
|
bgColor: '#ffffff',
|
|
@@ -224,6 +239,7 @@ export default {
|
|
|
224
239
|
display: flex;
|
|
225
240
|
flex-direction: column;
|
|
226
241
|
width: 100%;
|
|
242
|
+
position: relative;
|
|
227
243
|
}
|
|
228
244
|
.cv-geo-local-info {
|
|
229
245
|
display: flex;
|
|
@@ -28,9 +28,21 @@ import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
|
28
28
|
import mixin from '../../libs/mixin/mixin.js';
|
|
29
29
|
export default {
|
|
30
30
|
mixins: [mpMixin, mixin],
|
|
31
|
-
name: '
|
|
32
|
-
emits: ['input', 'update:modelValue', 'onChoose'],
|
|
31
|
+
name: 'cvGeoRegion',
|
|
32
|
+
emits: ['input', 'update:modelValue', 'update:province', 'update:city', 'update:district', 'onChoose'],
|
|
33
33
|
props: {
|
|
34
|
+
province: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: ''
|
|
37
|
+
},
|
|
38
|
+
city: {
|
|
39
|
+
type: [String, Number],
|
|
40
|
+
default: ''
|
|
41
|
+
},
|
|
42
|
+
district: {
|
|
43
|
+
type: [String, Number],
|
|
44
|
+
default: ''
|
|
45
|
+
},
|
|
34
46
|
value: {
|
|
35
47
|
type: [Array, Object],
|
|
36
48
|
default: () => []
|
|
@@ -54,6 +66,18 @@ export default {
|
|
|
54
66
|
}
|
|
55
67
|
},
|
|
56
68
|
watch: {
|
|
69
|
+
province(newVal) {
|
|
70
|
+
this.localVal[0] = newVal;
|
|
71
|
+
this.itemsSortOut();
|
|
72
|
+
},
|
|
73
|
+
city(newVal) {
|
|
74
|
+
this.localVal[1] = newVal;
|
|
75
|
+
this.itemsSortOut();
|
|
76
|
+
},
|
|
77
|
+
district(newVal) {
|
|
78
|
+
this.localVal[2] = newVal;
|
|
79
|
+
this.itemsSortOut();
|
|
80
|
+
},
|
|
57
81
|
value(newVal) {
|
|
58
82
|
this.localVal = newVal;
|
|
59
83
|
this.itemsSortOut();
|
|
@@ -71,7 +95,7 @@ export default {
|
|
|
71
95
|
last_range_data: [], //最终显示页面数组
|
|
72
96
|
items_index: [0, 0, 0], //当前下标
|
|
73
97
|
lastRetDataIndex: [0, 0, 0], // 最终确定选中的下标
|
|
74
|
-
|
|
98
|
+
localValField: 'text',
|
|
75
99
|
localDataValue: 'value',
|
|
76
100
|
localDataText: 'label',
|
|
77
101
|
localProvince: {},
|
|
@@ -81,7 +105,7 @@ export default {
|
|
|
81
105
|
},
|
|
82
106
|
created() {
|
|
83
107
|
this.localVal = this.doValueGet();
|
|
84
|
-
this.
|
|
108
|
+
this.localValField = this.dataType != 'value' ? 'text' : 'value';
|
|
85
109
|
this.itemsSortOut();
|
|
86
110
|
},
|
|
87
111
|
methods: {
|
|
@@ -146,7 +170,7 @@ export default {
|
|
|
146
170
|
if (localValue) {
|
|
147
171
|
/* 便利省级列表 找出省级的位置 */
|
|
148
172
|
for (const key in data) {
|
|
149
|
-
if (localValue == data[key][this.
|
|
173
|
+
if (localValue == data[key][this.localValField]) {
|
|
150
174
|
localKey = parseInt(key);
|
|
151
175
|
}
|
|
152
176
|
}
|
|
@@ -203,18 +227,18 @@ export default {
|
|
|
203
227
|
this.lastRetDataIndex = [...items_index];
|
|
204
228
|
let value = [];
|
|
205
229
|
let items = this.items;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
value[0] = this.range_data[0][items_index[0]].value;
|
|
212
|
-
value[1] = this.range_data[1][items_index[1]].value;
|
|
213
|
-
value[2] = this.range_data[2][items_index[2]].value;
|
|
214
|
-
}
|
|
230
|
+
let item_key = this.localValField == 'text' ? 'text' : 'value';
|
|
231
|
+
value[0] = this.range_data[0][items_index[0]][item_key];
|
|
232
|
+
value[1] = this.range_data[1][items_index[1]][item_key];
|
|
233
|
+
value[2] = this.range_data[2][items_index[2]][item_key];
|
|
234
|
+
|
|
215
235
|
this.$emit('input', value);
|
|
216
236
|
this.$emit('update:modelValue', value);
|
|
217
237
|
|
|
238
|
+
this.$emit('update:province', value[0]);
|
|
239
|
+
this.$emit('update:city', value[1]);
|
|
240
|
+
this.$emit('update:district', value[2]);
|
|
241
|
+
|
|
218
242
|
// 把选中的3个数组传递出去
|
|
219
243
|
|
|
220
244
|
let selectAllArr = {
|
|
@@ -145,7 +145,7 @@ export function parseFormData(data) {
|
|
|
145
145
|
// formData['file']= file; // file 必须为最后一个表单域
|
|
146
146
|
return formData;
|
|
147
147
|
}
|
|
148
|
-
function getFileInfo(imgStr) {
|
|
148
|
+
export function getFileInfo(imgStr) {
|
|
149
149
|
let index = imgStr.lastIndexOf('/');
|
|
150
150
|
let strName = imgStr.substring(index + 1, imgStr.length);
|
|
151
151
|
let strType = '';
|
|
@@ -165,7 +165,8 @@ import {
|
|
|
165
165
|
generateUniqidName,
|
|
166
166
|
parseJsonSafe,
|
|
167
167
|
parseFormData,
|
|
168
|
-
content_to_array
|
|
168
|
+
content_to_array,
|
|
169
|
+
getFileInfo
|
|
169
170
|
} from './file.js';
|
|
170
171
|
/**
|
|
171
172
|
* upload 上传
|
|
@@ -257,6 +258,7 @@ export default {
|
|
|
257
258
|
'delete',
|
|
258
259
|
'clickPreview',
|
|
259
260
|
'update:modelValue',
|
|
261
|
+
'update:initValue',
|
|
260
262
|
'update:fileList',
|
|
261
263
|
'afterAutoUpload'
|
|
262
264
|
],
|
|
@@ -542,6 +544,8 @@ export default {
|
|
|
542
544
|
let res2 = res1?.data || res1 || {};
|
|
543
545
|
// TODO 判断是否多图,
|
|
544
546
|
this.$emit('update:modelValue', res2.filelog_id || '');
|
|
547
|
+
this.localList.push(getFileInfo(res2.cdn_full_path));
|
|
548
|
+
this.formatFileList();
|
|
545
549
|
that.$emit(
|
|
546
550
|
'afterAutoUpload',
|
|
547
551
|
Object.assign(res2, {
|
|
@@ -666,6 +670,9 @@ export default {
|
|
|
666
670
|
},
|
|
667
671
|
deleteItem(index) {
|
|
668
672
|
if (this.autoDelete) {
|
|
673
|
+
this.localList.splice(index, 1);
|
|
674
|
+
this.$emit('update:initValue', this.localList);
|
|
675
|
+
|
|
669
676
|
this.fileList.splice(index, 1);
|
|
670
677
|
this.$emit('update:fileList', this.fileList);
|
|
671
678
|
} else {
|
package/libs/storage3.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
let cacheMap = new Map();
|
|
2
|
-
let timeoutDefault = 86400; // 设置默认超时时间,单位秒 60 * 60 * 24 (1天)
|
|
3
|
-
|
|
4
|
-
function isTimeout(name) {
|
|
5
|
-
const data = cacheMap.get(name);
|
|
6
|
-
if (!data) return true;
|
|
7
|
-
if (data.timeout === 0) return false;
|
|
8
|
-
const currentTime = Date.now();
|
|
9
|
-
const overTime = (currentTime - data.createTime) / 1000;
|
|
10
|
-
if (overTime > data.timeout) {
|
|
11
|
-
cacheMap.delete(name);
|
|
12
|
-
if (name.startsWith('_')) {
|
|
13
|
-
try {
|
|
14
|
-
uni.removeStorageSync(name);
|
|
15
|
-
} catch (e) {
|
|
16
|
-
console.log(e);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class CacheCell {
|
|
25
|
-
constructor(data, timeout) {
|
|
26
|
-
this.data = data;
|
|
27
|
-
this.timeout = timeout; // 设置超时时间,单位秒
|
|
28
|
-
this.createTime = Date.now(); // 对象创建时候的时间
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
class CacheClass {
|
|
33
|
-
constructor(timeout) {
|
|
34
|
-
try {
|
|
35
|
-
const res = uni.getStorageInfoSync();
|
|
36
|
-
res.keys.forEach((name) => {
|
|
37
|
-
try {
|
|
38
|
-
const value = uni.getStorageSync(name);
|
|
39
|
-
cacheMap.set(name, value);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
console.log(e);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
} catch (e) {
|
|
45
|
-
console.log(e);
|
|
46
|
-
}
|
|
47
|
-
timeoutDefault = timeout;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 设置缓存数据
|
|
52
|
-
* @param {Any} name 缓存的key, 以下划线命名表示永久缓存到Storage
|
|
53
|
-
* @param {Any} data 缓存的数据
|
|
54
|
-
* @param {Number} timeout 缓存时间(秒),默认86400秒即一天,0表示永久缓存
|
|
55
|
-
*/
|
|
56
|
-
set(name, data, timeout = timeoutDefault) {
|
|
57
|
-
const cachecell = new CacheCell(data, timeout);
|
|
58
|
-
let cache = null;
|
|
59
|
-
if (name.startsWith('_')) {
|
|
60
|
-
try {
|
|
61
|
-
uni.setStorageSync(name, cachecell);
|
|
62
|
-
cache = cacheMap.set(name, cachecell);
|
|
63
|
-
} catch (e) {
|
|
64
|
-
console.log(e);
|
|
65
|
-
}
|
|
66
|
-
} else {
|
|
67
|
-
cache = cacheMap.set(name, cachecell);
|
|
68
|
-
}
|
|
69
|
-
return cache;
|
|
70
|
-
}
|
|
71
|
-
get(name) {
|
|
72
|
-
return isTimeout(name) ? null : cacheMap.get(name).data;
|
|
73
|
-
}
|
|
74
|
-
delete(name) {
|
|
75
|
-
let value = false;
|
|
76
|
-
if (name.startsWith('_')) {
|
|
77
|
-
try {
|
|
78
|
-
uni.removeStorageSync(name);
|
|
79
|
-
value = cacheMap.delete(name);
|
|
80
|
-
} catch (e) {
|
|
81
|
-
console.log(e);
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
value = cacheMap.delete(name);
|
|
85
|
-
}
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
has(name) {
|
|
89
|
-
return !isTimeout(name);
|
|
90
|
-
}
|
|
91
|
-
clear() {
|
|
92
|
-
let value = false;
|
|
93
|
-
try {
|
|
94
|
-
uni.clearStorageSync();
|
|
95
|
-
cacheMap.clear();
|
|
96
|
-
value = true;
|
|
97
|
-
} catch (e) {
|
|
98
|
-
console.log(e);
|
|
99
|
-
}
|
|
100
|
-
return value;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export default CacheClass;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 复制文本 兼容H5
|
|
3
|
-
* 来自 ThorUI www.thorui.cn | 文档地址: www.donarui.com
|
|
4
|
-
* @author echo.
|
|
5
|
-
* @version 1.0.0
|
|
6
|
-
**/
|
|
7
|
-
// #ifdef H5
|
|
8
|
-
import ClipboardJS from '../js-sdk/clipboard.min.js';
|
|
9
|
-
// #endif
|
|
10
|
-
const thorui = {
|
|
11
|
-
/**
|
|
12
|
-
* data 需要复制的数据
|
|
13
|
-
* callback 回调
|
|
14
|
-
* e 当用户点击后需要先请求接口再进行复制时,需要传入此参数,或者将异步请求转为同步 (H5端)
|
|
15
|
-
* **/
|
|
16
|
-
getClipboardData: function (data, callback, e) {
|
|
17
|
-
// #ifdef APP-PLUS || MP
|
|
18
|
-
uni.setClipboardData({
|
|
19
|
-
data: data,
|
|
20
|
-
success(res) {
|
|
21
|
-
'function' == typeof callback && callback(true);
|
|
22
|
-
},
|
|
23
|
-
fail(res) {
|
|
24
|
-
'function' == typeof callback && callback(false);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// #endif
|
|
28
|
-
|
|
29
|
-
// #ifdef H5
|
|
30
|
-
let event = window.event || e || {};
|
|
31
|
-
let clipboard = new ClipboardJS('', {
|
|
32
|
-
text: () => data
|
|
33
|
-
});
|
|
34
|
-
clipboard.on('success', (e) => {
|
|
35
|
-
'function' == typeof callback && callback(true);
|
|
36
|
-
clipboard.off('success');
|
|
37
|
-
clipboard.off('error');
|
|
38
|
-
clipboard.destroy();
|
|
39
|
-
});
|
|
40
|
-
clipboard.on('error', (e) => {
|
|
41
|
-
'function' == typeof callback && callback(false);
|
|
42
|
-
clipboard.off('success');
|
|
43
|
-
clipboard.off('error');
|
|
44
|
-
clipboard.destroy();
|
|
45
|
-
});
|
|
46
|
-
clipboard.onClick(event);
|
|
47
|
-
// #endif
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default {
|
|
52
|
-
getClipboardData: thorui.getClipboardData
|
|
53
|
-
};
|