index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <!-- 订单列表 -->
  3. <view class="content">
  4. <!-- 搜索栏 -->
  5. <view class="search-container">
  6. <view class="search-box">
  7. <view class="search-icon">🔍</view>
  8. <input type="text" placeholder="搜索" class="search-input" v-model="searchKeyword" />
  9. </view>
  10. </view>
  11. <!-- 标签页 -->
  12. <view class="tabs">
  13. <view
  14. class="tab-item"
  15. :class="{ active: activeTab === 'current' }"
  16. @click="switchTab('current')"
  17. >
  18. 当前订单
  19. </view>
  20. <view
  21. class="tab-item"
  22. :class="{ active: activeTab === 'history' }"
  23. @click="switchTab('history')"
  24. >
  25. 历史订单
  26. </view>
  27. </view>
  28. <!-- 订单列表 -->
  29. <scroll-view class="order-list" scroll-y>
  30. <view
  31. v-for="(order, index) in currentOrderList"
  32. :key="order.id || index"
  33. class="order-card"
  34. >
  35. <!-- 订单头部 -->
  36. <view class="order-header">
  37. <view class="order-number">NO.{{ order.orderNo }}</view>
  38. <view class="order-status" :class="order.statusClass">{{ order.statusText }}</view>
  39. </view>
  40. <!-- 店铺信息 -->
  41. <view class="store-info" @click="handleStoreClick(order)">
  42. <text class="store-name">{{ order.storeName }}</text>
  43. <text class="store-arrow">›</text>
  44. </view>
  45. <!-- 订单时间 -->
  46. <view class="order-time">{{ order.createTime }}</view>
  47. <!-- 商品信息 -->
  48. <view class="order-goods">
  49. <view class="goods-images">
  50. <image
  51. v-for="(image, imgIndex) in order.goodsImages"
  52. :key="imgIndex"
  53. :src="getFileUrl(image)"
  54. mode="aspectFill"
  55. class="goods-image"
  56. />
  57. </view>
  58. <view class="goods-info">
  59. <view class="goods-price">¥{{ order.totalPrice }}</view>
  60. <view class="goods-count">共{{ order.goodsCount }}件</view>
  61. </view>
  62. </view>
  63. <!-- 操作按钮 -->
  64. <view class="order-actions">
  65. <view class="action-btn outline" @click="handleAddFood(order)">
  66. 去加餐
  67. </view>
  68. <view class="action-btn primary" @click="handleCheckout(order)">
  69. 去结算
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 空状态 -->
  74. <view v-if="currentOrderList.length === 0" class="empty-state">
  75. <text class="empty-text">暂无订单</text>
  76. </view>
  77. </scroll-view>
  78. </view>
  79. </template>
  80. <script setup>
  81. import { onLoad } from "@dcloudio/uni-app";
  82. import { ref, computed } from "vue";
  83. import { getFileUrl } from "@/utils/file.js";
  84. import { go } from "@/utils/utils.js";
  85. const activeTab = ref('current');
  86. const searchKeyword = ref('');
  87. // 示例订单数据
  88. const currentOrders = ref([
  89. {
  90. id: 1,
  91. orderNo: '1929065620709298441',
  92. storeName: '正旗手选海鲜烧烤(东港店)',
  93. createTime: '2025-06-01 14:40:58',
  94. totalPrice: 19.9,
  95. goodsCount: 2,
  96. statusText: '进行中',
  97. statusClass: 'status-active',
  98. goodsImages: ['/static/demo.png', '/static/demo.png']
  99. }
  100. ]);
  101. const historyOrders = ref([]);
  102. // 当前显示的订单列表
  103. const currentOrderList = computed(() => {
  104. const orders = activeTab.value === 'current' ? currentOrders.value : historyOrders.value;
  105. if (!searchKeyword.value) {
  106. return orders;
  107. }
  108. return orders.filter(order =>
  109. order.orderNo.includes(searchKeyword.value) ||
  110. order.storeName.includes(searchKeyword.value)
  111. );
  112. });
  113. // 切换标签页
  114. const switchTab = (tab) => {
  115. activeTab.value = tab;
  116. };
  117. // 处理店铺点击
  118. const handleStoreClick = (order) => {
  119. console.log('点击店铺:', order);
  120. // TODO: 跳转到店铺详情
  121. };
  122. // 处理加餐
  123. const handleAddFood = (order) => {
  124. console.log('去加餐:', order);
  125. // TODO: 跳转到点餐页面
  126. go('/pages/orderFood/index');
  127. };
  128. // 处理结算
  129. const handleCheckout = (order) => {
  130. console.log('去结算:', order);
  131. // TODO: 跳转到结算页面
  132. go('/pages/placeOrder/index');
  133. };
  134. onLoad((e) => {
  135. uni.setNavigationBarTitle({
  136. title: '我的订单'
  137. });
  138. });
  139. </script>
  140. <style lang="scss" scoped>
  141. .content {
  142. display: flex;
  143. flex-direction: column;
  144. height: 100vh;
  145. background-color: #f7f9fa;
  146. box-sizing: border-box;
  147. }
  148. // 搜索栏
  149. .search-container {
  150. width: 100%;
  151. padding: 20rpx 30rpx;
  152. background-color: #fff;
  153. box-sizing: border-box;
  154. .search-box {
  155. width: 100%;
  156. height: 80rpx;
  157. background-color: #f5f5f5;
  158. border-radius: 40rpx;
  159. display: flex;
  160. align-items: center;
  161. padding: 0 30rpx;
  162. box-sizing: border-box;
  163. .search-icon {
  164. font-size: 32rpx;
  165. color: #999;
  166. margin-right: 16rpx;
  167. line-height: 1;
  168. display: flex;
  169. align-items: center;
  170. }
  171. .search-input {
  172. flex: 1;
  173. font-size: 28rpx;
  174. color: #333;
  175. background: transparent;
  176. border: none;
  177. }
  178. }
  179. }
  180. // 标签页
  181. .tabs {
  182. display: flex;
  183. background-color: #fff;
  184. border-bottom: 1rpx solid #f0f0f0;
  185. padding: 0 30rpx;
  186. .tab-item {
  187. flex: 1;
  188. height: 88rpx;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. font-size: 32rpx;
  193. color: #666;
  194. position: relative;
  195. transition: color 0.3s;
  196. &.active {
  197. color: #FF6B35;
  198. font-weight: 600;
  199. &::after {
  200. content: '';
  201. position: absolute;
  202. bottom: 0;
  203. left: 50%;
  204. transform: translateX(-50%);
  205. width: 60rpx;
  206. height: 4rpx;
  207. background-color: #FF6B35;
  208. border-radius: 2rpx;
  209. }
  210. }
  211. }
  212. }
  213. // 订单列表
  214. .order-list {
  215. flex: 1;
  216. padding: 20rpx 30rpx;
  217. box-sizing: border-box;
  218. }
  219. // 订单卡片
  220. .order-card {
  221. width: 100%;
  222. background-color: #fff;
  223. border-radius: 20rpx;
  224. padding: 30rpx;
  225. margin-bottom: 20rpx;
  226. box-shadow: 0rpx 0rpx 11rpx 0rpx rgba(0, 0, 0, 0.06);
  227. box-sizing: border-box;
  228. // 订单头部
  229. .order-header {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. margin-bottom: 20rpx;
  234. .order-number {
  235. font-size: 28rpx;
  236. color: #151515;
  237. font-weight: 500;
  238. }
  239. .order-status {
  240. font-size: 28rpx;
  241. font-weight: 500;
  242. &.status-active {
  243. color: #07C160;
  244. }
  245. &.status-completed {
  246. color: #999;
  247. }
  248. &.status-cancelled {
  249. color: #FF3B30;
  250. }
  251. }
  252. }
  253. // 店铺信息
  254. .store-info {
  255. display: flex;
  256. align-items: center;
  257. justify-content: space-between;
  258. margin-bottom: 12rpx;
  259. .store-name {
  260. font-size: 30rpx;
  261. color: #151515;
  262. font-weight: 500;
  263. flex: 1;
  264. }
  265. .store-arrow {
  266. font-size: 36rpx;
  267. color: #999;
  268. margin-left: 10rpx;
  269. }
  270. }
  271. // 订单时间
  272. .order-time {
  273. font-size: 24rpx;
  274. color: #999;
  275. margin-bottom: 20rpx;
  276. }
  277. // 商品信息
  278. .order-goods {
  279. display: flex;
  280. align-items: center;
  281. margin-bottom: 30rpx;
  282. .goods-images {
  283. display: flex;
  284. gap: 12rpx;
  285. margin-right: 20rpx;
  286. .goods-image {
  287. width: 100rpx;
  288. height: 100rpx;
  289. border-radius: 8rpx;
  290. background-color: #f5f5f5;
  291. }
  292. }
  293. .goods-info {
  294. flex: 1;
  295. display: flex;
  296. flex-direction: column;
  297. align-items: flex-end;
  298. .goods-price {
  299. font-size: 32rpx;
  300. color: #151515;
  301. font-weight: 600;
  302. margin-bottom: 8rpx;
  303. }
  304. .goods-count {
  305. font-size: 24rpx;
  306. color: #999;
  307. }
  308. }
  309. }
  310. // 操作按钮
  311. .order-actions {
  312. display: flex;
  313. gap: 20rpx;
  314. padding-top: 20rpx;
  315. border-top: 1rpx solid #f0f0f0;
  316. .action-btn {
  317. flex: 1;
  318. height: 68rpx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. border-radius: 34rpx;
  323. font-size: 28rpx;
  324. font-weight: 500;
  325. transition: all 0.3s;
  326. &.outline {
  327. border: 2rpx solid #FF6B35;
  328. color: #FF6B35;
  329. background-color: transparent;
  330. &:active {
  331. background-color: #fff4e6;
  332. }
  333. }
  334. &.primary {
  335. background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
  336. color: #fff;
  337. &:active {
  338. opacity: 0.8;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. // 空状态
  345. .empty-state {
  346. width: 100%;
  347. padding: 100rpx 0;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. .empty-text {
  352. font-size: 28rpx;
  353. color: #999;
  354. }
  355. }
  356. </style>