|
@@ -3,6 +3,7 @@ import Taro from "@tarojs/taro";
|
3
|
3
|
import { View, Image, Video } from "@tarojs/components";
|
4
|
4
|
import { Loading } from "@antmjs/vantui";
|
5
|
5
|
import { uploadFileBase64, uploadFiles } from "@/utils/request";
|
|
6
|
+import { promise } from "@/utils/promise";
|
6
|
7
|
import icon from "@/assets/icons/uploader.png";
|
7
|
8
|
import closeIcon from "@/assets/icons/close.png";
|
8
|
9
|
import style from "./style.modules.less";
|
|
@@ -22,23 +23,32 @@ export default (props) => {
|
22
|
23
|
setLoading(true);
|
23
|
24
|
|
24
|
25
|
// eslint-disable-next-line no-undef
|
25
|
|
- if (IS_APP_CLIENT) {
|
26
|
|
- // eslint-disable-next-line no-undef
|
27
|
|
- SmartCity.chooseImage({
|
28
|
|
- count : 1 // 图片张数
|
29
|
|
- },function(res){
|
30
|
|
- console.log("--------上传图片---------", res);
|
31
|
|
- const base64 = res[0].imageData;
|
32
|
|
- const fileName = res[0].name;
|
33
|
|
- const fileType = res[0].type;
|
34
|
|
-
|
35
|
|
- uploadFileBase64(base64, fileName, fileType).then(resp => {
|
36
|
|
- setLoading(false);
|
37
|
|
- onChange((value || []).concat(resp));
|
38
|
|
- }).catch((err) => {
|
39
|
|
- console.error(err);
|
40
|
|
- setLoading(false);
|
41
|
|
- });
|
|
26
|
+ if (IS_APP_CLIENT) {
|
|
27
|
+ const p = promise((resolve, reject) => {
|
|
28
|
+ // eslint-disable-next-line no-undef
|
|
29
|
+ SmartCity.chooseImage({
|
|
30
|
+ count : 1 // 图片张数
|
|
31
|
+ },function(res){
|
|
32
|
+ console.log("--------上传图片---------", res);
|
|
33
|
+ const base64 = res[0].imageData;
|
|
34
|
+ const fileName = res[0].name;
|
|
35
|
+ const fileType = res[0].type;
|
|
36
|
+
|
|
37
|
+ uploadFileBase64(base64, fileName, fileType).then(resp => {
|
|
38
|
+ resolve(resp);
|
|
39
|
+ // onChange((value || []).concat(resp));
|
|
40
|
+ }).catch((err) => {
|
|
41
|
+ console.error(err);
|
|
42
|
+ reject(err);
|
|
43
|
+ });
|
|
44
|
+ });
|
|
45
|
+ }, 60 * 1000);
|
|
46
|
+
|
|
47
|
+ p.then((resp) => {
|
|
48
|
+ setLoading(false);
|
|
49
|
+ onChange((value || []).concat(resp));
|
|
50
|
+ }).catch(() => {
|
|
51
|
+ setLoading(false);
|
42
|
52
|
});
|
43
|
53
|
} else {
|
44
|
54
|
Taro.chooseMedia({
|