u-picker-select.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. <template>
  2. <u-popup :maskCloseAble="maskCloseAble" mode="bottom" :popup="false" v-model="value" length="auto"
  3. :safeAreaInsetBottom="safeAreaInsetBottom" @close="close" :z-index="uZIndex">
  4. <view class="u-datetime-picker">
  5. <view class="u-picker-header" @touchmove.stop.prevent="">
  6. <view class="u-btn-picker u-btn-picker--tips"
  7. :style="{ color: cancelColor }"
  8. hover-class="u-opacity"
  9. :hover-stay-time="150"
  10. v-show="!noselect"
  11. @tap="getResult('cancel')"
  12. >{{cancelText}}</view>
  13. <view></view>
  14. <view class="u-picker__title">{{ title }}</view>
  15. <view></view>
  16. <view
  17. class="u-btn-picker u-btn-picker--primary"
  18. :style="{ color: moving ? cancelColor : confirmColor }"
  19. hover-class="u-opacity"
  20. :hover-stay-time="150"
  21. @touchmove.stop=""
  22. @tap.stop="getResult('confirm')"
  23. v-show="!noselect"
  24. >
  25. {{confirmText}}
  26. </view>
  27. </view>
  28. <view class="u-datetime-picker" v-if="noselect">
  29. <view class="u-picker-header" @touchmove.stop.prevent="">
  30. <view class="headesParamsSelect" :class="{
  31. selectIndex:params.day
  32. }" @click="params.day=true,init()">按日期选择</view>
  33. <view class="headesParamsSelect" :class="{
  34. selectIndex:!params.day
  35. }" @click="params.day=false,init()">按月选择</view>
  36. </view>
  37. </view>
  38. <view class="u-picker-body">
  39. <picker-view :value="valueArr" @change="change" class="u-picker-view" @pickstart="pickstart"
  40. @pickend="pickend">
  41. <picker-view-column v-if="!reset && params.year">
  42. <view class="u-column-item" v-for="(item, index) in years" :key="index">
  43. {{ item }}
  44. <text class="u-text" v-if="showTimeTag">年</text>
  45. </view>
  46. </picker-view-column>
  47. <picker-view-column v-if="!reset && params.month">
  48. <view class="u-column-item" v-for="(item, index) in months" :key="index">
  49. {{ formatNumber(item) }}
  50. <text class="u-text" v-if="showTimeTag">月</text>
  51. </view>
  52. </picker-view-column>
  53. <picker-view-column v-if="!reset && params.day">
  54. <view class="u-column-item" v-for="(item, index) in days" :key="index">
  55. {{ formatNumber(item) }}
  56. <text class="u-text" v-if="showTimeTag">日</text>
  57. </view>
  58. </picker-view-column>
  59. </picker-view>
  60. </view>
  61. <view class="u-datetime-picker" v-if="noselect">
  62. <view class="u-picker-header u-picker-header2" @touchmove.stop.prevent="">
  63. <view class="u-btn-picker u-btn-picker--tips" :style="{ color: cancelColor }" hover-class="u-opacity"
  64. :hover-stay-time="150" @tap="getResult('reset')">
  65. <view class="headesParamsSelect" >重置</view>
  66. </view>
  67. <view class="u-picker__title"></view>
  68. <view class="u-btn-picker u-btn-picker--primary" :style="{ color: moving ? cancelColor : confirmColor }"
  69. hover-class="u-opacity" :hover-stay-time="150" @touchmove.stop="" @tap.stop="getResult('confirm')">
  70. <view class="headesParamsSelect selectIndex" >确定</view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </u-popup>
  76. </template>
  77. <script>
  78. import provinces from '../../libs/util/province.js';
  79. import citys from '../../libs/util/city.js';
  80. import areas from '../../libs/util/area.js';
  81. // 苹果手机时间显示bug
  82. /**
  83. * picker picker弹出选择器
  84. * @description 此选择器有两种弹出模式:一是时间模式,可以配置年,日,月,时,分,秒参数 二是地区模式,可以配置省,市,区参数
  85. * @tutorial https://www.uviewui.com/components/picker.html
  86. * @property {Object} params 需要显示的参数,见官网说明
  87. * @property {String} mode 模式选择,region-地区类型,time-时间类型(默认time)
  88. * @property {String Number} start-year 可选的开始年份,mode=time时有效(默认1950)
  89. * @property {String Number} end-year 可选的结束年份,mode=time时有效(默认2050)
  90. * @property {Boolean} safe-area-inset-bottom 是否开启底部安全区适配(默认false)
  91. * @property {Boolean} show-time-tag 时间模式时,是否显示后面的年月日中文提示
  92. * @property {String} cancel-color 取消按钮的颜色(默认#606266)
  93. * @property {String} confirm-color 确认按钮的颜色(默认#2979ff)
  94. * @property {String} default-time 默认选中的时间,mode=time时有效
  95. * @property {String} confirm-text 确认按钮的文字
  96. * @property {String} cancel-text 取消按钮的文字
  97. * @property {String} default-region 默认选中的地区,中文形式,mode=region时有效
  98. * @property {String} default-code 默认选中的地区,编号形式,mode=region时有效
  99. * @property {Boolean} mask-close-able 是否允许通过点击遮罩关闭Picker(默认true)
  100. * @property {String Number} z-index 弹出时的z-index值(默认1075)
  101. * @property {Array} default-selector 数组形式,其中每一项表示选择了range对应项中的第几个
  102. * @property {Array} range 自定义选择的数据,mode=selector或mode=multiSelector时有效
  103. * @property {String} range-key 当range参数的元素为对象时,指定Object中的哪个key的值作为选择器显示内容
  104. * @event {Function} confirm 点击确定按钮,返回当前选择的值
  105. * @event {Function} cancel 点击取消按钮,返回当前选择的值
  106. * @example <u-picker v-model="show" mode="time"></u-picker>
  107. */
  108. export default {
  109. name: 'u-picker',
  110. props: {
  111. // picker中需要显示的参数
  112. params: {
  113. type: Object,
  114. default () {
  115. return {
  116. year: true,
  117. month: true,
  118. day: true,
  119. hour: false,
  120. minute: false,
  121. second: false,
  122. province: true,
  123. city: true,
  124. area: true,
  125. timestamp: true,
  126. };
  127. }
  128. },
  129. // 当mode=selector或者mode=multiSelector时,提供的数组
  130. range: {
  131. type: Array,
  132. default () {
  133. return [];
  134. }
  135. },
  136. noselect:{
  137. type: Boolean,
  138. default: true
  139. },
  140. // 当mode=selector或者mode=multiSelector时,提供的默认选中的下标
  141. defaultSelector: {
  142. type: Array,
  143. default () {
  144. return [0];
  145. }
  146. },
  147. // 当 range 是一个 Array<Object> 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容
  148. rangeKey: {
  149. type: String,
  150. default: ''
  151. },
  152. // 模式选择,region-地区类型,time-时间类型,selector-单列模式,multiSelector-多列模式
  153. mode: {
  154. type: String,
  155. default: 'time'
  156. },
  157. // 年份开始时间
  158. startYear: {
  159. type: [String, Number],
  160. default: 2020
  161. },
  162. // 年份结束时间
  163. endYear: {
  164. type: [String, Number],
  165. default: 2050
  166. },
  167. // "取消"按钮的颜色
  168. cancelColor: {
  169. type: String,
  170. default: '#606266'
  171. },
  172. // "确定"按钮的颜色
  173. confirmColor: {
  174. type: String,
  175. default: '#2979ff'
  176. },
  177. // 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02
  178. defaultTime: {
  179. type: String,
  180. default: ''
  181. },
  182. // 默认显示的地区,可传类似["河北省", "秦皇岛市", "北戴河区"]
  183. defaultRegion: {
  184. type: Array,
  185. default () {
  186. return [];
  187. }
  188. },
  189. // 时间模式时,是否显示后面的年月日中文提示
  190. showTimeTag: {
  191. type: Boolean,
  192. default: true
  193. },
  194. // 默认显示地区的编码,defaultRegion和areaCode同时存在,areaCode优先,可传类似["13", "1303", "130304"]
  195. areaCode: {
  196. type: Array,
  197. default () {
  198. return [];
  199. }
  200. },
  201. safeAreaInsetBottom: {
  202. type: Boolean,
  203. default: false
  204. },
  205. // 是否允许通过点击遮罩关闭Picker
  206. maskCloseAble: {
  207. type: Boolean,
  208. default: false
  209. },
  210. // 通过双向绑定控制组件的弹出与收起
  211. value: {
  212. type: Boolean,
  213. default: false
  214. },
  215. // 弹出的z-index值
  216. zIndex: {
  217. type: [String, Number],
  218. default: 0
  219. },
  220. // 顶部标题
  221. title: {
  222. type: String,
  223. default: ''
  224. },
  225. // 取消按钮的文字
  226. cancelText: {
  227. type: String,
  228. default: '取消'
  229. },
  230. // 确认按钮的文字
  231. confirmText: {
  232. type: String,
  233. default: '确认'
  234. }
  235. },
  236. data() {
  237. return {
  238. years: [],
  239. months: [],
  240. days: [],
  241. hours: [],
  242. minutes: [],
  243. seconds: [],
  244. year: 0,
  245. month: 0,
  246. day: 0,
  247. hour: 0,
  248. minute: 0,
  249. second: 0,
  250. reset: false,
  251. startDate: '',
  252. endDate: '',
  253. valueArr: [],
  254. provinces: provinces,
  255. citys: citys[0],
  256. areas: areas[0][0],
  257. province: 0,
  258. city: 0,
  259. area: 0,
  260. moving: false // 列是否还在滑动中,微信小程序如果在滑动中就点确定,结果可能不准确
  261. };
  262. },
  263. mounted() {
  264. this.init();
  265. },
  266. computed: {
  267. propsChange() {
  268. // 引用这几个变量,是为了监听其变化
  269. return `${this.mode}-${this.defaultTime}-${this.startYear}-${this.endYear}-${this.defaultRegion}-${this.areaCode}`;
  270. },
  271. regionChange() {
  272. // 引用这几个变量,是为了监听其变化
  273. return `${this.province}-${this.city}`;
  274. },
  275. yearAndMonth() {
  276. return `${this.year}-${this.month}`;
  277. },
  278. uZIndex() {
  279. // 如果用户有传递z-index值,优先使用
  280. return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
  281. }
  282. },
  283. watch: {
  284. propsChange() {
  285. this.reset = true;
  286. setTimeout(() => this.init(), 10);
  287. },
  288. // 如果地区发生变化,为了让picker联动起来,必须重置this.citys和this.areas
  289. regionChange(val) {
  290. this.citys = citys[this.province];
  291. this.areas = areas[this.province][this.city];
  292. },
  293. // watch监听月份的变化,实时变更日的天数,因为不同月份,天数不一样
  294. // 一个月可能有30,31天,甚至闰年2月的29天,平年2月28天
  295. yearAndMonth(val) {
  296. if (this.params.year) this.setDays();
  297. },
  298. // 微信和QQ小程序由于一些奇怪的原因(故同时对所有平台均初始化一遍),需要重新初始化才能显示正确的值
  299. value(n) {
  300. if (n) {
  301. this.reset = true;
  302. setTimeout(() => this.init(), 10);
  303. }
  304. }
  305. },
  306. methods: {
  307. newDate (date) {
  308. var time=null;
  309. if (date) {
  310. var reg=new RegExp('-','gi')
  311. time=new Date(date.replace(reg,'/'));
  312. }
  313. return time
  314. },
  315. // 标识滑动开始,只有微信小程序才有这样的事件
  316. pickstart() {
  317. // #ifdef MP-WEIXIN
  318. this.moving = true;
  319. // #endif
  320. },
  321. // 标识滑动结束
  322. pickend() {
  323. // #ifdef MP-WEIXIN
  324. this.moving = false;
  325. // #endif
  326. },
  327. // 对单列和多列形式的判断是否有传入变量的情况
  328. getItemValue(item, mode) {
  329. // 目前(2020-05-25)uni-app对微信小程序编译有错误,导致v-if为false中的内容也执行,错误导致
  330. // 单列模式或者多列模式中的getItemValue同时被执行,故在这里再加一层判断
  331. if (this.mode == mode) {
  332. return typeof item == 'object' ? item[this.rangeKey] : item;
  333. }
  334. },
  335. // 小于10前面补0,用于月份,日期,时分秒等
  336. formatNumber(num) {
  337. return +num < 10 ? '0' + num : String(num);
  338. },
  339. // 生成递进的数组
  340. generateArray: function(start, end) {
  341. // 转为数值格式,否则用户给end-year等传递字符串值时,下面的end+1会导致字符串拼接,而不是相加
  342. start = Number(start);
  343. end = Number(end);
  344. end = end > start ? end : start;
  345. // 生成数组,获取其中的索引,并剪出来
  346. return [...Array(end + 1).keys()].slice(start);
  347. },
  348. getIndex: function(arr, val) {
  349. let index = arr.indexOf(val);
  350. // 如果index为-1(即找不到index值),~(-1)=-(-1)-1=0,导致条件不成立
  351. return ~index ? index : 0;
  352. },
  353. //日期时间处理
  354. initTimeValue() {
  355. // 格式化时间,在IE浏览器(uni不存在此情况),无法识别日期间的"-"间隔符号
  356. let fdate = this.defaultTime.replace(/\-/g, '/');
  357. fdate = fdate && fdate.indexOf('/') == -1 ? `2020/01/01 ${fdate}` : fdate;
  358. if(fdate.length==7){
  359. fdate+="/01"
  360. }
  361. let time = null;
  362. if (fdate) time = this.newDate(fdate);
  363. else time = new Date();
  364. // 获取年日月时分秒
  365. this.year = time.getFullYear();
  366. this.month = Number(time.getMonth()) + 1;
  367. this.day = time.getDate();
  368. this.hour = time.getHours();
  369. this.minute = time.getMinutes();
  370. this.second = time.getSeconds();
  371. },
  372. init() {
  373. this.valueArr = [];
  374. this.reset = false;
  375. if (this.mode == 'time') {
  376. this.initTimeValue();
  377. if (this.params.year) {
  378. this.valueArr.push(0);
  379. this.setYears();
  380. }
  381. if (this.params.month) {
  382. this.valueArr.push(0);
  383. this.setMonths();
  384. }
  385. if (this.params.day) {
  386. this.valueArr.push(0);
  387. this.setDays();
  388. }
  389. if (this.params.hour) {
  390. this.valueArr.push(0);
  391. this.setHours();
  392. }
  393. if (this.params.minute) {
  394. this.valueArr.push(0);
  395. this.setMinutes();
  396. }
  397. if (this.params.second) {
  398. this.valueArr.push(0);
  399. this.setSeconds();
  400. }
  401. } else if (this.mode == 'region') {
  402. if (this.params.province) {
  403. this.valueArr.push(0);
  404. this.setProvinces();
  405. }
  406. if (this.params.city) {
  407. this.valueArr.push(0);
  408. this.setCitys();
  409. }
  410. if (this.params.area) {
  411. this.valueArr.push(0);
  412. this.setAreas();
  413. }
  414. } else if (this.mode == 'selector') {
  415. this.valueArr = this.defaultSelector;
  416. } else if (this.mode == 'multiSelector') {
  417. this.valueArr = this.defaultSelector;
  418. this.multiSelectorValue = this.defaultSelector;
  419. }
  420. this.$forceUpdate();
  421. },
  422. // 设置picker的某一列值
  423. setYears() {
  424. // 获取年份集合
  425. this.years = this.generateArray(this.startYear, this.endYear);
  426. // 设置this.valueArr某一项的值,是为了让picker预选中某一个值
  427. this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.years, this.year));
  428. },
  429. setMonths() {
  430. this.months = this.generateArray(1, 12);
  431. this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.months, this.month));
  432. },
  433. setDays() {
  434. let totalDays = new Date(this.year, this.month, 0).getDate();
  435. this.days = this.generateArray(1, totalDays);
  436. let index = 0;
  437. // 这里不能使用类似setMonths()中的this.valueArr.splice(this.valueArr.length - 1, xxx)做法
  438. // 因为this.month和this.year变化时,会触发watch中的this.setDays(),导致this.valueArr.length计算有误
  439. if (this.params.year && this.params.month) index = 2;
  440. else if (this.params.month) index = 1;
  441. else if (this.params.year) index = 1;
  442. else index = 0;
  443. // 当月份变化时,会导致日期的天数也会变化,如果原来选的天数大于变化后的天数,则重置为变化后的最大值
  444. // 比如原来选中3月31日,调整为2月后,日期变为最大29,这时如果day值继续为31显然不合理,于是将其置为29(picker-column从1开始)
  445. if (this.day > this.days.length) this.day = this.days.length;
  446. this.valueArr.splice(index, 1, this.getIndex(this.days, this.day));
  447. },
  448. setHours() {
  449. this.hours = this.generateArray(0, 23);
  450. this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.hours, this.hour));
  451. },
  452. setMinutes() {
  453. this.minutes = this.generateArray(0, 59);
  454. this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.minutes, this.minute));
  455. },
  456. setSeconds() {
  457. this.seconds = this.generateArray(0, 59);
  458. this.valueArr.splice(this.valueArr.length - 1, 1, this.getIndex(this.seconds, this.second));
  459. },
  460. setProvinces() {
  461. // 判断是否需要province参数
  462. if (!this.params.province) return;
  463. let tmp = '';
  464. let useCode = false;
  465. // 如果同时配置了defaultRegion和areaCode,优先使用areaCode参数
  466. if (this.areaCode.length) {
  467. tmp = this.areaCode[0];
  468. useCode = true;
  469. } else if (this.defaultRegion.length) tmp = this.defaultRegion[0];
  470. else tmp = 0;
  471. // 历遍省份数组匹配
  472. provinces.map((v, k) => {
  473. if (useCode ? v.value == tmp : v.label == tmp) {
  474. tmp = k;
  475. }
  476. });
  477. this.province = tmp;
  478. this.provinces = provinces;
  479. // 设置默认省份的值
  480. this.valueArr.splice(0, 1, this.province);
  481. },
  482. setCitys() {
  483. if (!this.params.city) return;
  484. let tmp = '';
  485. let useCode = false;
  486. if (this.areaCode.length) {
  487. tmp = this.areaCode[1];
  488. useCode = true;
  489. } else if (this.defaultRegion.length) tmp = this.defaultRegion[1];
  490. else tmp = 0;
  491. citys[this.province].map((v, k) => {
  492. if (useCode ? v.value == tmp : v.label == tmp) {
  493. tmp = k;
  494. }
  495. });
  496. this.city = tmp;
  497. this.citys = citys[this.province];
  498. this.valueArr.splice(1, 1, this.city);
  499. },
  500. setAreas() {
  501. if (!this.params.area) return;
  502. let tmp = '';
  503. let useCode = false;
  504. if (this.areaCode.length) {
  505. tmp = this.areaCode[2];
  506. useCode = true;
  507. } else if (this.defaultRegion.length) tmp = this.defaultRegion[2];
  508. else tmp = 0;
  509. areas[this.province][this.city].map((v, k) => {
  510. if (useCode ? v.value == tmp : v.label == tmp) {
  511. tmp = k;
  512. }
  513. });
  514. this.area = tmp;
  515. this.areas = areas[this.province][this.city];
  516. this.valueArr.splice(2, 1, this.area);
  517. },
  518. close() {
  519. this.$emit('input', false);
  520. },
  521. // 用户更改picker的列选项
  522. change(e) {
  523. this.valueArr = e.detail.value;
  524. let i = 0;
  525. if (this.mode == 'time') {
  526. // 这里使用i++,是因为this.valueArr数组的长度是不确定长度的,它根据this.params的值来配置长度
  527. // 进入if规则,i会加1,保证了能获取准确的值
  528. if (this.params.year) this.year = this.years[this.valueArr[i++]];
  529. if (this.params.month) this.month = this.months[this.valueArr[i++]];
  530. if (this.params.day) this.day = this.days[this.valueArr[i++]];
  531. if (this.params.hour) this.hour = this.hours[this.valueArr[i++]];
  532. if (this.params.minute) this.minute = this.minutes[this.valueArr[i++]];
  533. if (this.params.second) this.second = this.seconds[this.valueArr[i++]];
  534. } else if (this.mode == 'region') {
  535. if (this.params.province) this.province = this.valueArr[i++];
  536. if (this.params.city) this.city = this.valueArr[i++];
  537. if (this.params.area) this.area = this.valueArr[i++];
  538. } else if (this.mode == 'multiSelector') {
  539. let index = null;
  540. // 对比前后两个数组,寻找变更的是哪一列,如果某一个元素不同,即可判定该列发生了变化
  541. this.defaultSelector.map((val, idx) => {
  542. if (val != e.detail.value[idx]) index = idx;
  543. });
  544. // 为了让用户对多列变化时,对动态设置其他列的变更
  545. if (index != null) {
  546. this.$emit('columnchange', {
  547. column: index,
  548. index: e.detail.value[index]
  549. });
  550. }
  551. }
  552. },
  553. // 用户点击确定按钮
  554. getResult(event = null) {
  555. // #ifdef MP-WEIXIN
  556. if (this.moving) return;
  557. // #endif
  558. let result = {};
  559. // 只返回用户在this.params中配置了为true的字段
  560. if (this.mode == 'time') {
  561. if (this.params.year) result.year = this.formatNumber(this.year || 0);
  562. if (this.params.month) result.month = this.formatNumber(this.month || 0);
  563. if (this.params.day) result.day = this.formatNumber(this.day || 0);
  564. if (this.params.hour) result.hour = this.formatNumber(this.hour || 0);
  565. if (this.params.minute) result.minute = this.formatNumber(this.minute || 0);
  566. if (this.params.second) result.second = this.formatNumber(this.second || 0);
  567. if (this.params.timestamp) result.timestamp = this.getTimestamp();
  568. } else if (this.mode == 'region') {
  569. if (this.params.province) result.province = provinces[this.province];
  570. if (this.params.city) result.city = citys[this.province][this.city];
  571. if (this.params.area) result.area = areas[this.province][this.city][this.area];
  572. } else if (this.mode == 'selector') {
  573. result = this.valueArr;
  574. } else if (this.mode == 'multiSelector') {
  575. result = this.valueArr;
  576. }
  577. if (event) this.$emit(event, result);
  578. this.close();
  579. },
  580. // 获取时间戳
  581. getTimestamp() {
  582. // yyyy-mm-dd为安卓写法,不支持iOS,需要使用"/"分隔,才能二者兼容
  583. let time = this.year + '/' + this.month + '/' + this.day + ' ' + this.hour + ':' + this.minute + ':' + this
  584. .second;
  585. return new Date(time).getTime() / 1000;
  586. }
  587. }
  588. };
  589. </script>
  590. <style lang="scss" scoped>
  591. @import '../../libs/css/style.components.scss';
  592. .u-datetime-picker {
  593. position: relative;
  594. z-index: 999;
  595. }
  596. .u-picker-view {
  597. height: 100%;
  598. box-sizing: border-box;
  599. }
  600. .u-picker-header {
  601. width: 100%;
  602. height: 90rpx;
  603. padding: 0 40rpx;
  604. @include vue-flex;
  605. justify-content: space-between;
  606. align-items: center;
  607. box-sizing: border-box;
  608. font-size: 30rpx;
  609. background: #fff;
  610. position: relative;
  611. .headesParamsSelect{
  612. width: 300rpx;
  613. height: 80rpx;
  614. line-height: 80rpx;
  615. border-radius: 25px;
  616. background-color: rgba(222,225,228,1);
  617. color: rgba(51,51,51,1);
  618. font-size: 28rpx;
  619. text-align: center;
  620. }
  621. .selectIndex{
  622. background:#307af7 ;
  623. color: rgba(255,255,255,1);
  624. }
  625. }
  626. .u-picker-header2{
  627. .headesParamsSelect{
  628. width: 300rpx;
  629. height: 80rpx;
  630. line-height: 80rpx;
  631. border-radius: 2px;
  632. background-color: rgba(222,225,228,1);
  633. color: rgba(51,51,51,1);
  634. font-size: 28rpx;
  635. text-align: center;
  636. }
  637. .selectIndex{
  638. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  639. color: rgba(255,255,255,1);
  640. }
  641. }
  642. .u-picker-header::after {
  643. content: '';
  644. position: absolute;
  645. border-bottom: 1rpx solid #eaeef1;
  646. -webkit-transform: scaleY(0.5);
  647. transform: scaleY(0.5);
  648. bottom: 0;
  649. right: 0;
  650. left: 0;
  651. }
  652. .u-picker__title {
  653. color: $u-content-color;
  654. }
  655. .u-picker-body {
  656. width: 100%;
  657. height: 500rpx;
  658. overflow: hidden;
  659. background-color: #fff;
  660. }
  661. .u-column-item {
  662. @include vue-flex;
  663. align-items: center;
  664. justify-content: center;
  665. font-size: 32rpx;
  666. color: $u-main-color;
  667. padding: 0 8rpx;
  668. }
  669. .u-text {
  670. font-size: 24rpx;
  671. padding-left: 8rpx;
  672. }
  673. .u-btn-picker {
  674. padding: 16rpx;
  675. box-sizing: border-box;
  676. text-align: center;
  677. text-decoration: none;
  678. }
  679. .u-opacity {
  680. opacity: 0.5;
  681. }
  682. .u-btn-picker--primary {
  683. color: $u-type-primary;
  684. }
  685. .u-btn-picker--tips {
  686. color: $u-tips-color;
  687. }
  688. </style>