Commit 95444de037894c295fd56ca300a047187c9e8bb8
1 parent
f955490d
select slide image from image gallery
Showing
1 changed file
with
34 additions
and
1 deletions
front-end/h5/src/components/plugins/lbp-slide.js
| 1 | 1 | import { |
| 2 | 2 | Slide |
| 3 | 3 | } from 'cube-ui' |
| 4 | +import ImageGallery from '@/components/core/support/image-gallery/gallery.js' | |
| 4 | 5 | |
| 5 | 6 | const defaultItems = [ |
| 6 | 7 | { |
| ... | ... | @@ -61,8 +62,28 @@ export default { |
| 61 | 62 | components: { |
| 62 | 63 | 'lbs-slide-items-editor': { |
| 63 | 64 | render () { |
| 65 | + const currentItem = this.value_[this.current - 1] | |
| 64 | 66 | return <div> |
| 65 | 67 | { |
| 68 | + <a-pagination | |
| 69 | + current={this.current} | |
| 70 | + onChange={(page) => { | |
| 71 | + this.current = page | |
| 72 | + }} | |
| 73 | + size="small" | |
| 74 | + total={this.value_.length} | |
| 75 | + defaultPageSize={1} | |
| 76 | + itemRender={this.itemRender} | |
| 77 | + /> | |
| 78 | + } | |
| 79 | + <ImageGallery | |
| 80 | + style={{ margin: '16px 0' }} | |
| 81 | + value={currentItem.image} | |
| 82 | + onChange={url => { | |
| 83 | + currentItem.image = url | |
| 84 | + }} | |
| 85 | + /> | |
| 86 | + {/* { | |
| 66 | 87 | this.value_.map((item, index) => ( |
| 67 | 88 | <div> |
| 68 | 89 | <label>图片 {index + 1}</label> |
| ... | ... | @@ -73,7 +94,7 @@ export default { |
| 73 | 94 | </a-button-group> |
| 74 | 95 | </div> |
| 75 | 96 | )) |
| 76 | - } | |
| 97 | + } */} | |
| 77 | 98 | </div> |
| 78 | 99 | }, |
| 79 | 100 | props: { |
| ... | ... | @@ -92,12 +113,24 @@ export default { |
| 92 | 113 | } |
| 93 | 114 | } |
| 94 | 115 | }, |
| 116 | + data: () => ({ | |
| 117 | + current: 1 | |
| 118 | + }), | |
| 95 | 119 | methods: { |
| 120 | + itemRender (current, type, originalElement) { | |
| 121 | + if (type === 'prev') { | |
| 122 | + return <a-button style={{ marginRight: '8px' }} size="small" icon="minus" onClick={this.minus}></a-button> | |
| 123 | + } else if (type === 'next') { | |
| 124 | + return <a-button style={{ marginLeft: '8px' }} size="small" icon="plus" onClick={this.add}></a-button> | |
| 125 | + } | |
| 126 | + return originalElement | |
| 127 | + }, | |
| 96 | 128 | add () { |
| 97 | 129 | console.log(this.value_.length) |
| 98 | 130 | this.$emit('change', [ |
| 99 | 131 | ...this.value_, |
| 100 | 132 | { |
| 133 | + image: '', | |
| 101 | 134 | value: `选项${this.value_.length + 1}-value`, |
| 102 | 135 | label: `选项${this.value_.length + 1}-label` |
| 103 | 136 | } | ... | ... |