<template>
	<view>
		<!-- #ifndef MP-ALIPAY -->
		<view class="uni-title uni-common-pl">时间选择器</view>
		<view class="uni-list">
			<view class="uni-list-cell">
				<view class="uni-list-cell-left">
					当前选择
				</view>
				<view class="uni-list-cell-db">
					<picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray">
						<view class="uni-input">{{multiArray[0][multiIndex[0]]}}，{{multiArray[1][multiIndex[1]]}}，{{multiArray[2][multiIndex[2]]}}</view>
					</picker>
				</view>
			</view>
		</view>
		<!-- #endif -->
	</view>
</template>
<script>
	export default {
		data() {
            // 需要服务器时间
            const startdate = new Date();
            const enddate = new Date(startdate.getTime() + 30*24*60*60*1000);
            const years = []
            const startyear = startdate.getFullYear()
            const endyear = enddate.getFullYear()
            const months = []
            const startmonth = startdate.getMonth() + 1
            const endmonth = enddate.getMonth() + 1
            const days = []
            const startdays = []
            const enddays = []
            const startday = startdate.getDate()
            const endday = enddate.getDate()
            const hours = []
            const starthour = startdate.getHours();
            const endhour = enddate.getHours();
            const minutes = []
            const startminute = startdate.getMinutes();
            const endminute = enddate.getMinutes();
            if (startyear === endyear) {
                years.push(startyear);
                months.push(startmonth, endmonth);
            }else {
                for (let i = startyear; i <= endyear; i++) {
                    years.push(i)
                }
                months.push(startmonth, endmonth);
            }
            // for (let i = 1; i <= 12; i++) {
            //     months.push(i)
            // }
            for (let i = startday; i <= 31; i++) {
                startdays.push(i)
            }
            for (let i = 0; i <= endday; i++) {
                enddays.push(i)
            }
            // days = startdays;
            for (let i = starthour; i <= 23; i++) {
                hours.push(i)
            }
            for (let i = startminute; i <= 59; i++) {
                minutes.push(i)
            }
			return {
				multiArray: [
					years,
					months,
                    startdays,
                    hours,
                    minutes
				],
				multiIndex: [0, 0, 0, 0, 0],
			}
		},
		methods: {
			bindMultiPickerColumnChange: function(e) {
				console.log('修改的列为：' + e.detail.column + '，值为：' + e.detail.value);
				this.multiIndex[e.detail.column] = e.detail.value;
				// switch (e.detail.column) {
				// 	case 0: //拖动第1列
				// 		switch (this.multiIndex[0]) {
				// 			case 0:
				// 				this.multiArray[1] = ['中国', '日本']
				// 				this.multiArray[2] = ['北京', '上海', '广州']
				// 				break
				// 			case 1:
				// 				this.multiArray[1] = ['英国', '法国']
				// 				this.multiArray[2] = ['伦敦', '曼彻斯特']
				// 				break
				// 		}
				// 		this.multiIndex[1] = 0
				// 		this.multiIndex[2] = 0
				// 		break
				// 	case 1: //拖动第2列
				// 		switch (this.multiIndex[0]) { //判断第一列是什么
				// 			case 0:
				// 				switch (this.multiIndex[1]) {
				// 					case 0:
				// 						this.multiArray[2] = ['北京', '上海', '广州']
				// 						break
				// 					case 1:
				// 						this.multiArray[2] = ['东京','北海道']
				// 						break
				// 				}
				// 				break
				// 			case 1:
				// 				switch (this.multiIndex[1]) {
				// 					case 0:
				// 						this.multiArray[2] = ['伦敦', '曼彻斯特']
				// 						break
				// 					case 1:
				// 						this.multiArray[2] = ['巴黎', '马赛']
				// 						break
				// 				}
				// 				break
				// 		}
				// 		this.multiIndex[2] = 0
				// 		break
				// }
				this.$forceUpdate()
			}
		}
	}
</script>

<style>

</style>
