calendar.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. <template>
  2. <view class="uni-calendar" @mouseleave="leaveCale">
  3. <view v-if="!insert && show" class="uni-calendar__mask" :class="{ 'uni-calendar--mask-show': aniMaskShow }" @click="maskClick"></view>
  4. <view
  5. v-if="insert || show"
  6. class="uni-calendar__content"
  7. :class="{ 'uni-calendar--fixed': !insert, 'uni-calendar--ani-show': aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow }"
  8. >
  9. <view class="uni-calendar__header" :class="{ 'uni-calendar__header-mobile': !insert }">
  10. <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
  11. <view class="uni-calendar__header-btn uni-calendar--left"></view>
  12. </view>
  13. <picker mode="date" :value="date" fields="month" @change="bindDateChange">
  14. <text class="uni-calendar__header-text">{{ (nowDate.year || '') + yearText + (nowDate.month || '') + monthText }}</text>
  15. </picker>
  16. <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
  17. <view class="uni-calendar__header-btn uni-calendar--right"></view>
  18. </view>
  19. <view v-if="!insert" class="dialog-close" @click="close">
  20. <view class="dialog-close-plus" data-id="close"></view>
  21. <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
  22. </view>
  23. </view>
  24. <view class="uni-calendar__box">
  25. <view v-if="showMonth" class="uni-calendar__box-bg">
  26. <text class="uni-calendar__box-bg-text">{{ nowDate.month }}</text>
  27. </view>
  28. <view class="uni-calendar__weeks" style="padding-bottom: 7px">
  29. <view class="uni-calendar__weeks-day">
  30. <text class="uni-calendar__weeks-day-text">{{ SUNText }}</text>
  31. </view>
  32. <view class="uni-calendar__weeks-day">
  33. <text class="uni-calendar__weeks-day-text">{{ MONText }}</text>
  34. </view>
  35. <view class="uni-calendar__weeks-day">
  36. <text class="uni-calendar__weeks-day-text">{{ TUEText }}</text>
  37. </view>
  38. <view class="uni-calendar__weeks-day">
  39. <text class="uni-calendar__weeks-day-text">{{ WEDText }}</text>
  40. </view>
  41. <view class="uni-calendar__weeks-day">
  42. <text class="uni-calendar__weeks-day-text">{{ THUText }}</text>
  43. </view>
  44. <view class="uni-calendar__weeks-day">
  45. <text class="uni-calendar__weeks-day-text">{{ FRIText }}</text>
  46. </view>
  47. <view class="uni-calendar__weeks-day">
  48. <text class="uni-calendar__weeks-day-text">{{ SATText }}</text>
  49. </view>
  50. </view>
  51. <view class="uni-calendar__weeks" v-for="(item, weekIndex) in weeks" :key="weekIndex">
  52. <view class="uni-calendar__weeks-item" v-for="(weeks, weeksIndex) in item" :key="weeksIndex">
  53. <calendar-item
  54. class="uni-calendar-item--hook"
  55. :weeks="weeks"
  56. :calendar="calendar"
  57. :selected="selected"
  58. :checkHover="range"
  59. @change="choiceDate"
  60. @handleMouse="handleMouse"
  61. ></calendar-item>
  62. </view>
  63. </view>
  64. </view>
  65. <view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top" style="padding: 0 80px">
  66. <view class="uni-date-changed--time-date">{{ tempSingleDate ? tempSingleDate : selectDateText }}</view>
  67. <time-picker
  68. type="time"
  69. :start="timepickerStartTime"
  70. :end="timepickerEndTime"
  71. v-model="time"
  72. :disabled="!tempSingleDate"
  73. :border="false"
  74. :hide-second="hideSecond"
  75. class="time-picker-style"
  76. ></time-picker>
  77. </view>
  78. <view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
  79. <view class="uni-date-changed--time-start">
  80. <view class="uni-date-changed--time-date">{{ tempRange.before ? tempRange.before : startDateText }}</view>
  81. <time-picker
  82. type="time"
  83. :start="timepickerStartTime"
  84. v-model="timeRange.startTime"
  85. :border="false"
  86. :hide-second="hideSecond"
  87. :disabled="!tempRange.before"
  88. class="time-picker-style"
  89. ></time-picker>
  90. </view>
  91. <view style="line-height: 50px">
  92. <uni-icons type="arrowthinright" color="#999"></uni-icons>
  93. </view>
  94. <view class="uni-date-changed--time-end">
  95. <view class="uni-date-changed--time-date">{{ tempRange.after ? tempRange.after : endDateText }}</view>
  96. <time-picker
  97. type="time"
  98. :end="timepickerEndTime"
  99. v-model="timeRange.endTime"
  100. :border="false"
  101. :hide-second="hideSecond"
  102. :disabled="!tempRange.after"
  103. class="time-picker-style"
  104. ></time-picker>
  105. </view>
  106. </view>
  107. <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
  108. <view class="uni-datetime-picker--btn" @click="confirm">{{ confirmText }}</view>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import { Calendar, getDate, getTime } from './util.js';
  115. import calendarItem from './calendar-item.vue';
  116. import timePicker from './time-picker.vue';
  117. import { initVueI18n } from '@dcloudio/uni-i18n';
  118. import i18nMessages from './i18n/index.js';
  119. const { t } = initVueI18n(i18nMessages);
  120. /**
  121. * Calendar 日历
  122. * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
  123. * @tutorial https://ext.dcloud.net.cn/plugin?id=56
  124. * @property {String} date 自定义当前时间,默认为今天
  125. * @property {String} startDate 日期选择范围-开始日期
  126. * @property {String} endDate 日期选择范围-结束日期
  127. * @property {Boolean} range 范围选择
  128. * @property {Boolean} insert = [true|false] 插入模式,默认为false
  129. * @value true 弹窗模式
  130. * @value false 插入模式
  131. * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
  132. * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
  133. * @property {Boolean} showMonth 是否选择月份为背景
  134. * @property {[String} defaultValue 选择器打开时默认显示的时间
  135. * @event {Function} change 日期改变,`insert :ture` 时生效
  136. * @event {Function} select 日期改变,`insert :false` 时生效(新增)
  137. * @event {Function} confirm 确认选择`insert :false` 时生效
  138. * @event {Function} monthSwitch 切换月份时触发
  139. * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
  140. */
  141. export default {
  142. components: {
  143. calendarItem,
  144. timePicker
  145. },
  146. props: {
  147. date: {
  148. type: String,
  149. default: ''
  150. },
  151. defTime: {
  152. type: [String, Object],
  153. default: ''
  154. },
  155. selectableTimes: {
  156. type: [Object],
  157. default() {
  158. return {};
  159. }
  160. },
  161. selected: {
  162. type: Array,
  163. default() {
  164. return [];
  165. }
  166. },
  167. startDate: {
  168. type: String,
  169. default: ''
  170. },
  171. endDate: {
  172. type: String,
  173. default: ''
  174. },
  175. startPlaceholder: {
  176. type: String,
  177. default: ''
  178. },
  179. endPlaceholder: {
  180. type: String,
  181. default: ''
  182. },
  183. range: {
  184. type: Boolean,
  185. default: false
  186. },
  187. hasTime: {
  188. type: Boolean,
  189. default: false
  190. },
  191. insert: {
  192. type: Boolean,
  193. default: true
  194. },
  195. showMonth: {
  196. type: Boolean,
  197. default: true
  198. },
  199. clearDate: {
  200. type: Boolean,
  201. default: true
  202. },
  203. checkHover: {
  204. type: Boolean,
  205. default: true
  206. },
  207. hideSecond: {
  208. type: [Boolean],
  209. default: false
  210. },
  211. pleStatus: {
  212. type: Object,
  213. default() {
  214. return {
  215. before: '',
  216. after: '',
  217. data: [],
  218. fulldate: ''
  219. };
  220. }
  221. },
  222. defaultValue: {
  223. type: [String, Object, Array],
  224. default: ''
  225. }
  226. },
  227. data() {
  228. return {
  229. show: false,
  230. weeks: [],
  231. calendar: {},
  232. nowDate: {},
  233. aniMaskShow: false,
  234. firstEnter: true,
  235. time: '',
  236. timeRange: {
  237. startTime: '',
  238. endTime: ''
  239. },
  240. tempSingleDate: '',
  241. tempRange: {
  242. before: '',
  243. after: ''
  244. }
  245. };
  246. },
  247. watch: {
  248. date: {
  249. immediate: true,
  250. handler(newVal) {
  251. if (!this.range) {
  252. this.tempSingleDate = newVal;
  253. setTimeout(() => {
  254. this.init(newVal);
  255. }, 100);
  256. }
  257. }
  258. },
  259. defTime: {
  260. immediate: true,
  261. handler(newVal) {
  262. if (!this.range) {
  263. this.time = newVal;
  264. } else {
  265. this.timeRange.startTime = newVal.start;
  266. this.timeRange.endTime = newVal.end;
  267. }
  268. }
  269. },
  270. startDate(val) {
  271. // 字节小程序 watch 早于 created
  272. if (!this.cale) {
  273. return;
  274. }
  275. this.cale.setStartDate(val);
  276. this.cale.setDate(this.nowDate.fullDate);
  277. this.weeks = this.cale.weeks;
  278. },
  279. endDate(val) {
  280. // 字节小程序 watch 早于 created
  281. if (!this.cale) {
  282. return;
  283. }
  284. this.cale.setEndDate(val);
  285. this.cale.setDate(this.nowDate.fullDate);
  286. this.weeks = this.cale.weeks;
  287. },
  288. selected(newVal) {
  289. // 字节小程序 watch 早于 created
  290. if (!this.cale) {
  291. return;
  292. }
  293. this.cale.setSelectInfo(this.nowDate.fullDate, newVal);
  294. this.weeks = this.cale.weeks;
  295. },
  296. pleStatus: {
  297. immediate: true,
  298. handler(newVal) {
  299. const { before, after, fulldate, which } = newVal;
  300. this.tempRange.before = before;
  301. this.tempRange.after = after;
  302. setTimeout(() => {
  303. if (fulldate) {
  304. this.cale.setHoverMultiple(fulldate);
  305. if (before && after) {
  306. this.cale.lastHover = true;
  307. if (this.rangeWithinMonth(after, before)) return;
  308. this.setDate(before);
  309. } else {
  310. this.cale.setMultiple(fulldate);
  311. this.setDate(this.nowDate.fullDate);
  312. this.calendar.fullDate = '';
  313. this.cale.lastHover = false;
  314. }
  315. } else {
  316. // 字节小程序 watch 早于 created
  317. if (!this.cale) {
  318. return;
  319. }
  320. this.cale.setDefaultMultiple(before, after);
  321. if (which === 'left' && before) {
  322. this.setDate(before);
  323. this.weeks = this.cale.weeks;
  324. } else if (after) {
  325. this.setDate(after);
  326. this.weeks = this.cale.weeks;
  327. }
  328. this.cale.lastHover = true;
  329. }
  330. }, 16);
  331. }
  332. }
  333. },
  334. computed: {
  335. timepickerStartTime() {
  336. const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate;
  337. return activeDate === this.startDate ? this.selectableTimes.start : '';
  338. },
  339. timepickerEndTime() {
  340. const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate;
  341. return activeDate === this.endDate ? this.selectableTimes.end : '';
  342. },
  343. /**
  344. * for i18n
  345. */
  346. selectDateText() {
  347. return t('uni-datetime-picker.selectDate');
  348. },
  349. startDateText() {
  350. return this.startPlaceholder || t('uni-datetime-picker.startDate');
  351. },
  352. endDateText() {
  353. return this.endPlaceholder || t('uni-datetime-picker.endDate');
  354. },
  355. okText() {
  356. return t('uni-datetime-picker.ok');
  357. },
  358. yearText() {
  359. return t('uni-datetime-picker.year');
  360. },
  361. monthText() {
  362. return t('uni-datetime-picker.month');
  363. },
  364. MONText() {
  365. return t('uni-calender.MON');
  366. },
  367. TUEText() {
  368. return t('uni-calender.TUE');
  369. },
  370. WEDText() {
  371. return t('uni-calender.WED');
  372. },
  373. THUText() {
  374. return t('uni-calender.THU');
  375. },
  376. FRIText() {
  377. return t('uni-calender.FRI');
  378. },
  379. SATText() {
  380. return t('uni-calender.SAT');
  381. },
  382. SUNText() {
  383. return t('uni-calender.SUN');
  384. },
  385. confirmText() {
  386. return t('uni-calender.confirm');
  387. }
  388. },
  389. created() {
  390. // 获取日历方法实例
  391. this.cale = new Calendar({
  392. selected: this.selected,
  393. startDate: this.startDate,
  394. endDate: this.endDate,
  395. range: this.range
  396. });
  397. // 选中某一天
  398. this.init(this.date);
  399. },
  400. methods: {
  401. leaveCale() {
  402. this.firstEnter = true;
  403. },
  404. handleMouse(weeks) {
  405. if (weeks.disable) return;
  406. if (this.cale.lastHover) return;
  407. let { before, after } = this.cale.multipleStatus;
  408. if (!before) return;
  409. this.calendar = weeks;
  410. // 设置范围选
  411. this.cale.setHoverMultiple(this.calendar.fullDate);
  412. this.weeks = this.cale.weeks;
  413. // hover时,进入一个日历,更新另一个
  414. if (this.firstEnter) {
  415. this.$emit('firstEnterCale', this.cale.multipleStatus);
  416. this.firstEnter = false;
  417. }
  418. },
  419. rangeWithinMonth(A, B) {
  420. const [yearA, monthA] = A.split('-');
  421. const [yearB, monthB] = B.split('-');
  422. return yearA === yearB && monthA === monthB;
  423. },
  424. // 蒙版点击事件
  425. maskClick() {
  426. this.close();
  427. this.$emit('maskClose');
  428. },
  429. clearCalender() {
  430. if (this.range) {
  431. this.timeRange.startTime = '';
  432. this.timeRange.endTime = '';
  433. this.tempRange.before = '';
  434. this.tempRange.after = '';
  435. this.cale.multipleStatus.before = '';
  436. this.cale.multipleStatus.after = '';
  437. this.cale.multipleStatus.data = [];
  438. this.cale.lastHover = false;
  439. } else {
  440. this.time = '';
  441. this.tempSingleDate = '';
  442. }
  443. this.calendar.fullDate = '';
  444. this.setDate(new Date());
  445. },
  446. bindDateChange(e) {
  447. const value = e.detail.value + '-1';
  448. this.setDate(value);
  449. },
  450. /**
  451. * 初始化日期显示
  452. * @param {Object} date
  453. */
  454. init(date) {
  455. // 字节小程序 watch 早于 created
  456. if (!this.cale) {
  457. return;
  458. }
  459. this.cale.setDate(date || new Date());
  460. this.weeks = this.cale.weeks;
  461. this.nowDate = this.cale.getInfo(date);
  462. this.calendar = { ...this.nowDate };
  463. if (!date) {
  464. // 优化date为空默认不选中今天
  465. this.calendar.fullDate = '';
  466. if (this.defaultValue && !this.range) {
  467. // 暂时只支持移动端非范围选择
  468. const defaultDate = new Date(this.defaultValue);
  469. const fullDate = getDate(defaultDate);
  470. const year = defaultDate.getFullYear();
  471. const month = defaultDate.getMonth() + 1;
  472. const date = defaultDate.getDate();
  473. const day = defaultDate.getDay();
  474. (this.calendar = {
  475. fullDate,
  476. year,
  477. month,
  478. date,
  479. day
  480. }),
  481. (this.tempSingleDate = fullDate);
  482. this.time = getTime(defaultDate, this.hideSecond);
  483. }
  484. }
  485. },
  486. /**
  487. * 打开日历弹窗
  488. */
  489. open() {
  490. // 弹窗模式并且清理数据
  491. if (this.clearDate && !this.insert) {
  492. this.cale.cleanMultipleStatus();
  493. this.init(this.date);
  494. }
  495. this.show = true;
  496. this.$nextTick(() => {
  497. setTimeout(() => {
  498. this.aniMaskShow = true;
  499. }, 50);
  500. });
  501. },
  502. /**
  503. * 关闭日历弹窗
  504. */
  505. close() {
  506. this.aniMaskShow = false;
  507. this.$nextTick(() => {
  508. setTimeout(() => {
  509. this.show = false;
  510. this.$emit('close');
  511. }, 300);
  512. });
  513. },
  514. /**
  515. * 确认按钮
  516. */
  517. confirm() {
  518. this.setEmit('confirm');
  519. this.close();
  520. },
  521. /**
  522. * 变化触发
  523. */
  524. change() {
  525. // 自定义修改
  526. if (!this.insert) {
  527. this.$emit('select', this.calendar);
  528. }
  529. this.setEmit('change');
  530. },
  531. /**
  532. * 选择月份触发
  533. */
  534. monthSwitch(type) {
  535. let { year, month } = this.nowDate;
  536. this.$emit('monthSwitch', {
  537. type,
  538. year,
  539. month: Number(month)
  540. });
  541. },
  542. /**
  543. * 派发事件
  544. * @param {Object} name
  545. */
  546. setEmit(name) {
  547. if (!this.range) {
  548. if (!this.calendar.fullDate) {
  549. this.calendar = this.cale.getInfo(new Date());
  550. this.tempSingleDate = this.calendar.fullDate;
  551. }
  552. if (this.hasTime && !this.time) {
  553. this.time = getTime(new Date(), this.hideSecond);
  554. }
  555. }
  556. let { year, month, date, fullDate, extraInfo } = this.calendar;
  557. this.$emit(name, {
  558. range: this.cale.multipleStatus,
  559. year,
  560. month,
  561. date,
  562. time: this.time,
  563. timeRange: this.timeRange,
  564. fulldate: fullDate,
  565. extraInfo: extraInfo || {}
  566. });
  567. },
  568. /**
  569. * 选择天触发
  570. * @param {Object} weeks
  571. */
  572. choiceDate(weeks) {
  573. if (weeks.disableChecked) {
  574. return;
  575. }
  576. if (weeks.year < this.nowDate.year) {
  577. this.changeMonth('pre');
  578. } else if (weeks.year > this.nowDate.year) {
  579. this.changeMonth('next');
  580. } else if (weeks.month < this.nowDate.month) {
  581. this.changeMonth('pre');
  582. } else if (weeks.month > this.nowDate.month) {
  583. this.changeMonth('next');
  584. }
  585. this.calendar = weeks;
  586. this.calendar.userChecked = true;
  587. // 设置多选
  588. this.cale.setMultiple(this.calendar.fullDate, true);
  589. this.weeks = this.cale.weeks;
  590. this.tempSingleDate = this.calendar.fullDate;
  591. const beforeDate = new Date(this.cale.multipleStatus.before).getTime();
  592. const afterDate = new Date(this.cale.multipleStatus.after).getTime();
  593. if (beforeDate > afterDate && afterDate) {
  594. this.tempRange.before = this.cale.multipleStatus.after;
  595. this.tempRange.after = this.cale.multipleStatus.before;
  596. } else {
  597. this.tempRange.before = this.cale.multipleStatus.before;
  598. this.tempRange.after = this.cale.multipleStatus.after;
  599. }
  600. this.change();
  601. },
  602. changeMonth(type) {
  603. let newDate;
  604. if (type === 'pre') {
  605. newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate;
  606. } else if (type === 'next') {
  607. newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate;
  608. }
  609. this.setDate(newDate);
  610. this.monthSwitch(type);
  611. },
  612. /**
  613. * 设置日期
  614. * @param {Object} date
  615. */
  616. setDate(date) {
  617. this.cale.setDate(date);
  618. this.weeks = this.cale.weeks;
  619. this.nowDate = this.cale.getInfo(date);
  620. }
  621. }
  622. };
  623. </script>
  624. <style lang="scss">
  625. $uni-primary: #007aff !default;
  626. .uni-calendar {
  627. /* #ifndef APP-NVUE */
  628. display: flex;
  629. /* #endif */
  630. flex-direction: column;
  631. }
  632. .uni-calendar__mask {
  633. position: fixed;
  634. bottom: 0;
  635. top: 0;
  636. left: 0;
  637. right: 0;
  638. background-color: rgba(0, 0, 0, 0.4);
  639. transition-property: opacity;
  640. transition-duration: 0.3s;
  641. opacity: 0;
  642. /* #ifndef APP-NVUE */
  643. z-index: 99;
  644. /* #endif */
  645. }
  646. .uni-calendar--mask-show {
  647. opacity: 1;
  648. }
  649. .uni-calendar--fixed {
  650. position: fixed;
  651. bottom: calc(var(--window-bottom));
  652. left: 0;
  653. right: 0;
  654. transition-property: transform;
  655. transition-duration: 0.3s;
  656. transform: translateY(460px);
  657. /* #ifndef APP-NVUE */
  658. z-index: 99;
  659. /* #endif */
  660. }
  661. .uni-calendar--ani-show {
  662. transform: translateY(0);
  663. }
  664. .uni-calendar__content {
  665. background-color: #fff;
  666. }
  667. .uni-calendar__content-mobile {
  668. border-top-left-radius: 10px;
  669. border-top-right-radius: 10px;
  670. box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
  671. }
  672. .uni-calendar__header {
  673. position: relative;
  674. /* #ifndef APP-NVUE */
  675. display: flex;
  676. /* #endif */
  677. flex-direction: row;
  678. justify-content: center;
  679. align-items: center;
  680. height: 50px;
  681. }
  682. .uni-calendar__header-mobile {
  683. padding: 10px;
  684. padding-bottom: 0;
  685. }
  686. .uni-calendar--fixed-top {
  687. /* #ifndef APP-NVUE */
  688. display: flex;
  689. /* #endif */
  690. flex-direction: row;
  691. justify-content: space-between;
  692. border-top-color: rgba(0, 0, 0, 0.4);
  693. border-top-style: solid;
  694. border-top-width: 1px;
  695. }
  696. .uni-calendar--fixed-width {
  697. width: 50px;
  698. }
  699. .uni-calendar__backtoday {
  700. position: absolute;
  701. right: 0;
  702. top: 25rpx;
  703. padding: 0 5px;
  704. padding-left: 10px;
  705. height: 25px;
  706. line-height: 25px;
  707. font-size: 12px;
  708. border-top-left-radius: 25px;
  709. border-bottom-left-radius: 25px;
  710. color: #fff;
  711. background-color: #f1f1f1;
  712. }
  713. .uni-calendar__header-text {
  714. text-align: center;
  715. width: 100px;
  716. font-size: 15px;
  717. color: #666;
  718. }
  719. .uni-calendar__button-text {
  720. text-align: center;
  721. width: 100px;
  722. font-size: 14px;
  723. color: $uni-primary;
  724. /* #ifndef APP-NVUE */
  725. letter-spacing: 3px;
  726. /* #endif */
  727. }
  728. .uni-calendar__header-btn-box {
  729. /* #ifndef APP-NVUE */
  730. display: flex;
  731. /* #endif */
  732. flex-direction: row;
  733. align-items: center;
  734. justify-content: center;
  735. width: 50px;
  736. height: 50px;
  737. }
  738. .uni-calendar__header-btn {
  739. width: 9px;
  740. height: 9px;
  741. border-left-color: #808080;
  742. border-left-style: solid;
  743. border-left-width: 1px;
  744. border-top-color: #555555;
  745. border-top-style: solid;
  746. border-top-width: 1px;
  747. }
  748. .uni-calendar--left {
  749. transform: rotate(-45deg);
  750. }
  751. .uni-calendar--right {
  752. transform: rotate(135deg);
  753. }
  754. .uni-calendar__weeks {
  755. position: relative;
  756. /* #ifndef APP-NVUE */
  757. display: flex;
  758. /* #endif */
  759. flex-direction: row;
  760. }
  761. .uni-calendar__weeks-item {
  762. flex: 1;
  763. }
  764. .uni-calendar__weeks-day {
  765. flex: 1;
  766. /* #ifndef APP-NVUE */
  767. display: flex;
  768. /* #endif */
  769. flex-direction: column;
  770. justify-content: center;
  771. align-items: center;
  772. height: 40px;
  773. border-bottom-color: #f5f5f5;
  774. border-bottom-style: solid;
  775. border-bottom-width: 1px;
  776. }
  777. .uni-calendar__weeks-day-text {
  778. font-size: 12px;
  779. color: #b2b2b2;
  780. }
  781. .uni-calendar__box {
  782. position: relative;
  783. // padding: 0 10px;
  784. padding-bottom: 7px;
  785. }
  786. .uni-calendar__box-bg {
  787. /* #ifndef APP-NVUE */
  788. display: flex;
  789. /* #endif */
  790. justify-content: center;
  791. align-items: center;
  792. position: absolute;
  793. top: 0;
  794. left: 0;
  795. right: 0;
  796. bottom: 0;
  797. }
  798. .uni-calendar__box-bg-text {
  799. font-size: 200px;
  800. font-weight: bold;
  801. color: #999;
  802. opacity: 0.1;
  803. text-align: center;
  804. /* #ifndef APP-NVUE */
  805. line-height: 1;
  806. /* #endif */
  807. }
  808. .uni-date-changed {
  809. padding: 0 10px;
  810. // line-height: 50px;
  811. text-align: center;
  812. color: #333;
  813. border-top-color: #dcdcdc;
  814. border-top-style: solid;
  815. border-top-width: 1px;
  816. flex: 1;
  817. }
  818. .uni-date-btn--ok {
  819. padding: 20px 15px;
  820. }
  821. .uni-date-changed--time-start {
  822. /* #ifndef APP-NVUE */
  823. display: flex;
  824. /* #endif */
  825. align-items: center;
  826. }
  827. .uni-date-changed--time-end {
  828. /* #ifndef APP-NVUE */
  829. display: flex;
  830. /* #endif */
  831. align-items: center;
  832. }
  833. .uni-date-changed--time-date {
  834. color: #999;
  835. line-height: 50px;
  836. /* #ifdef MP-TOUTIAO */
  837. font-size: 16px;
  838. /* #endif */
  839. margin-right: 5px;
  840. // opacity: 0.6;
  841. }
  842. .time-picker-style {
  843. // width: 62px;
  844. /* #ifndef APP-NVUE */
  845. display: flex;
  846. /* #endif */
  847. justify-content: center;
  848. align-items: center;
  849. }
  850. .mr-10 {
  851. margin-right: 10px;
  852. }
  853. .dialog-close {
  854. position: absolute;
  855. top: 0;
  856. right: 0;
  857. bottom: 0;
  858. /* #ifndef APP-NVUE */
  859. display: flex;
  860. /* #endif */
  861. flex-direction: row;
  862. align-items: center;
  863. padding: 0 25px;
  864. margin-top: 10px;
  865. }
  866. .dialog-close-plus {
  867. width: 16px;
  868. height: 2px;
  869. background-color: #737987;
  870. border-radius: 2px;
  871. transform: rotate(45deg);
  872. }
  873. .dialog-close-rotate {
  874. position: absolute;
  875. transform: rotate(-45deg);
  876. }
  877. .uni-datetime-picker--btn {
  878. border-radius: 100px;
  879. height: 40px;
  880. line-height: 40px;
  881. background-color: $uni-primary;
  882. color: #fff;
  883. font-size: 16px;
  884. letter-spacing: 2px;
  885. }
  886. /* #ifndef APP-NVUE */
  887. .uni-datetime-picker--btn:active {
  888. opacity: 0.7;
  889. }
  890. /* #endif */
  891. </style>