zizhong.wang vor 3 Jahren
Ursprung
Commit
d78eeb46ff
1 geänderte Dateien mit 29 neuen und 5 gelöschten Zeilen
  1. 29 5
      components/lx-calendar/lx-calendar.vue

+ 29 - 5
components/lx-calendar/lx-calendar.vue

@@ -2,9 +2,9 @@
 <template>
 	<view class="date">
 		<view class="head">
-			<view class="icon" @click="switch_month_week('prev',true)"><text class="iconfont icon-fanhui" :class="[currentMonth >= nowMonth ? 'month_disabled' : '']" /></view>
+			<view class="icon" @click="switch_month_week('prev',true)"><text class="iconfont icon-fanhui" :class="[disabled_goto_prev() ? 'month_disabled' : '']" /></view>
 			<view class="title">{{nowYear+'年'+nowMonth+'月'}}</view>
-			<view class="icon" @click="switch_month_week('next',true)"><text class="iconfont next icon-fanhui" :class="[currentMonth < nowMonth ? 'month_disabled' : '']" /></view>
+			<view class="icon" @click="switch_month_week('next',true)"><text class="iconfont next icon-fanhui" :class="[disabled_goto_next() ? 'month_disabled' : '']" /></view>
 		</view>
 		<view class="date_dl" >
 			<view class="dd" v-for="(item,index) in week" :key="index">{{item}}</view>
@@ -404,7 +404,7 @@ export default {
 			}else if(type == 'next'){
 				if(nowMonth == 12){
 					nowMonth = 1;
-					nowYear = nowYear + 1;
+					nowYear = parseInt(nowYear) + 1;
 				}else{
 					nowMonth++;
 				}
@@ -421,14 +421,38 @@ export default {
 		date_parse(str){
 			return Date.parse(str.replace(/-(\d)(?!\d)/g, '-0$1'));
 		},
+		disabled_goto_prev(){
+			let date = new Date();
+			let cy = date.getFullYear();
+			if (cy < this.nowYear){
+				return false;
+			}
+			if (this.currentMonth >= this.nowMonth){
+				 return true;
+			}
+			return false;
+		},
+		disabled_goto_next(){
+			let date = new Date();
+			let cy = date.getFullYear();
+			if (cy < this.nowYear){
+				return true;
+			}
+			if (this.currentMonth < this.nowMonth){
+				 return true;
+			}
+			return false;
+		},
+		
 		switch_month_week(type = 'next',update_week = false){
-			if (this.currentMonth >= this.nowMonth && type=="prev"){
+			if (type=="prev" && this.disabled_goto_prev()){
 				return;
 			}
-			if (this.currentMonth < this.nowMonth && type == "next"){
+			if (type == "next" && this.disabled_goto_next()){
 				return;
 			}
 			
+			
 //			this.nowDay = '';
 			this.date = '';