123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import api from '../../api/api'
- Component({
- properties: {
- list: {
- value: '',
- type: Array
- },
- isdelete: {
- type: Boolean,
- value: true
- },
- },
- data: {
- visible: false,
- showIndex: false,
- closeBtn: false,
- deleteBtn: false,
- images2: [],
- gridConfig: {
- column: 5,
- width: 120,
- height: 120,
- },
- },
- observers: {
- "list": function (list) {
- this.setData({
- images2: list.map(e => {
- return {
- url: e.url,
- type: this.validateImageType(e.postfix),
- linksid: e.linksid
- }
- })
- })
- }
- },
- methods: {
- validateImageType(file) {
- const allowedTypes = /(\jpg|\jpeg|\png|\gif)$/i;
- const allowedTypes1 = /(\mp4|\mov|\3gp|\3g2)$/i;
- if (allowedTypes.test(file)) {
- return 'image'
- } else if (allowedTypes1.test(file)) {
- return 'video'
- } else {
- return 'file'
- }
- },
- async deleteFile(data) {
- const res = await api._post({
- "classname": "system.attachment.Attachment",
- "method": "deleteFileLink",
- "content": {
- "linksids": [data.detail.file.linksid]
- }
- })
- if (res.code == 1) {
- this.setData({
- images2: this.data.images2.filter(e => {
- return e.linksid !== data.detail.file.linksid
- })
- })
- } else {
- wx.showToast({
- title: res.data,
- icon: 'none'
- })
- }
- }
- }
- })
|