Commit 578522bc by 李伟康

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

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