You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
942 B
47 lines
942 B
const util = require('../../utils/util') //导入模块
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
src: {
|
|
type: String,
|
|
value: ''
|
|
},
|
|
width: {
|
|
type: Number,
|
|
value: 80
|
|
},
|
|
height: {
|
|
type: Number,
|
|
value: 80
|
|
},
|
|
imageList: {
|
|
type: Array,
|
|
value: []
|
|
}
|
|
},
|
|
observers: {
|
|
'imageList': function () {
|
|
for (let index = 0; index < this.data.imageList.length; index++) {
|
|
if(!this.isPdfUrl(this.data.imageList[index])){
|
|
this.setData({ src: this.data.imageList[index] })
|
|
break
|
|
}
|
|
}
|
|
if(util.isEmpty(this.data.src)){
|
|
this.setData({ src: this.data.imageList[0] })
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
isPdfUrl: function (url) {
|
|
if (url && (url.indexOf('.pdf') >= 0 || url.indexOf('.PDF') >= 0)) {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
})
|