index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <!-- pages/tables/index.wxml -->
  3. <view class="wrap">
  4. <view class="list-back">
  5. <view class="table" @tap="goStore(item)" v-for="(item, index) in list" :key="item.id">
  6. <view class="name">{{ item.name }}</view>
  7. <view :class="'status ' + (item.status == 1 ? 'busy' : 'free')">{{ item.status == 1 ? '就餐' : '空闲' }}</view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. // pages/tables/index.js
  14. export default {
  15. data() {
  16. return {
  17. list: [
  18. {
  19. id: 1,
  20. name: '1号桌',
  21. status: '1' // 1 就餐 0 空闲
  22. },
  23. {
  24. id: 2,
  25. name: '2号桌',
  26. status: '0' // 1 就餐 0 空闲
  27. },
  28. {
  29. id: 3,
  30. name: '3号桌',
  31. status: '1' // 1 就餐 0 空闲
  32. },
  33. {
  34. id: 3,
  35. name: '3号桌',
  36. status: '4' // 1 就餐 0 空闲
  37. }
  38. ]
  39. };
  40. }
  41. /**
  42. * 生命周期函数--监听页面加载
  43. */,
  44. onLoad(options) {},
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady() {},
  49. /**
  50. * 生命周期函数--监听页面显示
  51. */
  52. onShow() {},
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide() {},
  57. /**
  58. * 生命周期函数--监听页面卸载
  59. */
  60. onUnload() {},
  61. /**
  62. * 页面相关事件处理函数--监听用户下拉动作
  63. */
  64. onPullDownRefresh() {},
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom() {},
  69. /**
  70. * 用户点击右上角分享
  71. */
  72. onShareAppMessage() {},
  73. methods: {
  74. goStore(e) {
  75. console.log(e);
  76. var item = e;
  77. uni.navigateTo({
  78. url: '/pages/goods/index?' + 'tableId=' + item.id
  79. });
  80. }
  81. }
  82. };
  83. </script>
  84. <style>
  85. /* pages/tables/index.wxss */
  86. .list-back {
  87. display: flex;
  88. flex-wrap: wrap;
  89. justify-content: space-around;
  90. }
  91. .list-back .table {
  92. margin-top: 30rpx;
  93. width: 45%;
  94. height: 200rpx;
  95. background-color: #f3f4f5;
  96. border-radius: 8rpx;
  97. display: flex;
  98. position: relative;
  99. align-items: center;
  100. justify-content: center;
  101. }
  102. .table .name {
  103. font-size: 40rpx;
  104. color: #333333;
  105. }
  106. .table .status {
  107. position: absolute;
  108. top: 0;
  109. right: 0;
  110. width: 50rpx;
  111. height: 50rpx;
  112. font-size: 20rpx;
  113. color: white;
  114. text-align: center;
  115. line-height: 50rpx;
  116. }
  117. .table .status.free {
  118. background-color: greenyellow;
  119. }
  120. .table .status.busy {
  121. background-color: red;
  122. }
  123. </style>