123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <template>
- <view>
- <sjs src="../wxs/utils.sjs" module="utils" />
- <view
- :class="'custom-class ' + utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }])"
- hover-class="van-cell--hover hover-class"
- hover-stay-time="70"
- :style="customStyle"
- @tap="onClick"
- >
- <van-icon :wx:if="icon" :name="icon" class="van-cell__left-icon-wrap" custom-class="van-cell__left-icon" />
- <slot wx:else name="icon" />
- <view :style="titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : ''" class="van-cell__title title-class">
- <block :wx:if="title">{{ title }}</block>
- <slot wx:else name="title" />
- <view :wx:if="label || useLabelSlot" class="van-cell__label label-class">
- <slot :wx:if="useLabelSlot" name="label" />
- <block :wx:elif="label">{{ label }}</block>
- </view>
- </view>
- <view class="van-cell__value value-class">
- <block :wx:if="value || value === 0">{{ value }}</block>
- <slot wx:else />
- </view>
- <van-icon
- :wx:if="isLink"
- :name="arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow'"
- class="van-cell__right-icon-wrap right-icon-class"
- custom-class="van-cell__right-icon"
- />
- <slot wx:else name="right-icon" />
- <slot name="extra" />
- </view>
- </view>
- </template>
- <script>
- import { link } from '../mixins/link';
- import { VantComponent } from '../common/component';
- export default {
- data() {
- return {};
- },
- classes: ['title-class', 'label-class', 'value-class', 'right-icon-class', 'hover-class'],
- mixins: [link],
- props: {
- title: null,
- value: null,
- icon: String,
- size: String,
- label: String,
- center: Boolean,
- isLink: Boolean,
- required: Boolean,
- clickable: Boolean,
- titleWidth: String,
- customStyle: String,
- arrowDirection: String,
- useLabelSlot: Boolean,
- border: {
- type: Boolean,
- default: true
- }
- },
- methods: {
- onClick(event) {
- this.$emit('click', event.detail);
- this.jumpLink();
- }
- }
- };
- </script>
- <style>
- @import '../common/index.ttss';
- .van-cell {
- position: relative;
- display: -webkit-flex;
- display: flex;
- box-sizing: border-box;
- width: 100%;
- padding: 10px 16px;
- padding: var(--cell-vertical-padding, 10px) var(--cell-horizontal-padding, 16px);
- font-size: 14px;
- font-size: var(--cell-font-size, 14px);
- line-height: 24px;
- line-height: var(--cell-line-height, 24px);
- color: #323233;
- color: var(--cell-text-color, #323233);
- background-color: #fff;
- background-color: var(--cell-background-color, #fff);
- }
- .van-cell:after {
- position: absolute;
- box-sizing: border-box;
- -webkit-transform-origin: center;
- transform-origin: center;
- content: ' ';
- pointer-events: none;
- top: auto;
- right: 0;
- bottom: 0;
- left: 16px;
- border-bottom: 1px solid #ebedf0;
- -webkit-transform: scaleY(0.5);
- transform: scaleY(0.5);
- }
- .van-cell--borderless:after {
- display: none;
- }
- .van-cell-group {
- background-color: #fff;
- background-color: var(--cell-background-color, #fff);
- }
- .van-cell__label {
- margin-top: 3px;
- margin-top: var(--cell-label-margin-top, 3px);
- font-size: 12px;
- font-size: var(--cell-label-font-size, 12px);
- line-height: 18px;
- line-height: var(--cell-label-line-height, 18px);
- color: #969799;
- color: var(--cell-label-color, #969799);
- }
- .van-cell__value {
- overflow: hidden;
- text-align: right;
- vertical-align: middle;
- color: #969799;
- color: var(--cell-value-color, #969799);
- }
- .van-cell__title,
- .van-cell__value {
- -webkit-flex: 1;
- flex: 1;
- }
- .van-cell__title:empty,
- .van-cell__value:empty {
- display: none;
- }
- .van-cell__left-icon-wrap,
- .van-cell__right-icon-wrap {
- display: -webkit-flex;
- display: flex;
- -webkit-align-items: center;
- align-items: center;
- height: 24px;
- height: var(--cell-line-height, 24px);
- font-size: 16px;
- font-size: var(--cell-icon-size, 16px);
- }
- .van-cell__left-icon-wrap {
- margin-right: 5px;
- }
- .van-cell__right-icon-wrap {
- margin-left: 5px;
- color: #969799;
- color: var(--cell-right-icon-color, #969799);
- }
- .van-cell__left-icon {
- vertical-align: middle;
- }
- .van-cell__left-icon,
- .van-cell__right-icon {
- line-height: 24px;
- line-height: var(--cell-line-height, 24px);
- }
- .van-cell--clickable.van-cell--hover {
- background-color: #f2f3f5;
- background-color: var(--cell-active-color, #f2f3f5);
- }
- .van-cell--required {
- overflow: visible;
- }
- .van-cell--required:before {
- position: absolute;
- content: '*';
- left: 8px;
- left: var(--padding-xs, 8px);
- font-size: 14px;
- font-size: var(--cell-font-size, 14px);
- color: #ee0a24;
- color: var(--cell-required-color, #ee0a24);
- }
- .van-cell--center {
- -webkit-align-items: center;
- align-items: center;
- }
- .van-cell--large {
- padding-top: 12px;
- padding-top: var(--cell-large-vertical-padding, 12px);
- padding-bottom: 12px;
- padding-bottom: var(--cell-large-vertical-padding, 12px);
- }
- .van-cell--large .van-cell__title {
- font-size: 16px;
- font-size: var(--cell-large-title-font-size, 16px);
- }
- .van-cell--large .van-cell__label {
- font-size: 14px;
- font-size: var(--cell-large-label-font-size, 14px);
- }
- </style>
|