index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <!-- 扫码点餐-选择就餐人数 -->
  3. <view class="content">
  4. <view class="title">请选择就餐人数</view>
  5. <view class="number-list">
  6. <view class="number-item" :class="{ 'current': currentDiners === item }" v-for="item in diners" :key="item"
  7. @click="selectDiners(item)" hover-class="hover-active">
  8. <view class="number-item-content">
  9. <view class="number-item-content-title">{{ item }}</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="more-number" @click="addDiners" v-if="diners < 16">查看更多</view>
  14. <view class="confirm-button" @click="toOrderFood" hover-class="hover-active">确定</view>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { onLoad } from "@dcloudio/uni-app";
  19. import { ref } from "vue";
  20. import { go } from "@/utils/utils.js";
  21. const diners = ref(12);
  22. const currentDiners = ref(2);
  23. const addDiners = () => {
  24. diners.value = 16
  25. };
  26. const selectDiners = (item) => {
  27. currentDiners.value = item;
  28. };
  29. const toOrderFood = () => {
  30. uni.setStorageSync('currentDiners', currentDiners.value);
  31. go('/pages/orderFood/index');
  32. };
  33. onLoad((e) => {
  34. let currentDiners = uni.getStorageSync('currentDiners');
  35. if (currentDiners) currentDiners.value = currentDiners;
  36. });
  37. </script>
  38. <style lang="scss" scoped>
  39. .title {
  40. font-size: 32rpx;
  41. font-weight: bold;
  42. text-align: center;
  43. margin-bottom: 20rpx;
  44. margin-top: 60rpx;
  45. }
  46. .number-list {
  47. display: flex;
  48. flex-wrap: wrap;
  49. justify-content: center;
  50. align-items: center;
  51. gap: 20rpx;
  52. margin-top: 60rpx;
  53. .number-item {
  54. width: 160rpx;
  55. height: 160rpx;
  56. background-color: #f0f0f0;
  57. border-radius: 8rpx;
  58. display: flex;
  59. justify-content: center;
  60. align-items: center;
  61. font-size: 32rpx;
  62. transition: all 0.3s ease;
  63. &.current {
  64. background: linear-gradient(180deg, #FCB73F 0%, #FC743D 100%);
  65. color: #fff;
  66. box-shadow: 0 8rpx 24rpx rgba(252, 183, 63, 0.4);
  67. }
  68. &.hover-active {
  69. opacity: 0.8;
  70. }
  71. }
  72. }
  73. .more-number {
  74. font-size: 28rpx;
  75. color: #aaa;
  76. text-align: center;
  77. margin-top: 20rpx;
  78. margin-top: 30rpx;
  79. }
  80. .confirm-button {
  81. width: 90%;
  82. height: 80rpx;
  83. background: linear-gradient(180deg, #FCB73F 0%, #FC743D 100%);
  84. color: #fff;
  85. text-align: center;
  86. line-height: 80rpx;
  87. border-radius: 24rpx;
  88. position: fixed;
  89. bottom: 80rpx;
  90. left: 50%;
  91. transform: translateX(-50%);
  92. font-size: 32rpx;
  93. }
  94. </style>