|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+/* eslint-disable */
|
|
|
2
|
+import mRouter from '@/utils/router';
|
|
|
3
|
+import mStore from '@/store';
|
|
|
4
|
+import appShare from '@/utils/share';
|
|
|
5
|
+import {
|
|
|
6
|
+ http
|
|
|
7
|
+} from '@/utils/request';
|
|
|
8
|
+import pageData from "@/pages/myTask/repairList/addRepair/pageData.js"
|
|
|
9
|
+
|
|
|
10
|
+export default {
|
|
|
11
|
+ /**
|
|
|
12
|
+ * toast提示
|
|
|
13
|
+ */
|
|
|
14
|
+ toast(title, duration = 3000, mask = false, icon = 'none') {
|
|
|
15
|
+ if (Boolean(title) === false) {
|
|
|
16
|
+ return;
|
|
|
17
|
+ }
|
|
|
18
|
+ uni.showToast({
|
|
|
19
|
+ title,
|
|
|
20
|
+ duration,
|
|
|
21
|
+ mask,
|
|
|
22
|
+ icon
|
|
|
23
|
+ });
|
|
|
24
|
+ },
|
|
|
25
|
+ // 工单状态
|
|
|
26
|
+ stateComm(type) {
|
|
|
27
|
+ const state = {
|
|
|
28
|
+ 1: 1000,
|
|
|
29
|
+ 2: 2000,
|
|
|
30
|
+ 3: 3000,
|
|
|
31
|
+ 4: 4000
|
|
|
32
|
+ }
|
|
|
33
|
+ return state[type]
|
|
|
34
|
+ },
|
|
|
35
|
+ // 通过工单标识获取到工单id
|
|
|
36
|
+ getOrderId(id,fn) {
|
|
|
37
|
+ const params = {
|
|
|
38
|
+ pid:0,
|
|
|
39
|
+ flag:1
|
|
|
40
|
+ }
|
|
|
41
|
+ http.get("GongDanType/GetList",params).then((res)=>{
|
|
|
42
|
+ if(res.state.toLowerCase() ==="success"){
|
|
|
43
|
+ res.data.forEach(v => {
|
|
|
44
|
+ if(v.identification == id) {
|
|
|
45
|
+ fn(v.id)
|
|
|
46
|
+ }
|
|
|
47
|
+ })
|
|
|
48
|
+ }
|
|
|
49
|
+ })
|
|
|
50
|
+ },
|
|
|
51
|
+ httpPost(url, params, delta,fn) {
|
|
|
52
|
+
|
|
|
53
|
+ uni.showLoading({title: '加载中'})
|
|
|
54
|
+
|
|
|
55
|
+ http.post(url, params).then((res) => {
|
|
|
56
|
+ uni.hideLoading()
|
|
|
57
|
+ if (res.state.toLowerCase() === "success") {
|
|
|
58
|
+
|
|
|
59
|
+ uni.showToast({
|
|
|
60
|
+ title: '操作成功',
|
|
|
61
|
+ duration: 500
|
|
|
62
|
+ });
|
|
|
63
|
+ setTimeout(() => {
|
|
|
64
|
+ uni.$emit("updateList", {}); //列表刷新数据
|
|
|
65
|
+ uni.navigateBack({delta})
|
|
|
66
|
+ fn(false)
|
|
|
67
|
+ }, 500)
|
|
|
68
|
+
|
|
|
69
|
+ }else{
|
|
|
70
|
+ this.toast(res.message)
|
|
|
71
|
+ fn(false)
|
|
|
72
|
+ }
|
|
|
73
|
+ })
|
|
|
74
|
+
|
|
|
75
|
+ },
|
|
|
76
|
+ httpGetDetail(url, type, workorderid, fn) {
|
|
|
77
|
+ const params = {
|
|
|
78
|
+ type,
|
|
|
79
|
+ workorderid,
|
|
|
80
|
+ token: uni.getStorageSync("token"),
|
|
|
81
|
+ }
|
|
|
82
|
+ http.get(url, params).then((response) => {
|
|
|
83
|
+ if (response.state.toLowerCase() === "success") {
|
|
|
84
|
+ fn(response.data)
|
|
|
85
|
+ }
|
|
|
86
|
+ }).catch((e) => {
|
|
|
87
|
+ console.log(e);
|
|
|
88
|
+ })
|
|
|
89
|
+ },
|
|
|
90
|
+ // 通过名称获取id
|
|
|
91
|
+ getValueByText(text, data) {
|
|
|
92
|
+ let value;
|
|
|
93
|
+ data.forEach(v =>{
|
|
|
94
|
+ if(v.text == text){
|
|
|
95
|
+ value = v.value
|
|
|
96
|
+ }
|
|
|
97
|
+ })
|
|
|
98
|
+ return value
|
|
|
99
|
+ },
|
|
|
100
|
+ // 通过id获取工单标识
|
|
|
101
|
+ getIdentification(treeData, id){
|
|
|
102
|
+ for (let i = 0; i < treeData.length; i++) {
|
|
|
103
|
+ if (treeData[i].id == id) {
|
|
|
104
|
+ return treeData[i].identification
|
|
|
105
|
+ } else {
|
|
|
106
|
+ if (treeData[i].children) {
|
|
|
107
|
+ var res = this.getIdentification(treeData[i].children, id)
|
|
|
108
|
+ if (res !== undefined) {
|
|
|
109
|
+ return res
|
|
|
110
|
+ }
|
|
|
111
|
+ }
|
|
|
112
|
+ }
|
|
|
113
|
+ }
|
|
|
114
|
+ },
|
|
|
115
|
+ // 详情返回页面 参数表示页面回退几级
|
|
|
116
|
+ returnPage(index) {
|
|
|
117
|
+ uni.navigateBack({
|
|
|
118
|
+ delta: index,
|
|
|
119
|
+ })
|
|
|
120
|
+ },
|
|
|
121
|
+ getImgString(string) {
|
|
|
122
|
+ const imgIdListToString= string.toString()
|
|
|
123
|
+ const imgid = (imgIdListToString.substring(imgIdListToString.length - 1) == ',') ?
|
|
|
124
|
+ imgIdListToString.substring(0, imgIdListToString.length - 1) : imgIdListToString;
|
|
|
125
|
+ return imgid
|
|
|
126
|
+ },
|
|
|
127
|
+ // 防抖
|
|
|
128
|
+ // 例子 debounceList = debounce(getList, 5000)先声明
|
|
|
129
|
+ // 后debounceList()调用,每个页面声明一次即可,调用可多次
|
|
|
130
|
+ debounce(fn, delay=3000, immediate = false, resultCallback) {
|
|
|
131
|
+ // 1.定义一个定时器, 保存上一次的定时器
|
|
|
132
|
+ let timer = null
|
|
|
133
|
+ let isInvoke = false
|
|
|
134
|
+
|
|
|
135
|
+ // 2.真正执行的函数
|
|
|
136
|
+ const _debounce = function(...args) {
|
|
|
137
|
+ return new Promise((resolve, reject) => {
|
|
|
138
|
+ // 取消上一次的定时器
|
|
|
139
|
+ if (timer) clearTimeout(timer)
|
|
|
140
|
+
|
|
|
141
|
+ // 判断是否需要立即执行
|
|
|
142
|
+ if (immediate && !isInvoke) {
|
|
|
143
|
+ const result = fn.apply(this, args)
|
|
|
144
|
+ if (resultCallback) resultCallback(result)
|
|
|
145
|
+ resolve(result)
|
|
|
146
|
+ isInvoke = true
|
|
|
147
|
+ } else {
|
|
|
148
|
+ // 延迟执行
|
|
|
149
|
+ timer = setTimeout(() => {
|
|
|
150
|
+ // 外部传入的真正要执行的函数
|
|
|
151
|
+ const result = fn.apply(this, args)
|
|
|
152
|
+ if (resultCallback) resultCallback(result)
|
|
|
153
|
+ resolve(result)
|
|
|
154
|
+ isInvoke = false
|
|
|
155
|
+ timer = null
|
|
|
156
|
+ }, delay)
|
|
|
157
|
+ }
|
|
|
158
|
+ })
|
|
|
159
|
+ }
|
|
|
160
|
+
|
|
|
161
|
+ // 封装取消功能
|
|
|
162
|
+ _debounce.cancel = function() {
|
|
|
163
|
+ if (timer) clearTimeout(timer)
|
|
|
164
|
+ timer = null
|
|
|
165
|
+ isInvoke = false
|
|
|
166
|
+ }
|
|
|
167
|
+
|
|
|
168
|
+ return _debounce
|
|
|
169
|
+ },
|
|
|
170
|
+ // 通过子级部门id获取父级
|
|
|
171
|
+ callback(treeData, id){
|
|
|
172
|
+ for (let i = 0; i < treeData.length; i++) {
|
|
|
173
|
+ if (Number(treeData[i].id) == Number(id)) {
|
|
|
174
|
+ return [treeData[i].text]
|
|
|
175
|
+ } else {
|
|
|
176
|
+ if (treeData[i].children) {
|
|
|
177
|
+ var res = this.callback(treeData[i].children, id)
|
|
|
178
|
+ if (res !== undefined) {
|
|
|
179
|
+ return res.concat(treeData[i].text)
|
|
|
180
|
+ }
|
|
|
181
|
+ }
|
|
|
182
|
+ }
|
|
|
183
|
+ }
|
|
|
184
|
+ },
|
|
|
185
|
+ findParents(treeData, id) {
|
|
|
186
|
+ let string = ''
|
|
|
187
|
+ if (treeData.length == 0) return
|
|
|
188
|
+ if (id == undefined) return
|
|
|
189
|
+ if(this.callback(treeData, id) !== undefined) {
|
|
|
190
|
+ this.callback(treeData, id).reverse().forEach((v,n) => {
|
|
|
191
|
+ string += v + '/'
|
|
|
192
|
+ })
|
|
|
193
|
+ }
|
|
|
194
|
+
|
|
|
195
|
+ const text = (string.substring(string.length - 1) == '/') ? string.substring(0, string.length - 1) : string;
|
|
|
196
|
+ return text
|
|
|
197
|
+ },
|
|
|
198
|
+ // 通过工单类别获取对应部门id
|
|
|
199
|
+ getDepartidByOrderid(treeData, id){
|
|
|
200
|
+ for (let i = 0; i < treeData.length; i++) {
|
|
|
201
|
+ if (Number(treeData[i].id) == Number(id)) {
|
|
|
202
|
+ return [treeData[i].autoDept]+ ','+ [treeData[i].identification]
|
|
|
203
|
+ } else {
|
|
|
204
|
+ if (treeData[i].children) {
|
|
|
205
|
+ var res = this.callback(treeData[i].children, id)
|
|
|
206
|
+ if (res !== undefined) {
|
|
|
207
|
+ return res.concat(treeData[i].autoDept) + ','+ [treeData[i].identification]
|
|
|
208
|
+ }
|
|
|
209
|
+ }
|
|
|
210
|
+ }
|
|
|
211
|
+ }
|
|
|
212
|
+ },
|
|
|
213
|
+ // 通过科室编码获取对应部门id
|
|
|
214
|
+ getDepartidByDepartCode(treeData, code){
|
|
|
215
|
+ for (let i = 0; i < treeData.length; i++) {
|
|
|
216
|
+ if (treeData[i].identification == code) {
|
|
|
217
|
+ return treeData[i].id
|
|
|
218
|
+ } else {
|
|
|
219
|
+ if (treeData[i].children) {
|
|
|
220
|
+ var res = this.getDepartidByDepartCode(treeData[i].children, code)
|
|
|
221
|
+ if (res !== undefined) {
|
|
|
222
|
+ console.log(treeData[i].id)
|
|
|
223
|
+ return res
|
|
|
224
|
+ }
|
|
|
225
|
+ }
|
|
|
226
|
+ }
|
|
|
227
|
+ }
|
|
|
228
|
+ },
|
|
|
229
|
+ findUserName(data, id) {
|
|
|
230
|
+ let string = ''
|
|
|
231
|
+ if (!id) {
|
|
|
232
|
+ return ''
|
|
|
233
|
+ } else {
|
|
|
234
|
+ data.forEach((v, n) => {
|
|
|
235
|
+ if (v.value == id) {
|
|
|
236
|
+ string = v.text
|
|
|
237
|
+ }
|
|
|
238
|
+ })
|
|
|
239
|
+ }
|
|
|
240
|
+ return string
|
|
|
241
|
+ },
|
|
|
242
|
+ //获取当前时间
|
|
|
243
|
+ CurentTime() {
|
|
|
244
|
+ const now = new Date();
|
|
|
245
|
+ const year = now.getFullYear(); //年
|
|
|
246
|
+ const month = now.getMonth() + 1; //月 .toString().padstart(2,0)
|
|
|
247
|
+ const day = now.getDate().toString().padStart(2, 0); //日
|
|
|
248
|
+ const hh = now.getHours().toString().padStart(2, 0); //时
|
|
|
249
|
+ const mm = now.getMinutes().toString().padStart(2, 0); //分
|
|
|
250
|
+ const ss = now.getSeconds().toString().padStart(2, 0); //秒
|
|
|
251
|
+ return year + "-" + month.toString().padStart(2, 0) + "-" + day + " " + hh + ":" + mm + ":" + ss;
|
|
|
252
|
+ },
|
|
|
253
|
+ /**
|
|
|
254
|
+ *获取当前日期: YYYY-MM-DD
|
|
|
255
|
+ */
|
|
|
256
|
+ getNowDate() {
|
|
|
257
|
+ var myDate = new Date();
|
|
|
258
|
+ myDate.getYear(); // 获取当前年份(2位)
|
|
|
259
|
+ var YY = myDate.getFullYear(); // 获取完整的年份(4位,1970-????)
|
|
|
260
|
+ var MM = myDate.getMonth() + 1; // 获取当前月份(0-11,0代表1月)
|
|
|
261
|
+ MM = MM > 9 ? MM : "0" + MM;
|
|
|
262
|
+ var DD = myDate.getDate(); // 获取当前日(1-31)
|
|
|
263
|
+ DD = DD > 9 ? DD : "0" + DD;
|
|
|
264
|
+ return YY + "-" + MM + "-" + DD;
|
|
|
265
|
+ },
|
|
|
266
|
+ getPreDate(pdate = 3600 * 1000 * 24 * 30) {
|
|
|
267
|
+ const start = new Date();
|
|
|
268
|
+ start.setTime(start.getTime() - pdate);
|
|
|
269
|
+ start.getYear(); // 获取当前年份(2位)
|
|
|
270
|
+ const YY = start.getFullYear(); // 获取完整的年份(4位,1970-????)
|
|
|
271
|
+ let MM = start.getMonth() + 1; // 获取当前月份(0-11,0代表1月)
|
|
|
272
|
+ MM = MM > 9 ? MM : "0" + MM;
|
|
|
273
|
+ let DD = start.getDate(); // 获取当前日(1-31)
|
|
|
274
|
+ DD = DD > 9 ? DD : "0" + DD;
|
|
|
275
|
+ return YY + "-" + MM + "-" + DD;
|
|
|
276
|
+ },
|
|
|
277
|
+ //获取当前时间年月份
|
|
|
278
|
+ CurentTimeType() {
|
|
|
279
|
+ const now = new Date();
|
|
|
280
|
+ const year = now.getFullYear(); //年
|
|
|
281
|
+ const month = now.getMonth() + 1; //月 .toString().padstart(2,0)
|
|
|
282
|
+ const day = now.getDate().toString().padStart(2, 0); //日
|
|
|
283
|
+ const hh = now.getHours().toString().padStart(2, 0); //时
|
|
|
284
|
+ const mm = now.getMinutes().toString().padStart(2, 0); //分
|
|
|
285
|
+ const ss = now.getSeconds().toString().padStart(2, 0); //秒
|
|
|
286
|
+ return year + "年" + month.toString().padStart(2, 0) + "月" + day + "日" + hh + "时" + mm + "分" + ss + "秒";
|
|
|
287
|
+
|
|
|
288
|
+ },
|
|
|
289
|
+ /**
|
|
|
290
|
+ * 返回上一页携带参数
|
|
|
291
|
+ */
|
|
|
292
|
+ prePage(index) {
|
|
|
293
|
+ let pages = getCurrentPages();
|
|
|
294
|
+ let prePage = pages[pages.length - (index || 2)];
|
|
|
295
|
+ // #ifdef H5
|
|
|
296
|
+ return prePage;
|
|
|
297
|
+ // #endif
|
|
|
298
|
+ return prePage.$vm;
|
|
|
299
|
+ },
|
|
|
300
|
+ /**
|
|
|
301
|
+ * 开发环境全局打印日志
|
|
|
302
|
+ * @param {Object} title
|
|
|
303
|
+ */
|
|
|
304
|
+ log(title) {
|
|
|
305
|
+ if (process.env.NODE_ENV === 'development' && Boolean(title) === true) {
|
|
|
306
|
+ console.log(JSON.stringify(title));
|
|
|
307
|
+ }
|
|
|
308
|
+ },
|
|
|
309
|
+ /**
|
|
|
310
|
+ * 异步获取设备信息
|
|
|
311
|
+ */
|
|
|
312
|
+ getInfoAsync() {
|
|
|
313
|
+ return new Promise((resolve, reject) => {
|
|
|
314
|
+ plus.device.getInfo({
|
|
|
315
|
+ success(e) {
|
|
|
316
|
+ resolve(e);
|
|
|
317
|
+ },
|
|
|
318
|
+ fail(e) {
|
|
|
319
|
+ reject(e.message);
|
|
|
320
|
+ }
|
|
|
321
|
+ });
|
|
|
322
|
+ });
|
|
|
323
|
+ },
|
|
|
324
|
+ /**
|
|
|
325
|
+ * 安卓10不支持IMEI,则获取OAID
|
|
|
326
|
+ */
|
|
|
327
|
+ getOaidAsync() {
|
|
|
328
|
+ return new Promise((resolve, reject) => {
|
|
|
329
|
+ plus.device.getOAID({
|
|
|
330
|
+ success(e) {
|
|
|
331
|
+ resolve(e);
|
|
|
332
|
+ },
|
|
|
333
|
+ fail(e) {
|
|
|
334
|
+ reject(e.message);
|
|
|
335
|
+ }
|
|
|
336
|
+ });
|
|
|
337
|
+ });
|
|
|
338
|
+ },
|
|
|
339
|
+ /**
|
|
|
340
|
+ * 获取一个随机数
|
|
|
341
|
+ * @param {Object} min
|
|
|
342
|
+ * @param {Object} max
|
|
|
343
|
+ */
|
|
|
344
|
+ random(min, max) {
|
|
|
345
|
+ switch (arguments.length) {
|
|
|
346
|
+ case 1:
|
|
|
347
|
+ return parseInt(Math.random() * min + 1, 10);
|
|
|
348
|
+ break;
|
|
|
349
|
+ case 2:
|
|
|
350
|
+ return parseInt(Math.random() * (max - min + 1) + min, 10);
|
|
|
351
|
+ break;
|
|
|
352
|
+ default:
|
|
|
353
|
+ return 0;
|
|
|
354
|
+ break;
|
|
|
355
|
+ }
|
|
|
356
|
+ },
|
|
|
357
|
+ /**
|
|
|
358
|
+ * 获取ios的IDFA
|
|
|
359
|
+ */
|
|
|
360
|
+ getIdfa() {
|
|
|
361
|
+ let idfa = '';
|
|
|
362
|
+ try {
|
|
|
363
|
+ if ('iOS' == plus.os.name) {
|
|
|
364
|
+ let manager = plus.ios.invoke('ASIdentifierManager', 'sharedManager');
|
|
|
365
|
+ if (plus.ios.invoke(manager, 'isAdvertisingTrackingEnabled')) {
|
|
|
366
|
+ let identifier = plus.ios.invoke(manager, 'advertisingIdentifier');
|
|
|
367
|
+ idfa = plus.ios.invoke(identifier, 'UUIDString');
|
|
|
368
|
+ plus.ios.deleteObject(identifier);
|
|
|
369
|
+ }
|
|
|
370
|
+ plus.ios.deleteObject(manager);
|
|
|
371
|
+ }
|
|
|
372
|
+ } catch (e) {
|
|
|
373
|
+ console.error('获取idfa失败');
|
|
|
374
|
+ }
|
|
|
375
|
+ return idfa;
|
|
|
376
|
+ },
|
|
|
377
|
+ /*
|
|
|
378
|
+ * obj 转 params字符串参数
|
|
|
379
|
+ * 例子:{a:1,b:2} => a=1&b=2
|
|
|
380
|
+ */
|
|
|
381
|
+ objParseParam(obj) {
|
|
|
382
|
+ let paramsStr = '';
|
|
|
383
|
+ if (obj instanceof Array) return paramsStr;
|
|
|
384
|
+ if (!(obj instanceof Object)) return paramsStr;
|
|
|
385
|
+ for (let key in obj) {
|
|
|
386
|
+ paramsStr += `${key}=${obj[key]}&`;
|
|
|
387
|
+ }
|
|
|
388
|
+ return paramsStr.substring(0, paramsStr.length - 1);
|
|
|
389
|
+ },
|
|
|
390
|
+ /*
|
|
|
391
|
+ * obj 转 路由地址带参数
|
|
|
392
|
+ * 例子:{a:1,b:2} => /pages/index/index?a=1&b=2
|
|
|
393
|
+ */
|
|
|
394
|
+ objParseUrlAndParam(path, obj) {
|
|
|
395
|
+ let url = path || '/';
|
|
|
396
|
+ let paramsStr = '';
|
|
|
397
|
+ if (obj instanceof Array) return url;
|
|
|
398
|
+ if (!(obj instanceof Object)) return url;
|
|
|
399
|
+ paramsStr = this.objParseParam(obj);
|
|
|
400
|
+ paramsStr && (url += '?');
|
|
|
401
|
+ url += paramsStr;
|
|
|
402
|
+ return url;
|
|
|
403
|
+ },
|
|
|
404
|
+ /*
|
|
|
405
|
+ * 获取url字符串参数
|
|
|
406
|
+ */
|
|
|
407
|
+ getRequestParameters(locationhref) {
|
|
|
408
|
+ let href = locationhref || '';
|
|
|
409
|
+ let theRequest = new Object();
|
|
|
410
|
+ let str = href.split('?')[1];
|
|
|
411
|
+ if (str != undefined) {
|
|
|
412
|
+ let strs = str.split('&');
|
|
|
413
|
+ for (let i = 0; i < strs.length; i++) {
|
|
|
414
|
+ theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
|
|
|
415
|
+ }
|
|
|
416
|
+ }
|
|
|
417
|
+ return theRequest;
|
|
|
418
|
+ },
|
|
|
419
|
+ /**
|
|
|
420
|
+ * 加密字符串
|
|
|
421
|
+ */
|
|
|
422
|
+ strEncode(str) {
|
|
|
423
|
+ const key = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
424
|
+ let l = key.length;
|
|
|
425
|
+ let a = key.split('');
|
|
|
426
|
+ let s = '',
|
|
|
427
|
+ b,
|
|
|
428
|
+ b1,
|
|
|
429
|
+ b2,
|
|
|
430
|
+ b3;
|
|
|
431
|
+ for (let i = 0; i < str.length; i++) {
|
|
|
432
|
+ b = str.charCodeAt(i);
|
|
|
433
|
+ b1 = b % l;
|
|
|
434
|
+ b = (b - b1) / l;
|
|
|
435
|
+ b2 = b % l;
|
|
|
436
|
+ b = (b - b2) / l;
|
|
|
437
|
+ b3 = b % l;
|
|
|
438
|
+ s += a[b3] + a[b2] + a[b1];
|
|
|
439
|
+ }
|
|
|
440
|
+ return s;
|
|
|
441
|
+ },
|
|
|
442
|
+ /**
|
|
|
443
|
+ * 解密字符串
|
|
|
444
|
+ */
|
|
|
445
|
+ strDecode(str) {
|
|
|
446
|
+ const key = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
447
|
+ let l = key.length;
|
|
|
448
|
+ let b,
|
|
|
449
|
+ b1,
|
|
|
450
|
+ b2,
|
|
|
451
|
+ b3,
|
|
|
452
|
+ d = 0,
|
|
|
453
|
+ s;
|
|
|
454
|
+ s = new Array(Math.floor(str.length / 3));
|
|
|
455
|
+ b = s.length;
|
|
|
456
|
+ for (let i = 0; i < b; i++) {
|
|
|
457
|
+ b1 = key.indexOf(str.charAt(d));
|
|
|
458
|
+ d++;
|
|
|
459
|
+ b2 = key.indexOf(str.charAt(d));
|
|
|
460
|
+ d++;
|
|
|
461
|
+ b3 = key.indexOf(str.charAt(d));
|
|
|
462
|
+ d++;
|
|
|
463
|
+ s[i] = b1 * l * l + b2 * l + b3;
|
|
|
464
|
+ }
|
|
|
465
|
+ b = eval('String.fromCharCode(' + s.join(',') + ')');
|
|
|
466
|
+ return b;
|
|
|
467
|
+ },
|
|
|
468
|
+ /**
|
|
|
469
|
+ * 比较版本号
|
|
|
470
|
+ */
|
|
|
471
|
+ compareVersion(reqV, curV) {
|
|
|
472
|
+ if (curV && reqV) {
|
|
|
473
|
+ let arr1 = curV.split('.'),
|
|
|
474
|
+ arr2 = reqV.split('.');
|
|
|
475
|
+ let minLength = Math.min(arr1.length, arr2.length),
|
|
|
476
|
+ position = 0,
|
|
|
477
|
+ diff = 0;
|
|
|
478
|
+ while (
|
|
|
479
|
+ position < minLength &&
|
|
|
480
|
+ (diff = parseInt(arr1[position]) - parseInt(arr2[position])) == 0
|
|
|
481
|
+ ) {
|
|
|
482
|
+ position++;
|
|
|
483
|
+ }
|
|
|
484
|
+ diff = diff != 0 ? diff : arr1.length - arr2.length;
|
|
|
485
|
+ if (diff > 0) {
|
|
|
486
|
+ if (position == minLength - 1) {
|
|
|
487
|
+ return 1;
|
|
|
488
|
+ } else {
|
|
|
489
|
+ return 2;
|
|
|
490
|
+ }
|
|
|
491
|
+ } else {
|
|
|
492
|
+ return 0;
|
|
|
493
|
+ }
|
|
|
494
|
+ } else {
|
|
|
495
|
+ return 0;
|
|
|
496
|
+ }
|
|
|
497
|
+ },
|
|
|
498
|
+ /**
|
|
|
499
|
+ * H5复制
|
|
|
500
|
+ */
|
|
|
501
|
+ h5Copy(content) {
|
|
|
502
|
+ let textarea = document.createElement('textarea');
|
|
|
503
|
+ textarea.value = content;
|
|
|
504
|
+ textarea.readOnly = 'readOnly';
|
|
|
505
|
+ document.body.appendChild(textarea);
|
|
|
506
|
+ textarea.select(); // 选择对象
|
|
|
507
|
+ textarea.setSelectionRange(0, content.length); //核心
|
|
|
508
|
+ let result = document.execCommand('Copy'); // 执行浏览器复制命令
|
|
|
509
|
+ textarea.remove();
|
|
|
510
|
+ const msg = result ? '复制成功' : '复制失败';
|
|
|
511
|
+ this.toast(msg);
|
|
|
512
|
+ },
|
|
|
513
|
+ /**
|
|
|
514
|
+ * app分享
|
|
|
515
|
+ */
|
|
|
516
|
+ handleAppShare(shareUrl, shareTitle, shareContent, shareImg) {
|
|
|
517
|
+ let shareData = {
|
|
|
518
|
+ shareUrl,
|
|
|
519
|
+ shareTitle,
|
|
|
520
|
+ shareContent,
|
|
|
521
|
+ shareImg
|
|
|
522
|
+ };
|
|
|
523
|
+ appShare(shareData, res => {});
|
|
|
524
|
+ },
|
|
|
525
|
+
|
|
|
526
|
+
|
|
|
527
|
+
|
|
|
528
|
+ // 去掉字符串中的空格
|
|
|
529
|
+ trim(str) {
|
|
|
530
|
+ if (!str) {
|
|
|
531
|
+ return '';
|
|
|
532
|
+ }
|
|
|
533
|
+ return str.replace(/\s*/g, '');
|
|
|
534
|
+ },
|
|
|
535
|
+
|
|
|
536
|
+ // 判断两个对象是否相同
|
|
|
537
|
+ isObjectValueEqual(x, y) {
|
|
|
538
|
+ // 指向同一内存时
|
|
|
539
|
+ if (x === y) {
|
|
|
540
|
+ return true;
|
|
|
541
|
+ } else if (
|
|
|
542
|
+ typeof x == 'object' &&
|
|
|
543
|
+ x != null &&
|
|
|
544
|
+ typeof y == 'object' && y != null
|
|
|
545
|
+ ) {
|
|
|
546
|
+ if (Object.keys(x).length != Object.keys(y).length) return false;
|
|
|
547
|
+
|
|
|
548
|
+ for (var prop in x) {
|
|
|
549
|
+ if (y.hasOwnProperty(prop)) {
|
|
|
550
|
+ if (!this.isObjectValueEqual(x[prop], y[prop])) return false;
|
|
|
551
|
+ } else return false;
|
|
|
552
|
+ }
|
|
|
553
|
+
|
|
|
554
|
+ return true;
|
|
|
555
|
+ } else return false;
|
|
|
556
|
+ },
|
|
|
557
|
+
|
|
|
558
|
+ platformGroupFilter() {
|
|
|
559
|
+ let platformGroup = 'wechat';
|
|
|
560
|
+ // #ifdef H5
|
|
|
561
|
+ platformGroup = 'h5';
|
|
|
562
|
+ // #endif
|
|
|
563
|
+ // #ifdef MP-QQ
|
|
|
564
|
+ platformGroup = 'qqMp';
|
|
|
565
|
+ // #endif
|
|
|
566
|
+ // #ifdef MP-WEIXIN
|
|
|
567
|
+ platformGroup = 'wechatMp';
|
|
|
568
|
+ // #endif
|
|
|
569
|
+ // #ifdef MP-ALIPAY
|
|
|
570
|
+ platformGroup = 'aliMp';
|
|
|
571
|
+ // #endif
|
|
|
572
|
+ // #ifdef MP-QQ
|
|
|
573
|
+ platformGroup = 'qqMp';
|
|
|
574
|
+ // #endif
|
|
|
575
|
+ // #ifdef MP-BAIDU
|
|
|
576
|
+ platformGroup = 'baiduMp';
|
|
|
577
|
+ // #endif
|
|
|
578
|
+ // #ifdef APP-PLUS
|
|
|
579
|
+ switch (uni.getSystemInfoSync().platform) {
|
|
|
580
|
+ case 'android':
|
|
|
581
|
+ platformGroup = 'android';
|
|
|
582
|
+ break;
|
|
|
583
|
+ case 'ios':
|
|
|
584
|
+ platformGroup = 'ios';
|
|
|
585
|
+ break;
|
|
|
586
|
+ }
|
|
|
587
|
+ // #endif
|
|
|
588
|
+ return platformGroup;
|
|
|
589
|
+ }
|
|
|
590
|
+};
|