|
@@ -13,6 +13,15 @@ Component({
|
|
accept: {
|
|
accept: {
|
|
type: String,
|
|
type: String,
|
|
value: "all"
|
|
value: "all"
|
|
|
|
+ },
|
|
|
|
+ /* 上传回调 */
|
|
|
|
+ uploadCallback: {
|
|
|
|
+ type: Function
|
|
|
|
+ },
|
|
|
|
+ /* 文件夹ID */
|
|
|
|
+ parentid: {
|
|
|
|
+ type: String,
|
|
|
|
+ value: wx.getStorageSync('siteP').appfolderid
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -33,6 +42,7 @@ Component({
|
|
// 初始化数据
|
|
// 初始化数据
|
|
let that = this,
|
|
let that = this,
|
|
data = this.requestType(event.detail.file[i]);
|
|
data = this.requestType(event.detail.file[i]);
|
|
|
|
+ data.content.filename = data.content.filename ? data.content.filename : `${Date.now()}.${data.content.filetype}`;
|
|
//发送请求
|
|
//发送请求
|
|
wx.getFileSystemManager().readFile({
|
|
wx.getFileSystemManager().readFile({
|
|
filePath: event.detail.file[i].url,
|
|
filePath: event.detail.file[i].url,
|
|
@@ -40,7 +50,6 @@ Component({
|
|
//返回临时文件路径
|
|
//返回临时文件路径
|
|
const fileData = result.data;
|
|
const fileData = result.data;
|
|
_Http.basic(data).then(res => {
|
|
_Http.basic(data).then(res => {
|
|
- console.log("res", res)
|
|
|
|
if (res.msg == "成功") {
|
|
if (res.msg == "成功") {
|
|
that.uploadFile(res.data, fileData)
|
|
that.uploadFile(res.data, fileData)
|
|
} else {
|
|
} else {
|
|
@@ -67,14 +76,13 @@ Component({
|
|
"content": {
|
|
"content": {
|
|
"filename": file.name,
|
|
"filename": file.name,
|
|
"filetype": ext,
|
|
"filetype": ext,
|
|
- "parentid": 2
|
|
|
|
|
|
+ "parentid": this.data.parentid
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
/* 上传成功反馈 */
|
|
/* 上传成功反馈 */
|
|
uploadFile(res, data) {
|
|
uploadFile(res, data) {
|
|
- console.log('asd', res, data)
|
|
|
|
- var that = this
|
|
|
|
|
|
+ var that = this;
|
|
wx.request({
|
|
wx.request({
|
|
url: res.uploadurl,
|
|
url: res.uploadurl,
|
|
method: "PUT",
|
|
method: "PUT",
|
|
@@ -83,7 +91,6 @@ Component({
|
|
'content-type': 'application/octet-stream'
|
|
'content-type': 'application/octet-stream'
|
|
},
|
|
},
|
|
success(a) {
|
|
success(a) {
|
|
- console.log("a", a)
|
|
|
|
_Http.basic({
|
|
_Http.basic({
|
|
"classname": "system.attachment.huawei.OBS",
|
|
"classname": "system.attachment.huawei.OBS",
|
|
"method": "uploadSuccess",
|
|
"method": "uploadSuccess",
|
|
@@ -91,30 +98,8 @@ Component({
|
|
"serialfilename": res.serialfilename
|
|
"serialfilename": res.serialfilename
|
|
}
|
|
}
|
|
}).then(s => {
|
|
}).then(s => {
|
|
- return console.log(s);
|
|
|
|
- if (res.msg != "成功") return;
|
|
|
|
- let fileList = that.data.fileList;
|
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
|
- let arr = {
|
|
|
|
- url: res.data[i].fobsurl,
|
|
|
|
- ownerid: res.data[i].ownerid,
|
|
|
|
- tattachmentid: res.data[i].tattachmentid,
|
|
|
|
- ownertable: res.data[i].ownertable,
|
|
|
|
- fdocument: res.data[i].fdocument,
|
|
|
|
- }
|
|
|
|
- fileList.push(arr)
|
|
|
|
- };
|
|
|
|
- // 用户头像 先删除 在修改
|
|
|
|
- if (that.data.upType == "userImage" && fileList.length >= 2) {
|
|
|
|
- that.dleeteDealWith(0);
|
|
|
|
- }
|
|
|
|
- that.setData({
|
|
|
|
- fileList
|
|
|
|
- });
|
|
|
|
- /* 返回数据 */
|
|
|
|
- that.triggerEvent("imageChange", {
|
|
|
|
- fileList
|
|
|
|
- })
|
|
|
|
|
|
+ if (s.msg != "成功") return;
|
|
|
|
+ that.triggerEvent("uploadCallback", s.data.attachmentids);
|
|
}).catch(err => {
|
|
}).catch(err => {
|
|
console.log(err)
|
|
console.log(err)
|
|
})
|
|
})
|