|
|
|
@ -28,8 +28,23 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(options) { |
|
|
|
let that = this; |
|
|
|
this.cropper = this.selectComponent("#image-cropper"); |
|
|
|
this.src= options.imgSrc |
|
|
|
// uni.getImageInfo({ |
|
|
|
// src: options.imgSrc, |
|
|
|
// success(res) { |
|
|
|
// that.height = res.height |
|
|
|
// that.width = res.width |
|
|
|
// that.max_width = res.width |
|
|
|
// that.max_height = res.height |
|
|
|
// }, |
|
|
|
// fail(err) { |
|
|
|
// console.error('获取图片信息失败:', err); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// console.log('宽',this.width) |
|
|
|
// console.log('高',this.height) |
|
|
|
if(!options.imgSrc){ |
|
|
|
this.cropper.upload(); //上传图片 |
|
|
|
} |
|
|
|
@ -140,15 +155,17 @@ |
|
|
|
}, |
|
|
|
submit() { |
|
|
|
let that = this; |
|
|
|
let hiver_token = uni.getStorageSync("hiver_token") |
|
|
|
this.cropper.getImg((obj) => { |
|
|
|
console.log(obj.url) |
|
|
|
console.log(that.tui.getToken()) |
|
|
|
uni.uploadFile({ |
|
|
|
url: 'https://dev.xenjoyou.com/hiver/upload/file', |
|
|
|
filePath: obj.url, |
|
|
|
name: 'file', |
|
|
|
header: { |
|
|
|
"content-type": "multipart/form-data", |
|
|
|
'accessToken': that.tui.getToken() |
|
|
|
'accessToken': hiver_token |
|
|
|
}, |
|
|
|
formData: {}, |
|
|
|
success: (uploadFileRes) => { |
|
|
|
@ -168,6 +185,11 @@ |
|
|
|
wx.navigateBack({ |
|
|
|
delta: 1 |
|
|
|
}) |
|
|
|
},fail: (err) =>{ |
|
|
|
uni.showToast({ |
|
|
|
title: JSON.stringify(err), |
|
|
|
icon: 'none' |
|
|
|
}) |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|