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
|
| $(function(){
| //图片预览
| $(".imgPreview").click(function() {
| var group = $(this).attr('data-group');
| var thissrc = $(this).attr('data-src');
| var imgarr = [];
| var startPosition = 0;
| $(".imgPreview[data-group='"+group+"']").each(function(index){
| imgsrc = $(this).attr('data-src');
| if(imgsrc){
| imgarr.push(imgsrc);
| if(thissrc==imgsrc){
| startPosition = index;
| }
| }
| })
| vant.ImagePreview({
| images:imgarr,
| startPosition: startPosition,
| });
| });
| })
| // 加载框
| function showLoading(msg = '加载中') {
| vant.Toast.loading({
| message: msg,
| duration: 0,
| forbidClick: true // 是否禁止背景点击
| });
| }
| // 关闭加载框
| function hideLoading() {
| vant.Toast.clear();
| }
| // 轻提示
| function showToast(msg = '', duration = 2, func) {
| vant.Toast({
| message: msg,
| duration: duration * 1000,
| forbidClick: true,
| onClose: function() {
| typeof func === 'function' && func();
| }
| });
| }
| // 待确定按钮的提示框
| function showModal(msg = '', func, confirmText = '确定') {
| vant.Dialog.alert({
| title: '温馨提示',
| message: msg, // 提示内容
| theme: 'round',
| confirmButtonText: confirmText // 确定按钮文本
| }).then(function(){
| typeof func === 'function' && func();
| })
| }
| // 询问框
| function showConfirm(msg, success, cancelText = '取消', confirmText = '确定', cancel) {
| vant.Dialog.confirm({
| title: '温馨提示',
| message: msg, // 提示内容
| theme: 'round',
| confirmButtonText: confirmText, // 确定按钮文本
| cancelButtonText: cancelText // 取消按钮文本
| }).then(function(){
| typeof success === 'function' && success();
| }).catch(function(){
| typeof cancel === 'function' && cancel();
| })
| }
| // 获取参数
| function getUrlKey(name){
| return decodeURIComponent((new RegExp('[?|&]'+name+'='+'([^&;]+?)(&|#|;|$)').exec(location.href)||[,""])[1].replace(/\+/g,'%20'))||null;
| }
|
|