123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <view
- @tap="click"
- class="u-cell"
- :class="{ 'u-border-bottom': borderBottom, 'u-border-top': borderTop, 'u-col-center': center, 'u-cell--required': required }"
- hover-stay-time="150"
- :hover-class="hoverClass"
- :style="{
- backgroundColor: bgColor
- }"
- >
- <u-icon :size="iconSize" :name="icon" v-if="icon" :custom-style="iconStyle" class="u-cell__left-icon-wrap"></u-icon>
- <view class="u-flex" v-else>
- <slot name="icon"></slot>
- </view>
- <view
- class="u-cell_title"
- :style="[
- {
- width: titleWidth ? titleWidth + 'rpx' : 'auto'
- },
- titleStyle
- ]"
- >
- <block v-if="title !== ''">{{ title }}</block>
- <slot name="title" v-else></slot>
- <view class="u-cell__label" v-if="label || $slots.label" :style="[labelStyle]">
- <block v-if="label !== ''">{{ label }}</block>
- <slot name="label" v-else></slot>
- </view>
- </view>
- <view class="u-cell__value" :style="[valueStyle]">
- <block class="u-cell__value" v-if="value !== ''">{{ value }}</block>
- <slot v-else></slot>
- </view>
- <view class="u-flex u-cell_right" v-if="$slots['right-icon']">
- <slot name="right-icon"></slot>
- </view>
- <u-icon v-if="arrow" name="arrow-right" :style="[arrowStyle]" class="u-icon-wrap u-cell__right-icon-wrap"></u-icon>
- </view>
- </template>
- <script>
- export default {
- name: 'u-cell-item',
- props: {
-
- icon: {
- type: String,
- default: ''
- },
-
- title: {
- type: [String, Number],
- default: ''
- },
-
- value: {
- type: [String, Number],
- default: ''
- },
-
- label: {
- type: [String, Number],
- default: ''
- },
-
- borderBottom: {
- type: Boolean,
- default: true
- },
-
- borderTop: {
- type: Boolean,
- default: false
- },
-
-
-
-
-
-
-
- hoverClass: {
- type: String,
- default: 'u-cell-hover'
- },
-
- arrow: {
- type: Boolean,
- default: true
- },
-
- center: {
- type: Boolean,
- default: false
- },
-
- required: {
- type: Boolean,
- default: false
- },
-
- titleWidth: {
- type: [Number, String],
- default: ''
- },
-
- arrowDirection: {
- type: String,
- default: 'right'
- },
-
- titleStyle: {
- type: Object,
- default() {
- return {};
- }
- },
-
- valueStyle: {
- type: Object,
- default() {
- return {};
- }
- },
-
- labelStyle: {
- type: Object,
- default() {
- return {};
- }
- },
-
- bgColor: {
- type: String,
- default: 'transparent'
- },
-
- index: {
- type: [String, Number],
- default: ''
- },
-
- useLabelSlot: {
- type: Boolean,
- default: false
- },
-
- iconSize: {
- type: [Number, String],
- default: 34
- },
-
- iconStyle: {
- type: Object,
- default() {
- return {}
- }
- },
- },
- data() {
- return {
- };
- },
- computed: {
- arrowStyle() {
- let style = {};
- if (this.arrowDirection == 'up') style.transform = 'rotate(-90deg)';
- else if (this.arrowDirection == 'down') style.transform = 'rotate(90deg)';
- else style.transform = 'rotate(0deg)';
- return style;
- }
- },
- methods: {
- click() {
- this.$emit('click', this.index);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/style.components.scss";
- .u-cell {
- @include vue-flex;
- align-items: center;
- position: relative;
- /* #ifndef APP-NVUE */
- box-sizing: border-box;
- /* #endif */
- width: 100%;
- padding: 26rpx 32rpx;
- font-size: 28rpx;
- line-height: 54rpx;
- color: $u-content-color;
- background-color: #fff;
- text-align: left;
- }
- .u-cell_title {
- font-size: 28rpx;
- }
- .u-cell__left-icon-wrap {
- margin-right: 10rpx;
- font-size: 32rpx;
- }
- .u-cell__right-icon-wrap {
- margin-left: 10rpx;
- color: #969799;
- font-size: 28rpx;
- }
- .u-cell__left-icon-wrap,
- .u-cell__right-icon-wrap {
- @include vue-flex;
- align-items: center;
- height: 48rpx;
- }
- .u-cell-border:after {
- position: absolute;
- /* #ifndef APP-NVUE */
- box-sizing: border-box;
- content: ' ';
- pointer-events: none;
- border-bottom: 1px solid $u-border-color;
- /* #endif */
- right: 0;
- left: 0;
- top: 0;
- transform: scaleY(0.5);
- }
- .u-cell-border {
- position: relative;
- }
- .u-cell__label {
- margin-top: 6rpx;
- font-size: 26rpx;
- line-height: 36rpx;
- color: $u-tips-color;
- /* #ifndef APP-NVUE */
- word-wrap: break-word;
- /* #endif */
- }
- .u-cell__value {
- overflow: hidden;
- text-align: right;
- /* #ifndef APP-NVUE */
- vertical-align: middle;
- /* #endif */
- color: $u-tips-color;
- font-size: 26rpx;
- }
- .u-cell__title,
- .u-cell__value {
- flex: 1;
- }
- .u-cell--required {
- /* #ifndef APP-NVUE */
- overflow: visible;
- /* #endif */
- @include vue-flex;
- align-items: center;
- }
- .u-cell--required:before {
- position: absolute;
- /* #ifndef APP-NVUE */
- content: '*';
- /* #endif */
- left: 8px;
- margin-top: 4rpx;
- font-size: 14px;
- color: $u-type-error;
- }
- .u-cell_right {
- line-height: 1;
- }
- </style>
|