Jacob
2026-10-13 95f1819b8e2a9bd5b2b81dc2c80e48899afc917c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
import {
   TOKENNAME,
   HTTP_REQUEST_URL
} from '../config/app.js';
import {
   HTTP_ADMIN_URL
} from '@/config/app.js';
import store from '../store';
import {
   pathToBase64
} from '@/plugin/image-tools/index.js';
export default {
   /**
    * opt  object | string
    * to_url object | string
    * 例:
    * this.Tips('/pages/test/test'); 跳转不提示
    * this.Tips({title:'提示'},'/pages/test/test'); 提示并跳转
    * this.Tips({title:'提示'},{tab:1,url:'/pages/index/index'}); 提示并跳转值table上
    * tab=1 一定时间后跳转至 table上
    * tab=2 一定时间后跳转至非 table上
    * tab=3 一定时间后返回上页面
    * tab=4 关闭所有页面跳转至非table上
    * tab=5 关闭当前页面跳转至table上
    */
   Tips: function(opt, to_url) {
       if (typeof opt == 'string') {
           to_url = opt;
           opt = {};
       }
       let title = opt.title || '',
           icon = opt.icon || 'none',
           endtime = opt.endtime || 3000,
           success = opt.success;
       let app = getApp();
       if ((typeof title) !== 'string' && (typeof title) !== 'number') {
           title = null;
       }
       console.log(app);
       console.log('tips content', title);
       if (title) {
           if (!app) {
               console.log('showToast')
               uni.showToast({
                   title: title,
                   icon: icon,
                   duration: endtime,
                   contentTrim: false,
                   success: success ? success : null
               })
           } else {
               console.log('showTips')
               uni.$emit("showTips", {
                   title: title,
                   icon: icon,
                   duration: endtime,
                   contentTrim: false,
                   success: success ? success : null
               });
           }
       }
       if (to_url != undefined) {
           if (typeof to_url == 'object') {
               let tab = to_url.tab || 1,
                   url = to_url.url || '';
               switch (tab) {
                   case 1:
                       //一定时间后跳转至 table
                       setTimeout(function() {
                           uni.switchTab({
                               url: url
                           })
                       }, endtime);
                       break;
                   case 2:
                       //跳转至非table页面
                       setTimeout(function() {
                           uni.navigateTo({
                               url: url,
                           })
                       }, endtime);
                       break;
                   case 3:
                       //返回上页面
                       setTimeout(function() {
                           // #ifndef H5
                           uni.navigateBack({
                               delta: parseInt(url),
                           })
                           // #endif
                           // #ifdef H5
                           history.back();
                           // #endif
                       }, endtime);
                       break;
                   case 4:
                       //关闭当前所有页面跳转至非table页面
                       setTimeout(function() {
                           uni.reLaunch({
                               url: url,
                           })
                       }, endtime);
                       break;
                   case 5:
                       //关闭当前页面跳转至非table页面
                       setTimeout(function() {
                           uni.redirectTo({
                               url: url,
                           })
                       }, endtime);
                       break;
               }
 
           } else if (typeof to_url == 'function') {
               setTimeout(function() {
                   to_url && to_url();
               }, endtime);
           } else {
               //没有提示时跳转不延迟
               setTimeout(function() {
                   uni.navigateTo({
                       url: to_url,
                   })
               }, title ? endtime : 0);
           }
       }
   },
   /**
    * 移除数组中的某个数组并组成新的数组返回
    * @param array array 需要移除的数组
    * @param int index 需要移除的数组的键值
    * @param string | int 值
    * @return array
    * 
    */
   ArrayRemove: function(array, index, value) {
       const valueArray = [];
       if (array instanceof Array) {
           for (let i = 0; i < array.length; i++) {
               if (typeof index == 'number' && array[index] != i) {
                   valueArray.push(array[i]);
               } else if (typeof index == 'string' && array[i][index] != value) {
                   valueArray.push(array[i]);
               }
           }
       }
       return valueArray;
   },
   /**
    * 生成海报获取文字
    * @param string text 为传入的文本
    * @param int num 为单行显示的字节长度
    * @return array 
    */
   textByteLength: function(text, num) {
 
       let strLength = 0;
       let rows = 1;
       let str = 0;
       let arr = [];
       for (let j = 0; j < text.length; j++) {
           if (text.charCodeAt(j) > 255) {
               strLength += 2;
               if (strLength > rows * num) {
                   strLength++;
                   arr.push(text.slice(str, j));
                   str = j;
                   rows++;
               }
           } else {
               strLength++;
               if (strLength > rows * num) {
                   arr.push(text.slice(str, j));
                   str = j;
                   rows++;
               }
           }
       }
       arr.push(text.slice(str, text.length));
       return [strLength, arr, rows] //  [处理文字的总字节长度,每行显示内容的数组,行数]
   },
 
   /**
    * 获取分享海报
    * @param array arr2 海报素材
    * @param string store_name 素材文字
    * @param string price 价格
    * @param string ot_price 原始价格
    * @param function successFn 回调函数
    * 
    * store_name, price, careBean, ot_price, 
    */
   
   PosterCanvas: function(arr2, info, successFn) {
       let that = this;
       const ctx = uni.createCanvasContext('firstCanvas');
       ctx.clearRect(0, 0, 0, 0);
       /**
        * 只能获取合法域名下的图片信息,本地调试无法获取
        * 
        */
       ctx.fillStyle = '#fff';
       ctx.fillRect(0, 0, 750, 1150);
       uni.getImageInfo({
           src: arr2[0],
           success: function(res) {
               const WIDTH = res.width;
               const HEIGHT = res.height;
               // ctx.drawImage(arr2[0], 0, 0, WIDTH, 1050);
               ctx.drawImage(arr2[1], 0, 0, WIDTH, WIDTH);
               ctx.save();
               let r = 110;
               let d = r * 2;
               let cx = 480;
               let cy = 790;
               ctx.arc(cx + r, cy + r, r, 0, 2 * Math.PI);
               // ctx.clip();
               ctx.drawImage(arr2[2], cx, cy, d, d);
               ctx.restore();
               const CONTENT_ROW_LENGTH = 20;
               let [contentLeng, contentArray, contentRows] = that.textByteLength(info.storeName,
                   CONTENT_ROW_LENGTH);
               if (contentRows > 2) {
                   contentRows = 2;
                   let textArray = contentArray.slice(0, 2);
                   textArray[textArray.length - 1] += '……';
                   contentArray = textArray;
               }
               ctx.setTextAlign('left');
               ctx.setFontSize(36);
               ctx.setFillStyle('#000');
               // let contentHh = 36 * 1.5;
               let contentHh = 36;
               for (let m = 0; m < contentArray.length; m++) {
                   // ctx.fillText(contentArray[m], 50, 1000 + contentHh * m,750);
                   if (m) {
                       ctx.fillText(contentArray[m], 50, 1000 + contentHh * m + 18, 1100);
                   } else {
                       ctx.fillText(contentArray[m], 50, 1000 + contentHh * m, 1100);
                   }
               }
               var underline = function(ctx, text, x, y, size, color, thickness, offset) {
                   var width = ctx.measureText(text).width;
                   switch (ctx.textAlign) {
                       case "center":
                           x -= (width / 2);
                           break;
                       case "right":
                           x -= width;
                           break;
                   }
 
                   y += size + offset;
 
                   ctx.beginPath();
                   ctx.strokeStyle = color;
                   ctx.lineWidth = thickness;
                   ctx.moveTo(x, y);
                   ctx.lineTo(x + width, y);
                   ctx.stroke();
               }
               ctx.textBaseline = 'middle';
               let w = 0;
               console.log('drawcanvs info',info);
               function toThousands(num) {
                   if (num < 1000) return num;
                   if (Number.isInteger(num)) {
                       return String(num).replace(/(?!^)(?=(\d{3})+$)/g, ',')
                   } else {
                       return String(num).replace(/(?!^)(?=(\d{3})+\.)/g, ',')
                   }
               }
               if (info.selectPrice > 0) {
                   ctx.setTextAlign('left')
                   ctx.setFontSize(42);
                   ctx.setFillStyle('#0265CA');
                   ctx.fillText('¥' + info.selectPrice, 40, 800 + contentHh);
                   w = ctx.measureText('¥' + info.selectPrice).width + 10;
               }
               if (info.selectCareBeanNumber > 0) {
                   ctx.setTextAlign('left')
                   ctx.setFontSize(42);
                   ctx.setFillStyle('#0265CA');
                   ctx.fillText((info.selectCareBeanNumber>0&&info.selectPrice>0?'+':'')+toThousands(info.selectCareBeanNumber)  + '悦养豆',
                       40, (info.selectPrice > 0?850:800) + contentHh);
                   if(!info.selectPrice||info.selectPrice <=0){
                       w = ctx.measureText(toThousands(info.selectCareBeanNumber) + '悦养豆').width + 10;
                   }
               }
               
               if(info.topLabel){
                   ctx.setTextAlign('left')
                   ctx.setFontSize(22);
                   ctx.setFillStyle('#EAF0FF');
                   let w2=ctx.measureText(info.topLabel).width;
                   ctx.fillRect(40 + w, 800 + contentHh - 21, w2 + 30, 42);
                   ctx.setFillStyle('#016DCC');
                   ctx.fillText(info.topLabel, 40 + w + 15, 800 + contentHh);
               }
               if(info.bottomLabel&&!(info.selectPrice==info.bottomNumber)){
                   ctx.setTextAlign('left')
                   ctx.setFontSize(22);
                   ctx.setFillStyle('#999');
                   let top = 906;
                   if (info.selectCareBeanNumber > 0 && info.selectPrice > 0) {
                       top = 906;
                   } else {
                       top = 856;
                   }
                   ctx.fillText(info.bottomLabel, 50, top + contentHh);
                   underline(ctx,info.bottomLabel, 55, top, 36, '#999', 2, 0)
               }
               
               ctx.setTextAlign('left')
               ctx.setFontSize(28);
               ctx.setFillStyle('#999');
               ctx.fillText('长按或扫描查看', 490, 1030 + contentHh);
               ctx.draw(true, function() {
                   uni.canvasToTempFilePath({
                       canvasId: 'firstCanvas',
                       fileType: 'png',
                       destWidth: WIDTH,
                       destHeight: HEIGHT,
                       success: function(res) {
                           // uni.hideLoading();
                           successFn && successFn(res.tempFilePath);
                       }
                   })
               });
           },
           fail: function(err) {
               console.log('失败', err)
               uni.hideLoading();
               that.Tips({
                   title: '无法获取图片信息'
               });
           }
       })
   },
   /**
    * 绘制文字自动换行
    * @param array arr2 海报素材
    * @param Number x , y 绘制的坐标
    * @param Number maxWigth 绘制文字的宽度
    * @param Number lineHeight 行高
    * @param Number maxRowNum 最大行数
    */
   canvasWraptitleText(canvas, text, x, y, maxWidth, lineHeight, maxRowNum) {
       if (typeof text != 'string' || typeof x != 'number' || typeof y != 'number') {
           return;
       }
       // canvas.font = '20px Bold PingFang SC'; //绘制文字的字号和大小
       // 字符分隔为数组
       var arrText = text.split('');
       var line = '';
       var rowNum = 1
       for (var n = 0; n < arrText.length; n++) {
           var testLine = line + arrText[n];
           var metrics = canvas.measureText(testLine);
           var testWidth = metrics.width;
           if (testWidth > maxWidth && n > 0) {
               if (rowNum >= maxRowNum) {
                   var arrLine = testLine.split('')
                   arrLine.splice(-9)
                   var newTestLine = arrLine.join("")
                   newTestLine += "..."
                   canvas.fillText(newTestLine, x, y);
                   //如果需要在省略号后面添加其他的东西,就在这个位置写(列如添加扫码查看详情字样)
                   //canvas.fillStyle = '#2259CA';
                   //canvas.fillText('扫码查看详情',x + maxWidth-90, y);
                   return
               }
               canvas.fillText(line, x, y);
               line = arrText[n];
               y += lineHeight;
               rowNum += 1
           } else {
               line = testLine;
           }
       }
       canvas.fillText(line, x, y);
   },
   /**
    * 获取活动分享海报
    * @param array arr2 海报素材
    * @param string storeName 素材文字
    * @param string price 价格
    * @param string people 人数
    * @param string count 剩余人数
    * @param function successFn 回调函数
    */
   activityCanvas: function(arrImages, storeName, price, people, count, num, successFn) {
       let that = this;
       let rain = 2;
       const context = uni.createCanvasContext('activityCanvas');
       context.clearRect(0, 0, 0, 0);
       /**
        * 只能获取合法域名下的图片信息,本地调试无法获取
        * 
        */
       context.fillStyle = '#fff';
       context.fillRect(0, 0, 594, 850);
       uni.getImageInfo({
           src: arrImages[0],
           success: function(res) {
               context.drawImage(arrImages[0], 0, 0, 594, 850);
               context.setFontSize(14 * rain);
               context.setFillStyle('#333333');
               that.canvasWraptitleText(context, storeName, 110 * rain, 110 * rain, 230 * rain, 30 *
                   rain, 1)
               context.drawImage(arrImages[2], 68 * rain, 194 * rain, 160 * rain, 160 * rain);
               context.save();
 
               context.setFontSize(14 * rain);
               context.setFillStyle('#fc4141');
               context.fillText('¥', 157 * rain, 145 * rain);
 
               context.setFontSize(24 * rain);
               context.setFillStyle('#fc4141');
               context.fillText(price, 170 * rain, 145 * rain);
 
               context.setFontSize(10 * rain);
               context.setFillStyle('#fff');
               context.fillText(people, 118 * rain, 143 * rain);
 
 
               context.setFontSize(12 * rain);
               context.setFillStyle('#666666');
               context.setTextAlign('center');
               context.fillText(count, (167 - num) * rain, 166 * rain);
 
               that.handleBorderRect(context, 27 * rain, 94 * rain, 75 * rain, 75 * rain, 6 * rain);
               context.clip();
               context.drawImage(arrImages[1], 27 * rain, 94 * rain, 75 * rain, 75 * rain);
               context.draw(true, function() {
                   uni.canvasToTempFilePath({
                       canvasId: 'activityCanvas',
                       fileType: 'png',
                       destWidth: 594,
                       destHeight: 850,
                       success: function(res) {
                           // uni.hideLoading();
                           successFn && successFn(res.tempFilePath);
                       }
                   })
               });
 
           },
           fail: function(err) {
               console.log('失败', err)
               uni.hideLoading();
               that.Tips({
                   title: '无法获取图片信息'
               });
           }
       })
   },
 
   /**
    * 图片圆角设置
    * @param string x x轴位置
    * @param string y y轴位置
    * @param string w 图片宽
    * @param string y 图片高
    * @param string r 圆角值
    */
   handleBorderRect(ctx, x, y, w, h, r) {
       ctx.beginPath();
       // 左上角
       ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI);
       ctx.moveTo(x + r, y);
       ctx.lineTo(x + w - r, y);
       ctx.lineTo(x + w, y + r);
       // 右上角
       ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI);
       ctx.lineTo(x + w, y + h - r);
       ctx.lineTo(x + w - r, y + h);
       // 右下角
       ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI);
       ctx.lineTo(x + r, y + h);
       ctx.lineTo(x, y + h - r);
       // 左下角
       ctx.arc(x + r, y + h - r, r, 0.5 * Math.PI, Math.PI);
       ctx.lineTo(x, y + r);
       ctx.lineTo(x + r, y);
 
       ctx.fill();
       ctx.closePath();
   },
 
   /*
    * 单图上传
    * @param object opt
    * @param callable successCallback 成功执行方法 data 
    * @param callable errorCallback 失败执行方法 
    */
   uploadImageOne: function(opt, successCallback, errorCallback) {
       let that = this;
       if (typeof opt === 'string') {
           let url = opt;
           opt = {};
           opt.url = url;
       }
       let count = opt.count || 1,
           sizeType = opt.sizeType || ['compressed'],
           sourceType = opt.sourceType || ['album', 'camera'],
           is_load = opt.is_load || true,
           uploadUrl = opt.url || '',
           inputName = opt.name || 'pics',
           pid = opt.pid,
           model = opt.model;
       if (opt.isWxPath) {
           //启动上传等待中...
           uni.showLoading({
               title: '图片上传中',
           });
           let urlPath = HTTP_ADMIN_URL + '/api/admin/upload/image' + "?model=" + model + "&pid=" + pid;
           urlPath=HTTP_REQUEST_URL+'/api/front/user/upload/image' + "?model=" + model +"&pid=" + pid;
           uni.uploadFile({
               url: urlPath,
               filePath: opt.filePath,
               name: inputName,
               header: {
                   // #ifdef MP
                   "Content-Type": "multipart/form-data",
                   // #endif
                   [TOKENNAME]: store.state.app.token
               },
               success: function(res) {
                   uni.hideLoading();
                   if (res.statusCode == 403) {
                       that.Tips({
                           title: res.data
                       });
                   } else {
                       let data = res.data ? JSON.parse(res.data) : {};
                       if (data.code == 200) {
                           successCallback && successCallback(data)
                       } else {
                           errorCallback && errorCallback(data);
                           that.Tips({
                               title: data.message
                           });
                       }
                   }
               },
               fail: function(res) {
                   console.log(res);
                   uni.hideLoading();
                   that.Tips({
                       title: '上传图片失败'
                   });
               }
           })
       } else {
           uni.chooseImage({
               count: count, //最多可以选择的图片总数  
               sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有  
               sourceType: sourceType, // 可以指定来源是相册还是相机,默认二者都有  
               success: function(res) {
                   //启动上传等待中...  
                   uni.showLoading({
                       title: '图片上传中',
                   });
                   let urlPath = HTTP_ADMIN_URL + '/api/admin/upload/image' + "?model=" + model +
                       "&pid=" + pid;
                   urlPath=HTTP_REQUEST_URL+'/api/front/user/upload/image' + "?model=" + model +"&pid=" + pid;
                   let localPath = res.tempFilePaths[0];
                   uni.uploadFile({
                       url: urlPath,
                       filePath: localPath,
                       name: inputName,
                       header: {
                           // #ifdef MP
                           "Content-Type": "multipart/form-data",
                           // #endif
                           [TOKENNAME]: store.state.app.token
                       },
                       success: function(res) {
                           uni.hideLoading();
                           if (res.statusCode == 403) {
                               that.Tips({
                                   title: res.data
                               });
                           } else {
                               let data = res.data ? JSON.parse(res.data) : {};
                               if (data.code == 200) {
                                   data.data.localPath = localPath;
                                   successCallback && successCallback(data)
                               } else {
                                   errorCallback && errorCallback(data);
                                   that.Tips({
                                       title: data.message
                                   });
                               }
                           }
                       },
                       fail: function(res) {
                           uni.hideLoading();
                           that.Tips({
                               title: '上传图片失败'
                           });
                       }
                   })
                   // pathToBase64(res.tempFilePaths[0])
                   //     .then(imgBase64 => {
                   //         console.log(imgBase64);
 
                   //     })
                   //     .catch(error => {
                   //         console.error(error)
                   //     })
               }
           })
       }
 
   },
   /**
    * 处理服务器扫码带进来的参数
    * @param string param 扫码携带参数
    * @param string k 整体分割符 默认为:&
    * @param string p 单个分隔符 默认为:=
    * @return object
    * 
    */
   // #ifdef MP
   getUrlParams: function(param, k, p) {
       if (typeof param != 'string') return {};
       k = k ? k : '&'; //整体参数分隔符
       p = p ? p : '='; //单个参数分隔符
       var value = {};
       if (param.indexOf(k) !== -1) {
           param = param.split(k);
           for (var val in param) {
               if (param[val].indexOf(p) !== -1) {
                   var item = param[val].split(p);
                   value[item[0]] = item[1];
               }
           }
       } else if (param.indexOf(p) !== -1) {
           var item = param.split(p);
           value[item[0]] = item[1];
       } else {
           return param;
       }
       return value;
   },
   /**根据格式组装公共参数
    * @param {Object} value
    */
   formatMpQrCodeData(value) {
       let values = value.split(',');
       let result = {};
       if (values.length === 2) {
           let v1 = values[0].split(":");
           if (v1[0] === 'pid') {
               result.spread = v1[1];
           } else {
               result.id = v1[1];
           }
           let v2 = values[1].split(":");
           if (v2[0] === 'pid') {
               result.spread = v2[1];
           } else {
               result.id = v2[1];
           }
       } else {
           result = values[0].split(":")[1];
       }
       return result;
   },
   // #endif
   /*
    * 合并数组
    */
   SplitArray(list, sp) {
       if (typeof list != 'object') return [];
       if (sp === undefined) sp = [];
       for (var i = 0; i < list.length; i++) {
           sp.push(list[i]);
       }
       return sp;
   },
   trim(str) {
       return String.prototype.trim.call(str);
   },
   $h: {
       //除法函数,用来得到精确的除法结果
       //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。
       //调用:$h.Div(arg1,arg2)
       //返回值:arg1除以arg2的精确结果
       Div: function(arg1, arg2) {
           arg1 = parseFloat(arg1);
           arg2 = parseFloat(arg2);
           var t1 = 0,
               t2 = 0,
               r1, r2;
           try {
               t1 = arg1.toString().split(".")[1].length;
           } catch (e) {}
           try {
               t2 = arg2.toString().split(".")[1].length;
           } catch (e) {}
           r1 = Number(arg1.toString().replace(".", ""));
           r2 = Number(arg2.toString().replace(".", ""));
           return this.Mul(r1 / r2, Math.pow(10, t2 - t1));
       },
       //加法函数,用来得到精确的加法结果
       //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。
       //调用:$h.Add(arg1,arg2)
       //返回值:arg1加上arg2的精确结果
       Add: function(arg1, arg2) {
           arg2 = parseFloat(arg2);
           var r1, r2, m;
           try {
               r1 = arg1.toString().split(".")[1].length
           } catch (e) {
               r1 = 0
           }
           try {
               r2 = arg2.toString().split(".")[1].length
           } catch (e) {
               r2 = 0
           }
           m = Math.pow(100, Math.max(r1, r2));
           return (this.Mul(arg1, m) + this.Mul(arg2, m)) / m;
       },
       //减法函数,用来得到精确的减法结果
       //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的减法结果。
       //调用:$h.Sub(arg1,arg2)
       //返回值:arg1减去arg2的精确结果
       Sub: function(arg1, arg2) {
           arg1 = parseFloat(arg1);
           arg2 = parseFloat(arg2);
           var r1, r2, m, n;
           try {
               r1 = arg1.toString().split(".")[1].length
           } catch (e) {
               r1 = 0
           }
           try {
               r2 = arg2.toString().split(".")[1].length
           } catch (e) {
               r2 = 0
           }
           m = Math.pow(10, Math.max(r1, r2));
           //动态控制精度长度
           n = (r1 >= r2) ? r1 : r2;
           return ((this.Mul(arg1, m) - this.Mul(arg2, m)) / m).toFixed(n);
       },
       //乘法函数,用来得到精确的乘法结果
       //说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
       //调用:$h.Mul(arg1,arg2)
       //返回值:arg1乘以arg2的精确结果
       Mul: function(arg1, arg2) {
           arg1 = parseFloat(arg1);
           arg2 = parseFloat(arg2);
           var m = 0,
               s1 = arg1.toString(),
               s2 = arg2.toString();
           try {
               m += s1.split(".")[1].length
           } catch (e) {}
           try {
               m += s2.split(".")[1].length
           } catch (e) {}
           return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
       },
   },
   // 获取地理位置;
   $L: {
       async getLocation() {
           // #ifdef MP-WEIXIN || MP-TOUTIAO || MP-QQ
           let status = await this.getSetting();
           if (status === 2) {
               this.openSetting();
               return;
           }
           // #endif
 
           this.doGetLocation();
       },
       doGetLocation() {
           uni.getLocation({
               success: (res) => {
                   uni.removeStorageSync('CACHE_LONGITUDE');
                   uni.removeStorageSync('CACHE_LATITUDE');
                   uni.setStorageSync('CACHE_LONGITUDE', res.longitude);
                   uni.setStorageSync('CACHE_LATITUDE', res.latitude);
               },
               fail: (err) => {
                   // #ifdef MP-BAIDU
                   if (err.errCode === 202 || err.errCode === 10003) { // 202模拟器 10003真机 user deny
                       this.openSetting();
                   }
                   // #endif
                   // #ifndef MP-BAIDU
                   if (err.errMsg.indexOf("auth deny") >= 0) {
                       uni.showToast({
                           title: "访问位置被拒绝"
                       })
                   } else {
                       uni.showToast({
                           title: err.errMsg
                       })
                   }
                   // #endif
               }
           })
       },
       getSetting: function() {
           return new Promise((resolve, reject) => {
               uni.getSetting({
                   success: (res) => {
                       if (res.authSetting['scope.userLocation'] === undefined) {
                           resolve(0);
                           return;
                       }
                       if (res.authSetting['scope.userLocation']) {
                           resolve(1);
                       } else {
                           resolve(2);
                       }
                   }
               });
           });
       },
       openSetting: function() {
           uni.openSetting({
               success: (res) => {
                   if (res.authSetting && res.authSetting['scope.userLocation']) {
                       this.doGetLocation();
                   }
               },
               fail: (err) => {}
           })
       },
       async checkPermission() {
           let status = permision.isIOS ? await permision.requestIOS('location') :
               await permision.requestAndroid('android.permission.ACCESS_FINE_LOCATION');
 
           if (status === null || status === 1) {
               status = 1;
           } else if (status === 2) {
               uni.showModal({
                   content: "系统定位已关闭",
                   confirmText: "确定",
                   showCancel: false,
                   success: function(res) {}
               })
           } else if (status.code) {
               uni.showModal({
                   content: status.message
               })
           } else {
               uni.showModal({
                   content: "需要定位权限",
                   confirmText: "设置",
                   success: function(res) {
                       if (res.confirm) {
                           permision.gotoAppSetting();
                       }
                   }
               })
           }
           return status;
       },
   },
 
   toStringValue: function(obj) {
       if (obj instanceof Array) {
           var arr = [];
           for (var i = 0; i < obj.length; i++) {
               arr[i] = toStringValue(obj[i]);
           }
           return arr;
       } else if (typeof obj == 'object') {
           for (var p in obj) {
               obj[p] = toStringValue(obj[p]);
           }
       } else if (typeof obj == 'number') {
           obj = obj + '';
       }
       return obj;
   },
 
   /*
    * 替换域名
    */
   setDomain: function(url) {
       url = url ? url.toString() : '';
       if (url.indexOf("https://") > -1) return url;
       else return url.replace('http://', 'https://');
   },
 
 
 
   /**
    * 姓名除了姓显示其他
    */
   formatName: function(str) {
       return str.substr(0, 1) + new Array(str.length).join('*');
   },
   setQueryString: function(json) {
       var _str = "";
       for (var o in json) {
           if (json[o] != -1) {
               _str += o + "=" + json[o] + "&";
           }
       }
       return _str.substring(0, _str.length - 1);
   },
   setShareBelong: function(belongJson) {
       let json = {};
       /**
           代理人工号,代理人渠道,代理人公司,代理人支公司,所在机构
        */
       if (belongJson && belongJson.agentNo) {
           json['agentNo'] = belongJson.agentNo || ''; //归属营销员编号
           json['channel'] = belongJson.channel || ''; //归属营销员渠道
           json['companyCode'] = belongJson.companyCode || ''; //归属分公司编号
           json['branchCode'] = belongJson.branchCode || ''; //代理人支公司
           json['subCode'] = belongJson.subCode || ''; //归属营销员机构编码
       }
       return this.setQueryString(json);
   },
   setShareBelongObj: function() {
       let belongJson = store.state.app.belong;
       let json = {};
       /**
           代理人工号,代理人渠道,代理人公司,代理人支公司,所在机构
        */
       if (belongJson && belongJson.agentNo) {
           json['agentNo'] = belongJson.agentNo; //归属营销员编号
           json['channel'] = belongJson.channel; //归属营销员渠道
           json['companyCode'] = belongJson.companyCode; //归属分公司编号
           json['branchCode'] = belongJson.branchCode; //代理人支公司
           json['subCode'] = belongJson.subCode; //归属营销员机构编码
       }
       return json;
   },
}