index.vue 5.5 KB

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