Files
JayuCloud/JC-Salon-WeChat/components/product-selector-sheet/index.js
T

48 lines
1.9 KiB
JavaScript

Component({
properties: {
visible: { type: Boolean, value: false },
mode: { type: String, value: 'list' },
title: { type: String, value: '选择作品' },
keyword: { type: String, value: '' },
placeholder: { type: String, value: '搜索作品名称' },
items: { type: Array, value: [] },
selectedId: { type: null, value: '' },
loading: { type: Boolean, value: false },
errorText: { type: String, value: '' },
emptyText: { type: String, value: '暂无作品' },
manualForm: { type: Object, value: {} },
manualMoreExpanded: { type: Boolean, value: false },
showManualExtra: { type: Boolean, value: true },
showManualAction: { type: Boolean, value: true },
manualImageUrl: { type: String, value: '' },
manualImageUploading: { type: Boolean, value: false }
},
methods: {
close() { this.triggerEvent('close') },
stopEvent() {},
onSearch(event) { this.triggerEvent('search', { value: event.detail.value }) },
selectItem(event) {
const item = this.data.items[Number(event.currentTarget.dataset.index)]
if (item) this.triggerEvent('select', { item })
},
onCoverImageError(event) {
const index = Number(event.currentTarget.dataset.index)
if (!Number.isInteger(index) || !this.data.items[index]) return
this.setData({ [`items[${index}].coverImage`]: '' })
},
onManualImageError() {
this.setData({ manualImageUrl: '' })
},
openManual() { this.triggerEvent('openmanual') },
backToList() { this.triggerEvent('backtolist') },
onManualInput(event) {
this.triggerEvent('manualinput', { field: event.currentTarget.dataset.field, value: event.detail.value })
},
toggleMore() { this.triggerEvent('togglemore') },
chooseImage() { this.triggerEvent('chooseimage') },
removeImage() { this.triggerEvent('removeimage') },
confirmManual() { this.triggerEvent('confirmmanual') },
retry() { this.triggerEvent('retry') }
}
})