Commit bbc20ab1e6be99873eda60f7b772be15fe75a05f

Authored by ly525
1 parent 94594a01

refactor(cover) update card cover style and placeholder image

front-end/h5/src/assets/lbp-picture-placeholder.png 0 → 100644

23.2 KB

front-end/h5/src/components/common/work/card-cover.js
  1 +import placeholderImg from '@/assets/lbp-picture-placeholder.png'
  2 +
  3 +function getDefaultStyle (img, isPlaceholder) {
  4 + return {
  5 + position: 'absolute',
  6 + top: 0,
  7 + left: 0,
  8 + zIndex: 0,
  9 + height: '100%',
  10 + width: '100%',
  11 + backgroundSize: isPlaceholder ? 'contain' : 'cover',
  12 + backgroundRepeat: 'no-repeat',
  13 + backgroundImage: `url(${img})`
  14 + }
  15 +}
  16 +
1 export default { 17 export default {
2 props: { 18 props: {
3 qrcodeUrl: String, 19 qrcodeUrl: String,
4 coverImageUrl: String 20 coverImageUrl: String
5 }, 21 },
6 - render (h) {  
7 - const img = this.qrcodeUrl || this.coverImageUrl  
8 - if (img) { 22 + methods: {
  23 + getCover (img, isPlaceholder = false) {
  24 + const width = 70
9 const style = { 25 const style = {
10 - 'background-image': `url(${img})`,  
11 - 'background-size': this.qrcodeUrl ? 'contain' : 'cover' 26 + ...getDefaultStyle(img, isPlaceholder),
  27 + zIndex: 1,
  28 + width: `${width}%`,
  29 + margin: `0 ${50 - width / 2}%`
12 } 30 }
13 - return <div style={style} class="work-cover-img"></div> 31 + return [
  32 + <div style={style}></div>
  33 + ]
  34 + },
  35 + getCoverBg (img) {
  36 + const style = {
  37 + ...getDefaultStyle(img),
  38 + filter: 'blur(10px)'
  39 + }
  40 + return [
  41 + <div style={style}></div>
  42 + ]
  43 + }
  44 + },
  45 + render (h) {
  46 + let covers = [this.getCover(placeholderImg, true/** isPlaceholder */)]
  47 + const coverImg = this.coverImageUrl
  48 +
  49 + if (this.qrcodeUrl) {
  50 + covers = this.getCover(this.qrcodeUrl)
  51 + } else if (coverImg) {
  52 + covers = [this.getCover(coverImg), this.getCoverBg(coverImg)]
14 } 53 }
15 54
16 - return <span>Luban H5</span> 55 + return <div class="card-cover-wrapper" >
  56 + {covers}
  57 + </div>
17 } 58 }
18 } 59 }
front-end/h5/src/components/core/styles/index.scss
@@ -118,15 +118,14 @@ @@ -118,15 +118,14 @@
118 .active-page { 118 .active-page {
119 color: #2981fa; 119 color: #2981fa;
120 } 120 }
121 -  
122 } 121 }
123 122
124 - .work-cover-img {  
125 - background-size: contain;  
126 - width: 100%;  
127 - height: 100%;  
128 - background-repeat: no-repeat;  
129 - background-position: center center; 123 + .card-cover-wrapper {
  124 + position: relative;
  125 + height: 300px;
  126 + border: 1px dashed #eee;
  127 + color: #aaa;
  128 + padding: 4px;
130 } 129 }
131 } 130 }
132 131
@@ -171,4 +170,8 @@ @@ -171,4 +170,8 @@
171 display: flex !important; 170 display: flex !important;
172 align-items: center; 171 align-items: center;
173 justify-content: center; 172 justify-content: center;
  173 +}
  174 +
  175 +.cursor-pointer {
  176 + cursor: pointer !important;
174 } 177 }
175 \ No newline at end of file 178 \ No newline at end of file
front-end/h5/src/components/plugins/lbp-picture-placeholder.png 0 → 100644

23.2 KB

front-end/h5/src/views/work-manager/list.vue
@@ -41,9 +41,7 @@ const ListItemCard = { @@ -41,9 +41,7 @@ const ListItemCard = {
41 render (h) { 41 render (h) {
42 return ( 42 return (
43 <a-card hoverable > 43 <a-card hoverable >
44 - <div slot="cover" class="flex-center" style="height: 200px;font-size: 24px;border: 1px dashed #eee;color: #aaa;background: #f7f5f557;" >  
45 - <CardCover qrcodeUrl={this.qrcodeUrl} coverImageUrl={this.work.cover_image_url} />  
46 - </div> 44 + <CardCover slot="cover" qrcodeUrl={this.qrcodeUrl} coverImageUrl={this.work.cover_image_url} />
47 <template class="ant-card-actions" slot="actions"> 45 <template class="ant-card-actions" slot="actions">
48 {/** 编辑 */} 46 {/** 编辑 */}
49 <a-tooltip effect="dark" placement="bottom" title={this.$t('workCard.edit')}> 47 <a-tooltip effect="dark" placement="bottom" title={this.$t('workCard.edit')}>
@@ -86,7 +84,7 @@ const AddNewCard = { @@ -86,7 +84,7 @@ const AddNewCard = {
86 render (h, { props, parent }) { 84 render (h, { props, parent }) {
87 return ( 85 return (
88 <a-card hoverable> 86 <a-card hoverable>
89 - <div slot="cover" class="flex-center" style="height: 305px;background: #f7f5f557;" onClick={props.handleCreate}> 87 + <div slot="cover" class="flex-center" style="height: 415px;background: #f7f5f557;" onClick={props.handleCreate}>
90 <a-icon type="plus" /> 88 <a-icon type="plus" />
91 </div> 89 </div>
92 <template class="ant-card-actions" slot="actions"> 90 <template class="ant-card-actions" slot="actions">
front-end/h5/src/views/work-manager/templates.vue
@@ -45,9 +45,7 @@ const ListItemCard = { @@ -45,9 +45,7 @@ const ListItemCard = {
45 render (h) { 45 render (h) {
46 return ( 46 return (
47 <a-card hoverable > 47 <a-card hoverable >
48 - <div slot="cover" class="flex-center" style="height: 200px;font-size: 24px;border: 1px dashed #eee;color: #aaa;background: #f7f5f557;" >  
49 - <CardCover qrcodeUrl={this.qrcodeUrl} coverImageUrl={this.work.cover_image_url} />  
50 - </div> 48 + <CardCover slot="cover" qrcodeUrl={this.qrcodeUrl} coverImageUrl={this.work.cover_image_url} />
51 <template class="ant-card-actions" slot="actions"> 49 <template class="ant-card-actions" slot="actions">
52 <a-tooltip effect="dark" placement="bottom" title={this.$t('workCard.useNow')}> 50 <a-tooltip effect="dark" placement="bottom" title={this.$t('workCard.useNow')}>
53 <a-icon type="plus-square" title={this.$t('workCard.useNow')} onClick={() => { 51 <a-icon type="plus-square" title={this.$t('workCard.useNow')} onClick={() => {