const app = getApp() Component({ properties: { list: { type: Array, value: [] }, name: { type: String }, count: { type: Number, value: 1 }, }, data: {}, methods: { // 图片上传 imgUpload() { const that = this; const name = that.data.name; wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], async success(chooseRes) { const file = chooseRes.tempFilePaths; let res = await app.$apifile('files/ball/team/upload', null, file[0]) res = JSON.parse(res); if (res.errcode == '0') { that.triggerEvent('imgUpload', { name: res.name, url: `${app.globalData.fileserverUrl}` + res.uri, uri: res.uri }) } else { wx.showToast({ title: `${res.errmsg}`, icon: 'error' }) } } }) }, imgDel(e) { const that = this; const name = that.data.name; const { item, index } = e.currentTarget.dataset; that.triggerEvent('imgDel', { file: item, index: index }) }, // 预览 toView: function (e) { const { item } = e.currentTarget.dataset; wx.previewImage({ current: '', urls: [item.url] }) } } })