date-select.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view>
  3. <z-text style="min-width: 300rpx;" arrow v-model="value" :placeholder="placeholder" @click="visible=true">
  4. </z-text>
  5. <z-slide-card title="选择日期时间" :visible.sync="visible">
  6. <scroll-view class="date-select" scroll-y>
  7. <z-date-area v-model="date" @change="changeDate"></z-date-area>
  8. <view class="select_time_range shadow-2">
  9. <z-cell height="100rpx" :contentStyle="{color:'#999999'}" label="时间" :content="startTime||'请选择'"
  10. arrow hideline @click.native="showTime1=true;">
  11. <image slot="icon" class="common_icon" src="../../../static/icon_time.png"></image>
  12. </z-cell>
  13. </view>
  14. <z-time-select :visible.sync="showTime1" start="07:00" v-model="startTime" @ok="getBottomShowText">
  15. </z-time-select>
  16. </scroll-view>
  17. <view class="select_time_result shadow-2 flex-n fac fjb">
  18. <view class="select_time_result_left">
  19. <view class="select_time_result_left_1">
  20. 当前选定时间:
  21. </view>
  22. <view class="select_time_result_left_2 mt-10">
  23. <!-- 2019年08月07日 星期三 10:30-12:00 -->
  24. {{showtext}}
  25. </view>
  26. </view>
  27. <view class="select_time_result_btn" v-if="isSelect" @click="submit">确定</view>
  28. <view class="select_time_result_btn select_time_result_btn_disabled" v-else>确定</view>
  29. </view>
  30. </z-slide-card>
  31. </view>
  32. </template>
  33. <script>
  34. const app = getApp({
  35. allowDefault: true
  36. });
  37. export default {
  38. name: 'date-select',
  39. props: {
  40. value: String,
  41. placeholder: {
  42. type: String,
  43. default: ''
  44. },
  45. // houseInfo: Object,
  46. // visible:{
  47. // type:Boolean,
  48. // default:false
  49. // }
  50. },
  51. model: {
  52. prop: 'value',
  53. },
  54. onBackPress() {
  55. if (this.visible) {
  56. this.visible = false;
  57. return true;
  58. }
  59. },
  60. data() {
  61. return {
  62. weekName: ['一', '二', '三', '四', '五', '六', '日'],
  63. monthDayList: [],
  64. isSelect: false,
  65. choose: 20,
  66. timechoose: -1,
  67. once: true,
  68. visible: false,
  69. startTime: '', //开始时间
  70. date: '', //日期
  71. showTime1: false,
  72. showTime2: false,
  73. showtext: '请选择日期时间',
  74. orderTagList: [], //预定时间标签
  75. houseName: '',
  76. disableSelectedRange: [],
  77. importantDataList: []
  78. }
  79. },
  80. mounted() {
  81. //时间段列表
  82. // this.getTimeRange();
  83. },
  84. watch: {
  85. visible(newval, oldval) {
  86. if(newval){
  87. if (this.value) {
  88. console.error(this.value)
  89. var data = this.value.split(' ');
  90. var time = data[1];
  91. this.startTime = time;
  92. this.date = data[0];
  93. this.getBottomShowText();
  94. }
  95. }
  96. },
  97. },
  98. methods: {
  99. //禁止触发后面移动
  100. moveHandle() {},
  101. getBottomShowText() {
  102. let xx = new Date(this.date).getDay();
  103. let week = ['日', '一', '二', '三', '四', '五', '六'];
  104. this.showtext = this.$Date.setTextData(this.date) + ' 星期' + week[xx] + ' ' + this.startTime;
  105. this.isSelect = true;
  106. },
  107. changeDate(date) {
  108. console.log(date)
  109. this.date=date.date;
  110. if (this.startTime != '') {
  111. this.getBottomShowText();
  112. } else {
  113. this.isSelect = false;
  114. if (this.startTime == '')
  115. return this.showtext = '请选择时间';
  116. }
  117. },
  118. submit() {
  119. this.visible = false;
  120. this.$emit('input', this.date + ' ' + this.startTime);
  121. // this.$emit('changeDate', this.day.yy + '-' + (this.day.mm > 9 ? this.day.mm : ('0' + this.day.mm)) + '-' +
  122. // (this.day
  123. // .dd >
  124. // 9 ? this.day.dd : ('0' + this.day.dd)));
  125. },
  126. beforeClose() {
  127. // this.$emit('update:visible', false);
  128. this.visible = false;
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .date-select {
  135. position: relative;
  136. height: calc(100vh - 224rpx - var(--status-bar-height));
  137. }
  138. .time-tips-list {
  139. padding: 35rpx 30rpx 35rpx 20rpx;
  140. text-align: center;
  141. .time-tips-item {
  142. width: 165rpx;
  143. line-height: 86rpx;
  144. border-radius: 2px;
  145. font-size: 24rpx;
  146. color: #666666;
  147. margin-left: 10rpx;
  148. white-space: nowrap;
  149. }
  150. .time-tips-item_choose {
  151. background: #2481EE !important;
  152. color: white !important;
  153. }
  154. }
  155. .select_time_range {
  156. width: 690rpx;
  157. margin: 0 auto;
  158. margin-top: 40rpx;
  159. height: 100rpx;
  160. }
  161. .select_time_old {
  162. width: 650rpx;
  163. margin: 0 auto;
  164. margin-top: 20rpx;
  165. padding: 20rpx;
  166. // outline:1px solid #fb7a7a;//重复时使用得提示色
  167. .order_title {
  168. font-size: 30rpx;
  169. line-height: 30rpx;
  170. color: #007aff;
  171. font-weight: bold;
  172. }
  173. }
  174. .select_time_result {
  175. height: 80rpx;
  176. width: calc(100% - 60rpx);
  177. padding: 30rpx;
  178. .select_time_result_left {
  179. font-size: 24rpx;
  180. color: #333333;
  181. }
  182. .select_time_result_btn {
  183. width: 165rpx;
  184. text-align: center;
  185. font-size: 30rpx;
  186. color: white;
  187. padding: 20rpx 0;
  188. background: #2481EE;
  189. border-radius: 6rpx;
  190. }
  191. .select_time_result_btn_disabled {
  192. background: #dddddd !important;
  193. }
  194. }
  195. .common_icon {
  196. width: 58rpx;
  197. height: 58rpx;
  198. min-width: 58rpx;
  199. margin-right: 30rpx;
  200. }
  201. </style>