123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- // commpents/mobile-frame/mobile-main.js
- const app = getApp()
- Component({
- /**
- * 组件的属性列表
- */
- options: { multipleSlots: true },
- properties: {
- list: { type: 'array', value: [] },
- count: { type: Number, value: 1 },
- previewSize: { type: String, value: '60' }
- },
- // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
- attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
- ready: function () { },
- pageLifetimes: {
- // 组件所在页面的生命周期函数
- show: function () { },
- hide: function () { },
- resize: function () { },
- },
- /**
- * 组件的初始数据
- */
- data: {
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 图片上传
- imgUpload(event) {
- const { file } = event.detail;
- wx.uploadFile({
- url: `${app.globalData.imageUrl}/files/court/elimg/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 })
- }
- }
- })
|