index.vue 8.9 KB

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