|
@@ -0,0 +1,57 @@
|
|
|
+
|
|
|
+const app = getApp()
|
|
|
+Component({
|
|
|
+
|
|
|
+ * 组件的属性列表
|
|
|
+ */
|
|
|
+ options: { multipleSlots: true },
|
|
|
+ properties: {
|
|
|
+ list: { type: 'array', value: [] },
|
|
|
+ count: { type: Number, value: 1 },
|
|
|
+ previewSize: { type: String, value: '60' }
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ attached: function () { },
|
|
|
+ ready: function () { },
|
|
|
+ pageLifetimes: {
|
|
|
+
|
|
|
+ show: function () { },
|
|
|
+ hide: function () { },
|
|
|
+ resize: function () { },
|
|
|
+ },
|
|
|
+
|
|
|
+ * 组件的初始数据
|
|
|
+ */
|
|
|
+ data: {
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ * 组件的方法列表
|
|
|
+ */
|
|
|
+ methods: {
|
|
|
+
|
|
|
+ imgUpload(event) {
|
|
|
+ const { file } = event.detail;
|
|
|
+ wx.uploadFile({
|
|
|
+ url: app.globalData.fileUrl + '/files/consumables/market/upload',
|
|
|
+ filePath: file.url,
|
|
|
+ name: 'file',
|
|
|
+ formData: {},
|
|
|
+ success: (res) => {
|
|
|
+ let arr = JSON.parse(res.data);
|
|
|
+ if (res.statusCode == 200) {
|
|
|
+ this.triggerEvent('imgUpload', { name: arr.name, url: `${app.globalData.imageUrl}` + arr.uri, uri: arr.uri })
|
|
|
+ } else {
|
|
|
+ wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ imgDel(e) {
|
|
|
+ this.triggerEvent('imgDel', { file: e.detail.file, index: e.detail.index })
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|