bulade-ui 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/miniprogram_dist/bld-action-sheet/index.js +196 -0
  2. package/miniprogram_dist/bld-action-sheet/index.js.map +1 -0
  3. package/miniprogram_dist/bld-action-sheet/index.json +8 -0
  4. package/miniprogram_dist/bld-action-sheet/index.wxml +57 -0
  5. package/miniprogram_dist/bld-action-sheet/index.wxss +160 -0
  6. package/miniprogram_dist/bld-badge/index.js +156 -0
  7. package/miniprogram_dist/bld-badge/index.js.map +1 -0
  8. package/miniprogram_dist/bld-badge/index.json +4 -0
  9. package/miniprogram_dist/bld-badge/index.wxml +14 -0
  10. package/miniprogram_dist/bld-badge/index.wxss +43 -0
  11. package/miniprogram_dist/bld-button/index.wxml +0 -1
  12. package/miniprogram_dist/bld-drawer/index.js +2 -2
  13. package/miniprogram_dist/bld-drawer/index.js.map +1 -1
  14. package/miniprogram_dist/bld-drawer/index.wxss +4 -3
  15. package/miniprogram_dist/bld-empty-page/index.js +123 -0
  16. package/miniprogram_dist/bld-empty-page/index.js.map +1 -0
  17. package/miniprogram_dist/bld-empty-page/index.json +3 -0
  18. package/miniprogram_dist/bld-empty-page/index.wxml +11 -0
  19. package/miniprogram_dist/bld-empty-page/index.wxss +14 -0
  20. package/miniprogram_dist/bld-message/index.js +2 -2
  21. package/miniprogram_dist/bld-message/index.js.map +1 -1
  22. package/miniprogram_dist/bld-message/message.js +2 -2
  23. package/miniprogram_dist/bld-message/message.js.map +1 -1
  24. package/miniprogram_dist/bld-modal/index.js +223 -0
  25. package/miniprogram_dist/bld-modal/index.js.map +1 -0
  26. package/miniprogram_dist/bld-modal/index.json +6 -0
  27. package/miniprogram_dist/bld-modal/index.wxml +23 -0
  28. package/miniprogram_dist/bld-modal/index.wxss +97 -0
  29. package/miniprogram_dist/bld-modal/modal.js +147 -0
  30. package/miniprogram_dist/bld-modal/modal.js.map +1 -0
  31. package/miniprogram_dist/bld-navbar/index.js +167 -0
  32. package/miniprogram_dist/bld-navbar/index.js.map +1 -0
  33. package/miniprogram_dist/bld-navbar/index.json +6 -0
  34. package/miniprogram_dist/bld-navbar/index.wxml +8 -0
  35. package/miniprogram_dist/bld-navbar/index.wxss +31 -0
  36. package/miniprogram_dist/bld-navbar-group/index.js +243 -0
  37. package/miniprogram_dist/bld-navbar-group/index.js.map +1 -0
  38. package/miniprogram_dist/bld-navbar-group/index.json +4 -0
  39. package/miniprogram_dist/bld-navbar-group/index.wxml +37 -0
  40. package/miniprogram_dist/bld-navbar-group/index.wxss +30 -0
  41. package/miniprogram_dist/bld-notice-bar/index.js +171 -0
  42. package/miniprogram_dist/bld-notice-bar/index.js.map +1 -0
  43. package/miniprogram_dist/bld-notice-bar/index.json +3 -0
  44. package/miniprogram_dist/bld-notice-bar/index.wxml +30 -0
  45. package/miniprogram_dist/bld-notice-bar/index.wxss +51 -0
  46. package/miniprogram_dist/bld-pop-up/index.js +129 -0
  47. package/miniprogram_dist/bld-pop-up/index.js.map +1 -0
  48. package/miniprogram_dist/bld-pop-up/index.json +6 -0
  49. package/miniprogram_dist/bld-pop-up/index.wxml +18 -0
  50. package/miniprogram_dist/bld-pop-up/index.wxss +27 -0
  51. package/miniprogram_dist/bld-tag/index.js +134 -0
  52. package/miniprogram_dist/bld-tag/index.js.map +1 -0
  53. package/miniprogram_dist/bld-tag/index.json +3 -0
  54. package/miniprogram_dist/bld-tag/index.wxml +3 -0
  55. package/miniprogram_dist/bld-tag/index.wxss +108 -0
  56. package/miniprogram_dist/bld-toast/index.js +2 -2
  57. package/miniprogram_dist/bld-toast/index.js.map +1 -1
  58. package/miniprogram_dist/bld-toast/toast.js +2 -2
  59. package/miniprogram_dist/bld-toast/toast.js.map +1 -1
  60. package/miniprogram_dist/cell/index.js +2 -2
  61. package/miniprogram_dist/cell/index.js.map +1 -1
  62. package/miniprogram_dist/cell-group/index.js +2 -2
  63. package/miniprogram_dist/cell-group/index.js.map +1 -1
  64. package/miniprogram_dist/grid/index.js +2 -2
  65. package/miniprogram_dist/grid/index.js.map +1 -1
  66. package/miniprogram_dist/grid-item/index.js +2 -2
  67. package/miniprogram_dist/grid-item/index.js.map +1 -1
  68. package/miniprogram_dist/icon/index.js +2 -2
  69. package/miniprogram_dist/icon/index.js.map +1 -1
  70. package/miniprogram_dist/timeline/index.js +2 -2
  71. package/miniprogram_dist/timeline/index.js.map +1 -1
  72. package/miniprogram_dist/timeline-item/index.js +2 -2
  73. package/miniprogram_dist/timeline-item/index.js.map +1 -1
  74. package/package.json +1 -1
  75. package/src/bld-action-sheet/index.js +83 -0
  76. package/src/bld-action-sheet/index.json +8 -0
  77. package/src/bld-action-sheet/index.scss +180 -0
  78. package/src/bld-action-sheet/index.wxml +57 -0
  79. package/src/bld-action-sheet/index.wxss +160 -0
  80. package/src/bld-badge/index.js +53 -0
  81. package/src/bld-badge/index.json +4 -0
  82. package/src/bld-badge/index.scss +46 -0
  83. package/src/bld-badge/index.wxml +14 -0
  84. package/src/bld-badge/index.wxss +43 -0
  85. package/src/bld-button/index.wxml +0 -1
  86. package/src/bld-content-container/index.js +46 -0
  87. package/src/bld-content-container/index.json +3 -0
  88. package/src/bld-content-container/index.scss +0 -0
  89. package/src/bld-content-container/index.wxml +5 -0
  90. package/src/bld-content-container/index.wxss +0 -0
  91. package/src/bld-drawer/index.scss +8 -3
  92. package/src/bld-drawer/index.wxss +4 -3
  93. package/src/bld-empty-page/index.js +23 -0
  94. package/src/bld-empty-page/index.json +3 -0
  95. package/src/bld-empty-page/index.scss +15 -0
  96. package/src/bld-empty-page/index.wxml +11 -0
  97. package/src/bld-empty-page/index.wxss +14 -0
  98. package/src/bld-modal/index.js +123 -0
  99. package/src/bld-modal/index.json +6 -0
  100. package/src/bld-modal/index.scss +108 -0
  101. package/src/bld-modal/index.wxml +23 -0
  102. package/src/bld-modal/index.wxss +97 -0
  103. package/src/bld-modal/modal.js +38 -0
  104. package/src/bld-navbar/index.js +63 -0
  105. package/src/bld-navbar/index.json +6 -0
  106. package/src/bld-navbar/index.scss +35 -0
  107. package/src/bld-navbar/index.wxml +8 -0
  108. package/src/bld-navbar/index.wxss +31 -0
  109. package/src/bld-navbar-group/index.js +139 -0
  110. package/src/bld-navbar-group/index.json +4 -0
  111. package/src/bld-navbar-group/index.scss +33 -0
  112. package/src/bld-navbar-group/index.wxml +37 -0
  113. package/src/bld-navbar-group/index.wxss +30 -0
  114. package/src/bld-notice-bar/index.js +69 -0
  115. package/src/bld-notice-bar/index.json +3 -0
  116. package/src/bld-notice-bar/index.scss +59 -0
  117. package/src/bld-notice-bar/index.wxml +30 -0
  118. package/src/bld-notice-bar/index.wxss +51 -0
  119. package/src/bld-pop-up/index.js +29 -0
  120. package/src/bld-pop-up/index.json +6 -0
  121. package/src/bld-pop-up/index.scss +27 -0
  122. package/src/bld-pop-up/index.wxml +18 -0
  123. package/src/bld-pop-up/index.wxss +27 -0
  124. package/src/bld-tag/index.js +34 -0
  125. package/src/bld-tag/index.json +3 -0
  126. package/src/bld-tag/index.scss +127 -0
  127. package/src/bld-tag/index.wxml +3 -0
  128. package/src/bld-tag/index.wxss +108 -0
@@ -0,0 +1,108 @@
1
+ .m-mask {
2
+ z-index: 1000;
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ right: 0;
7
+ bottom: 0;
8
+ opacity: 1;
9
+ visibility: visible;
10
+ background: var(--color-mask, rgba(0, 0, 0, 0.55));
11
+ transition: all 0.25s ease-in-out;
12
+
13
+ &.is-hidden {
14
+ opacity: 0;
15
+ visibility: hidden;
16
+ }
17
+ }
18
+
19
+ .m-modal-wrap {
20
+ z-index: 1001;
21
+ position: fixed;
22
+ left: 50%;
23
+ top: 50%;
24
+ visibility: visible;
25
+ transform: translate3d(-50%, -50%, 0);
26
+
27
+ &.is-hidden {
28
+ visibility: hidden;
29
+ }
30
+
31
+ .m-modal {
32
+ z-index: 9;
33
+ position: relative;
34
+ width: 540rpx;
35
+ transform: scale(.9);
36
+ opacity: 0;
37
+ transition: transform 0.2s ease-in-out, opacity .2s ease-in-out;
38
+
39
+ &.is-show {
40
+ opacity: 1;
41
+ transform: scale(1);
42
+ }
43
+
44
+ .m-modal__content {
45
+ position: relative;
46
+ padding-top: 30rpx;
47
+ height: 100%;
48
+ border: 0;
49
+ border-radius: 3rpx;
50
+ text-align: center;
51
+ background-color: #fff;
52
+ background-clip: padding-box;
53
+ overflow: hidden;
54
+ }
55
+
56
+ .m-modal__title {
57
+ margin: 0;
58
+ padding: 12rpx 30rpx 24rpx;
59
+ font-size: 36rpx;
60
+ line-height: 1;
61
+ color: #1c2438;
62
+ text-align: center;
63
+ }
64
+
65
+ .m-modal__body {
66
+ max-height: 300rpx;
67
+ margin-bottom: 30rpx;
68
+ padding: 20rpx 40rpx;
69
+ font-size: 28rpx;
70
+ color: #80848f;
71
+ line-height: 1.5;
72
+ overflow: auto;
73
+ -webkit-overflow-scrolling: touch;
74
+ }
75
+
76
+ .m-modal__btn-group {
77
+ position: relative;
78
+ display: flex;
79
+
80
+ &::after {
81
+ content: '';
82
+ position: absolute;
83
+ top: 0;
84
+ left: 0;
85
+ width: 100%;
86
+ height: 1px;
87
+ transform: scaleY(0.5);
88
+ background: #ddd;
89
+ }
90
+
91
+ .m-modal__btn {
92
+ position: relative;
93
+ flex: 1;
94
+
95
+ &.m-modal__btn--cancel::after {
96
+ content: '';
97
+ position: absolute;
98
+ top: 0;
99
+ right: 0;
100
+ width: 1px;
101
+ height: 100%;
102
+ transform: scaleX(0.5);
103
+ background: #ddd;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
@@ -0,0 +1,23 @@
1
+ <view class="m-mask custom-mask-class {{ visible ? '' : 'is-hidden' }}" bindtap="onMaskClick"></view>
2
+
3
+ <view class="m-modal-wrap custom-class {{ visible ? '' : 'is-hidden' }}">
4
+ <view class="m-modal {{ visible ? 'is-show' : '' }}">
5
+ <view class="m-modal__content">
6
+ <view class="m-modal__title" wx:if="{{ title }}">{{ title }}</view>
7
+ <view class="m-modal__body custom-body-class" wx:if="{{ content }}">{{ content }}</view>
8
+ <view class="m-modal__body custom-body-class" wx:else>
9
+ <slot />
10
+ </view>
11
+ <view class="m-modal__btn-group">
12
+ <view class="m-modal__btn m-modal__btn--cancel" wx:if="{{ showCancelButton }}">
13
+ <m-button full type="ghost" bind:click="onCancel">{{ cancelButtonText }}</m-button>
14
+ </view>
15
+ <view class="m-modal__btn" wx:if="{{ showConfirmButton }}">
16
+ <m-button full type="ghost" loading="{{ loading }}" bind:click="onConfirm" color="{{ confirmTextColor }}">
17
+ {{ confirmButtonText }}
18
+ </m-button>
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </view>
23
+ </view>
@@ -0,0 +1,97 @@
1
+ .m-mask {
2
+ z-index: 1000;
3
+ position: fixed;
4
+ top: 0;
5
+ left: 0;
6
+ right: 0;
7
+ bottom: 0;
8
+ opacity: 1;
9
+ visibility: visible;
10
+ background: var(--color-mask, rgba(0, 0, 0, 0.55));
11
+ transition: all 0.25s ease-in-out;
12
+ }
13
+ .m-mask.is-hidden {
14
+ opacity: 0;
15
+ visibility: hidden;
16
+ }
17
+
18
+ .m-modal-wrap {
19
+ z-index: 1001;
20
+ position: fixed;
21
+ left: 50%;
22
+ top: 50%;
23
+ visibility: visible;
24
+ transform: translate3d(-50%, -50%, 0);
25
+ }
26
+ .m-modal-wrap.is-hidden {
27
+ visibility: hidden;
28
+ }
29
+ .m-modal-wrap .m-modal {
30
+ z-index: 9;
31
+ position: relative;
32
+ width: 540rpx;
33
+ transform: scale(0.9);
34
+ opacity: 0;
35
+ transition: transform 0.2s ease-in-out, opacity 0.2s ease-in-out;
36
+ }
37
+ .m-modal-wrap .m-modal.is-show {
38
+ opacity: 1;
39
+ transform: scale(1);
40
+ }
41
+ .m-modal-wrap .m-modal .m-modal__content {
42
+ position: relative;
43
+ padding-top: 30rpx;
44
+ height: 100%;
45
+ border: 0;
46
+ border-radius: 3rpx;
47
+ text-align: center;
48
+ background-color: #fff;
49
+ background-clip: padding-box;
50
+ overflow: hidden;
51
+ }
52
+ .m-modal-wrap .m-modal .m-modal__title {
53
+ margin: 0;
54
+ padding: 12rpx 30rpx 24rpx;
55
+ font-size: 36rpx;
56
+ line-height: 1;
57
+ color: #1c2438;
58
+ text-align: center;
59
+ }
60
+ .m-modal-wrap .m-modal .m-modal__body {
61
+ max-height: 300rpx;
62
+ margin-bottom: 30rpx;
63
+ padding: 20rpx 40rpx;
64
+ font-size: 28rpx;
65
+ color: #80848f;
66
+ line-height: 1.5;
67
+ overflow: auto;
68
+ -webkit-overflow-scrolling: touch;
69
+ }
70
+ .m-modal-wrap .m-modal .m-modal__btn-group {
71
+ position: relative;
72
+ display: flex;
73
+ }
74
+ .m-modal-wrap .m-modal .m-modal__btn-group::after {
75
+ content: "";
76
+ position: absolute;
77
+ top: 0;
78
+ left: 0;
79
+ width: 100%;
80
+ height: 1px;
81
+ transform: scaleY(0.5);
82
+ background: #ddd;
83
+ }
84
+ .m-modal-wrap .m-modal .m-modal__btn-group .m-modal__btn {
85
+ position: relative;
86
+ flex: 1;
87
+ }
88
+ .m-modal-wrap .m-modal .m-modal__btn-group .m-modal__btn.m-modal__btn--cancel::after {
89
+ content: "";
90
+ position: absolute;
91
+ top: 0;
92
+ right: 0;
93
+ width: 1px;
94
+ height: 100%;
95
+ transform: scaleX(0.5);
96
+ background: #ddd;
97
+ }
@@ -0,0 +1,38 @@
1
+ function getCtx(selector) {
2
+ const pages = getCurrentPages()
3
+ const ctx = pages[pages.length - 1]
4
+ const componentCtx = ctx.selectComponent(selector)
5
+
6
+ if (!componentCtx) {
7
+ console.error('无法找到对应的组件,请按文档说明使用组件')
8
+ return null
9
+ }
10
+ return componentCtx
11
+ }
12
+
13
+ const Modal = options => {
14
+
15
+ return new Promise((resolve, reject) => {
16
+ const { selector = '#modal' } = options
17
+ const modal = getCtx(selector)
18
+ modal._reset()
19
+
20
+ modal._confirm = resolve
21
+ modal._cancel = reject
22
+ modal._show(options)
23
+
24
+ return modal
25
+ })
26
+ }
27
+
28
+ Modal.alert = options => Modal(Object.assign({
29
+ showCancelButton: false
30
+ }, options))
31
+ Modal.confirm = options => Modal(options)
32
+
33
+ Modal.close = (selector = '#modal') => {
34
+ const ctx = getCtx(selector)
35
+ ctx.close()
36
+ }
37
+
38
+ export default Modal
@@ -0,0 +1,63 @@
1
+ Component({
2
+ externalClasses: ['custom-class'],
3
+
4
+ options: {
5
+ addGlobalClass: true,
6
+ },
7
+
8
+ relations: {
9
+ '../bld-navbar-group/index': {
10
+ type: 'parent',
11
+ linked(target) {
12
+ this.parent = target
13
+ },
14
+ unlinked() {
15
+ this.parent = null
16
+ }
17
+ }
18
+ },
19
+
20
+ properties: {
21
+ name: {
22
+ type: String,
23
+ value: ''
24
+ },
25
+ title: {
26
+ type: String,
27
+ value: ''
28
+ },
29
+ value: {
30
+ type: String,
31
+ optionalTypes: [Number, String],
32
+ value: ''
33
+ }
34
+ },
35
+
36
+ data: {
37
+ activeName: '',
38
+ activeColor: ''
39
+ },
40
+
41
+ methods: {
42
+ onClick(ev = null) {
43
+ const parent = this.parent
44
+
45
+ parent.triggerEvent('click', this.data.name)
46
+
47
+ const baseLeft = parent.data.baseLeft
48
+
49
+ const query = this.createSelectorQuery()
50
+
51
+ query.select('.m-tab-item').boundingClientRect()
52
+ query.select('.m-tab-item__text').boundingClientRect()
53
+
54
+ query.exec(res => {
55
+ const offsetLeft = ev ? ev.currentTarget.offsetLeft : res[0].left - baseLeft
56
+ const itemWidth = res[0].width
57
+ const textWidth = res[1].width
58
+
59
+ parent.updateScrollPositon(offsetLeft, itemWidth, textWidth, this.data.name)
60
+ })
61
+ }
62
+ }
63
+ })
@@ -0,0 +1,6 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {
4
+ "bld-badge": "../bld-badge/index"
5
+ }
6
+ }
@@ -0,0 +1,35 @@
1
+ :host {
2
+ flex: 1;
3
+ }
4
+
5
+ .m-tab-item {
6
+ position: relative;
7
+ flex: 1;
8
+ box-sizing: border-box;
9
+ padding: 0 5px;
10
+ display: flex;
11
+ justify-content: center;
12
+ color: #7d7e80;
13
+ line-height: 88rpx;
14
+ font-size: 28rpx;
15
+ -webkit-tap-highlight-color: transparent;
16
+
17
+ &.is-active {
18
+ font-weight: 500;
19
+ color: #323233;
20
+ }
21
+
22
+ .m-tab-item__content {
23
+ margin: 0 20rpx;
24
+ white-space: nowrap;
25
+
26
+ .m-tab-item__text {
27
+ display: inline-block;
28
+
29
+ .m-badge-custom {
30
+ margin-left: 6rpx;
31
+ vertical-align: text-top;
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,8 @@
1
+ <view class="m-tab-item {{activeName === name ? 'is-active': ''}}" bind:tap="onClick">
2
+ <view class="m-tab-item__content">
3
+ <view class="m-tab-item__text" style="{{ activeColor ? 'color:' + activeColor: '' }}">
4
+ {{ title }}
5
+ <bld-badge wx:if="{{ value }}" custom-class="m-badge-custom" value="{{ value }}" static />
6
+ </view>
7
+ </view>
8
+ </view>
@@ -0,0 +1,31 @@
1
+ :host {
2
+ flex: 1;
3
+ }
4
+
5
+ .m-tab-item {
6
+ position: relative;
7
+ flex: 1;
8
+ box-sizing: border-box;
9
+ padding: 0 5px;
10
+ display: flex;
11
+ justify-content: center;
12
+ color: #7d7e80;
13
+ line-height: 88rpx;
14
+ font-size: 28rpx;
15
+ -webkit-tap-highlight-color: transparent;
16
+ }
17
+ .m-tab-item.is-active {
18
+ font-weight: 500;
19
+ color: #323233;
20
+ }
21
+ .m-tab-item .m-tab-item__content {
22
+ margin: 0 20rpx;
23
+ white-space: nowrap;
24
+ }
25
+ .m-tab-item .m-tab-item__content .m-tab-item__text {
26
+ display: inline-block;
27
+ }
28
+ .m-tab-item .m-tab-item__content .m-tab-item__text .m-badge-custom {
29
+ margin-left: 6rpx;
30
+ vertical-align: text-top;
31
+ }
@@ -0,0 +1,139 @@
1
+ Component({
2
+ externalClasses: ['custom-class'],
3
+
4
+ options: {
5
+ addGlobalClass: true,
6
+ },
7
+
8
+ relations: {
9
+ '../bld-navbar/index': {
10
+ type: 'child',
11
+ linked() {
12
+ this._updateChildren()
13
+ },
14
+ unlinked() {
15
+ this._updateChildren()
16
+ }
17
+ }
18
+ },
19
+
20
+ properties: {
21
+ activeName: {
22
+ type: String,
23
+ optionalTypes: [Number, String],
24
+ value: ''
25
+ },
26
+
27
+ activeColor: {
28
+ type: String,
29
+ value: ''
30
+ },
31
+
32
+ lineWidth: {
33
+ type: Number,
34
+ optionalTypes: [Number, String],
35
+ value: 0
36
+ },
37
+
38
+ lineColor: {
39
+ type: String,
40
+ value: ''
41
+ },
42
+
43
+ lineHeight: {
44
+ type: Number,
45
+ value: 6
46
+ }
47
+ },
48
+
49
+ data: {
50
+ baseLeft: 0,
51
+ scrollLeft: 0,
52
+ lineLeft: 0,
53
+ activeLineWidth: 0,
54
+ tabWidth: 0,
55
+ },
56
+
57
+ methods: {
58
+ _updateChildren() {
59
+ // 防抖减少重复触发
60
+ if (this.timer) {
61
+ clearTimeout(this.timer)
62
+ this.timer = null
63
+ }
64
+
65
+ this.timer = setTimeout(() => {
66
+ let children = this.getRelationNodes('../navbar/index')
67
+ this.children = children
68
+ const len = children.length
69
+
70
+ // 渲染完成后更新内容区域宽度
71
+ if (len) {
72
+ this._updateWrapInfo(children)
73
+ }
74
+ }, 60)
75
+ },
76
+
77
+
78
+ // 渲染完成后更新内容区域宽度
79
+ _updateWrapInfo(children) {
80
+ wx.nextTick(() => {
81
+ const query = this.createSelectorQuery()
82
+ query.select('.m-tabs').boundingClientRect()
83
+ query.select('.m-tabs__scroll').scrollOffset()
84
+ query.exec(res => {
85
+ this.data.baseLeft = res[0].left
86
+
87
+ const tabWidth = res[0].width // 选项卡总宽度
88
+ this.data.tabWidth = tabWidth
89
+
90
+ const { activeName } = this.data
91
+
92
+ if (activeName) {
93
+ children.forEach((child, index) => {
94
+ if (child.data.name === activeName) {
95
+ child.onClick()
96
+ }
97
+ })
98
+ } else {
99
+ children[0].onClick()
100
+ }
101
+
102
+ })
103
+ })
104
+ },
105
+
106
+
107
+ updateScrollPositon(left, domWidth, lineWidth, name) {
108
+
109
+ // 设置选中标签的字体颜色
110
+ const { activeColor } = this.data
111
+
112
+ if (activeColor) {
113
+ this.children.forEach((child, index) => {
114
+ let color = child.data.name === name ? activeColor : ''
115
+ child.setData({
116
+ activeName: name,
117
+ activeColor: color
118
+ })
119
+ })
120
+ }
121
+
122
+ const scrollLeft = left - this.data.tabWidth / 2 + domWidth / 2
123
+
124
+ const custonLineWidth = Math.floor(parseInt(this.data.lineWidth) * (this.data.tabWidth / 750))
125
+
126
+ const activeLineWidth = custonLineWidth ? custonLineWidth <= domWidth ? custonLineWidth : domWidth : lineWidth
127
+
128
+ const lineLeft = left + domWidth / 2 - activeLineWidth / 2
129
+
130
+ this.setData({
131
+ scrollLeft,
132
+ lineLeft,
133
+ activeLineWidth
134
+ }, () => {
135
+ this.triggerEvent('change', name)
136
+ })
137
+ }
138
+ }
139
+ })
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "usingComponents": {}
4
+ }
@@ -0,0 +1,33 @@
1
+ .m-tabs {
2
+ position: relative;
3
+ justify-content: center;
4
+ height: 88rpx;
5
+ overflow: hidden;
6
+
7
+ .m-tabs__scroll {
8
+ margin-bottom: 10rpx;
9
+ height: 88rpx;
10
+
11
+ .m-tabs__nav {
12
+ position: relative;
13
+ display: flex;
14
+
15
+ .m-tabs__line {
16
+ position: absolute;
17
+ bottom: 0;
18
+ left: 0;
19
+ z-index: 1;
20
+ height: 6rpx;
21
+ border-radius: 12rpx;
22
+ background-color: var(--color-primary, #409EFF);
23
+ transition-duration: 0.3s;
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ ::-webkit-scrollbar {
30
+ width: 0;
31
+ height: 0;
32
+ color: transparent;
33
+ }
@@ -0,0 +1,37 @@
1
+ <view class="m-tabs custom-class">
2
+ <scroll-view
3
+ scroll-x="{{ true }}"
4
+ scroll-with-animation
5
+ scroll-left="{{ -130 }}"
6
+ class="m-tabs__scroll"
7
+ >
8
+ <view class="m-tabs__nav">
9
+ <view class="m-tabs__line" wx:if="{{ true }}" style="{{ tabs.getLineStyle(lineLeft, activeLineWidth, lineHeight, lineColor) }}"></view>
10
+ <slot />
11
+ </view>
12
+ </scroll-view>
13
+ </view>
14
+
15
+
16
+ <wxs module="tabs">
17
+ function getLineStyle(lineLeft, lineWidth, lineHeight, lineColor) {
18
+ var styles = [
19
+ 'transform: translateX(' + lineLeft + 'px)',
20
+ 'width:' + lineWidth + 'px'
21
+ ];
22
+
23
+ if(lineHeight) {
24
+ styles.push('height:' + lineHeight + 'rpx')
25
+ }
26
+
27
+ if(lineColor) {
28
+ styles.push('background-color:' + lineColor)
29
+ }
30
+
31
+ return styles.join(';');
32
+ }
33
+
34
+ module.exports = {
35
+ getLineStyle: getLineStyle
36
+ }
37
+ </wxs>
@@ -0,0 +1,30 @@
1
+ .m-tabs {
2
+ position: relative;
3
+ justify-content: center;
4
+ height: 88rpx;
5
+ overflow: hidden;
6
+ }
7
+ .m-tabs .m-tabs__scroll {
8
+ margin-bottom: 10rpx;
9
+ height: 88rpx;
10
+ }
11
+ .m-tabs .m-tabs__scroll .m-tabs__nav {
12
+ position: relative;
13
+ display: flex;
14
+ }
15
+ .m-tabs .m-tabs__scroll .m-tabs__nav .m-tabs__line {
16
+ position: absolute;
17
+ bottom: 0;
18
+ left: 0;
19
+ z-index: 1;
20
+ height: 6rpx;
21
+ border-radius: 12rpx;
22
+ background-color: var(--color-primary, #409EFF);
23
+ transition-duration: 0.3s;
24
+ }
25
+
26
+ ::-webkit-scrollbar {
27
+ width: 0;
28
+ height: 0;
29
+ color: transparent;
30
+ }