index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <template>
  2. <!-- 菜品详情 -->
  3. <view class="content">
  4. <swiper class="swiper" :circular="true" :autoplay="true" :interval="3000">
  5. <swiper-item>
  6. <image :src="getFileUrl('/static/demo.png')" mode="aspectFill" class="food-image"></image>
  7. </swiper-item>
  8. <swiper-item>
  9. <image :src="getFileUrl('/static/demo.png')" mode="aspectFill" class="food-image"></image>
  10. </swiper-item>
  11. <swiper-item>
  12. <image :src="getFileUrl('/static/demo.png')" mode="aspectFill" class="food-image"></image>
  13. </swiper-item>
  14. </swiper>
  15. <view class="food-info">
  16. <view class="food-price">
  17. <text class="price-symbol">¥</text>
  18. <text class="price-main">49.8</text>
  19. <text class="price-decimal">.00</text>
  20. </view>
  21. <view class="food-sales">
  22. <image :src="getFileUrl('img/icon/star.png')" mode="aspectFill" class="star-icon"></image>
  23. <text class="sales-text">月售:0</text>
  24. </view>
  25. </view>
  26. <view class="food-desc">
  27. <view class="food-desc-title">香煎M9和牛粒</view>
  28. <view class="food-desc-tags">
  29. <view class="food-desc-tag signature">招牌</view>
  30. <view class="food-desc-tag spicy">中辣</view>
  31. </view>
  32. <view class="food-desc-content">香煎 M9 和牛粒是将澳洲顶级 M9 和牛切成均匀小粒,以高温快煎方式锁住肉汁。</view>
  33. </view>
  34. <view class="food-desc">
  35. <view class="food-desc-title-intro">菜品介绍</view>
  36. <view class="food-desc-content">
  37. 描述:甜麻辣。携手周黑鸭,朝鲜族特色碰撞武汉地道风味。精选鸭腿肉,酱香入骨,紧实入味,年糕Q弹软糯,裹满酱汁,醇厚浓郁。口味层次丰富,前调甜,中段辣,尾韵麻。每份含黑鸭块240克,年糕42克,热烫爆香,甜辣带劲。
  38. </view>
  39. </view>
  40. <!-- 底部按钮 -->
  41. <view class="bottom-btn">
  42. <!-- 左侧:数量选择器 -->
  43. <view class="quantity-selector">
  44. <view class="action-btn minus" :class="{ disabled: quantity === 0 }" @click="handleDecrease"
  45. hover-class="hover-active">
  46. <image :src="getFileUrl('img/icon/reduce1.png')" mode="aspectFit" class="action-icon" v-show="quantity == 0">
  47. </image>
  48. <image :src="getFileUrl('img/icon/reduce2.png')" mode="aspectFit" class="action-icon" v-show="quantity != 0">
  49. </image>
  50. </view>
  51. <view class="quantity">{{ quantity || 0 }}</view>
  52. <view class="action-btn plus" @click="handleIncrease" hover-class="hover-active">
  53. <image :src="getFileUrl('img/icon/add2.png')" mode="widthFix" class="action-icon" v-show="quantity < 99">
  54. </image>
  55. <image :src="getFileUrl('img/icon/add1.png')" mode="widthFix" class="action-icon" v-show="quantity >= 99">
  56. </image>
  57. </view>
  58. </view>
  59. <!-- 右侧:加入购物车按钮 -->
  60. <view class="add-to-cart-btn" @click="handleAddToCart" hover-class="hover-active">
  61. 加入购物车
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. <script setup>
  67. import { ref } from 'vue';
  68. import { onLoad } from "@dcloudio/uni-app";
  69. import { getFileUrl } from "@/utils/file.js";
  70. import NavBar from '@/components/NavBar/index.vue';
  71. const quantity = ref(1);
  72. const handleIncrease = () => {
  73. if (quantity.value >= 99) return;
  74. quantity.value++;
  75. };
  76. const handleDecrease = () => {
  77. if (quantity.value > 0) {
  78. quantity.value--;
  79. }
  80. };
  81. const handleAddToCart = () => {
  82. // TODO: 实现加入购物车逻辑
  83. console.log('加入购物车,数量:', quantity.value);
  84. uni.navigateBack();
  85. uni.showToast({
  86. title: '加入购物车成功',
  87. icon: 'none'
  88. });
  89. };
  90. onLoad((e) => {
  91. });
  92. </script>
  93. <style lang="scss" scoped>
  94. .swiper {
  95. width: 100%;
  96. height: 510rpx;
  97. }
  98. .food-image {
  99. width: 100%;
  100. height: 510rpx;
  101. }
  102. .food-info {
  103. width: 100%;
  104. height: 100rpx;
  105. background: linear-gradient(90deg, #1E1E1E 0%, #464646 100%);
  106. display: flex;
  107. align-items: center;
  108. justify-content: space-between;
  109. color: #fff;
  110. box-sizing: border-box;
  111. padding: 0 30rpx;
  112. .food-price {
  113. display: flex;
  114. align-items: baseline;
  115. line-height: 1;
  116. .price-symbol {
  117. font-size: 24rpx;
  118. font-weight: bold;
  119. margin-right: 10rpx;
  120. }
  121. .price-main {
  122. font-size: 44rpx;
  123. font-weight: bold;
  124. }
  125. .price-decimal {
  126. font-size: 24rpx;
  127. font-weight: bold;
  128. }
  129. }
  130. .food-sales {
  131. font-size: 22rpx;
  132. color: #fff;
  133. display: flex;
  134. align-items: center;
  135. gap: 4rpx;
  136. }
  137. .star-icon {
  138. width: 26rpx;
  139. height: 26rpx;
  140. }
  141. }
  142. .food-desc {
  143. width: 100%;
  144. padding: 30rpx;
  145. box-sizing: border-box;
  146. background-color: #fff;
  147. margin-top: 20rpx;
  148. .food-desc-title {
  149. font-weight: bold;
  150. font-size: 38rpx;
  151. color: #151515;
  152. }
  153. .food-desc-tags {
  154. display: flex;
  155. gap: 10rpx;
  156. margin-top: 10rpx;
  157. }
  158. .food-desc-tag {
  159. padding: 4rpx 12rpx;
  160. border-radius: 4rpx;
  161. font-size: 20rpx;
  162. &.signature {
  163. background: linear-gradient(90deg, #FCB13F 0%, #FC793D 100%);
  164. color: #fff;
  165. }
  166. &.spicy {
  167. background: #2E2E2E;
  168. color: #fff;
  169. }
  170. }
  171. .food-desc-content {
  172. font-size: 27rpx;
  173. color: #666666;
  174. line-height: 38rpx;
  175. margin-top: 22rpx;
  176. }
  177. .food-desc-title-intro {
  178. font-weight: bold;
  179. font-size: 27rpx;
  180. color: #151515;
  181. }
  182. }
  183. .bottom-btn {
  184. position: fixed;
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. z-index: 999;
  189. display: flex;
  190. align-items: center;
  191. justify-content: space-between;
  192. padding: 20rpx 30rpx;
  193. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  194. box-sizing: border-box;
  195. background-color: #fff;
  196. box-shadow: 0rpx -11rpx 46rpx 0rpx rgba(0, 0, 0, 0.05);
  197. }
  198. .quantity-selector {
  199. display: flex;
  200. align-items: center;
  201. justify-content: space-between;
  202. width: 214rpx;
  203. height: 58rpx;
  204. background: #F8F8F8;
  205. border-radius: 56rpx;
  206. box-sizing: border-box;
  207. padding: 0 3rpx;
  208. }
  209. .action-btn {
  210. width: 52rpx;
  211. height: 52rpx;
  212. border-radius: 50%;
  213. display: flex;
  214. align-items: center;
  215. justify-content: center;
  216. font-size: 32rpx;
  217. font-weight: 600;
  218. transition: all 0.3s;
  219. background-color: #fff;
  220. .action-icon {
  221. width: 24rpx;
  222. height: 24rpx;
  223. }
  224. &.disabled {
  225. opacity: 0.5;
  226. }
  227. }
  228. .quantity {
  229. font-size: 30rpx;
  230. color: #000;
  231. min-width: 40rpx;
  232. text-align: center;
  233. }
  234. .add-to-cart-btn {
  235. width: 266rpx;
  236. height: 80rpx;
  237. margin-left: 20rpx;
  238. background: linear-gradient(90deg, #FF6B35 0%, #F7931E 100%);
  239. border-radius: 40rpx;
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. color: #fff;
  244. font-size: 32rpx;
  245. font-weight: bold;
  246. transition: all 0.3s;
  247. &.hover-active {
  248. opacity: 0.8;
  249. }
  250. }
  251. </style>