changeCalendar.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view class="changeCalendar">
  3. <view class="zheZhao"></view>
  4. <view class="content">
  5. <view class="title">选择日期</view>
  6. <view class="cont">
  7. <text class="fenjie">/</text>
  8. <picker-view
  9. :indicator-style="indicatorStyle"
  10. :value="value"
  11. @change="bindChange"
  12. >
  13. <picker-view-column>
  14. <view class="item" v-for="(item, index) in years" :key="index"
  15. >{{ item }}年</view
  16. >
  17. </picker-view-column>
  18. <picker-view-column>
  19. <view class="item" v-for="(item, index) in months" :key="index"
  20. >{{ item }}月</view
  21. >
  22. </picker-view-column>
  23. <!-- <picker-view-column>
  24. <view class="item" v-for="(item,index) in days" :key="index">{{item}}日</view>
  25. </picker-view-column> -->
  26. </picker-view>
  27. </view>
  28. <view class="change">
  29. <view class="cancel" @click="cancelCC">取消</view>
  30. <view class="sure" @click="sureCC">确定</view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import moment from "moment";
  37. export default {
  38. props: {
  39. changedYear: {},
  40. changedMonth: {},
  41. },
  42. data() {
  43. return {
  44. title: "picker-view",
  45. years: [],
  46. year: "",
  47. months: [],
  48. month: "",
  49. days: [],
  50. day: "",
  51. value: [],
  52. visible: true,
  53. // indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`
  54. indicatorStyle: `height: 80rpx;`,
  55. };
  56. },
  57. mounted() {
  58. this.year = this.changedYear;
  59. this.month = this.changedMonth;
  60. let date = new Date();
  61. let years = [];
  62. let year = date.getFullYear();
  63. let months = [
  64. "01",
  65. "02",
  66. "03",
  67. "04",
  68. "05",
  69. "06",
  70. "07",
  71. "08",
  72. "09",
  73. "10",
  74. "11",
  75. "12",
  76. ];
  77. let month = date.getMonth() + 1;
  78. let days = [];
  79. let day = date.getDate();
  80. for (let i = 1990; i <= date.getFullYear() + 100; i++) {
  81. years.push(i);
  82. }
  83. this.years = years;
  84. this.months = months;
  85. this.value = [this.changedYear - 1990, this.changedMonth - 1];
  86. },
  87. methods: {
  88. bindChange(e) {
  89. const val = e.detail.value;
  90. this.year = this.years[val[0]];
  91. this.month = this.months[val[1]];
  92. },
  93. cancelCC() {
  94. this.$emit("cancelCC", false);
  95. },
  96. sureCC() {
  97. this.$emit("sureCC", false, this.year, this.month);
  98. },
  99. },
  100. };
  101. </script>
  102. <style lang="less">
  103. .changeCalendar {
  104. // margin-top: -105rpx;
  105. // width: 100%;
  106. // height: 100vh;
  107. // background: #12141A;
  108. // opacity: 0.5;
  109. // position: absolute;
  110. // left: 0rpx;
  111. // top: 0rpx;
  112. // z-index: 3;
  113. .picker-view {
  114. width: 100%;
  115. height: 400rpx;
  116. // margin-top: 20rpx;
  117. }
  118. .item {
  119. height: 80rpx;
  120. line-height: 80rpx;
  121. align-items: center;
  122. justify-content: center;
  123. text-align: center;
  124. font-size: 40rpx;
  125. }
  126. .zheZhao {
  127. width: 100%;
  128. height: calc(100% - 575rpx);
  129. background: #12141a;
  130. opacity: 0.5;
  131. position: absolute;
  132. left: 0rpx;
  133. top: 0rpx;
  134. z-index: 3;
  135. }
  136. .content {
  137. width: 100%;
  138. height: 600rpx;
  139. background-color: #fff;
  140. position: absolute;
  141. bottom: 0rpx;
  142. opacity: 1;
  143. z-index: 4;
  144. border-radius: 25rpx 25rpx 0rpx 0px;
  145. // height: 575rpx;
  146. .title {
  147. margin-top: 35rpx;
  148. margin-left: 40rpx;
  149. font-size: 30rpx;
  150. color: #292c33;
  151. }
  152. .cont {
  153. margin: 42.5rpx 0rpx 17.5rpx 0rpx;
  154. height: 400rpx;
  155. overflow: hidden;
  156. position: relative;
  157. .fenjie{
  158. position: absolute;
  159. left: 391.87rpx;
  160. top: 187.5rpx;
  161. font-size: 25rpx;
  162. font-weight: bold;
  163. }
  164. }
  165. .change {
  166. text-align: center;
  167. border-top: 0.62rpx solid #dadee6;
  168. .cancel {
  169. padding: 26.25rpx 0rpx;
  170. display: inline-block;
  171. width: 50%;
  172. color: #3377ff;
  173. }
  174. .sure {
  175. padding: 26.25rpx 0rpx;
  176. display: inline-block;
  177. width: 50%;
  178. color: #fff;
  179. background-color: #3377ff;
  180. }
  181. }
  182. uni-picker-view {
  183. display: block;
  184. height: 400rpx !important;
  185. }
  186. uni-picker-view .uni-picker-view-wrapper {
  187. display: flex;
  188. position: relative;
  189. overflow: hidden;
  190. height: 100%;
  191. background-color: white;
  192. }
  193. uni-picker-view[hidden] {
  194. display: none;
  195. }
  196. picker-view {
  197. width: 100%;
  198. height: 600upx;
  199. font-weight: bold;
  200. }
  201. }
  202. }
  203. </style>