123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <template>
- <view class="changeCalendar">
- <view class="zheZhao"></view>
- <view class="content">
- <view class="title">选择日期</view>
- <view class="cont">
- <text class="fenjie">/</text>
- <picker-view
- :indicator-style="indicatorStyle"
- :value="value"
- @change="bindChange"
- >
- <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="change">
- <view class="cancel" @click="cancelCC">取消</view>
- <view class="sure" @click="sureCC">确定</view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import moment from "moment";
- export default {
- props: {
- changedYear: {},
- changedMonth: {},
- },
- data() {
- return {
- title: "picker-view",
- years: [],
- year: "",
- months: [],
- month: "",
- days: [],
- day: "",
- value: [],
- visible: true,
- // indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`
- indicatorStyle: `height: 80rpx;`,
- };
- },
- mounted() {
- this.year = this.changedYear;
- this.month = this.changedMonth;
- let date = new Date();
- let years = [];
- let year = date.getFullYear();
- let months = [
- "01",
- "02",
- "03",
- "04",
- "05",
- "06",
- "07",
- "08",
- "09",
- "10",
- "11",
- "12",
- ];
- let month = date.getMonth() + 1;
- let days = [];
- let day = date.getDate();
- for (let i = 1990; i <= date.getFullYear() + 100; i++) {
- years.push(i);
- }
- this.years = years;
- this.months = months;
- this.value = [this.changedYear - 1990, this.changedMonth - 1];
- },
- methods: {
- bindChange(e) {
- const val = e.detail.value;
- this.year = this.years[val[0]];
- this.month = this.months[val[1]];
- },
- cancelCC() {
- this.$emit("cancelCC", false);
- },
- sureCC() {
- this.$emit("sureCC", false, this.year, this.month);
- },
- },
- };
- </script>
- <style lang="less">
- .changeCalendar {
- // margin-top: -105rpx;
- // width: 100%;
- // height: 100vh;
- // background: #12141A;
- // opacity: 0.5;
- // position: absolute;
- // left: 0rpx;
- // top: 0rpx;
- // z-index: 3;
- .picker-view {
- width: 100%;
- height: 400rpx;
- // margin-top: 20rpx;
- }
- .item {
- height: 80rpx;
- line-height: 80rpx;
- align-items: center;
- justify-content: center;
- text-align: center;
- font-size: 40rpx;
- }
- .zheZhao {
- width: 100%;
- height: calc(100% - 575rpx);
- background: #12141a;
- opacity: 0.5;
- position: absolute;
- left: 0rpx;
- top: 0rpx;
- z-index: 3;
- }
- .content {
- width: 100%;
- height: 600rpx;
- background-color: #fff;
- position: absolute;
- bottom: 0rpx;
- opacity: 1;
- z-index: 4;
- border-radius: 25rpx 25rpx 0rpx 0px;
- // height: 575rpx;
- .title {
- margin-top: 35rpx;
- margin-left: 40rpx;
- font-size: 30rpx;
- color: #292c33;
- }
- .cont {
- margin: 42.5rpx 0rpx 17.5rpx 0rpx;
- height: 400rpx;
- overflow: hidden;
- position: relative;
- .fenjie{
- position: absolute;
- left: 391.87rpx;
- top: 187.5rpx;
- font-size: 25rpx;
- font-weight: bold;
- }
- }
- .change {
- text-align: center;
- border-top: 0.62rpx solid #dadee6;
- .cancel {
- padding: 26.25rpx 0rpx;
- display: inline-block;
- width: 50%;
- color: #3377ff;
- }
- .sure {
- padding: 26.25rpx 0rpx;
- display: inline-block;
- width: 50%;
- color: #fff;
- background-color: #3377ff;
- }
- }
- uni-picker-view {
- display: block;
- height: 400rpx !important;
- }
- uni-picker-view .uni-picker-view-wrapper {
- display: flex;
- position: relative;
- overflow: hidden;
- height: 100%;
- background-color: white;
- }
- uni-picker-view[hidden] {
- display: none;
- }
- picker-view {
- width: 100%;
- height: 600upx;
- font-weight: bold;
- }
- }
- }
- </style>
|