Skip to content

Commit

Permalink
add: 增加card卡片组件
Browse files Browse the repository at this point in the history
  • Loading branch information
jry committed Aug 9, 2024
1 parent f1aac92 commit f2e4ebe
Show file tree
Hide file tree
Showing 8 changed files with 444 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@
"style": {
"navigationBarTitleText": "瀑布流"
}
}, {
"path": "card/card",
"style": {
"navigationBarTitleText": "卡片"
}
}]
}, {
"root": "pages/componentsC",
Expand Down
115 changes: 115 additions & 0 deletions src/pages/componentsB/card/card.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<template>
<view>
<view class="u-card-wrap">
<up-card @click="click" @head-click="headClick" :title="title"
:sub-title="subTitle" :thumb="thumb" :padding="padding" :border="border">
<template #body>
<view>
<view class="u-body-item u-flex u-border-bottom u-col-between u-p-t-0">
<view class="u-body-item-title u-line-2">瓶身描绘的牡丹一如你初妆,冉冉檀香透过窗心事我了然,宣纸上走笔至此搁一半</view>
<image src="https://img11.360buyimg.com/n7/jfs/t1/94448/29/2734/524808/5dd4cc16E990dfb6b/59c256f85a8c3757.jpg" mode="aspectFill"></image>
</view>
<view class="u-body-item u-flex u-row-between u-p-b-0">
<view class="u-body-item-title u-line-2">釉色渲染仕女图韵味被私藏,而你嫣然的一笑如含苞待放</view>
<image src="https://img12.360buyimg.com/n7/jfs/t1/102191/19/9072/330688/5e0af7cfE17698872/c91c00d713bf729a.jpg" mode="aspectFill"></image>
</view>
</view>
</template>
<template #foot>
<view>
<up-icon name="chat-fill" size="34" color="" label="30评论"></up-icon>
</view>
</template>
</up-card>
</view>
<view class="u-demo">
<view class="u-demo-block">
<text class="u-demo-block__title">参数配置</text>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">左上角图标</text>
<view class="u-demo-block__content">
<up-subsection :list="['显示', '隐藏']" @change="thumbChange"></up-subsection>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">内边距</text>
<view class="u-demo-block__content">
<up-subsection current="1" :list="['20', '30', '40']" @change="paddingChange"></up-subsection>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">底部</text>
<view class="u-demo-block__content">
<up-subsection :list="['显示', '隐藏']" @change="bottomChange"></up-subsection>
</view>
</view>
<view class="u-demo-block">
<text class="u-demo-block__title">外边框</text>
<view class="u-demo-block__content">
<up-subsection :list="['显示', '隐藏']" @change="borderChange"></up-subsection>
</view>
</view>
</view>
</view>
</template>

<script>
export default {
data() {
return {
title: '素胚勾勒出青花,笔锋浓转淡',
subTitle: '2020-05-15',
thumb: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
padding: 20,
bottomSlot: true,
border: true
}
},
methods: {
thumbChange(index) {
this.thumb = index == 0 ? 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg' : '';
},
paddingChange(index) {
this.padding = [20, 30, 40][index];
},
bottomChange(index) {
this.bottomSlot = !index;
},
borderChange(index) {
this.border = !index;
},
click(index) {
console.log(index);
},
headClick(index) {
console.log(index);
}
}
}
</script>

<style scoped lang="scss">
.u-demo {
padding: 20x;
}
.u-card-wrap {
background-color: $u-bg-color;
padding: 1px;
.u-body-item {
font-size: 32rpx;
color: #333;
padding: 20rpx 10rpx;
}
.u-body-item image {
width: 120rpx;
flex: 0 0 120rpx;
height: 120rpx;
border-radius: 8rpx;
margin-left: 12rpx;
}
}
</style>
2 changes: 1 addition & 1 deletion src/pages/componentsB/dropdown/dropdown.nvue
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@

<style scoped lang="scss">
.u-config-wrap {
padding: 40rpx;
padding: 20px;
}

.slot-content {
Expand Down
10 changes: 10 additions & 0 deletions src/pages/example/components.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ export default [{
icon: 'line',
title: 'Line 线条',
title_en: 'Line'
}, {
path: '/pages/componentsB/card/card',
icon: 'empty',
title: 'Card 卡片',
title_en: 'Card'
}, {
path: '/pages/componentsA/overlay/overlay',
icon: 'mask',
Expand Down Expand Up @@ -304,6 +309,11 @@ export default [{
icon: 'divider',
title: 'Divider 分割线',
title_en: 'Divider'
}, {
path: '/pages/componentsD/box/box',
icon: 'box',
title: 'Box 盒子',
title_en: 'Box'
}
]
},
Expand Down
Binary file added src/static/uview/demo/box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/static/uview/demo/card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions src/uni_modules/uview-plus/components/u-card/props.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { defineMixin } from '../../libs/vue'
import defProps from '../../libs/config/props.js'

export const propsCard = defineMixin({
props: {
// 与屏幕两侧是否留空隙
full: {
type: Boolean,
default: false
},
// 标题
title: {
type: String,
default: ''
},
// 标题颜色
titleColor: {
type: String,
default: '#303133'
},
// 标题字体大小
titleSize: {
type: [Number, String],
default: '15px'
},
// 副标题
subTitle: {
type: String,
default: ''
},
// 副标题颜色
subTitleColor: {
type: String,
default: '#909399'
},
// 副标题字体大小
subTitleSize: {
type: [Number, String],
default: '13'
},
// 是否显示外部边框,只对full=false时有效(卡片与边框有空隙时)
border: {
type: Boolean,
default: true
},
// 用于标识点击了第几个
index: {
type: [Number, String, Object],
default: ''
},
// 用于隔开上下左右的边距,带单位的写法,如:"30px 30px","20px 20px 30px 30px"
margin: {
type: String,
default: '15px'
},
// card卡片的圆角
borderRadius: {
type: [Number, String],
default: '8px'
},
// 头部自定义样式,对象形式
headStyle: {
type: Object,
default() {
return {};
}
},
// 主体自定义样式,对象形式
bodyStyle: {
type: Object,
default() {
return {};
}
},
// 底部自定义样式,对象形式
footStyle: {
type: Object,
default() {
return {};
}
},
// 头部是否下边框
headBorderBottom: {
type: Boolean,
default: true
},
// 底部是否有上边框
footBorderTop: {
type: Boolean,
default: true
},
// 标题左边的缩略图
thumb: {
type: String,
default: ''
},
// 缩略图宽高
thumbWidth: {
type: [String, Number],
default: '30px'
},
// 缩略图是否为圆形
thumbCircle: {
type: Boolean,
default: false
},
// 给head,body,foot的内边距
padding: {
type: [String, Number],
default: '15px'
},
// 是否显示头部
showHead: {
type: Boolean,
default: true
},
// 是否显示尾部
showFoot: {
type: Boolean,
default: true
},
// 卡片外围阴影,字符串形式
boxShadow: {
type: String,
default: 'none'
}
}
})
Loading

0 comments on commit f2e4ebe

Please sign in to comment.