index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view>
  3. <sjs src="../wxs/utils.sjs" module="utils" />
  4. <view
  5. :class="'custom-class ' + utils.bem('cell', [size, { center, required, borderless: !border, clickable: isLink || clickable }])"
  6. hover-class="van-cell--hover hover-class"
  7. hover-stay-time="70"
  8. :style="customStyle"
  9. @tap="onClick"
  10. >
  11. <van-icon :wx:if="icon" :name="icon" class="van-cell__left-icon-wrap" custom-class="van-cell__left-icon" />
  12. <slot wx:else name="icon" />
  13. <view :style="titleWidth ? 'max-width:' + titleWidth + ';min-width:' + titleWidth : ''" class="van-cell__title title-class">
  14. <block :wx:if="title">{{ title }}</block>
  15. <slot wx:else name="title" />
  16. <view :wx:if="label || useLabelSlot" class="van-cell__label label-class">
  17. <slot :wx:if="useLabelSlot" name="label" />
  18. <block :wx:elif="label">{{ label }}</block>
  19. </view>
  20. </view>
  21. <view class="van-cell__value value-class">
  22. <block :wx:if="value || value === 0">{{ value }}</block>
  23. <slot wx:else />
  24. </view>
  25. <van-icon
  26. :wx:if="isLink"
  27. :name="arrowDirection ? 'arrow' + '-' + arrowDirection : 'arrow'"
  28. class="van-cell__right-icon-wrap right-icon-class"
  29. custom-class="van-cell__right-icon"
  30. />
  31. <slot wx:else name="right-icon" />
  32. <slot name="extra" />
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { link } from '../mixins/link';
  38. import { VantComponent } from '../common/component';
  39. export default {
  40. data() {
  41. return {};
  42. },
  43. classes: ['title-class', 'label-class', 'value-class', 'right-icon-class', 'hover-class'],
  44. mixins: [link],
  45. props: {
  46. title: null,
  47. value: null,
  48. icon: String,
  49. size: String,
  50. label: String,
  51. center: Boolean,
  52. isLink: Boolean,
  53. required: Boolean,
  54. clickable: Boolean,
  55. titleWidth: String,
  56. customStyle: String,
  57. arrowDirection: String,
  58. useLabelSlot: Boolean,
  59. border: {
  60. type: Boolean,
  61. default: true
  62. }
  63. },
  64. methods: {
  65. onClick(event) {
  66. this.$emit('click', event.detail);
  67. this.jumpLink();
  68. }
  69. }
  70. };
  71. </script>
  72. <style>
  73. @import '../common/index.ttss';
  74. .van-cell {
  75. position: relative;
  76. display: -webkit-flex;
  77. display: flex;
  78. box-sizing: border-box;
  79. width: 100%;
  80. padding: 10px 16px;
  81. padding: var(--cell-vertical-padding, 10px) var(--cell-horizontal-padding, 16px);
  82. font-size: 14px;
  83. font-size: var(--cell-font-size, 14px);
  84. line-height: 24px;
  85. line-height: var(--cell-line-height, 24px);
  86. color: #323233;
  87. color: var(--cell-text-color, #323233);
  88. background-color: #fff;
  89. background-color: var(--cell-background-color, #fff);
  90. }
  91. .van-cell:after {
  92. position: absolute;
  93. box-sizing: border-box;
  94. -webkit-transform-origin: center;
  95. transform-origin: center;
  96. content: ' ';
  97. pointer-events: none;
  98. top: auto;
  99. right: 0;
  100. bottom: 0;
  101. left: 16px;
  102. border-bottom: 1px solid #ebedf0;
  103. -webkit-transform: scaleY(0.5);
  104. transform: scaleY(0.5);
  105. }
  106. .van-cell--borderless:after {
  107. display: none;
  108. }
  109. .van-cell-group {
  110. background-color: #fff;
  111. background-color: var(--cell-background-color, #fff);
  112. }
  113. .van-cell__label {
  114. margin-top: 3px;
  115. margin-top: var(--cell-label-margin-top, 3px);
  116. font-size: 12px;
  117. font-size: var(--cell-label-font-size, 12px);
  118. line-height: 18px;
  119. line-height: var(--cell-label-line-height, 18px);
  120. color: #969799;
  121. color: var(--cell-label-color, #969799);
  122. }
  123. .van-cell__value {
  124. overflow: hidden;
  125. text-align: right;
  126. vertical-align: middle;
  127. color: #969799;
  128. color: var(--cell-value-color, #969799);
  129. }
  130. .van-cell__title,
  131. .van-cell__value {
  132. -webkit-flex: 1;
  133. flex: 1;
  134. }
  135. .van-cell__title:empty,
  136. .van-cell__value:empty {
  137. display: none;
  138. }
  139. .van-cell__left-icon-wrap,
  140. .van-cell__right-icon-wrap {
  141. display: -webkit-flex;
  142. display: flex;
  143. -webkit-align-items: center;
  144. align-items: center;
  145. height: 24px;
  146. height: var(--cell-line-height, 24px);
  147. font-size: 16px;
  148. font-size: var(--cell-icon-size, 16px);
  149. }
  150. .van-cell__left-icon-wrap {
  151. margin-right: 5px;
  152. }
  153. .van-cell__right-icon-wrap {
  154. margin-left: 5px;
  155. color: #969799;
  156. color: var(--cell-right-icon-color, #969799);
  157. }
  158. .van-cell__left-icon {
  159. vertical-align: middle;
  160. }
  161. .van-cell__left-icon,
  162. .van-cell__right-icon {
  163. line-height: 24px;
  164. line-height: var(--cell-line-height, 24px);
  165. }
  166. .van-cell--clickable.van-cell--hover {
  167. background-color: #f2f3f5;
  168. background-color: var(--cell-active-color, #f2f3f5);
  169. }
  170. .van-cell--required {
  171. overflow: visible;
  172. }
  173. .van-cell--required:before {
  174. position: absolute;
  175. content: '*';
  176. left: 8px;
  177. left: var(--padding-xs, 8px);
  178. font-size: 14px;
  179. font-size: var(--cell-font-size, 14px);
  180. color: #ee0a24;
  181. color: var(--cell-required-color, #ee0a24);
  182. }
  183. .van-cell--center {
  184. -webkit-align-items: center;
  185. align-items: center;
  186. }
  187. .van-cell--large {
  188. padding-top: 12px;
  189. padding-top: var(--cell-large-vertical-padding, 12px);
  190. padding-bottom: 12px;
  191. padding-bottom: var(--cell-large-vertical-padding, 12px);
  192. }
  193. .van-cell--large .van-cell__title {
  194. font-size: 16px;
  195. font-size: var(--cell-large-title-font-size, 16px);
  196. }
  197. .van-cell--large .van-cell__label {
  198. font-size: 14px;
  199. font-size: var(--cell-large-label-font-size, 14px);
  200. }
  201. </style>