dd.chooseImage({
//请求图片
count: 1, //上传图片张数限制
success: res => {
console.log("返回的文件信息为:");
console.log(res);
var filePaths = res.filePaths;
dd.getAuthCode({
success: function(res) {
console.log("filePath的值为:");
console.log(filePaths);
var authCode = res.authCode;
dd.uploadFile({
url:
app.data.globalData.url +
"public/index.php/api/activity/upload_img",
fileType: "image",
fileName: "img",
filePath: filePaths[0],
formData: {
authCode: authCode
},
success: res => {
var data = JSON.parse(res.data);
console.log("转换后的data为:");
console.log(data);
var img_url = data.data.img_url;
that.data.actImg = img_url;
that.data.isUp = 1; //同时将是否已经上传改为是
console.log("图片信息为:");
console.log(that.data.actImg);
that.setData({
coverImg: that.data.actImg,
isUp: 1
});
},
fail: function(res) {
dd.showToast({
content: "上传信息失败",
type: "fail"
});
}
});
},
fail: function(res) {
dd.showToast({
content: "获取用户权限信息失败",
type: "fail"
});
}
});
}
});
标签:console,log,img,上传,dd,程序开发,res,data,图片
From: https://blog.51cto.com/u_16085144/6217748