dolphin-weex-ui 2.2.0 → 2.2.1

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.
@@ -1,209 +1,217 @@
1
1
  <template>
2
- <div class="step-body">
3
- <div class="step-item-wrapper" :style="[rowStyles]" ref="wrapper">
4
- <div class="step-flow-wrapper">
5
- <template v-for="(item, index) in formattedList">
6
- <div v-if="index < formattedList.length-1" :class="['step-line', showLine&&'hline']" :key="'line'+index" :style="[item.lineStyles, linePos[index]]"></div>
7
- </template>
8
- </div>
9
- <div v-for="(item, index) in formattedList" :key="'desc'+index" class="step-item" :ref="'item'+index" :style="[item.columnStyles]">
10
- <div :class="['step-point']" :style="[item.pointStyles]" :ref="'point'+index"></div>
11
- <text :class="['step-desc']" :style="[item.descStyles]">{{item.desc}}</text>
12
- </div>
13
- </div>
2
+ <div class="step-body">
3
+ <div class="step-item-wrapper" :style="[rowStyles]" ref="wrapper">
4
+ <div class="step-flow-wrapper">
5
+ <template v-for="(item, index) in formattedList">
6
+ <div
7
+ v-if="index < formattedList.length - 1"
8
+ :class="['step-line', showLine && 'hline']"
9
+ :key="'line' + index"
10
+ :style="{ ...item.lineStyles, ...linePos[index] }"
11
+ ></div>
12
+ </template>
13
+ </div>
14
+ <div
15
+ v-for="(item, index) in formattedList"
16
+ :key="'desc' + index"
17
+ class="step-item"
18
+ :ref="'item' + index"
19
+ :style="[item.columnStyles]"
20
+ >
21
+ <div :class="['step-point']" :style="[item.pointStyles]" :ref="'point' + index"></div>
22
+ <text :class="['step-desc']" :style="[item.descStyles]">{{ item.desc }}</text>
23
+ </div>
14
24
  </div>
25
+ </div>
15
26
  </template>
16
27
 
17
28
  <script>
18
29
  const domModule = weex.requireModule('dom')
19
30
  export default {
20
- props: {
21
- list: {
22
- type: Array,
23
- default: ()=>[]
24
- },
25
- stylesConfig: {
26
- type: Object,
27
- default: function () {
28
- return {
29
- }
30
- }
31
- },
32
- showLine:{
33
- type: Boolean,
34
- default: false
35
- }
31
+ props: {
32
+ list: {
33
+ type: Array,
34
+ default: () => []
36
35
  },
37
- data() {
38
- return {
39
- componentWidth: 750,
40
- activeIndex: -1,
41
- linePos: []
42
- }
36
+ stylesConfig: {
37
+ type: Object,
38
+ default: function() {
39
+ return {}
40
+ }
43
41
  },
44
- watch: {
45
- list(newVal) {
46
- this.$nextTick(() => {
47
- setTimeout(() => {
48
- this.init()
49
- }, 100);
50
- })
51
- }
42
+ showLine: {
43
+ type: Boolean,
44
+ default: false
45
+ }
46
+ },
47
+ data() {
48
+ return {
49
+ componentWidth: 750,
50
+ activeIndex: -1,
51
+ linePos: []
52
+ }
53
+ },
54
+ watch: {
55
+ list(newVal) {
56
+ this.$nextTick(() => {
57
+ setTimeout(() => {
58
+ this.init()
59
+ }, 100)
60
+ })
61
+ }
62
+ },
63
+ computed: {
64
+ formattedList() {
65
+ let formattedList = this.formatList(this.list)
66
+ return formattedList
52
67
  },
53
- computed: {
54
- formattedList() {
55
- return this.formatList(this.list)
56
- },
57
- rowStyles() {
58
- const {
59
- rowStyles = {}
60
- } = this.stylesConfig
68
+ rowStyles() {
69
+ const { rowStyles = {} } = this.stylesConfig
61
70
 
62
- //处理行
63
- return { ...rowStyles }
64
- }
71
+ //处理行
72
+ return { ...rowStyles }
73
+ }
74
+ },
75
+ methods: {
76
+ init() {
77
+ this.list.forEach(item => {
78
+ this.linePos.push({ width: 0 })
79
+ })
80
+ // 确定第一条线的左边距离
81
+ if (this.linePos.length > 0) {
82
+ domModule.getComponentRect(this.$refs['item0'][0], data => {
83
+ this.linePos[0]['margin-left'] = data.size.width / 2 + 8 + 'px'
84
+ })
85
+ }
86
+ this.list.forEach((item, index, arr) => {
87
+ // 确定条线的宽度
88
+ domModule.getComponentRect(this.$refs['point' + index][0], data => {
89
+ if (index == 0) {
90
+ this.linePos[index]['data-right'] = data.size.right
91
+ } else {
92
+ this.linePos[index]['data-right'] = data.size.right
93
+ this.linePos[index - 1]['width'] = data.size.left - this.linePos[index - 1]['data-right'] + 'px'
94
+ }
95
+ })
96
+ })
65
97
  },
66
- methods: {
67
- init() {
68
- this.list.forEach((item) => {
69
- this.linePos.push({ width: 0 })
70
- })
71
- // 确定第一条线的左边距离
72
- if (this.linePos.length > 0) {
73
- domModule.getComponentRect(this.$refs['item0'][0], (data) => {
74
- this.linePos[0]['margin-left'] = (data.size.width / 2) + 8
75
- })
76
- }
77
- this.list.forEach((item, index, arr) => {
78
- // 确定条线的宽度
79
- domModule.getComponentRect(this.$refs['point' + index][0], (data) => {
80
- if (index == 0) {
81
- this.linePos[index]['data-right'] = data.size.right
82
- } else {
83
- this.linePos[index]['data-right'] = data.size.right
84
- this.linePos[index - 1]['width'] = data.size.left - this.linePos[index - 1]['data-right']
85
- }
86
- })
87
- })
88
- },
89
- formatList(list) {
90
- let tempList = JSON.parse(JSON.stringify(list))
91
- const {
92
- activedColor = '#00de51',
93
- pointStyles = {},
94
- lineStyles = {},
95
- descStyles = {},
96
- columnStyles = {}
97
- } = this.stylesConfig
98
+ formatList(list) {
99
+ let tempList = JSON.parse(JSON.stringify(list))
100
+ const {
101
+ activedColor = '#00de51',
102
+ pointStyles = {},
103
+ lineStyles = {},
104
+ descStyles = {},
105
+ columnStyles = {}
106
+ } = this.stylesConfig
98
107
 
99
- tempList.forEach((item, index) => {
100
- if (item.isActived) this.activeIndex = index
101
- })
108
+ tempList.forEach((item, index) => {
109
+ if (item.isActived) this.activeIndex = index
110
+ })
102
111
 
103
- let result = []
104
- result = tempList.map((item, index) => {
105
- //处理列
106
- item['columnStyles'] = { ...item['columnStyles'], ...columnStyles }
112
+ let result = []
113
+ result = tempList.map((item, index) => {
114
+ //处理列
115
+ item['columnStyles'] = { ...item['columnStyles'], ...columnStyles }
107
116
 
108
- //处理节点point
109
- item['pointStyles'] = { ...item['pointStyles'], ...pointStyles }
117
+ //处理节点point
118
+ item['pointStyles'] = { ...item['pointStyles'], ...pointStyles }
110
119
 
111
- if (index <= this.activeIndex) {
112
- item['pointStyles']['background-color'] = activedColor
113
- item['pointStyles']['opacity'] = 1
114
- }
120
+ if (index <= this.activeIndex) {
121
+ item['pointStyles']['background-color'] = activedColor
122
+ item['pointStyles']['opacity'] = 1
123
+ }
115
124
 
116
- //处理节点线条
117
- item['lineStyles'] = { ...item['lineStyles'], ...lineStyles }
118
- if (index < this.activeIndex) {
119
- item['lineStyles']['border-top-color'] = activedColor
120
- item['lineStyles']['opacity'] = 1
121
- }
125
+ //处理节点线条
126
+ item['lineStyles'] = { ...item['lineStyles'], ...lineStyles }
127
+ if (index < this.activeIndex) {
128
+ item['lineStyles']['border-top-color'] = activedColor
129
+ item['lineStyles']['opacity'] = 1
130
+ }
122
131
 
123
- //处理内容
124
- item['descStyles'] = { ...item['descStyles'], ...descStyles }
125
- if (item.isActived && activedColor) {
126
- item['descStyles']['color'] = activedColor
127
- item['descStyles']['opacity'] = 1
128
- }
132
+ //处理内容
133
+ item['descStyles'] = { ...item['descStyles'], ...descStyles }
134
+ if (item.isActived && activedColor) {
135
+ item['descStyles']['color'] = activedColor
136
+ item['descStyles']['opacity'] = 1
137
+ }
129
138
 
130
- return item
131
- })
139
+ return item
140
+ })
132
141
 
133
- console.log(JSON.stringify(result))
134
- return result
135
- }
136
- },
137
- mounted() {
138
- this.$nextTick(() => {
139
- setTimeout(() => {
140
- this.init()
141
- }, 100);
142
- })
142
+ return result
143
143
  }
144
+ },
145
+ mounted() {
146
+ this.$nextTick(() => {
147
+ setTimeout(() => {
148
+ this.init()
149
+ }, 100)
150
+ })
151
+ }
144
152
  }
145
153
  </script>
146
154
 
147
155
  <style scoped>
148
156
  .step-body {
149
- flex-direction: column;
150
- justify-content: center;
151
- align-items: stretch;
152
- overflow: hidden;
157
+ flex-direction: column;
158
+ justify-content: center;
159
+ align-items: stretch;
160
+ overflow: hidden;
153
161
  }
154
162
  .step-flow-wrapper {
155
- position: absolute;
156
- left: 0;
157
- right: 0;
158
- top: 0;
159
- height: 16px;
160
- flex-direction: row;
161
- justify-content: flex-start;
162
- align-items: center;
163
- overflow: hidden;
163
+ position: absolute;
164
+ left: 0;
165
+ right: 0;
166
+ top: 0;
167
+ height: 16px;
168
+ flex-direction: row;
169
+ justify-content: flex-start;
170
+ align-items: center;
171
+ overflow: hidden;
164
172
  }
165
173
  .step-line {
166
- width: 0px;
167
- height: 2px;
168
- border-top-color: #e5e5e8;
169
- border-top-width: 2px;
170
- border-top-style: solid;
171
- margin-left: 8px;
172
- margin-right: 8px;
174
+ width: 0px;
175
+ height: 2px;
176
+ border-top-color: #e5e5e8;
177
+ border-top-width: 2px;
178
+ border-top-style: solid;
179
+ margin-left: 8px;
180
+ margin-right: 8px;
173
181
  }
174
182
 
175
- .hline{
176
- border-top-width: 4px;
183
+ .hline {
184
+ border-top-width: 4px;
177
185
  }
178
186
  .step-item-wrapper {
179
- flex-direction: row;
180
- justify-content: space-between;
181
- align-items: flex-start;
187
+ flex-direction: row;
188
+ justify-content: space-between;
189
+ align-items: flex-start;
182
190
  }
183
191
  .step-item {
184
- flex-direction: column;
185
- justify-content: flex-start;
186
- align-items: center;
187
- overflow: hidden;
188
- word-wrap: break-word;
189
- word-break: break-all;
190
- padding-left: 8px;
191
- padding-right: 8px;
192
+ flex-direction: column;
193
+ justify-content: flex-start;
194
+ align-items: center;
195
+ overflow: hidden;
196
+ word-wrap: break-word;
197
+ word-break: break-all;
198
+ padding-left: 8px;
199
+ padding-right: 8px;
192
200
  }
193
201
  .step-point {
194
- width: 16px;
195
- height: 16px;
196
- background-color: #c7c7cc;
197
- border-radius: 32px;
202
+ width: 16px;
203
+ height: 16px;
204
+ background-color: #c7c7cc;
205
+ border-radius: 32px;
198
206
  }
199
207
  .step-desc {
200
- padding-top: 20px;
201
- font-family: PingFangSC-Regular;
202
- font-size: 26px;
203
- color: #8a8a8f;
204
- text-align: center;
208
+ padding-top: 20px;
209
+ font-family: PingFangSC-Regular;
210
+ font-size: 26px;
211
+ color: #8a8a8f;
212
+ text-align: center;
205
213
  }
206
214
  .active-step {
207
- color: #000000;
215
+ color: #000000;
208
216
  }
209
217
  </style>