MenuDiet.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="MenuDiet">
  3. <br v-if="!list.length" />
  4. <br v-if="!list.length" />
  5. <van-skeleton title v-if="!list.length" :row="10" />
  6. <van-dropdown-menu v-if="list.length">
  7. <van-dropdown-item v-model="value1" :options="list" @change="change">
  8. <template #title>
  9. {{
  10. list[value1]
  11. ? list[value1].text + "(" + list[value1].date + ")"
  12. : ""
  13. }}
  14. </template>
  15. <template #default></template>
  16. </van-dropdown-item>
  17. </van-dropdown-menu>
  18. <template
  19. v-if="
  20. list.length &&
  21. list[value1] &&
  22. list[value1].child &&
  23. list[value1].child.length
  24. "
  25. >
  26. <van-cell-group inset v-for="(item, i) in list[value1].child" :key="i">
  27. <template #title>
  28. <b class="meal" style="color: #899ded" v-text="item.meal"></b>
  29. </template>
  30. <div v-if="item.varietyOfDishes && item.varietyOfDishes.length">
  31. <van-cell
  32. :title="v.title"
  33. v-for="(v, p) in item.varietyOfDishes"
  34. :key="p"
  35. >
  36. <template #label>
  37. <span>{{ v.value.join("、") }}</span>
  38. </template>
  39. </van-cell>
  40. </div>
  41. </van-cell-group>
  42. </template>
  43. <van-cell-group
  44. v-if="list.length"
  45. :border="false"
  46. title="【温馨提示】每日菜品可能会临时调整,以现场提供的实际菜品为准哦~"
  47. />
  48. </div>
  49. </template>
  50. <script>
  51. // @ is an alias to /src
  52. import {
  53. DropdownMenu as vanDropdownMenu,
  54. DropdownItem as vanDropdownItem,
  55. Cell as vanCell,
  56. CellGroup as vanCellGroup,
  57. Skeleton as vanSkeleton,
  58. } from "vant";
  59. import "vant/lib/dropdown-menu/style/index";
  60. import "vant/lib/dropdown-item/style/index";
  61. import "vant/lib/skeleton/style/index";
  62. import "vant/lib/cell/style/index";
  63. import "vant/lib/cell-group/style/index";
  64. // import { orderList, cancel } from "../api/index";
  65. export default {
  66. name: "MenuDiet",
  67. data() {
  68. return {
  69. list: [],
  70. option1: [
  71. { text: "今天(2022/02/11)", value: 0 },
  72. { text: "明天(2022/02/12)", value: 1 },
  73. ],
  74. value1: 0,
  75. };
  76. },
  77. mounted() {
  78. let list = [
  79. {
  80. text: "今天",
  81. date: "2022/02/12",
  82. id: 0,
  83. child: [
  84. {
  85. meal: "早餐",
  86. varietyOfDishes: [
  87. {
  88. title: "热菜",
  89. value: [
  90. "干炸马面鱼",
  91. "宽粉红烧肉",
  92. "莲菜炒肉片",
  93. "麻婆豆腐",
  94. "酸辣土豆丝",
  95. "蘑菇青菜",
  96. ],
  97. },
  98. {
  99. title: "主食",
  100. value: ["米饭", "馒头", "花卷", "杂粮"],
  101. },
  102. {
  103. title: "汤",
  104. value: ["西红柿鸡蛋汤", "醪糟羹"],
  105. },
  106. {
  107. title: "其他",
  108. value: ["时令水果"],
  109. },
  110. ],
  111. },
  112. ],
  113. },
  114. ];
  115. let o = setTimeout(() => {
  116. clearTimeout(o);
  117. this.list = list.map((v, i) => {
  118. v.value = i;
  119. return v;
  120. });
  121. }, 2000);
  122. console.log(this.list);
  123. document.title = "菜单";
  124. },
  125. computed: {},
  126. methods: {
  127. change(v) {
  128. console.log(v);
  129. },
  130. },
  131. beforeUnmount: function () {
  132. localStorage.token = "";
  133. },
  134. components: {
  135. vanDropdownMenu,
  136. vanDropdownItem,
  137. vanCell,
  138. vanSkeleton,
  139. vanCellGroup,
  140. },
  141. };
  142. </script>
  143. <style>
  144. .MenuDiet {
  145. min-height: 100%;
  146. box-sizing: border-box;
  147. background-color: #f7f8fa;
  148. }
  149. .MenuDiet .van-sidebar {
  150. width: 100px;
  151. }
  152. .MenuDiet .main {
  153. width: calc(100% - 100px);
  154. height: 100%;
  155. overflow-y: scroll;
  156. background-color: #fff;
  157. box-sizing: border-box;
  158. padding: 5px;
  159. float: right;
  160. }
  161. .MenuDiet .van-sidebar-item--select::before {
  162. background-color: #e42417;
  163. }
  164. .MenuDiet .meal {
  165. font-weight: 600;
  166. font-size: 16px;
  167. }
  168. </style>