<template>
|
<uni-popup ref="date" background-color="#fff">
|
<view class="date">
|
<view class="title">
|
<text>我的生日</text>
|
<view class="title_icon" @click="closeDate">
|
<uni-icons color="#CCCCCB" type="closeempty" size="20"></uni-icons>
|
</view>
|
</view>
|
<view class="content">
|
<picker-view
|
:indicator-style="indicatorStyle"
|
:value="date"
|
:immediate-change="true"
|
@change="bindChangeDate"
|
class="picker-view">
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
|
</picker-view-column>
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
|
</picker-view-column>
|
<picker-view-column>
|
<view class="item" v-for="(item,index) in days" :key="index">{{item}}日</view>
|
</picker-view-column>
|
</picker-view>
|
</view>
|
<view class="submit" @click="updata">确定</view>
|
</view>
|
</uni-popup>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
const date = new Date()
|
const years = []
|
const year = date.getFullYear()
|
const months = []
|
const month = date.getMonth() + 1
|
const days = []
|
const day = date.getDate()
|
|
for (let i = 1990; i <= date.getFullYear(); i++) {
|
years.push(i)
|
}
|
for (let i = 1; i <= 12; i++) {
|
months.push(i)
|
}
|
for (let i = 1; i <= 31; i++) {
|
days.push(i)
|
}
|
return {
|
years,
|
year,
|
months,
|
month,
|
days,
|
day,
|
date: [9999, month - 1, day - 1],
|
visible: true,
|
indicatorStyle: `height: 50px;`
|
}
|
},
|
methods: {
|
open() {
|
this.$refs.date.open('bottom')
|
},
|
bindChangeDate(v) {
|
const val = v.detail.value
|
this.year = this.years[val[0]]
|
this.month = this.months[val[1]]
|
this.day = this.days[val[2]]
|
},
|
updata() {
|
this.$emit('updata', [this.year, this.month, this.day])
|
this.$refs.date.close()
|
},
|
closeDate() {
|
this.$refs.date.close()
|
},
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.date {
|
padding: 44rpx 32rpx;
|
background-color: #FFFFFF;
|
box-sizing: border-box;
|
.title {
|
width: 100%;
|
text-align: center;
|
position: relative;
|
text {
|
font-size: 32rpx;
|
font-family: PingFang SC-Semibold, PingFang SC;
|
font-weight: 600;
|
color: #333333;
|
}
|
.title_icon {
|
position: absolute;
|
right: 0;
|
top: 0;
|
}
|
}
|
.content {
|
width: 100%;
|
margin-top: 80rpx;
|
.picker-view {
|
width: 100%;
|
height: 600rpx;
|
.item {
|
height: 40px;
|
line-height: 40px;
|
text-align: center;
|
}
|
}
|
}
|
.submit {
|
width: 100%;
|
height: 72rpx;
|
line-height: 72rpx;
|
text-align: center;
|
background: linear-gradient(270deg, #D20A0A 0%, #D95A5A 100%);
|
border-radius: 36rpx;
|
font-size: 32rpx;
|
font-family: PingFang SC-Medium, PingFang SC;
|
font-weight: 500;
|
color: #FFFFFF;
|
margin-top: 50rpx;
|
}
|
}
|
</style>
|