dever 4 роки тому
батько
коміт
9948f30739
1 змінених файлів з 33 додано та 5 видалено
  1. 33 5
      pages/dream/func/times.vue

+ 33 - 5
pages/dream/func/times.vue

@@ -7,9 +7,12 @@
 					<view class="cu-capsule radius">
 						<view class="cu-tag bg-cyan">{{v1.name}}</view>
 						<view class="cu-tag line-white">
-							<picker mode="date" :value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day" :start="v1.year+`-01-01`" :end="v1.year+`-12-31`" :fields="`day`" @change="selectDay" :data-year="v1.year" :data-name="v1.name" :data-id="v1.id">
+							<!--
+							<picker mode="date" :value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day" :start="v1.year+`-01-01`" :end="(v1.end_year ? v1.end_year : v1.year) +`-12-31`" :fields="`day`" @change="selectDay" :data-year="v1.year" :data-name="v1.name" :data-id="v1.id">
 								<view class="uni-input">{{fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : '主序时间'}}</view>
 							</picker>
+							-->
+							<view class="uni-input" @click="openTime()">{{fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : '主序时间'}}</view>
 						</view>
 					</view>
 					<view @click="go(v1)">
@@ -17,12 +20,26 @@
 						<view class="margin-top" v-if="v1.pic && !v1.desc"><image :src="v1.pic" mode="widthFix" class="slide-image" style="height:auto"></image></view>
 					</view>
 				</view>
+				
+				<w-picker
+					:visible.sync="timeVisible"
+					mode="date" 
+					:startYear="v1.year" 
+					:endYear="(v1.end_year ? v1.end_year : v1.year)"
+					:value="fetch.user_times[v1.id] && fetch.user_times[v1.id].day != 0 ? fetch.user_times[v1.id].day : v1.year + '-' + month + '-' + day"
+					:current="true"
+					fields="day"
+					@confirm="selectDay($event,v1.id, v1.year, v1.name)"
+					:disabled-after="false"
+					ref="date" 
+				></w-picker>
 			</view>
 		</view>
 	</view>
 </template>
 
 <script>
+import wPicker from "@/lib/w-picker/w-picker.vue";
 export default {
 	name: "times",
 	props: {
@@ -41,6 +58,7 @@ export default {
 	},
 	data() {
 		return {
+			timeVisible:false,
 			fetch : {},
 			current : '',
 			year : '',
@@ -48,11 +66,17 @@ export default {
 			day : '',
 		}
 	},
+	components:{
+		wPicker
+	},
 	mounted() {
 		this.fetch = this.param;
 		this.getDate();
 	},
 	methods:{
+		openTime : function() {
+			this.timeVisible = true;
+		},
 		getDate : function(type) {
 			const date = new Date();
 			let year = date.getFullYear();
@@ -93,20 +117,24 @@ export default {
 			})
 			
 		},
-		selectDay : function(res) {
+		selectDay : function(res, id, year, name) {
 			var times = {};
-			times = res.currentTarget.dataset;
+			times.id = id;
+			times.year = year;
+			times.name = name;
+			//times = res.currentTarget.dataset;
+			var value = res.value;
 			if (!this.fetch.user_times[times.id]) {
 				this.fetch.user_times[times.id] = {};
 				this.fetch.user_times[times.id].day = '主序时间';
 			}
 			var old = this.fetch.user_times[times.id].day;
-			this.fetch.user_times[times.id].day = res.detail.value;
+			this.fetch.user_times[times.id].day = value;
 			var current = times.year + '-' + this.month + '-' + this.day;
 			if (this.fetch.user_times[times.id].day == current) {
 				this.fetch.user_times[times.id].day = '主序时间';
 			}
-			if (old != res.detail.value) {
+			if (old != value) {
 				this.go(times);
 			}
 		},