|
@@ -11,7 +11,11 @@ Component({
|
|
|
fileList: {
|
|
|
type: Array
|
|
|
},
|
|
|
- /* 上传类型 */
|
|
|
+ /* 父页面传递图片 */
|
|
|
+ attinfos: {
|
|
|
+ type: Object
|
|
|
+ },
|
|
|
+ /* 上传类型 Logo-品牌logo userImage-用户头像 */
|
|
|
upType: {
|
|
|
type: String
|
|
|
},
|
|
@@ -28,6 +32,20 @@ Component({
|
|
|
/* 提示文本 */
|
|
|
Tips: {
|
|
|
type: String
|
|
|
+ },
|
|
|
+ /* 显示隐藏 */
|
|
|
+ UploadShow: {
|
|
|
+ type: Boolean,
|
|
|
+ value: false
|
|
|
+ },
|
|
|
+ /* 文本行高 */
|
|
|
+ lineHeight: {
|
|
|
+ type: String,
|
|
|
+ value: "100rpx"
|
|
|
+ },
|
|
|
+ /* 返回图片数据函数 */
|
|
|
+ imageChange: {
|
|
|
+ type: Function
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -87,6 +105,7 @@ Component({
|
|
|
let data = {};
|
|
|
//不同类型图片数据
|
|
|
if (this.data.upType == 'Logo') {
|
|
|
+ //logo上传
|
|
|
data = {
|
|
|
"accesstoken": wx.getStorageSync('userData').token,
|
|
|
"classname": "system.system.docManage",
|
|
@@ -99,6 +118,20 @@ Component({
|
|
|
"ftype": "brandlogo"
|
|
|
}
|
|
|
}
|
|
|
+ } else if (this.data.upType == 'userImage') {
|
|
|
+ //头像上传
|
|
|
+ data = {
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "getFileName",
|
|
|
+ "content": {
|
|
|
+ "filename": timestamp,
|
|
|
+ "filetype": ext,
|
|
|
+ "ownertable": "tenterprise_users",
|
|
|
+ "ownerid": wx.getStorageSync('userData').userid,
|
|
|
+ "ftype": "headportrait"
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
//发送请求
|
|
|
wx.getFileSystemManager().readFile({
|
|
@@ -108,8 +141,7 @@ Component({
|
|
|
const fileData = result.data
|
|
|
_Http.basic(data).then(res => {
|
|
|
that.uploadFile(res, fileData)
|
|
|
- }).catch(err => {
|
|
|
- })
|
|
|
+ }).catch(err => {})
|
|
|
},
|
|
|
fail: console.error
|
|
|
})
|
|
@@ -144,9 +176,18 @@ Component({
|
|
|
}
|
|
|
fileList.push(arr)
|
|
|
};
|
|
|
- that.setData({
|
|
|
- fileList
|
|
|
- })
|
|
|
+ if (that.data.upType != "userImage") {
|
|
|
+ //普通返回
|
|
|
+ that.setData({
|
|
|
+ fileList
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.dleeteDealWith();
|
|
|
+ // 需要返回到父组件中 userImage
|
|
|
+ that.triggerEvent("imageChange", {
|
|
|
+ fileList
|
|
|
+ })
|
|
|
+ }
|
|
|
}).catch(err => {
|
|
|
console.log(err)
|
|
|
})
|
|
@@ -164,35 +205,56 @@ Component({
|
|
|
const {
|
|
|
index
|
|
|
} = e.detail;
|
|
|
- let ownertable = '';
|
|
|
- if (that.data.upType == 'Logo') {
|
|
|
- //品牌logo
|
|
|
- ownertable = "tagents"
|
|
|
- };
|
|
|
- _Http.basic({
|
|
|
- "accesstoken": wx.getStorageSync('userData').token,
|
|
|
- "classname": "system.system.docManage",
|
|
|
- "method": "deleteDoc",
|
|
|
- "content": {
|
|
|
- "ownertable": ownertable,
|
|
|
- "ownerid": that.data.fileList[index].ownerid,
|
|
|
- "tattachmentid": that.data.fileList[index].tattachmentid
|
|
|
- }
|
|
|
- }).then(s => {
|
|
|
- if (s.msg != '成功') return;
|
|
|
- console.log(s)
|
|
|
- let fileList = that.data.fileList;
|
|
|
- fileList.splice(index - 1, 1);
|
|
|
- that.setData({
|
|
|
- fileList
|
|
|
- })
|
|
|
- })
|
|
|
- } else {
|
|
|
- return
|
|
|
+ that.dleeteDealWith(index);
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+ },
|
|
|
+ /* 处理删除 */
|
|
|
+ dleeteDealWith(index) {
|
|
|
+ const that = this;
|
|
|
+ let ownertable = '';
|
|
|
+ if (that.data.upType == 'Logo') {
|
|
|
+ //品牌logo
|
|
|
+ ownertable = "tagents"
|
|
|
+ } else if (that.data.upType == 'userImage') {
|
|
|
+ //用户头像
|
|
|
+ ownertable = "tenterprise_users"
|
|
|
+ };
|
|
|
+ let content = {}
|
|
|
+ if (that.data.upType != "userImage") {
|
|
|
+ //图片在本页面
|
|
|
+ content = {
|
|
|
+ "ownertable": ownertable,
|
|
|
+ "ownerid": that.data.fileList[index].ownerid,
|
|
|
+ "tattachmentid": that.data.fileList[index].tattachmentid
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //图片在父组件
|
|
|
+ content = {
|
|
|
+ "ownertable": ownertable,
|
|
|
+ "ownerid": that.data.attinfos.ownerid,
|
|
|
+ "tattachmentid": that.data.attinfos.tattachmentid
|
|
|
+ }
|
|
|
+ }
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "deleteDoc",
|
|
|
+ "content": content
|
|
|
+ }).then(s => {
|
|
|
+ if (s.msg != '成功') return;
|
|
|
+ console.log(s)
|
|
|
+ if (that.data.upType != "userImage") {
|
|
|
+ let fileList = that.data.fileList;
|
|
|
+ fileList.splice(index - 1, 1);
|
|
|
+ that.setData({
|
|
|
+ fileList
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log("删除成功")
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
/* 验证是否上传附件 */
|
|
|
VerifyThere() {
|