Commit 578522bc by 李伟康

refactor(calendar): 优化日历组件功能和样式

- 添加隐藏今天按钮的选项
- 增加下个月按钮的显示逻辑
- 调整日历头部样式
- 优化 OrderPopup 组件代码
1 parent 649404dd
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
@choose="chooseContent = $event" @choose="chooseContent = $event"
@openSkuPopup="openSkuPopup" @openSkuPopup="openSkuPopup"
@onComplete="componentObject[popupType].loadComplete = true" @onComplete="componentObject[popupType].loadComplete = true"
@updateCacheData="updateCacheData"
></component> ></component>
<template v-if="componentObject[popupType].noData"> <template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view> <view class="nothing flex">暂无数据</view>
...@@ -218,6 +217,7 @@ export default { ...@@ -218,6 +217,7 @@ export default {
} }
if (chooseContent) { if (chooseContent) {
if (Array.isArray(chooseContent) && !chooseContent.length && componentObject[popupType].nullTips) throw componentObject[popupType].nullTips if (Array.isArray(chooseContent) && !chooseContent.length && componentObject[popupType].nullTips) throw componentObject[popupType].nullTips
console.log(chooseContent)
this.$emit('onConfirm', { this.$emit('onConfirm', {
chooseContent, chooseContent,
popupType popupType
......
...@@ -40,18 +40,23 @@ ...@@ -40,18 +40,23 @@
<picker <picker
mode="date" mode="date"
:value="date" :value="date"
:end="endDate"
fields="month" fields="month"
@change="bindDateChange" @change="bindDateChange"
> >
<text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text> <text class="uni-calendar__header-text">{{ (nowDate.year||'') +' / '+( nowDate.month||'')}}</text>
</picker> </picker>
<view <view
class="uni-calendar__header-btn-box" :class="['uni-calendar__header-btn-box next-btn',{'show-next-btn':showNextBtn}]"
@click.stop="next" @click.stop="next"
> >
<view class="uni-calendar__header-btn uni-calendar--right"></view> <view class="uni-calendar__header-btn uni-calendar--right"></view>
</view> </view>
<!-- <text class="uni-calendar__backtoday" @click="backToday">{{todayText}}</text> --> <text
class="uni-calendar__backtoday"
@click="backToday"
v-if="!hideTodayBtn"
>{{todayText}}</text>
</view> </view>
<view class="uni-calendar__box"> <view class="uni-calendar__box">
...@@ -189,9 +194,13 @@ export default { ...@@ -189,9 +194,13 @@ export default {
type: String, type: String,
default: '#fff' default: '#fff'
}, },
title:{ title: {
type: String, type: String,
default: '选择日期' default: '选择日期'
},
hideTodayBtn: {
type: Boolean,
default: true
} }
}, },
data () { data () {
...@@ -238,10 +247,14 @@ export default { ...@@ -238,10 +247,14 @@ export default {
SUNText () { SUNText () {
return t("uni-calender.SUN") return t("uni-calender.SUN")
}, },
showNextBtn () {
let { cale, endDate, nowDate} = this,
maxDate = cale.getDate(endDate, -1, 'month')
return cale.dateCompare(`${nowDate.year}/${nowDate.month}`, `${maxDate.year}/${maxDate.month}`)
}
}, },
watch: { watch: {
date (newVal) { date (newVal) {
// this.cale.setDate(newVal)
this.init(newVal) this.init(newVal)
}, },
startDate (val) { startDate (val) {
...@@ -257,6 +270,17 @@ export default { ...@@ -257,6 +270,17 @@ export default {
selected (newVal) { selected (newVal) {
this.cale.setSelectInfo(this.nowDate.fullDate, newVal) this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
this.weeks = this.cale.weeks this.weeks = this.cale.weeks
},
nowDate: {
handler (val) {
if (val) {
let { cale, endDate } = this,
maxDate = cale.getDate(endDate, -1, 'month')
cale.dateCompare(`${val.year}/${val.month}`, `${maxDate.year}/${maxDate.month}`)
}
},
deep: true,
immediate: true
} }
}, },
created () { created () {
...@@ -427,6 +451,8 @@ export default { ...@@ -427,6 +451,8 @@ export default {
* 下个月 * 下个月
*/ */
next () { next () {
let {showNextBtn} = this
if(!showNextBtn) return
const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate const nextDate = this.cale.getDate(this.nowDate.fullDate, +1, 'month').fullDate
this.setDate(nextDate) this.setDate(nextDate)
this.monthSwitch() this.monthSwitch()
...@@ -567,7 +593,12 @@ $uni-text-color-grey: #999; ...@@ -567,7 +593,12 @@ $uni-text-color-grey: #999;
width: 50px; width: 50px;
height: 50px; height: 50px;
} }
.next-btn{
opacity: 0;
}
.show-next-btn{
opacity: 1;
}
.uni-calendar__header-btn { .uni-calendar__header-btn {
width: 10px; width: 10px;
height: 10px; height: 10px;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!