Skip to content

Commit d5af715

Browse files
committed
update: 更新uni-ui
1 parent 51d93c8 commit d5af715

File tree

13 files changed

+281
-217
lines changed

13 files changed

+281
-217
lines changed

components/uni-count-down/uni-count-down.vue

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
data() {
5959
return {
6060
timer: null,
61+
syncFlag: false,
6162
d: '00',
6263
h: '00',
6364
i: '00',
@@ -66,17 +67,22 @@
6667
seconds: 0
6768
}
6869
},
70+
watch: {
71+
day(val) {
72+
this.changeFlag()
73+
},
74+
hour(val) {
75+
this.changeFlag()
76+
},
77+
minute(val) {
78+
this.changeFlag()
79+
},
80+
second(val) {
81+
this.changeFlag()
82+
}
83+
},
6984
created: function(e) {
70-
this.seconds = this.toSeconds(this.day, this.hour, this.minute, this.second)
71-
this.countDown()
72-
this.timer = setInterval(() => {
73-
this.seconds--
74-
if (this.seconds < 0) {
75-
this.timeUp()
76-
return
77-
}
78-
this.countDown()
79-
}, 1000)
85+
this.startData();
8086
},
8187
beforeDestroy() {
8288
clearInterval(this.timer)
@@ -94,9 +100,9 @@
94100
let [day, hour, minute, second] = [0, 0, 0, 0]
95101
if (seconds > 0) {
96102
day = Math.floor(seconds / (60 * 60 * 24))
97-
hour = Math.floor(seconds / (60 * 60)) - day * 24
98-
minute = Math.floor(seconds / 60) - day * 24 * 60 - hour * 60
99-
second = Math.floor(seconds) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60
103+
hour = Math.floor(seconds / (60 * 60)) - (day * 24)
104+
minute = Math.floor(seconds / 60) - (day * 24 * 60) - (hour * 60)
105+
second = Math.floor(seconds) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60)
100106
} else {
101107
this.timeUp()
102108
}
@@ -116,6 +122,28 @@
116122
this.h = hour
117123
this.i = minute
118124
this.s = second
125+
},
126+
startData() {
127+
this.seconds = this.toSeconds(this.day, this.hour, this.minute, this.second)
128+
if (this.seconds <= 0) {
129+
return
130+
}
131+
this.countDown()
132+
this.timer = setInterval(() => {
133+
this.seconds--
134+
if (this.seconds < 0) {
135+
this.timeUp()
136+
return
137+
}
138+
this.countDown()
139+
}, 1000)
140+
},
141+
changeFlag() {
142+
if (!this.syncFlag) {
143+
this.seconds = this.toSeconds(this.day, this.hour, this.minute, this.second)
144+
this.startData();
145+
this.syncFlag = true;
146+
}
119147
}
120148
}
121149
}
@@ -149,11 +177,7 @@
149177
width: 52rpx;
150178
height: 48rpx;
151179
line-height: 48rpx;
152-
border-radius: 6rpx;
153180
margin: 5rpx;
154-
border-width: 1rpx;
155-
border-style: solid;
156-
border-color: #000000;
157181
text-align: center;
158182
font-size: 24rpx;
159183
}

components/uni-fab/uni-fab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
rightBottom: rightBottom,
66
leftTop: leftTop,
77
rightTop: rightTop
8-
}" class="fab-box fab">
8+
}" v-if="leftBottom||rightBottom||leftTop||rightTop" class="fab-box fab">
99
<view :class="{
1010
left: horizontal === 'left' && direction === 'horizontal',
1111
top: vertical === 'top' && direction === 'vertical',

components/uni-grid-item/uni-grid-item.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@
3939
this.left = this.ver === 0 ? this.grid.ver : this.ver
4040
this.borderColor = this.grid.borderColor
4141
this.index = this.grid.index++
42-
},
43-
mounted() {
44-
this.grid._getSize(width => {
45-
this.width = width
46-
})
42+
this.grid.children.push(this)
4743
},
4844
methods: {
4945
_onClick() {

components/uni-grid/uni-grid.vue

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@
6262
}
6363
},
6464
created() {
65+
this.children = []
6566
this.index = 0
66-
this.childrens = []
67-
this.pIndex = this.pIndex ? this.pIndex++ : 0
6867
},
6968
mounted() {
70-
// this._getSize()
69+
setTimeout(() => {
70+
this._getSize((width) => {
71+
this.children.forEach((item, index) => {
72+
item.width = width
73+
})
74+
})
75+
}, 50)
7176
},
7277
methods: {
7378
change(e) {
@@ -80,26 +85,14 @@
8085
.select(`#${this.elId}`)
8186
.boundingClientRect()
8287
.exec(ret => {
83-
if (!ret[0]) {
84-
setTimeout(() => {
85-
this._getSize(fn)
86-
}, 50)
87-
return
88-
}
89-
let width = parseInt(ret[0].width / this.column) - 1 + 'px'
90-
typeof fn === 'function' && fn(width)
88+
this.width = parseInt(ret[0].width / this.column) - 1 + 'px'
89+
fn(this.width)
9190
})
9291
// #endif
9392
// #ifdef APP-NVUE
9493
dom.getComponentRect(this.$refs['uni-grid'], (ret) => {
95-
if (ret.size.width === 0) {
96-
setTimeout(() => {
97-
this._getSize(fn)
98-
}, 50)
99-
return
100-
}
101-
let width = parseInt(ret.size.width / this.column) - 1 + 'px'
102-
typeof fn === 'function' && fn(width)
94+
this.width = parseInt(ret.size.width / this.column) - 1 + 'px'
95+
fn(this.width)
10396
})
10497
// #endif
10598
}

0 commit comments

Comments
 (0)