@xtdev/xt-miniprogram-ui 1.2.51 → 1.2.52
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/xt-uploader/index.js +20 -2
- package/package.json +1 -1
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
// src/xt-uploader/index.js
|
|
2
2
|
const utils = require("./utils");
|
|
3
|
+
// 节流函数
|
|
4
|
+
function _throttle(fn, wait = 500, isImmediate = false){
|
|
5
|
+
var flag = true;
|
|
6
|
+
return function(){
|
|
7
|
+
if(flag == true){
|
|
8
|
+
var context = this
|
|
9
|
+
var args = arguments
|
|
10
|
+
flag = false
|
|
11
|
+
isImmediate && fn.apply(context,args)
|
|
12
|
+
setTimeout(() => {
|
|
13
|
+
!isImmediate && fn.apply(context,args)
|
|
14
|
+
flag = true
|
|
15
|
+
},wait)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
Component({
|
|
4
21
|
/**
|
|
5
22
|
* 组件的属性列表
|
|
@@ -78,7 +95,8 @@ Component({
|
|
|
78
95
|
this.triggerEvent("error", { errMsg });
|
|
79
96
|
},
|
|
80
97
|
// 点击上传
|
|
81
|
-
startTakePhoto() {
|
|
98
|
+
startTakePhoto: _throttle(function (e) {
|
|
99
|
+
console.log("onStartTakePhoto", e);
|
|
82
100
|
const _this = this;
|
|
83
101
|
const {
|
|
84
102
|
customUpload,
|
|
@@ -142,7 +160,7 @@ Component({
|
|
|
142
160
|
console.log("-----选取失败", error && error.errMsg);
|
|
143
161
|
},
|
|
144
162
|
});
|
|
145
|
-
},
|
|
163
|
+
}, 1500, true),
|
|
146
164
|
getSystemInfo() {
|
|
147
165
|
const environment = wx.getSystemInfoSync().environment || "wechat";
|
|
148
166
|
const platform = wx.getSystemInfoSync().platform;
|