123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- <template>
- <view
- class="tn-list-view-class tn-list-view"
- :class="[
- backgroundColorClass,
- viewClass
- ]"
- :style="[viewStyle]"
- >
- <view
- v-if="showTitle"
- class="tn-list-view__title"
- :class="[
- fontColorClass
- ]"
- :style="[titleStyle]"
- @tap="handleClickTitle"
- >{{ title }}</view>
-
- <view
- v-else
- :class="[{'tn-list-view__title--card': card}]"
- @tap="handleClickTitle"
- >
- <slot name="title"></slot>
- </view>
-
- <view
- class="tn-list-view__content tn-border-solid-top tn-border-solid-bottom"
- :class="[contentClass]"
- >
- <slot></slot>
- </view>
- </view>
- </template>
- <script>
- import componentsColorMixin from '../../libs/mixin/components_color.js'
- export default {
- mixins: [ componentsColorMixin ],
- name: 'tn-list-view',
- props: {
- // 标题
- title: {
- type: String,
- default: ''
- },
- // 去掉边框 上边框 top, 下边框 bottom, 所有边框 all
- unlined: {
- type: String,
- default: 'all'
- },
- // 上外边距
- marginTop: {
- type: String,
- default: ''
- },
- // 内容是否显示为卡片模式
- card: {
- type: Boolean,
- default: false
- },
- // 是否自定义标题
- customTitle: {
- type: Boolean,
- default: false
- }
- },
- computed: {
- showTitle() {
- return !this.customTitle && this.title
- },
- viewClass() {
- let clazz = ''
-
- if (this.card) {
- clazz += ' tn-list-view--card'
- }
-
- return clazz
- },
- viewStyle() {
- let style = {}
-
- if (this.backgroundColorStyle) {
- style.backgroundColor = this.backgroundColorStyle
- }
-
- if (this.marginTop) {
- style.marginTop = this.marginTop
- }
-
- return style
- },
- titleStyle() {
- let style = {}
-
- if (this.fontColorStyle) {
- style.color = this.fontColorStyle
- }
- if (this.fontSize) {
- style.fontSize = this.fontSize + this.fontUnit
- }
-
- return style
- },
- contentClass() {
- let clazz = ''
-
- if (this.card) {
- clazz += ' tn-list-view__content--card'
- }
-
- switch(this.unlined) {
- case 'top':
- clazz += ' tn-none-border-top'
- break
- case 'bottom':
- clazz += ' tn-none-border-bottom'
- break
- case 'all':
- clazz += ' tn-none-border'
- break
- }
-
- return clazz
- }
- },
- data () {
- return {
- kindShowFlag: this.showKind
- }
- },
- methods: {
- // 处理标题点击事件
- handleClickTitle() {
- if (!this.kindList) return
- this.kindShowFlag = !this.kindShowFlag
- this.$emit("clickTitle", {})
- }
- }
- }
- </script>
- <style lang="scss" scoped>
-
- .tn-list-view {
- background-color: #FFFFFF;
-
- &__title {
- width: 100%;
- padding: 30rpx;
- font-size: 30rpx;
- line-height: 30rpx;
- box-sizing: border-box;
-
- &--card {
- // margin: 0rpx 30rpx;
- }
- }
-
- &__content {
- width: 100%;
- position: relative;
- border-radius: 0;
-
- &--card {
- // width: auto;
- // overflow: hidden;
- // margin-right: 30rpx;
- // margin-left: 30rpx;
- // border-radius: 20rpx
- }
- }
-
- &--card {
- // padding-bottom: 30rpx;
- border-radius: 20rpx;
- overflow: hidden;
- }
-
- }
-
- </style>
|