1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
| import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
| // Utils
| import { createNamespace } from '../utils';
| import { emit, inherit } from '../utils/functional'; // Components
|
| import Icon from '../icon';
| import Button from '../button'; // Types
|
| var _createNamespace = createNamespace('submit-bar'),
| createComponent = _createNamespace[0],
| bem = _createNamespace[1],
| t = _createNamespace[2];
|
| function SubmitBar(h, props, slots, ctx) {
| var tip = props.tip,
| price = props.price,
| tipIcon = props.tipIcon;
|
| function Text() {
| if (typeof price === 'number') {
| var priceArr = (price / 100).toFixed(props.decimalLength).split('.');
| var decimalStr = props.decimalLength ? "." + priceArr[1] : '';
| return h("div", {
| "style": {
| textAlign: props.textAlign ? props.textAlign : ''
| },
| "class": bem('text')
| }, [h("span", [props.label || t('label')]), h("span", {
| "class": bem('price')
| }, [props.currency, h("span", {
| "class": bem('price', 'integer')
| }, [priceArr[0]]), decimalStr]), props.suffixLabel && h("span", {
| "class": bem('suffix-label')
| }, [props.suffixLabel])]);
| }
| }
|
| function Tip() {
| if (slots.tip || tip) {
| return h("div", {
| "class": bem('tip')
| }, [tipIcon && h(Icon, {
| "class": bem('tip-icon'),
| "attrs": {
| "name": tipIcon
| }
| }), tip && h("span", {
| "class": bem('tip-text')
| }, [tip]), slots.tip && slots.tip()]);
| }
| }
|
| return h("div", _mergeJSXProps([{
| "class": bem({
| unfit: !props.safeAreaInsetBottom
| })
| }, inherit(ctx)]), [slots.top && slots.top(), Tip(), h("div", {
| "class": bem('bar')
| }, [slots.default && slots.default(), Text(), slots.button ? slots.button() : h(Button, {
| "attrs": {
| "round": true,
| "type": props.buttonType,
| "text": props.loading ? '' : props.buttonText,
| "color": props.buttonColor,
| "loading": props.loading,
| "disabled": props.disabled
| },
| "class": bem('button', props.buttonType),
| "on": {
| "click": function click() {
| emit(ctx, 'submit');
| }
| }
| })])]);
| }
|
| SubmitBar.props = {
| tip: String,
| label: String,
| price: Number,
| tipIcon: String,
| loading: Boolean,
| disabled: Boolean,
| textAlign: String,
| buttonText: String,
| buttonColor: String,
| suffixLabel: String,
| safeAreaInsetBottom: {
| type: Boolean,
| default: true
| },
| decimalLength: {
| type: [Number, String],
| default: 2
| },
| currency: {
| type: String,
| default: '¥'
| },
| buttonType: {
| type: String,
| default: 'danger'
| }
| };
| export default createComponent(SubmitBar);
|
|