selectImage: function(type) {
var vm = this
uni.chooseImage({
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['camera', 'album'], //从相册选择
success: (e) => {
let list = []
uni.showLoading({
title: "正在上传..."
})
let imagePathArr = e.tempFilePaths
let keyname = (this.fileKeyName ? this.fileKeyName : 'file');
for (let i = 0; i < imagePathArr.length; i++) {
let params = {
filePath: imagePathArr[i],
name: keyname,
}
uploadFile({
...params
}).then((path) => {
if (!path) return;
if (type === 'wateringSystem') {
this.valiFormData.wxWateringSystem.push(imagePathArr[i]);
this.valiFormData.wateringSystemPath = [...this.valiFormData
.wateringSystemPath, path
]
} else if (type === 'instrumentPanel') {
this.valiFormData.wxInstrumentPanel.push(imagePathArr[i]);
this.valiFormData.instrumentPanelPath = [...this.valiFormData
.instrumentPanelPath, path
]
} else if (type === 'carLights') {
this.valiFormData.wxCarLights.push(imagePathArr[i]);
this.valiFormData.carLightsPath = [...this.valiFormData
.carLightsPath, path
]
} else if (type === 'tyre') {
this.valiFormData.wxtyre.push(imagePathArr[i]);
this.valiFormData.tyrePath = [...this.valiFormData.tyrePath,
path
]
}
uni.hideLoading();
})
}
}
})
},

2***@qq.com
- 发布:2024-04-23 14:52
- 更新:2024-04-23 14:52
- 阅读:117
0 个回复