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
上传图片跟文件都是显示
看到代码中有几个需要排查的地方:
app.globalData.rqurl:这个值是从哪里获取的,是否正确?
app.globalData.corpId:这个值是否正确?
dd.biz.util.uploadAttachment:该方法是否执行成功?
result.isok:该变量是否为 true?
result.obj:该变量是否正确?
rs.isok:该变量是否为 true?
rs.obj:该变量是否正确?
可以从这些方面入手排查。
以下是实现钉钉【发起审批实例】上传文件到钉盘的步骤:
获取钉钉access_token:首先需要使用钉钉开放平台的接口获取access_token。
上传文件到钉盘:使用钉钉钉盘接口进行文件上传,将文件内容作为请求体发送给钉钉服务器,并通过参数指定文件名和文件夹路径。
使用C# .Net处理后端:可以使用C# .Net进行文件的读取和处理,对文件内容进行操作,将处理结果保存在本地。
注意:在使用钉钉的接口前,需要先在钉钉开放平台注册应用,并获取app_key和app_secret。需要对数据的安全性和隐私性进行考虑。