index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view class="order_index">
  3. <!-- 日期选择器 -->
  4. <!-- datevalue -->
  5. <w-picker mode="date" startYear="2000" endYear="2100" :value="datevalue" :current="true" :fields="showtype"
  6. @confirm="onConfirm($event)" @cancel="onCancel" :disabled-after="false" ref="date"></w-picker>
  7. <z-navbar>
  8. <!-- <view slot="left" style="font-size: 28rpx;">
  9. 筛选
  10. </view> -->
  11. <!-- <view slot="left" class="iconfont iconjuxing5" @click="gotoSearch"></view> -->
  12. <view class="flex-n fac" style="width: 100%;" slot="title">
  13. <view class="iconfont iconjuxing18kaobei" style="position: absolute;left: 30rpx;font-size: 30rpx;"
  14. @click="backtoday"></view>
  15. <view @click="chooseDate(stateTab)">{{dataYearMonth}}</view>
  16. </view>
  17. <view slot="right" class="iconfont iconjuxing5" style="font-size: 30rpx;" @click="gotoSearch"></view>
  18. </z-navbar>
  19. <!-- '列表','场地', -->
  20. <z-tabs :tabs="['日','月']" v-model="stateTab" @change="changeTabs"></z-tabs>
  21. <!-- 列表 -->
  22. <!-- <book-list :refresh="refresh" v-if="stateTab==0" :date="datevalue"></book-list> -->
  23. <!-- 场地 -->
  24. <!-- <book-field :refresh="refresh" v-if="stateTab==1" @getDateInfo="getDateInfo"></book-field> -->
  25. <!-- 日 -->
  26. <view class="day-height" v-if="stateTab==0">
  27. <book-day ref='day' @changeDate="changeDate"></book-day>
  28. </view>
  29. <!-- 月 -->
  30. <view class="month-height" v-if="stateTab==1">
  31. <book-month ref="month" @changeDate="changeDate" @clickDate="clickDate"></book-month>
  32. </view>
  33. <view class="add_order flex-n fac fjc" @click="addBook">
  34. <view class="iconfont iconjia"></view>
  35. </view>
  36. <!-- <view class="add_order flex-n fac fjc">
  37. <view class="iconfont iconjia"></view>
  38. </view> -->
  39. <!-- <view class="add_content">
  40. <view class="">增加预定</view>
  41. <view class="">场地筛选</view>
  42. <view class="">帮助</view>
  43. </view> -->
  44. <z-tabbar></z-tabbar>
  45. </view>
  46. </template>
  47. <script>
  48. import bookList from './book-list.vue';
  49. import bookField from './book-field.vue';
  50. import bookDay from './book-day.vue';
  51. import bookMonth from './book-month.vue';
  52. export default {
  53. components: {
  54. bookList,
  55. bookField,
  56. bookDay,
  57. bookMonth,
  58. },
  59. data() {
  60. return {
  61. dataYearMonth: '2020.04',
  62. showtype: 'day',
  63. datevalue: '',
  64. stateTab: 1,
  65. backState: true
  66. };
  67. },
  68. mounted() {
  69. uni.hideTabBar();
  70. uni.$on('saveOrder', (date) => {
  71. console.log('---------------保存訂單后跳轉回來的-------------------')
  72. this.datevalue = date;
  73. this.tabInfo();
  74. })
  75. uni.$on('switchTab', (router) => {
  76. console.log('--------------------', router, '----------------------')
  77. if (router == 'book/index/index')
  78. this.backtoday();
  79. })
  80. this.backtoday();
  81. },
  82. computed: {
  83. },
  84. methods: {
  85. //新增预定
  86. addBook() {
  87. uni.navigateTo({
  88. url: '../manage/index?type=0',
  89. success: res => {},
  90. fail: () => {},
  91. complete: () => {}
  92. });
  93. },
  94. gotoSearch() {
  95. uni.navigateTo({
  96. url: '../../search/index?type=1',
  97. success: res => {},
  98. fail: () => {},
  99. complete: () => {}
  100. });
  101. },
  102. onConfirm(e) {
  103. console.log('-------', e, '-------')
  104. this.datevalue = e.value;
  105. this.tabInfo();
  106. },
  107. onCancel() {
  108. console.log(this.$refs.date.value, this.$refs.date.pickVal)
  109. },
  110. chooseDate: function(state) {
  111. if (state != 3) {
  112. this.showtype = 'day';
  113. } else {
  114. this.showtype = 'month';
  115. }
  116. this.$refs.date.show();
  117. },
  118. tabInfo() {
  119. console.warn(this.datevalue)
  120. var a = this.datevalue.split("-");
  121. this.dataYearMonth = a[0] + '.' + a[1];
  122. setTimeout(() => {
  123. console.log('???', this.datevalue)
  124. if (this.stateTab == 0) { //日
  125. if (this.$refs.day)
  126. this.$refs.day.getDate(this.datevalue);
  127. }
  128. if (this.stateTab == 1) { //月
  129. if (this.$refs.month)
  130. this.$refs.month.getDate(this.datevalue);
  131. }
  132. },0)
  133. },
  134. changeTabs(idx) {
  135. console.log(idx, this.datevalue)
  136. this.stateTab = idx;
  137. this.tabInfo();
  138. },
  139. backtoday() {
  140. let date = new Date();
  141. let month = date.getMonth() + 1;
  142. let day = date.getDate()
  143. this.datevalue = date.getFullYear() + '-' + (month > 9 ? month : ('0' + month)) + '-' + (day > 9 ? day : (
  144. '0' +
  145. day));
  146. this.tabInfo();
  147. },
  148. //日月切换日期
  149. changeDate(date) {
  150. console.log('日月切换日期', date)
  151. this.datevalue = date;
  152. var a = this.datevalue.split("-");
  153. this.dataYearMonth = a[0] + '.' + a[1];
  154. },
  155. clickDate(date) {
  156. console.log(1312)
  157. this.changeDate(date);
  158. this.stateTab = 0;
  159. this.$nextTick(() => {
  160. this.$refs.day.getDate(this.datevalue);
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped lang="scss">
  167. .month-height {
  168. height: calc(100vh - 280rpx - var(--status-bar-height));
  169. }
  170. .day-height {
  171. height: calc(100vh - 280rpx - var(--status-bar-height));
  172. }
  173. .order_index {
  174. .add_order {
  175. position: fixed;
  176. width: 82rpx;
  177. height: 82rpx;
  178. background: #2481EE;
  179. border-radius: 50%;
  180. right: 51rpx;
  181. bottom: 143rpx;
  182. z-index: 10;
  183. view {
  184. width: 49rpx;
  185. height: 49rpx;
  186. font-size: 49rpx;
  187. line-height: 49rpx;
  188. color: white;
  189. z-index: 300;
  190. }
  191. color: white;
  192. box-shadow:10rpx 10rpx 30rpx 0rpx #C6E0FF;
  193. }
  194. // .add_content{
  195. // position: fixed;
  196. // right: 51rpx;
  197. // bottom: 243rpx;
  198. // background: white;
  199. // font-size: 28rpx;
  200. // line-height: 80rpx;
  201. // padding: 0 20rpx;
  202. // border-radius: 5rpx;
  203. // box-shadow: 0 0 10rpx #aaa;
  204. // view{
  205. // border-bottom: 1rpx solid #aaa;
  206. // padding: 0 20rpx;
  207. // text-align: right;
  208. // }
  209. // }
  210. }
  211. </style>