time.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view>
  3. <uni-popup ref="popupTime" type="bottom">
  4. <view class="pop-address box-border-box">
  5. <view class="text-align-center fs-36 fw-600 box-title mb-32">
  6. 选择预计送达时间
  7. <uni-icons @click="closeCoupon" class="box-close" type="closeempty" size="20"></uni-icons>
  8. </view>
  9. <view class="scroll-view-css flex-justify-space">
  10. <view class="time-left">
  11. <view class="item-box" :class="type == item.type?'bgc-f':''" v-for="(item,i) in list" :key="i"
  12. @click="select(1,item)">
  13. {{item.name}}
  14. </view>
  15. </view>
  16. <view class="time-right flex-1" v-if="timeList.length>0">
  17. <view class="item-box b-b-F9F9F9" :class="time == item?'fc-41ABF5':''"
  18. v-for="(item,i) in timeList" :key="i" @click="select(2,item)">
  19. {{item}}
  20. </view>
  21. </view>
  22. <view class="flex-1 align-items-center flex-justify-center" v-else>
  23. 暂无可选时间
  24. </view>
  25. </view>
  26. </view>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. orderTime
  33. } from '@/api/order.js'
  34. export default {
  35. data() {
  36. return {
  37. list: [],
  38. timeList: [],
  39. type: '',
  40. time: '',
  41. }
  42. },
  43. methods: {
  44. getList(id) {
  45. let school_id = uni.getStorageSync('school_id');
  46. orderTime({
  47. shop_id: id,
  48. school_id: school_id
  49. }).then((res) => {
  50. if (res.code == 1) {
  51. this.list = res.data
  52. this.timeList = this.list[0].timeList;
  53. this.time = this.timeList[0];
  54. this.type = this.list[0].type;
  55. }
  56. })
  57. console.log(this.list, '&&&&&&&&&&&&&&&&&&');
  58. // if (this.list[0].timeList.length > 0) {
  59. // this.timeList = this.list[0].timeList;
  60. // this.time = this.timeList[0];
  61. // }
  62. // this.type = this.list[0].type;
  63. this.openPop();
  64. },
  65. openPop() {
  66. this.$refs.popupTime.open();
  67. },
  68. closeCoupon() {
  69. this.$refs.popupTime.close();
  70. },
  71. select(type, item) {
  72. if (type === 1) {
  73. if (this.type != item.type) {
  74. this.type = item.type;
  75. this.time = '';
  76. if(this.type == 2) {
  77. this.timeList = this.list[1].timeList;
  78. }else {
  79. this.timeList = this.list[0].timeList;
  80. }
  81. }
  82. } else {
  83. this.time = item
  84. this.closeCoupon()
  85. this.$emit('timeAndType', this.type, this.time)
  86. }
  87. }
  88. },
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .pop-address {
  93. width: 100%;
  94. height: 50vh;
  95. background-color: #fff;
  96. border-radius: 24rpx 24rpx 0rpx 0rpx;
  97. padding-top: 32rpx !important;
  98. display: flex;
  99. flex-direction: column;
  100. .box-title {
  101. position: relative;
  102. .box-close {
  103. position: absolute;
  104. right: 22rpx;
  105. }
  106. }
  107. .time-left {
  108. width: 240rpx;
  109. height: auto;
  110. background-color: #F7F8FA;
  111. }
  112. .time-right {
  113. overflow-y: scroll;
  114. }
  115. .item-box {
  116. width: 100%;
  117. height: 104rpx;
  118. line-height: 104rpx;
  119. font-size: 28rpx;
  120. font-weight: 400;
  121. text-align: center;
  122. }
  123. }
  124. </style>