敢为人鲜小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

430 lines
10 KiB

10 months ago
10 months ago
10 months ago
10 months ago
  1. <template>
  2. <view class="page">
  3. <navbar title="首页" bgColor="#019245" color="#fff" />
  4. <!-- 内容区域 -->
  5. <view class="content">
  6. <!-- 轮播图 -->
  7. <swiper class="banner-swiper" circular autoplay>
  8. <swiper-item v-for="item in homeData.banners" :key="item.id">
  9. <image :src="item.image" mode="aspectFill" class="banner-image" />
  10. </swiper-item>
  11. </swiper>
  12. <!-- 店铺信息 -->
  13. <view class="restaurant-info">
  14. <div class="restaurant-logo">
  15. <image :src="configList.config_logo" mode="aspectFill" style="width: 100%; height: 100%;" />
  16. </div>
  17. <view class="restaurant-name">{{homeData.restaurant.name}}</view>
  18. <!-- <view class="service-btns">
  19. <view class="service-btn">
  20. <text>客服</text>
  21. </view>
  22. <view class="order-btn">
  23. <text>订阅</text>
  24. </view>
  25. </view> -->
  26. </view>
  27. <!-- 商店内容区域 -->
  28. <view class="shop-content">
  29. <!-- 产品标签页 -->
  30. <view class="product-tabs">
  31. <!-- 公告信息 -->
  32. <view class="notice">
  33. <text class="notice-text">{{homeData.restaurant.notice}}</text>
  34. <text class="notice-desc">{{homeData.restaurant.description}}</text>
  35. </view>
  36. <!-- 标签列表 -->
  37. <view class="tag-list">
  38. <view class="tag" v-for="(tag, index) in homeData.tags" :key="index">{{tag}}</view>
  39. </view>
  40. <!-- 价格区间 -->
  41. <view class="price-range">
  42. <text class="price">{{homeData.priceRange}}</text>
  43. </view>
  44. <!-- 产品展示 -->
  45. <scroll-view scroll-x class="food-scroll">
  46. <view class="food-item" v-for="food in homeData.foods" :key="food.id">
  47. <image :src="food.image" mode="aspectFill" class="food-image" />
  48. <view class="food-detail">
  49. <view class="food-name">{{food.name}}</view>
  50. <view class="food-desc">{{food.desc}}</view>
  51. <view class="food-price">
  52. <text class="current-price">¥{{food.price}}</text>
  53. <text class="original-price">¥{{food.originalPrice}}</text>
  54. </view>
  55. </view>
  56. </view>
  57. </scroll-view>
  58. </view>
  59. </view>
  60. <!-- 跟团部分 -->
  61. <view class="group-purchase">
  62. <view class="group-order-list">
  63. <swiper vertical autoplay circular interval="3000" duration="500"
  64. display-multiple-items="3">
  65. <swiper-item v-for="(order, index) in orderList" :key="index">
  66. <view class="order-item">
  67. <view class="order-id">{{ order.id }}</view>
  68. <view class="order-user">
  69. <image :src="order.avatar" mode="aspectFill" class="user-avatar" />
  70. <text class="user-name">{{ order.userName }}</text>
  71. <text class="order-time">{{ order.time }}</text>
  72. </view>
  73. <view class="order-content">
  74. <text class="order-desc">{{ order.content }}</text>
  75. <text class="order-count">+{{ order.count }}</text>
  76. </view>
  77. </view>
  78. </swiper-item>
  79. </swiper>
  80. </view>
  81. </view>
  82. </view>
  83. <tabbar select="index" />
  84. </view>
  85. </template>
  86. <script>
  87. import navbar from '@/components/base/navbar.vue'
  88. import tabbar from '@/components/base/tabbar.vue'
  89. import { homeData } from '@/static/js/mockHomeData.js'
  90. export default {
  91. components: {
  92. navbar,
  93. tabbar
  94. },
  95. data() {
  96. return {
  97. homeData: homeData,
  98. orderList: [
  99. {
  100. id: 19141,
  101. userName: '3**',
  102. avatar: '/static/image/中森明菜.webp',
  103. time: '1分钟前',
  104. content: '【单点】小炒黄牛肉...',
  105. count: 1
  106. },
  107. {
  108. id: 19145,
  109. userName: 'B**',
  110. avatar: '/static/image/中森明菜.webp',
  111. time: '1分钟前',
  112. content: '黑椒肥牛饭(1份)',
  113. count: 1
  114. },
  115. {
  116. id: 19144,
  117. userName: '吃**',
  118. avatar: '/static/image/中森明菜.webp',
  119. time: '1分钟前',
  120. content: '【单点】黑盒220g...',
  121. count: 1
  122. },
  123. {
  124. id: 19143,
  125. userName: 'L**',
  126. avatar: '/static/image/中森明菜.webp',
  127. time: '2分钟前',
  128. content: '红烧肉套餐(1份)',
  129. count: 2
  130. },
  131. {
  132. id: 19142,
  133. userName: '美**',
  134. avatar: '/static/image/中森明菜.webp',
  135. time: '3分钟前',
  136. content: '【单点】小炒肉(1份)',
  137. count: 1
  138. }
  139. ]
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .content {
  146. flex: 1;
  147. background: linear-gradient(to bottom, #fff, #f5f5f5);
  148. // padding-bottom: 120rpx;
  149. }
  150. .banner-swiper {
  151. width: 100%;
  152. height: 350rpx;
  153. position: relative;
  154. z-index: 1;
  155. }
  156. .banner-image {
  157. width: 100%;
  158. height: 100%;
  159. }
  160. .restaurant-info {
  161. display: flex;
  162. align-items: center;
  163. padding: 20rpx;
  164. margin-top: -30rpx;
  165. max-height: 60rpx;
  166. border-radius: 20rpx 20rpx 0 0;
  167. background-color: #fff;
  168. border-bottom: 1px solid #eee;
  169. position: relative;
  170. z-index: 2;
  171. }
  172. .restaurant-logo {
  173. width: 130rpx;
  174. height: 130rpx;
  175. border-radius: 20rpx;
  176. margin-right: 20rpx;
  177. margin-top: -60rpx;
  178. overflow: hidden;
  179. border: 4rpx solid #eee;
  180. }
  181. .restaurant-name {
  182. flex: 1;
  183. font-size: 32rpx;
  184. font-weight: 500;
  185. }
  186. .service-btns {
  187. display: flex;
  188. }
  189. .service-btn, .order-btn {
  190. padding: 8rpx 20rpx;
  191. border-radius: 30rpx;
  192. font-size: 24rpx;
  193. margin-left: 10rpx;
  194. }
  195. .service-btn {
  196. border: 1px solid #ccc;
  197. color: #666;
  198. }
  199. .order-btn {
  200. background-color: #4cd964;
  201. color: #fff;
  202. }
  203. .shop-content {
  204. margin-top: 0;
  205. padding: 20rpx;
  206. position: relative;
  207. z-index: 2;
  208. }
  209. /* 产品标签页 */
  210. .product-tabs {
  211. // border: 2rpx solid red;
  212. background-color: #fff;
  213. border-radius: 20rpx;
  214. margin-bottom: 10rpx;
  215. padding: 20rpx;
  216. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  217. }
  218. .notice {
  219. margin-bottom: 15rpx;
  220. }
  221. .notice-text {
  222. font-size: 32rpx;
  223. font-weight: bold;
  224. margin-right: 10rpx;
  225. max-width: 80%;
  226. white-space: nowrap;
  227. overflow: hidden;
  228. text-overflow: ellipsis;
  229. display: inline-block;
  230. }
  231. .notice-desc {
  232. font-size: 24rpx;
  233. color: #999;
  234. background-color: #f5f5f5;
  235. padding: 4rpx 10rpx;
  236. border-radius: 4rpx;
  237. }
  238. .tag-list {
  239. display: flex;
  240. flex-wrap: wrap;
  241. margin-bottom: 15rpx;
  242. }
  243. .tag {
  244. font-size: 24rpx;
  245. color: $uni-color-second;
  246. border: 1px solid #ffcccc;
  247. padding: 4rpx 12rpx;
  248. border-radius: 4rpx;
  249. margin-right: 10rpx;
  250. margin-bottom: 10rpx;
  251. }
  252. .price-range {
  253. margin-bottom: 20rpx;
  254. }
  255. .price {
  256. font-size: 36rpx;
  257. color: $uni-color-second;
  258. font-weight: bold;
  259. }
  260. .food-scroll {
  261. white-space: nowrap;
  262. }
  263. .food-item {
  264. display: inline-block;
  265. width: 300rpx;
  266. margin-right: 20rpx;
  267. background-color: #fff;
  268. border-radius: 10rpx;
  269. overflow: hidden;
  270. box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
  271. }
  272. .food-image {
  273. width: 140rpx;
  274. height: 140rpx;
  275. }
  276. .food-detail {
  277. padding: 10rpx;
  278. }
  279. .food-name {
  280. font-size: 28rpx;
  281. font-weight: bold;
  282. margin-bottom: 5rpx;
  283. }
  284. .food-desc {
  285. font-size: 24rpx;
  286. color: #999;
  287. margin-bottom: 5rpx;
  288. white-space: normal;
  289. overflow: hidden;
  290. text-overflow: ellipsis;
  291. display: -webkit-box;
  292. -webkit-line-clamp: 1;
  293. -webkit-box-orient: vertical;
  294. }
  295. .food-price {
  296. display: flex;
  297. align-items: baseline;
  298. }
  299. .current-price {
  300. font-size: 28rpx;
  301. color: $uni-color-second;
  302. font-weight: bold;
  303. margin-right: 10rpx;
  304. }
  305. .original-price {
  306. font-size: 24rpx;
  307. color: #999;
  308. text-decoration: line-through;
  309. }
  310. .group-purchase {
  311. background-color: #fff;
  312. border-radius: 20rpx;
  313. margin: 0rpx 20rpx 30rpx 20rpx;
  314. padding: 30rpx 20rpx;
  315. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  316. }
  317. .group-order-list {
  318. // height: 330rpx;
  319. overflow: hidden;
  320. }
  321. .order-item {
  322. display: flex;
  323. padding: 10rpx;
  324. border-bottom: 1rpx solid #f2f2f2;
  325. align-items: center;
  326. justify-content: space-between;
  327. }
  328. .order-id {
  329. // flex: 1;
  330. font-size: 26rpx;
  331. color: #999;
  332. margin-right: 10rpx;
  333. // display: inline-block;
  334. }
  335. .order-user {
  336. flex: 1;
  337. display: flex;
  338. align-items: center;
  339. width: 140rpx;
  340. }
  341. .user-avatar {
  342. width: 54rpx;
  343. height: 54rpx;
  344. border-radius: 6rpx;
  345. margin-right: 10rpx;
  346. }
  347. .user-name {
  348. font-size: 26rpx;
  349. color: black;
  350. }
  351. .order-time {
  352. font-size: 24rpx;
  353. color: #999;
  354. margin-left: 10rpx;
  355. }
  356. .order-content {
  357. flex: 1;
  358. display: flex;
  359. justify-content: flex-end;
  360. align-items: center;
  361. // margin-left: 10rpx;
  362. }
  363. .order-desc {
  364. font-size: 28rpx;
  365. color: #333;
  366. font-weight: bold;
  367. max-width: 88%;
  368. white-space: nowrap;
  369. overflow: hidden;
  370. text-overflow: ellipsis;
  371. margin-right: 10rpx;
  372. }
  373. .order-count {
  374. font-size: 28rpx;
  375. color: $uni-color-second;
  376. // font-weight: bold;
  377. }
  378. </style>