敢为人鲜小程序前端代码仓库
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.

479 lines
12 KiB

5 months ago
5 months ago
5 months ago
5 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="homeData.restaurant.icon" 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.title}}</text>
  34. <!-- <text class="notice-desc">{{homeData.restaurant.tag}}</text> -->
  35. </view>
  36. <!-- 标签列表 -->
  37. <view class="tag-list">
  38. <view class="tag" v-for="(tag, index) in homeData.restaurant.tag.split('、')" :key="index">{{tag}}</view>
  39. </view>
  40. <!-- 价格区间 -->
  41. <view class="price-range">
  42. <text class="price">{{homeData.restaurant.price}}</text>
  43. </view>
  44. <!-- 产品展示 -->
  45. <scroll-view scroll-x class="food-scroll">
  46. <view class="food-item" v-for="food in homeData.goodsList" :key="food.categoryId" @click="goGoodsDetail">
  47. <image :src="food.image" mode="aspectFill" class="food-image" />
  48. <view class="food-detail">
  49. <view class="food-name">{{food.title}}</view>
  50. <view class="food-desc">{{food.categoryId_dictText}}</view>
  51. <view class="food-price">
  52. <text class="current-price">¥{{food.price}}</text>
  53. <text class="original-price">¥{{food.price + 10}}</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.hanHaiMember.id).substring(0, 3) + '****' + (order.hanHaiMember.id).substring(6, 9) }}</view>
  68. <view class="order-user">
  69. <image :src="order.hanHaiMember.headImage" mode="aspectFill" class="user-avatar" />
  70. <text class="user-name">{{ order.hanHaiMember.nickName }}</text>
  71. <text class="order-time">
  72. {{
  73. order.updateTime ?
  74. $timeUtils.formatTime($dayjs(order.updateTime).unix()) :
  75. $timeUtils.formatTime($dayjs(order.createTime).unix())
  76. }}
  77. </text>
  78. </view>
  79. <view class="order-content">
  80. <text class="order-desc">{{ order.goodsList[0].goods.title }}</text>
  81. <text class="order-count">+{{ order.goodsList[0].num }}</text>
  82. </view>
  83. </view>
  84. </swiper-item>
  85. </swiper>
  86. </view>
  87. </view>
  88. </view>
  89. <tabbar select="index" />
  90. </view>
  91. </template>
  92. <script>
  93. import navbar from '@/components/base/navbar.vue'
  94. import tabbar from '@/components/base/tabbar.vue'
  95. import { homeData } from '@/static/js/mockHomeData.js'
  96. export default {
  97. components: {
  98. navbar,
  99. tabbar
  100. },
  101. data() {
  102. return {
  103. homeData: homeData,
  104. orderList: [
  105. {
  106. id: 19141,
  107. userName: '3**',
  108. avatar: '/static/image/中森明菜.webp',
  109. time: '1分钟前',
  110. content: '【单点】小炒黄牛肉...',
  111. count: 1
  112. },
  113. {
  114. id: 19145,
  115. userName: 'B**',
  116. avatar: '/static/image/中森明菜.webp',
  117. time: '1分钟前',
  118. content: '黑椒肥牛饭(1份)',
  119. count: 1
  120. },
  121. {
  122. id: 19144,
  123. userName: '吃**',
  124. avatar: '/static/image/中森明菜.webp',
  125. time: '1分钟前',
  126. content: '【单点】黑盒220g...',
  127. count: 1
  128. },
  129. {
  130. id: 19143,
  131. userName: 'L**',
  132. avatar: '/static/image/中森明菜.webp',
  133. time: '2分钟前',
  134. content: '红烧肉套餐(1份)',
  135. count: 2
  136. },
  137. {
  138. id: 19142,
  139. userName: '美**',
  140. avatar: '/static/image/中森明菜.webp',
  141. time: '3分钟前',
  142. content: '【单点】小炒肉(1份)',
  143. count: 1
  144. }
  145. ]
  146. }
  147. },
  148. onShow() {
  149. this.getBannerList()
  150. this.getInfoList()
  151. this.getGoodsList()
  152. this.getRollList()
  153. },
  154. methods: {
  155. getBannerList() {
  156. this.$api('queryBannerList', {
  157. type: '0'
  158. }, res => {
  159. if (res.code == 200) {
  160. this.homeData.banners = res.result.records
  161. }
  162. })
  163. },
  164. getInfoList() {
  165. this.$api('queryInfoList', {}, res => {
  166. if (res.code == 200) {
  167. this.homeData.restaurant = res.result.records[0]
  168. }
  169. })
  170. },
  171. getGoodsList() {
  172. this.$api('queryGoodsList', { }, res => {
  173. if (res.code == 200) {
  174. this.$set(this.homeData, 'goodsList', res.result.records)
  175. }
  176. })
  177. },
  178. getRollList() {
  179. this.$api('rollList', { }, res => {
  180. if (res.code == 200) {
  181. this.orderList = res.result.records
  182. }
  183. })
  184. },
  185. goGoodsDetail() {
  186. uni.navigateTo({
  187. url: '/pages/index/category'
  188. })
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .content {
  195. flex: 1;
  196. background: linear-gradient(to bottom, #fff, #f5f5f5);
  197. // padding-bottom: 120rpx;
  198. }
  199. .banner-swiper {
  200. width: 100%;
  201. height: 350rpx;
  202. position: relative;
  203. z-index: 1;
  204. }
  205. .banner-image {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. .restaurant-info {
  210. display: flex;
  211. align-items: center;
  212. padding: 20rpx;
  213. margin-top: -30rpx;
  214. max-height: 60rpx;
  215. border-radius: 20rpx 20rpx 0 0;
  216. background-color: #fff;
  217. border-bottom: 1px solid #eee;
  218. position: relative;
  219. z-index: 2;
  220. }
  221. .restaurant-logo {
  222. width: 130rpx;
  223. height: 130rpx;
  224. border-radius: 20rpx;
  225. margin-right: 20rpx;
  226. margin-top: -60rpx;
  227. overflow: hidden;
  228. border: 4rpx solid #eee;
  229. }
  230. .restaurant-name {
  231. flex: 1;
  232. font-size: 32rpx;
  233. font-weight: 500;
  234. }
  235. .service-btns {
  236. display: flex;
  237. }
  238. .service-btn, .order-btn {
  239. padding: 8rpx 20rpx;
  240. border-radius: 30rpx;
  241. font-size: 24rpx;
  242. margin-left: 10rpx;
  243. }
  244. .service-btn {
  245. border: 1px solid #ccc;
  246. color: #666;
  247. }
  248. .order-btn {
  249. background-color: #4cd964;
  250. color: #fff;
  251. }
  252. .shop-content {
  253. margin-top: 0;
  254. padding: 20rpx;
  255. position: relative;
  256. z-index: 2;
  257. }
  258. /* 产品标签页 */
  259. .product-tabs {
  260. // border: 2rpx solid red;
  261. background-color: #fff;
  262. border-radius: 20rpx;
  263. margin-bottom: 10rpx;
  264. padding: 20rpx;
  265. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  266. }
  267. .notice {
  268. margin-bottom: 15rpx;
  269. }
  270. .notice-text {
  271. font-size: 32rpx;
  272. font-weight: bold;
  273. margin-right: 10rpx;
  274. max-width: 80%;
  275. white-space: nowrap;
  276. overflow: hidden;
  277. text-overflow: ellipsis;
  278. display: inline-block;
  279. }
  280. .notice-desc {
  281. font-size: 24rpx;
  282. color: #999;
  283. background-color: #f5f5f5;
  284. padding: 4rpx 10rpx;
  285. border-radius: 4rpx;
  286. }
  287. .tag-list {
  288. display: flex;
  289. flex-wrap: wrap;
  290. margin-bottom: 15rpx;
  291. }
  292. .tag {
  293. font-size: 24rpx;
  294. color: $uni-color-second;
  295. border: 1px solid #ffcccc;
  296. padding: 4rpx 12rpx;
  297. border-radius: 4rpx;
  298. margin-right: 10rpx;
  299. margin-bottom: 10rpx;
  300. }
  301. .price-range {
  302. margin-bottom: 20rpx;
  303. }
  304. .price {
  305. font-size: 36rpx;
  306. color: $uni-color-second;
  307. font-weight: bold;
  308. }
  309. .food-scroll {
  310. white-space: nowrap;
  311. }
  312. .food-item {
  313. display: inline-block;
  314. width: 300rpx;
  315. margin-right: 20rpx;
  316. background-color: #fff;
  317. border-radius: 10rpx;
  318. overflow: hidden;
  319. box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
  320. }
  321. .food-image {
  322. width: 160rpx;
  323. height: 160rpx;
  324. }
  325. .food-detail {
  326. padding: 10rpx;
  327. }
  328. .food-name {
  329. font-size: 28rpx;
  330. font-weight: bold;
  331. margin-bottom: 5rpx;
  332. }
  333. .food-desc {
  334. font-size: 24rpx;
  335. color: #999;
  336. margin-bottom: 5rpx;
  337. white-space: normal;
  338. overflow: hidden;
  339. text-overflow: ellipsis;
  340. display: -webkit-box;
  341. -webkit-line-clamp: 1;
  342. -webkit-box-orient: vertical;
  343. }
  344. .food-price {
  345. display: flex;
  346. align-items: baseline;
  347. }
  348. .current-price {
  349. font-size: 28rpx;
  350. color: $uni-color-second;
  351. font-weight: bold;
  352. margin-right: 10rpx;
  353. }
  354. .original-price {
  355. font-size: 24rpx;
  356. color: #999;
  357. text-decoration: line-through;
  358. }
  359. .group-purchase {
  360. background-color: #fff;
  361. border-radius: 20rpx;
  362. margin: 0rpx 20rpx 30rpx 20rpx;
  363. padding: 30rpx 20rpx;
  364. box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.1);
  365. }
  366. .group-order-list {
  367. // height: 330rpx;
  368. overflow: hidden;
  369. }
  370. .order-item {
  371. display: flex;
  372. padding: 10rpx;
  373. border-bottom: 1rpx solid #f2f2f2;
  374. align-items: center;
  375. justify-content: space-between;
  376. }
  377. .order-id {
  378. // flex: 1;
  379. font-size: 26rpx;
  380. color: #999;
  381. margin-right: 10rpx;
  382. // display: inline-block;
  383. }
  384. .order-user {
  385. flex: 1;
  386. display: flex;
  387. align-items: center;
  388. width: 140rpx;
  389. }
  390. .user-avatar {
  391. width: 54rpx;
  392. height: 54rpx;
  393. border-radius: 6rpx;
  394. margin-right: 10rpx;
  395. }
  396. .user-name {
  397. font-size: 26rpx;
  398. color: black;
  399. }
  400. .order-time {
  401. font-size: 24rpx;
  402. color: #999;
  403. margin-left: 10rpx;
  404. }
  405. .order-content {
  406. flex: 1;
  407. display: flex;
  408. justify-content: flex-end;
  409. align-items: center;
  410. // margin-left: 10rpx;
  411. }
  412. .order-desc {
  413. font-size: 28rpx;
  414. color: #333;
  415. font-weight: bold;
  416. max-width: 88%;
  417. white-space: nowrap;
  418. overflow: hidden;
  419. text-overflow: ellipsis;
  420. margin-right: 10rpx;
  421. }
  422. .order-count {
  423. font-size: 28rpx;
  424. color: $uni-color-second;
  425. // font-weight: bold;
  426. }
  427. </style>