Skip to content

Commit 048dba5

Browse files
committed
fix(uni-datetime-picker): mp platform
1 parent 0ab7397 commit 048dba5

File tree

9 files changed

+66
-602
lines changed

9 files changed

+66
-602
lines changed

.hbuilderx/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
{
1919
"launchtype" : "local"
2020
},
21+
"mp-baidu" :
22+
{
23+
"launchtype" : "local"
24+
},
2125
"mp-feishu" :
2226
{
2327
"launchtype" : "local"
@@ -26,6 +30,10 @@
2630
{
2731
"launchtype" : "local"
2832
},
33+
"mp-qq" :
34+
{
35+
"launchtype" : "local"
36+
},
2937
"mp-toutiao" :
3038
{
3139
"launchtype" : "local"

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,6 @@
5050
},
5151
"title" : "uni-ui",
5252
"template" : "template.h5.html"
53-
}
53+
},
54+
"vueVersion" : "2"
5455
}

pages/vue/datetime-picker/datetime-picker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</view>
2626
<uni-section :title="'时间戳用法:' + single" type="line"></uni-section>
2727
<view class="example-body">
28-
<uni-datetime-picker returnType="timestamp" v-model="single" @change="changeLog($event)" start="2021-3-20" end="2021-5-20" />
28+
<uni-datetime-picker returnType="timestamp" v-model="single" @change="changeLog($event)" />
2929
</view>
3030
<uni-section :title="'date 对象用法:' + datetimesingle" type="line"></uni-section>
3131
<view class="example-body">

uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
'uni-calendar-item--after-checked-x':weeks.afterMultiple,
77
}" @click="choiceDate(weeks)" @mouseenter="handleMousemove(weeks)">
88
<view class="uni-calendar-item__weeks-box-item" :class="{
9-
'uni-calendar-item--isDay-text': weeks.isDay,
109
'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
1110
'uni-calendar-item--checked-range-text': checkHover,
1211
'uni-calendar-item--before-checked':weeks.beforeMultiple,
1312
'uni-calendar-item--multiple': weeks.multiple,
1413
'uni-calendar-item--after-checked':weeks.afterMultiple,
1514
'uni-calendar-item--disable':weeks.disable,
16-
}">
15+
}">
1716
<text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
1817
<text class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
19-
</view>
18+
</view>
19+
<view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view>
2020
</view>
2121
</template>
2222

@@ -70,7 +70,8 @@
7070
flex-direction: column;
7171
justify-content: center;
7272
align-items: center;
73-
margin: 1px 0;
73+
margin: 1px 0;
74+
position: relative;
7475
}
7576
7677
.uni-calendar-item__weeks-box-text {
@@ -121,14 +122,14 @@
121122
color: #D1D1D1;
122123
}
123124
124-
.uni-calendar-item__weeks-box .uni-calendar-item--isDay-text {
125-
color: #007aff;
126-
}
127-
128-
.uni-calendar-item--isDay {
129-
background-color: #007aff;
130-
opacity: 0.8;
131-
color: #fff;
125+
.uni-calendar-item--isDay {
126+
position: absolute;
127+
top: 10px;
128+
right: 17%;
129+
background-color: #dd524d;
130+
width:6px;
131+
height: 6px;
132+
border-radius: 50%;
132133
}
133134
134135
.uni-calendar-item--extra {

uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.js

Lines changed: 0 additions & 546 deletions
This file was deleted.

uni_modules/uni-datetime-picker/components/uni-datetime-picker/calendar.vue

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
<view class="uni-calendar__header-btn uni-calendar--left"></view>
1010
</view>
1111
<picker mode="date" :value="date" fields="month" @change="bindDateChange">
12-
<text class="uni-calendar__header-text">{{ (nowDate.year||'') + ' 年 ' + ( nowDate.month||'') +' 月'}}</text>
12+
<text
13+
class="uni-calendar__header-text">{{ (nowDate.year||'') + ' 年 ' + ( nowDate.month||'') +' 月'}}</text>
1314
</picker>
1415
<view v-if="right" class="uni-calendar__header-btn-box" @click.stop="next">
1516
<view class="uni-calendar__header-btn uni-calendar--right"></view>
@@ -85,8 +86,7 @@
8586
<!-- <view class="uni-calendar__header-btn-box">
8687
<text class="uni-calendar__button-text uni-calendar--fixed-width">{{okText}}</text>
8788
</view> -->
88-
<button type="primary" class="uni-btn uni-btn-radius" hover-class="hover-class"
89-
@click="confirm">确认</button>
89+
<view class="uni-datetime-picker--btn" @click="confirm">确认</view>
9090
</view>
9191
</view>
9292
</view>
@@ -366,7 +366,6 @@
366366
})
367367
// 选中某一天
368368
// this.cale.setDate(this.date)
369-
370369
this.init(this.date)
371370
// this.setDay
372371
},
@@ -430,7 +429,6 @@
430429
* @param {Object} date
431430
*/
432431
init(date) {
433-
434432
this.cale.setDate(date)
435433
this.weeks = this.cale.weeks
436434
this.nowDate = this.calendar = this.cale.getInfo(date)
@@ -643,12 +641,12 @@
643641
.uni-calendar__content {
644642
background-color: #fff;
645643
}
646-
644+
647645
.uni-calendar__content-mobile {
648646
border-top-left-radius: 10px;
649-
border-top-right-radius: 10px;
647+
border-top-right-radius: 10px;
650648
box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
651-
}
649+
}
652650
653651
.uni-calendar__header {
654652
position: relative;
@@ -659,11 +657,11 @@
659657
justify-content: center;
660658
align-items: center;
661659
height: 50px;
662-
}
663-
664-
.uni-calendar__header-mobile {
665-
padding: 10px;
666-
padding-bottom: 0;
660+
}
661+
662+
.uni-calendar__header-mobile {
663+
padding: 10px;
664+
padding-bottom: 0;
667665
}
668666
669667
.uni-calendar--fixed-top {
@@ -777,7 +775,7 @@
777775
778776
.uni-calendar__box {
779777
position: relative;
780-
// padding: 0 10px;
778+
// padding: 0 10px;
781779
padding-bottom: 7px;
782780
}
783781
@@ -865,7 +863,7 @@
865863
/* #endif */
866864
flex-direction: row;
867865
align-items: center;
868-
padding: 0 25px;
866+
padding: 0 25px;
869867
margin-top: 10px;
870868
}
871869
@@ -881,4 +879,20 @@
881879
position: absolute;
882880
transform: rotate(-45deg);
883881
}
882+
883+
.uni-datetime-picker--btn {
884+
border-radius: 100px;
885+
height: 40px;
886+
line-height: 40px;
887+
background-color: #007aff;
888+
color: #fff;
889+
font-size: 16px;
890+
letter-spacing: 5px;
891+
}
892+
893+
/* #ifndef APP-NVUE */
894+
.uni-datetime-picker--btn:active {
895+
opacity: 0.7;
896+
}
897+
/* #endif */
884898
</style>

uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<view v-if="!isPhone" ref="datePicker" v-show="popup" class="uni-date-picker__container">
3232
<view v-if="!isRange" class="uni-date-single--x" :style="popover">
3333
<view class="uni-popper__arrow"></view>
34-
<view v-show="hasTime" class="uni-date-changed popup-x-header">
34+
<view v-if="hasTime" class="uni-date-changed popup-x-header">
3535
<input class="uni-date__input t-c" type="text" v-model="tempSingleDate"
3636
:placeholder="selectDateText" />
3737
<time-picker type="time" v-model="time" :border="false" :disabled="!tempSingleDate"
@@ -52,7 +52,7 @@
5252

5353
<view v-else class="uni-date-range--x" :style="popover">
5454
<view class="uni-popper__arrow"></view>
55-
<view v-show="hasTime" class="popup-x-header uni-date-changed">
55+
<view v-if="hasTime" class="popup-x-header uni-date-changed">
5656
<view class="popup-x-header--datetime">
5757
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
5858
:placeholder="startDateText" />
@@ -90,7 +90,7 @@
9090
</view>
9191
</view>
9292
</view>
93-
<calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime"
93+
<calendar v-show="isPhone" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime"
9494
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime"
9595
:pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false"
9696
:hideSecond="hideSecond" @confirm="mobileChange" />
@@ -685,9 +685,9 @@
685685
this.tempSingleDate = ''
686686
this.time = ''
687687
if (this.isPhone) {
688-
this.$refs.mobile.clearCalender()
688+
this.$refs.mobile && this.$refs.mobile.clearCalender()
689689
} else {
690-
this.$refs.pcSingle.clearCalender()
690+
this.$refs.pcSingle && this.$refs.pcSingle.clearCalender()
691691
}
692692
if (needEmit) {
693693
this.formItem && this.formItem.setValue('')
@@ -703,11 +703,11 @@
703703
this.tempRange.endDate = ''
704704
this.tempRange.endTime = ''
705705
if (this.isPhone) {
706-
this.$refs.mobile.clearCalender()
706+
this.$refs.mobile && this.$refs.mobile.clearCalender()
707707
} else {
708-
this.$refs.left.clearCalender()
709-
this.$refs.right.clearCalender()
710-
this.$refs.right.next()
708+
this.$refs.left && this.$refs.left.clearCalender()
709+
this.$refs.right && this.$refs.right.clearCalender()
710+
this.$refs.right && this.$refs.right.next()
711711
}
712712
if (needEmit) {
713713
this.formItem && this.formItem.setValue([])

uni_modules/uni-datetime-picker/components/uni-datetime-picker/util.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import CALENDAR from './calendar.js'
2-
31
class Calendar {
42
constructor({
53
date,
@@ -112,7 +110,6 @@ class Calendar {
112110
dateArr.push({
113111
date: beforeDate,
114112
month: full.month - 1,
115-
lunar: this.getlunar(full.year, full.month - 1, beforeDate),
116113
disable: true
117114
})
118115
}
@@ -173,7 +170,6 @@ class Calendar {
173170
beforeMultiple: this.isLogicBefore(nowDate, this.multipleStatus.before, this.multipleStatus.after),
174171
afterMultiple: this.isLogicAfter(nowDate, this.multipleStatus.before, this.multipleStatus.after),
175172
month: full.month,
176-
lunar: this.getlunar(full.year, full.month, i),
177173
disable: !(disableBefore && disableAfter),
178174
isDay,
179175
userChecked: false
@@ -195,7 +191,6 @@ class Calendar {
195191
dateArr.push({
196192
date: i,
197193
month: Number(full.month) + 1,
198-
lunar: this.getlunar(full.year, Number(full.month) + 1, i),
199194
disable: true
200195
})
201196
}
@@ -285,19 +280,6 @@ class Calendar {
285280
}
286281
return arr
287282
}
288-
/**
289-
* 计算阴历日期显示
290-
*/
291-
getlunar(year, month, date) {
292-
return CALENDAR.solar2lunar(year, month, date)
293-
}
294-
/**
295-
* 设置打点
296-
*/
297-
setSelectInfo(data, value) {
298-
this.selected = value
299-
this._getWeek(data)
300-
}
301283

302284
/**
303285
* 获取多选状态

组件修改说明.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@
3434
- nvue 下 radius 问题同 padding
3535
- button 样式 ,如果使用的话,可能会导致 hover-class 失效 ,因为样式权重会高于 hover-class 的样式
3636
- fav 插槽内点击事件失效
37+
38+
- 头条按钮有问题,其他平台正常
39+
- uni-list 组件 flex 失效
40+

0 commit comments

Comments
 (0)