
这边按了文档要求先获取审批钉盘空间信息,获取spaceId。 然后再调用H5微应用上传附件到钉盘/从钉盘选择文件
uploadFile: function() {
var that = this;
uni.request({
data: {
userID: app.globalData.userID,
unionID: app.globalData.unionID,
},
url: app.globalData.rqurl +
'/InvoicingWeb/InvoicingController.aspx?method=getSpaceInfo',
success: function(res) {
var result = res.data;
if (result.isok) {
dd.biz.util.uploadAttachment({
image: {
multiple: true,
compress: true,
max: 9,
spaceId: result.obj
},
space: {
corpId: app.globalData.corpId,
spaceId: result.obj,
isCopy: 1,
max: 9
},
file: {
spaceId: result.obj,
max: 1
},
types: ["photo", "file"], //PC端支持["photo","file","space"]
onSuccess: function(result) {
alert(result.data[0].fileId);
that.infoData.annex.push({
fileId: result.data[0].fileId,
fileName: result.data[0].fileName,
spaceId: result.data[0].spaceId,
fileSize: result.data[0].fileSize,
fileType: result.data[0].fileType,
})
},
onFail: function(err) {
alert(JSON.stringify(err));
uni.hideLoading();
}
});
uni.hideLoading();
} else {
uni.showModal({
title: "提示",
content: result.remark,
showCancel: false,
confirmText: "确定"
});
uni.hideLoading();
}
}
});
},
public string getSpaceInfo()
{
Result rs = new Result();
var userID = Request["userID"];
var unionID = Request["unionID"];
var api = getTokenAndTicket();
//获取审批钉盘空间信息
var spaceUrl = "https://oapi.dingtalk.com/topapi/processinstance/cspace/info?access_token=" + api["access_token"];
var spaceJobject = PublicMethods.postRequest(spaceUrl, "user_id", userID);
var space_Id = JObject.Parse(spaceJobject)["result"]["space_id"];
rs.isok = true;
rs.obj = space_Id;
return JObject.FromObject(rs).ToString();
}
#endregion
上传图片跟文件都是显示
