index.vue 3.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 '+(utils.bem('submit-bar__bar', { safe: safeAreaInsetBottom && isIPhoneX }))">
  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>{{ priceStr }}</text>
  18. </text>
  19. <text class="van-submit-bar__suffix-label">{{ suffixLabel }}</text>
  20. </view>
  21. <van-button square size="large" :type="buttonType" :loading="loading" :disabled="disabled" class="van-submit-bar__button" custom-class="button-class" @click="onSubmit">
  22. {{ loading ? '' : buttonText }}
  23. </van-button>
  24. </view>
  25. </view></uni-shadow-root>
  26. </template>
  27. <wxs src="../wxs/utils.wxs" module="utils"></wxs>
  28. <script>
  29. import VanButton from '../button/index.vue'
  30. import VanIcon from '../icon/index.vue'
  31. global['__wxVueOptions'] = {components:{'van-button': VanButton,'van-icon': VanIcon}}
  32. global['__wxRoute'] = 'vant/submit-bar/index'
  33. import { VantComponent } from '../common/component';
  34. import { safeArea } from '../mixins/safe-area';
  35. VantComponent({
  36. mixins: [safeArea()],
  37. classes: [
  38. 'bar-class',
  39. 'price-class',
  40. 'button-class'
  41. ],
  42. props: {
  43. tip: {
  44. type: null,
  45. observer: 'updateTip'
  46. },
  47. tipIcon: String,
  48. type: Number,
  49. price: {
  50. type: null,
  51. observer: 'updatePrice'
  52. },
  53. label: String,
  54. loading: Boolean,
  55. disabled: Boolean,
  56. buttonText: String,
  57. currency: {
  58. type: String,
  59. value: '¥'
  60. },
  61. buttonType: {
  62. type: String,
  63. value: 'danger'
  64. },
  65. decimalLength: {
  66. type: Number,
  67. value: 2,
  68. observer: 'updatePrice'
  69. },
  70. suffixLabel: String
  71. },
  72. methods: {
  73. updatePrice() {
  74. const { price, decimalLength } = this.data;
  75. this.set({
  76. hasPrice: typeof price === 'number',
  77. priceStr: (price / 100).toFixed(decimalLength)
  78. });
  79. },
  80. updateTip() {
  81. this.set({ hasTip: typeof this.data.tip === 'string' });
  82. },
  83. onSubmit(event) {
  84. this.$emit('submit', event.detail);
  85. }
  86. }
  87. });
  88. export default global['__wxComponents']['vant/submit-bar/index']
  89. </script>
  90. <style platform="mp-weixin">
  91. @import '../common/index.css';.van-submit-bar{position:fixed;bottom:0;left:0;z-index:100;width:100%;-webkit-user-select:none;user-select:none}.van-submit-bar__tip{padding:10px;font-size:12px;line-height:1.5;color:#f56723;background-color:#fff7cc}.van-submit-bar__tip:empty{display:none}.van-submit-bar__tip-icon{width:12px;height:12px;margin-right:4px;vertical-align:middle}.van-submit-bar__tip-text{display:inline;vertical-align:middle}.van-submit-bar__bar{display:-webkit-flex;display:flex;height:50px;font-size:14px;background-color:#fff;-webkit-align-items:center;align-items:center;-webkit-justify-content:flex-end;justify-content:flex-end}.van-submit-bar__bar--safe{padding-bottom:34px}.van-submit-bar__text{padding-right:12px;font-weight:500;color:#333;-webkit-flex:1;flex:1;text-align:right}.van-submit-bar__price{font-size:18px;color:#f44}.van-submit-bar__currency{font-size:14px}.van-submit-bar__suffix-label{margin-left:5px}.van-submit-bar__button{width:110px}
  92. </style>