index.vue 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <uni-shadow-root class="vant-submit-bar-index"><view class="van-submit-bar custom-class">
  3. <slot name="top"></slot>
  4. <view class="van-submit-bar__tip">
  5. <van-icon v-if="tipIcon" size="12px" :name="tipIcon" custom-class="van-submit-bar__tip-icon"></van-icon>
  6. <view v-if="hasTip" class="van-submit-bar__tip-text">
  7. {{ tip }}
  8. </view>
  9. <slot name="tip"></slot>
  10. </view>
  11. <view class="bar-class van-submit-bar__bar">
  12. <slot></slot>
  13. <view v-if="hasPrice" class="van-submit-bar__text">
  14. <text>{{ label || '合计:' }}</text>
  15. <text class="van-submit-bar__price price-class">
  16. <text class="van-submit-bar__currency">{{ currency }} </text>
  17. <text class="van-submit-bar__price-integer">{{ integerStr }}</text><text>{{decimalStr}}</text>
  18. </text>
  19. <text class="van-submit-bar__suffix-label">{{ suffixLabel }}</text>
  20. </view>
  21. <van-button round :type="buttonType" :loading="loading" :disabled="disabled" class="van-submit-bar__button" custom-class="button-class" custom-style="width: 100%;" @click="onSubmit">
  22. {{ loading ? '' : buttonText }}
  23. </van-button>
  24. </view>
  25. <view v-if="safeAreaInsetBottom" class="van-submit-bar__safe"></view>
  26. </view></uni-shadow-root>
  27. </template>
  28. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  29. <script>
  30. import VanButton from '../button/index.vue'
  31. import VanIcon from '../icon/index.vue'
  32. global['__wxVueOptions'] = {components:{'van-button': VanButton,'van-icon': VanIcon}}
  33. global['__wxRoute'] = 'vant/submit-bar/index'
  34. import { VantComponent } from '../common/component';
  35. VantComponent({
  36. classes: ['bar-class', 'price-class', 'button-class'],
  37. props: {
  38. tip: {
  39. type: null,
  40. observer: 'updateTip',
  41. },
  42. tipIcon: String,
  43. type: Number,
  44. price: {
  45. type: null,
  46. observer: 'updatePrice',
  47. },
  48. label: String,
  49. loading: Boolean,
  50. disabled: Boolean,
  51. buttonText: String,
  52. currency: {
  53. type: String,
  54. value: '¥',
  55. },
  56. buttonType: {
  57. type: String,
  58. value: 'danger',
  59. },
  60. decimalLength: {
  61. type: Number,
  62. value: 2,
  63. observer: 'updatePrice',
  64. },
  65. suffixLabel: String,
  66. safeAreaInsetBottom: {
  67. type: Boolean,
  68. value: true,
  69. },
  70. },
  71. methods: {
  72. updatePrice() {
  73. const { price, decimalLength } = this.data;
  74. const priceStrArr = typeof price === 'number' &&
  75. (price / 100).toFixed(decimalLength).split('.');
  76. this.setData({
  77. hasPrice: typeof price === 'number',
  78. integerStr: priceStrArr && priceStrArr[0],
  79. decimalStr: decimalLength && priceStrArr ? `.${priceStrArr[1]}` : '',
  80. });
  81. },
  82. updateTip() {
  83. this.setData({ hasTip: typeof this.data.tip === 'string' });
  84. },
  85. onSubmit(event) {
  86. this.$emit('submit', event.detail);
  87. },
  88. },
  89. });
  90. export default global['__wxComponents']['vant/submit-bar/index']
  91. </script>
  92. <style platform="mp-weixin">
  93. @import '../common/index.css';.van-submit-bar{background-color:var(--submit-bar-background-color,#fff);bottom:0;left:0;position:fixed;-webkit-user-select:none;user-select:none;width:100%;z-index:var(--submit-bar-z-index,100)}.van-submit-bar__tip{background-color:var(--submit-bar-tip-background-color,#fff7cc);color:var(--submit-bar-tip-color,#f56723);font-size:var(--submit-bar-tip-font-size,12px);line-height:var(--submit-bar-tip-line-height,1.5);padding:var(--submit-bar-tip-padding,10px)}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{margin-right:4px;vertical-align:middle}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{align-items:center;background-color:var(--submit-bar-background-color,#fff);display:flex;font-size:var(--submit-bar-text-font-size,14px);height:var(--submit-bar-height,50px);justify-content:flex-end;padding:var(--submit-bar-padding,0 16px)}.van-submit-bar__safe{height:constant(safe-area-inset-bottom);height:env(safe-area-inset-bottom)}.van-submit-bar__text{color:var(--submit-bar-text-color,#323233);flex:1;font-weight:var(--font-weight-bold,500);padding-right:var(--padding-sm,12px);text-align:right}.van-submit-bar__price{color:var(--submit-bar-price-color,#ee0a24);font-size:var(--submit-bar-price-font-size,12px);font-weight:var(--font-weight-bold,500)}.van-submit-bar__price-integer{font-family:Avenir-Heavy,PingFang SC,Helvetica Neue,Arial,sans-serif;font-size:20px}.van-submit-bar__currency{font-size:var(--submit-bar-currency-font-size,12px)}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{--button-default-height:var(--submit-bar-button-height,40px)!important;--button-line-height:var(--submit-bar-button-height,40px)!important;font-weight:var(--font-weight-bold,500);width:var(--submit-bar-button-width,110px)}
  94. </style>