完整代码提交

提交完整代码
zw-dev
lsl 3 years ago
parent a153e3a87f
commit 8aa2d6772c

@ -9,7 +9,7 @@ Page({
* 页面的初始数据
*/
data: {
fileList: ['https://xzjl-1257436036.cos.ap-nanjing.myqcloud.com/me/reback.png'],//图片list
fileList: [],//图片list
form:{
content:"",
deadline:'',
@ -40,7 +40,45 @@ Page({
this.setData({
fileList: [...fileList, ...files], // 此时设置了 fileList 之后才会展示选择的图片
});
files.forEach(file => this.uploadFile(file))
// files.forEach(file => this.uploadFile(file))
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: res => {
var tempFilePaths = res.tempFilePaths;
wx.uploadFile({
url: 'https://xzjl-api.windymuse.cn/api/resource',
filePath: tempFilePaths[0],
name: 'file',
header: {
'Authorization': wx.getStorageSync('token'),
'Content-Type': 'multipart/form-data'
},
formData: {
type: 'poster'
},
success: async res => {
console.log(res, '111111');
if (res.statusCode == 200) {
res.data = JSON.parse(res.data);
console.log(res.data);
if (res.data.code == 1) {
console.log(res.data.data.url);
this.img = this.baseUrl + res.data.data.url;
// 图片路径
this.userinfo.avatar = res.data.data.url;
// let n = await this.$api.upload({ file: res.data.fullurl });
// console.log(n, '上传后');
}
}
},
fail(res) {
showToast('图片上传失败');
}
});
}
});
},
handleRemove(e){/**删除图片 */
const { index } = e.detail;

@ -35,6 +35,7 @@
bind:remove="handleRemove"
>
</t-upload>
</view>

Loading…
Cancel
Save