MenuDiet.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <div class="MenuDiet">
  3. <br v-if="load" />
  4. <br v-if="load" />
  5. <van-skeleton title v-if="load" :row="10" />
  6. <van-tabs
  7. line-width="16"
  8. title-active-color="#FA6400"
  9. color="#FA6400"
  10. v-if="list.length"
  11. :active="value1"
  12. :before-change="change"
  13. >
  14. <van-tab :title="item.text" v-for="(item, i) in list" :key="i"></van-tab>
  15. </van-tabs>
  16. <template
  17. v-if="
  18. list.length &&
  19. list[value1] &&
  20. list[value1].child &&
  21. list[value1].child.length
  22. "
  23. >
  24. <div v-for="(item, i) in list[value1].child" :key="i">
  25. <br />
  26. <van-cell-group inset :border="false">
  27. <van-cell
  28. :style="
  29. 'padding: 5px 16px;font-size: 14px; color: #fff;background-color: ' +
  30. (i % 2 === 1 ? '#FFB07B' : '#74BBFF') +
  31. ';'
  32. "
  33. :title="item.meal"
  34. ></van-cell>
  35. <div v-if="item.varietyOfDishes && item.varietyOfDishes.length">
  36. <van-cell v-for="(v, p) in item.varietyOfDishes" :key="p">
  37. <template #title>
  38. <div
  39. class="p"
  40. :style="
  41. 'background-color:' + (i % 2 === 1 ? '#FFB07B' : '#74BBFF')
  42. "
  43. ></div>
  44. <span
  45. v-text="v.title"
  46. class="title"
  47. style="vertical-align: middle"
  48. ></span>
  49. </template>
  50. <template #label>
  51. <span>{{ v.value.join("、") }}</span>
  52. </template>
  53. </van-cell>
  54. </div>
  55. </van-cell-group>
  56. </div>
  57. </template>
  58. <van-cell-group v-if="list.length" :border="false">
  59. <template #title>
  60. <div class="t">
  61. <span>【温馨提示】</span>
  62. <p>每日菜品可能会临时调整,以现场提供的实际菜品为准哦~</p>
  63. </div>
  64. </template>
  65. </van-cell-group>
  66. </div>
  67. </template>
  68. <script>
  69. // @ is an alias to /src
  70. import {
  71. Cell as vanCell,
  72. CellGroup as vanCellGroup,
  73. Skeleton as vanSkeleton,
  74. Tab as vanTab,
  75. Tabs as vanTabs,
  76. } from "vant";
  77. import "vant/lib/skeleton/style/index";
  78. import "vant/lib/tab/style/index";
  79. import "vant/lib/tabs/style/index";
  80. import "vant/lib/cell/style/index";
  81. import "vant/lib/cell-group/style/index";
  82. import { menulist } from "../api/index";
  83. export default {
  84. name: "MenuDiet",
  85. data() {
  86. return {
  87. load: false,
  88. list: [],
  89. option1: [
  90. { text: "今天(2022/02/11)", value: 0 },
  91. { text: "明天(2022/02/12)", value: 1 },
  92. ],
  93. value1: 0,
  94. };
  95. },
  96. mounted() {
  97. this.load = true;
  98. menulist()
  99. .then(r => {
  100. this.list = (r || []).map((v, i) => {
  101. v.value = i;
  102. return v;
  103. });
  104. this.load = false;
  105. })
  106. .catch(() => {
  107. this.load = false;
  108. });
  109. document.title = "菜单";
  110. },
  111. computed: {},
  112. methods: {
  113. change(v) {
  114. this.value1 = v;
  115. },
  116. },
  117. beforeUnmount: function () {
  118. localStorage.token = "";
  119. },
  120. components: {
  121. vanCell,
  122. vanSkeleton,
  123. vanCellGroup,
  124. vanTab,
  125. vanTabs,
  126. },
  127. };
  128. </script>
  129. <style>
  130. .MenuDiet {
  131. min-height: 100%;
  132. font-weight: 400;
  133. box-sizing: border-box;
  134. background-color: #fff;
  135. }
  136. .MenuDiet .van-sidebar {
  137. width: 100px;
  138. }
  139. .MenuDiet .van-cell-group {
  140. box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.08);
  141. }
  142. .MenuDiet .main {
  143. width: calc(100% - 100px);
  144. height: 100%;
  145. overflow-y: scroll;
  146. background-color: #fff;
  147. box-sizing: border-box;
  148. padding: 5px;
  149. float: right;
  150. }
  151. .MenuDiet .van-sidebar-item--select::before {
  152. background-color: #e42417;
  153. }
  154. .MenuDiet .meal {
  155. font-weight: 600;
  156. font-size: 16px;
  157. }
  158. .MenuDiet .p {
  159. display: inline-block;
  160. width: 5px;
  161. height: 5px;
  162. background-color: #ffb07b;
  163. border-radius: 50%;
  164. vertical-align: middle;
  165. margin-right: 4px;
  166. }
  167. .MenuDiet .title {
  168. font-weight: 600;
  169. }
  170. .MenuDiet .t {
  171. text-align: center;
  172. line-height: 20px;
  173. font-size: 11px;
  174. }
  175. .MenuDiet .t span {
  176. color: #fa6400;
  177. }
  178. .MenuDiet .van-tabs__line {
  179. border-radius: 2px;
  180. }
  181. .MenuDiet .van-cell__label {
  182. color: #555555;
  183. padding-left: 9px;
  184. }
  185. </style>