time.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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, data) {
  45. if (id && id != 0) {
  46. let school_id = uni.getStorageSync('school_id');
  47. orderTime({
  48. shop_id: id,
  49. school_id: school_id
  50. }).then((res) => {
  51. if (res.code == 1) {
  52. this.list = res.data
  53. this.timeList = this.list[0].timeList;
  54. this.time = this.timeList[0];
  55. this.type = this.list[0].type;
  56. }
  57. })
  58. } else {
  59. this.list = data
  60. this.timeList = this.list[0].timeList;
  61. this.time = this.timeList[0];
  62. this.type = this.list[0].type;
  63. }
  64. console.log(this.list, '&&&&&&&&&&&&&&&&&&');
  65. // if (this.list[0].timeList.length > 0) {
  66. // this.timeList = this.list[0].timeList;
  67. // this.time = this.timeList[0];
  68. // }
  69. // this.type = this.list[0].type;
  70. this.openPop();
  71. },
  72. openPop() {
  73. this.$refs.popupTime.open();
  74. },
  75. closeCoupon() {
  76. this.$refs.popupTime.close();
  77. },
  78. select(type, item) {
  79. if (type === 1) {
  80. if (this.type != item.type) {
  81. this.type = item.type;
  82. this.time = '';
  83. if (this.type == 2) {
  84. this.timeList = this.list[1].timeList;
  85. } else {
  86. this.timeList = this.list[0].timeList;
  87. }
  88. }
  89. } else {
  90. this.time = item
  91. this.closeCoupon()
  92. this.$emit('timeAndType', this.type, this.time)
  93. }
  94. }
  95. },
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .pop-address {
  100. width: 100%;
  101. height: 50vh;
  102. background-color: #fff;
  103. border-radius: 24rpx 24rpx 0rpx 0rpx;
  104. padding-top: 32rpx !important;
  105. display: flex;
  106. flex-direction: column;
  107. .box-title {
  108. position: relative;
  109. .box-close {
  110. position: absolute;
  111. right: 22rpx;
  112. }
  113. }
  114. .time-left {
  115. width: 240rpx;
  116. height: auto;
  117. background-color: #F7F8FA;
  118. }
  119. .time-right {
  120. overflow-y: scroll;
  121. }
  122. .item-box {
  123. width: 100%;
  124. height: 104rpx;
  125. line-height: 104rpx;
  126. font-size: 28rpx;
  127. font-weight: 400;
  128. text-align: center;
  129. }
  130. }
  131. </style>