Skip to content

Commit 12197e3

Browse files
committed
update
1 parent a8c050c commit 12197e3

20 files changed

Lines changed: 198 additions & 341 deletions

File tree

components/uni-badge/uni-badge.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<text class="uni-badge" v-if="text" :class="setClass" @click="onClick()">{{text}}</text>
2+
<text class="uni-badge" v-if="text" :class="['uni-badge-' + type, 'uni-badge--' + size,{'uni-badge-inverted':inverted}]" @click="onClick()">{{text}}</text>
33
</template>
44

55
<script>
@@ -23,15 +23,6 @@
2323
default: 'normal'
2424
}
2525
},
26-
computed: {
27-
setClass() {
28-
let classList = ['uni-badge-' + this.type, 'uni-badge--' + this.size];
29-
if (this.inverted === true) {
30-
classList.push('uni-badge-inverted')
31-
}
32-
return classList.join(" ")
33-
}
34-
},
3526
methods: {
3627
onClick() {
3728
this.$emit('click')

components/uni-calendar/uni-calendar.vue

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@
8080
* 当前日期
8181
*/
8282
date: {
83-
type: null,
84-
default: () => {
85-
return new Date();
86-
}
83+
type: String,
84+
default: ''
8785
},
8886
/**
8987
* 打点日期
@@ -160,12 +158,10 @@
160158
this.getMonthAll(0, this.date, true);
161159
} else {
162160
this.getMonthAll(1, this.date, true);
163-
setTimeout(() => {
164-
this.getQueryDom(1);
165-
}, 300);
161+
this.getQueryDom(1);
162+
166163
}
167164
},
168-
computed: {},
169165
watch: {
170166
selected(newVal) {
171167
let canlender = this.canlender;
@@ -204,6 +200,9 @@
204200
* 获取全部月份
205201
*/
206202
getMonthAll(index, date, first) {
203+
if (date === '') {
204+
date = new Date();
205+
}
207206
let canlender = this.getWeek(date);
208207
this.currentSelDate = canlender.date;
209208
let tempyear = canlender.year + '-' + canlender.month + '-1';
@@ -305,6 +304,7 @@
305304
* 今天之前的日期是否可选
306305
*/
307306
isDisableBefore(year, month, date) {
307+
let nowDate = this.date ? this.date : new Date();
308308
let time = year + '-' + month + '-' + date;
309309
let startDate = false;
310310
let endDate = false;
@@ -318,13 +318,13 @@
318318
if (this.disableBefore) {
319319
if (!this.startDate) {
320320
if (!this.endDate) {
321-
return !this.dateCompare(this.getDate(this.date, 0), time);
321+
return !this.dateCompare(this.getDate(nowDate, 0), time);
322322
} else {
323-
return !this.dateCompare(this.getDate(this.date, 0), time) || endDate;
323+
return !this.dateCompare(this.getDate(nowDate, 0), time) || endDate;
324324
}
325325
} else {
326326
return (
327-
!this.dateCompare(this.getDate(this.date, 0), time) || !startDate || endDate
327+
!this.dateCompare(this.getDate(nowDate, 0), time) || !startDate || endDate
328328
);
329329
}
330330
} else {
@@ -381,7 +381,6 @@
381381
} else {
382382
num = 1;
383383
}
384-
console.log(num);
385384
let year =
386385
this.canlender.year + '-' + this.canlender.month + '-' + this.canlender.date;
387386
@@ -600,10 +599,10 @@
600599
* 计算时间大小
601600
*/
602601
dateCompare(startDate, endDate) {
603-
//计划截止时间
604-
var startDate = new Date(startDate.replace('-', '/').replace('-', '/'));
605-
//计划详细项的截止时间
606-
var endDate = new Date(endDate.replace('-', '/').replace('-', '/'));
602+
//计算截止时间
603+
startDate = new Date(startDate.replace('-', '/').replace('-', '/'));
604+
//计算详细项的截止时间
605+
endDate = new Date(endDate.replace('-', '/').replace('-', '/'));
607606
if (startDate <= endDate) {
608607
return true;
609608
} else {
@@ -612,8 +611,11 @@
612611
},
613612
getQueryDom(index) {
614613
let dom = uni.createSelectorQuery().selectAll(`.${this.elClass}`);
615-
616614
dom.boundingClientRect(rect => {}).exec(e => {
615+
if (!e[0]) {
616+
this.getQueryDom(1);
617+
return;
618+
}
617619
if (e[0][index]) {
618620
this.domHeihgt = e[0][index].height;
619621
}

components/uni-drawer/uni-drawer.vue

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@
5757
}
5858
}
5959
},
60-
computed: {
61-
showMask() {
62-
return String(this.mask) === 'true'
63-
}
64-
},
6560
created() {
6661
this.visibleSync = this.visible
6762
setTimeout(() => {

components/uni-grid/uni-grid.vue

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<view class="uni-grid" :class="setBorderClass">
2+
<view class="uni-grid" :class="{'uni-grid-no-border':!showBorder,'uni-grid-no-out-border':showBorder && !showOutBorder}">
33
<view class="uni-grid__flex" v-for="(items,i) in gridGroup" :key="i">
4-
<view class="uni-grid-item" hover-class="uni-grid-item-hover" :hover-start-time="20" :hover-stay-time="70" v-for="(item,index) in items" :key="index" :class="[index === columnNumber ? 'uni-grid-item-last' : '','uni-grid-item-' + type]" @click="onClick(i,index)">
4+
<view class="uni-grid-item" hover-class="uni-grid-item-hover" :hover-start-time="20" :hover-stay-time="70" v-for="(item,index) in items" :key="index" :class="[index == columnNum ? 'uni-grid-item-last' : '','uni-grid-item-' + type]" @click="onClick(i,index)">
55
<view class="uni-grid-item__content">
66
<image class="uni-grid-item-image" :src="item.image"></image>
77
<text class="uni-grid-item-text">{{item.text}}</text>
@@ -15,7 +15,7 @@
1515
export default {
1616
name: "uni-grid",
1717
props: {
18-
data: Array,
18+
options: Array,
1919
type: { //布局格式,长方形oblong,正方形square
2020
type: String,
2121
default: 'square'
@@ -37,13 +37,10 @@
3737
return {}
3838
},
3939
computed: {
40-
columnNumber() {
41-
return Number(this.columnNum) ? Number(this.columnNum) : 3
42-
},
4340
gridGroup() {
4441
let group = []
4542
let groupItem = []
46-
this.data && this.data.forEach((item, index) => {
43+
this.options && this.options.forEach((item, index) => {
4744
groupItem.push(item)
4845
if (index % this.columnNum === this.columnNum - 1) {
4946
group.push(groupItem)
@@ -55,17 +52,6 @@
5552
}
5653
groupItem = null
5754
return group
58-
},
59-
setBorderClass() {
60-
let classList = []
61-
if (this.showBorder === false || this.showBorder === 'false') {
62-
classList.push('uni-grid-no-border')
63-
return classList
64-
}
65-
if (this.showOutBorder === false || this.showOutBorder === 'false') {
66-
classList.push('uni-grid-no-out-border')
67-
}
68-
return classList
6955
}
7056
},
7157
methods: {

components/uni-icon/uni-icon.vue

Lines changed: 22 additions & 19 deletions
Large diffs are not rendered by default.

components/uni-nav-bar/uni-nav-bar.vue

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<view class="uni-navbar">
3-
<view class="uni-navbar__content" :class="{'uni-navbar--fixed':isFixed,'uni-navbar--shadow':hasShadow,'uni-navbar--border':hasBorder}" :style="{'background-color':backgroundColor}">
4-
<uni-status-bar v-if="insertStatusBar"></uni-status-bar>
3+
<view class="uni-navbar__content" :class="{'uni-navbar--fixed': !!fixed,'uni-navbar--shadow':!!border,'uni-navbar--border':!!border}" :style="{'background-color':backgroundColor}">
4+
<uni-status-bar v-if="statusBar"></uni-status-bar>
55
<view class="uni-navbar__header" :style="{color:color}">
66
<view class="uni-navbar__header-btns" @tap="onClickLeft">
77
<view v-if="leftIcon.length">
@@ -25,8 +25,8 @@
2525
</view>
2626
</view>
2727
</view>
28-
<view class="uni-navbar__placeholder" v-if="isFixed">
29-
<uni-status-bar v-if="insertStatusBar"></uni-status-bar>
28+
<view class="uni-navbar__placeholder" v-if="fixed">
29+
<uni-status-bar v-if="statusBar"></uni-status-bar>
3030
<view class="uni-navbar__placeholder-view"></view>
3131
</view>
3232
</view>
@@ -88,20 +88,6 @@
8888
default: true
8989
}
9090
},
91-
computed: {
92-
isFixed() {
93-
return String(this.fixed) === 'true'
94-
},
95-
insertStatusBar() {
96-
return String(this.statusBar) === 'true'
97-
},
98-
hasShadow() {
99-
return String(this.border) === 'true'
100-
},
101-
hasBorder() {
102-
return String(this.border) === 'true'
103-
}
104-
},
10591
methods: {
10692
onClickLeft() {
10793
this.$emit('click-left')

components/uni-notice-bar/uni-notice-bar.vue

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<view v-if="showClose === 'true' || showClose === true" class="uni-noticebar__close">
44
<uni-icon type="closefill" size="12"></uni-icon>
55
</view>
6-
<view class="uni-noticebar__content" :class="setContenClass">
6+
<view class="uni-noticebar__content" :class="{'uni-noticebar--flex': scrollable || single || moreText}">
77
<view v-if="showIcon === 'true' || showIcon === true" class="uni-noticebar__content-icon" :style="{backgroundColor:backgroundColor,color:color}">
88
<uni-icon type="sound" size="14" :color="color"></uni-icon>
99
</view>
10-
<view class="uni-noticebar__content-text" :class="setTextClass">
10+
<view class="uni-noticebar__content-text" :class="{'uni-noticebar--scrollable':scrollable,'uni-noticebar--single':!scrollable && (single || moreText)}">
1111
<view class="uni-noticebar__content-inner" :id="elId" :style="{'animation': animation,'-webkit-animation': animation}">{{text}}</view>
1212
</view>
1313
<view class="uni-noticebar__content-more" v-if="showGetMore === 'true' || showGetMore === true" @click="clickMore" :style="{width:moreText ? '180upx' : '20px'}">
@@ -76,29 +76,8 @@
7676
})
7777
}
7878
},
79-
computed: {
80-
setTextClass() {
81-
let classList = []
82-
if (this.scrollable === true || this.scrollable === 'true') {
83-
classList.push('uni-noticebar--scrollable')
84-
} else {
85-
if (this.single === 'true' || this.single === true || this.moreText) {
86-
classList.push('uni-noticebar--single')
87-
}
88-
}
89-
return classList
90-
},
91-
setContenClass() {
92-
let classList = []
93-
if (this.scrollable === true || this.scrollable === 'true' || this.single === 'true' || this.single === true ||
94-
this.moreText) {
95-
classList.push('uni-noticebar--flex')
96-
}
97-
return classList
98-
}
99-
},
10079
// #ifdef H5
101-
mounted() { //在h5的时候走mounted,app和小程序走onReady
80+
mounted() {
10281
this.setAnimation()
10382
},
10483
// #endif
@@ -125,13 +104,13 @@
125104
}
126105
//#ifdef MP-TOUTIAO
127106
setTimeout(() => {
128-
uni.createSelectorQuery().select(`#${this.elId}`).boundingClientRect().exec((ret) => {
107+
uni.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {
129108
this.animation = `notice ${ret[0].width / this.speed}s linear infinite both`;
130109
});
131110
}, 200)
132111
// #endif
133112
// #ifndef MP-TOUTIAO
134-
uni.createSelectorQuery().select(`#${this.elId}`).boundingClientRect().exec((ret) => {
113+
uni.createSelectorQuery().in(this).select(`#${this.elId}`).boundingClientRect().exec((ret) => {
135114
this.animation = `notice ${ret[0].width / this.speed}s linear infinite both`;
136115
});
137116
// #endif

components/uni-number-box/uni-number-box.vue

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<template>
22
<view class="uni-numbox">
3-
<view class="uni-numbox__minus" :class="{'uni-numbox--disabled': disableSubtract||disabled}" @click="_calcValue('subtract')">-</view>
4-
<input class="uni-numbox__value" type="number" :disabled="disabled" :value="inputValue" @blur="_onBlur">
5-
<view class="uni-numbox__plus" :class="{'uni-numbox--disabled': disableAdd||disabled}" @click="_calcValue('add')">+</view>
3+
<view class="uni-numbox__minus" :class="{'uni-numbox--disabled': inputValue <= min || disabled}" @click="_calcValue('minus')">-</view>
4+
<input class="uni-numbox__value" type="number" :disabled="disabled" v-model="inputValue" @blur="_onBlur">
5+
<view class="uni-numbox__plus" :class="{'uni-numbox--disabled': inputValue >= max || disabled}" @click="_calcValue('plus')">+</view>
66
</view>
77
</template>
88
<script>
99
export default {
1010
name: 'uni-number-box',
1111
props: {
1212
value: {
13-
type: Number,
13+
type: [Number, String],
1414
default: 1
1515
},
1616
min: {
@@ -32,23 +32,17 @@
3232
},
3333
data() {
3434
return {
35-
inputValue: this.value
36-
}
37-
},
38-
computed: {
39-
disableSubtract() {
40-
return this.inputValue <= this.min
41-
},
42-
disableAdd() {
43-
return this.inputValue >= this.max
35+
inputValue: +this.value
4436
}
4537
},
4638
watch: {
4739
value(val) {
48-
this.inputValue = val;
40+
this.inputValue = +val;
4941
},
50-
inputValue(val) {
51-
this.$emit('change', val);
42+
inputValue(newVal, oldVal) {
43+
if (+newVal !== +oldVal) {
44+
this.$emit('change', newVal);
45+
}
5246
}
5347
},
5448
methods: {
@@ -59,9 +53,9 @@
5953
const scale = this._getDecimalScale()
6054
let value = this.inputValue * scale
6155
let step = this.step * scale
62-
if (type === 'subtract') {
56+
if (type === 'minus') {
6357
value -= step
64-
} else if (type === 'add') {
58+
} else if (type === 'plus') {
6559
value += step
6660
}
6761
if (value < this.min || value > this.max) {

0 commit comments

Comments
 (0)