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

383 lines
8.7 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
1 month ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title=" " bgColor="#019245" color="#fff" />
  5. <!-- 搜索框 -->
  6. <view class="search-box" style="background-color: #fff; padding: 12rpx 20rpx 0rpx; ">
  7. <uv-search placeholder="搜索商品名" v-model="keyword" :showAction="false" actionText="" height="80rpx" animation
  8. bgColor="#F5F5F5" inputAlign="center" color="#000" placeholderColor="#979797"
  9. searchIconSize="50rpx"></uv-search>
  10. </view>
  11. <!-- 订单筛选 -->
  12. <view class="tabs">
  13. <uv-tabs :list="tabs" :activeStyle="{ color: '#019245'}" lineColor="#019245" :scrollable="false"
  14. :inactiveStyle="{color: 'black'}" lineHeight="6rpx" lineWidth="55rpx" :current="current"
  15. @click="clickTabs"></uv-tabs>
  16. </view>
  17. <!-- 订单列表 -->
  18. <view class="order-list">
  19. <OrderItem v-for="(order, index) in orderList" :key="order.id" :order="order" @cancel="handleCancelOrder"
  20. @pay="handlePayOrder" @click="goToOrderDetail(order)" />
  21. <view style="
  22. margin-top: 200rpx;
  23. min-width: 700rpx;">
  24. <uv-empty mode="order" v-if="orderList.length == 0"></uv-empty>
  25. </view>
  26. </view>
  27. <!-- <view class="list">
  28. <view class="item" v-for="(item, index) in list" @click="toOrderDetail(item.id)" :key="index">
  29. <view class="content" :key="index" v-for="(good, index) in item.commonOrderSkuList">
  30. <view class="top">
  31. <view class="service">
  32. {{ good.title }}
  33. </view>
  34. <view class="status">
  35. <text> {{ tabs[Number(item.state) + 1].name }}</text>
  36. </view>
  37. </view>
  38. <view class="main">
  39. <view class="left">
  40. <image mode="aspectFill" :src="good.image && good.image.split(',')[0]"></image>
  41. </view>
  42. <view class="right">
  43. <view class="text-hidden-1">
  44. 客户姓名{{item.name}}
  45. </view>
  46. <view class="text-hidden-1">
  47. 下单时间{{item.createTime}}
  48. </view>
  49. <view class="text-hidden-1">
  50. 联系电话{{item.phone}}
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="bottom">
  56. <view class="price">
  57. <text class="total-title">总价格</text>
  58. <text class="unit"></text>
  59. <text class="num">{{item.price}}</text>
  60. <text class="c-unit"></text>
  61. </view>
  62. <view @click.stop="toPayOrder(item)" class="btn" v-if="item.state == 0">
  63. 立即付款
  64. </view>
  65. <view @click.stop="cancelOrder(item)" class="btn" v-if="item.state == 0">
  66. 取消订单
  67. </view>
  68. <view class="btn" @click.stop="confirmOrder(item)" v-if="item.state == 2">
  69. 确认收货
  70. </view>
  71. <view @click.stop="$refs.customerServicePopup.open()" class="btn" v-if="item.state > 0">
  72. 联系客服
  73. </view>
  74. </view>
  75. </view>
  76. <view style="
  77. margin-top: 20rpx;
  78. min-width: 700rpx;">
  79. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  80. </view>
  81. </view> -->
  82. <customerServicePopup ref="customerServicePopup" />
  83. <tabber select="order" />
  84. </view>
  85. </template>
  86. <script>
  87. import {
  88. mapGetters
  89. } from 'vuex'
  90. import mixinsList from '@/mixins/list.js'
  91. import mixinsOrder from '@/mixins/order.js'
  92. import tabber from '@/components/base/tabbar.vue'
  93. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  94. import OrderItem from '@/components/order/OrderItem.vue'
  95. import mockOrders from '@/static/js/mockOrders.js'
  96. export default {
  97. mixins: [mixinsList, mixinsOrder],
  98. components: {
  99. tabber,
  100. customerServicePopup,
  101. OrderItem
  102. },
  103. computed: {},
  104. data() {
  105. return {
  106. keyword: '',
  107. // tabs: [{
  108. // name: '全部'
  109. // },
  110. // {
  111. // name: '待付款'
  112. // },
  113. // {
  114. // name: '待发货'
  115. // },
  116. // {
  117. // name: '待收货'
  118. // },
  119. // {
  120. // name: '已完成'
  121. // },
  122. // {
  123. // name: '已取消'
  124. // }
  125. // ],
  126. tabs: [{
  127. name: '待支付'
  128. },
  129. {
  130. name: '待出餐'
  131. },
  132. {
  133. name: '送餐中'
  134. },
  135. {
  136. name: '待取餐'
  137. },
  138. {
  139. name: '已完成'
  140. }
  141. ],
  142. current: 0,
  143. mixinsListApi: 'getOrderPageList',
  144. orderList: [],
  145. }
  146. },
  147. onLoad(args) {
  148. this.current = args.type || 0
  149. this.clickTabs({
  150. index: this.current
  151. })
  152. // 加载模拟订单数据
  153. this.loadMockOrders()
  154. this.filterOrdersByStatus(this.current)
  155. },
  156. methods: {
  157. //点击tab栏
  158. clickTabs({
  159. index
  160. }) {
  161. if (index == 0) {
  162. delete this.queryParams.state
  163. } else {
  164. this.queryParams.state = index - 1
  165. }
  166. // 关闭请求
  167. // this.getData()
  168. // 模拟根据状态筛选订单
  169. this.filterOrdersByStatus(index)
  170. },
  171. // 跳转到新订单详情页
  172. goToOrderDetail(order) {
  173. if (order.status === 'completed') {
  174. tthis.$utils.navigateTo({
  175. url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
  176. })
  177. } else {
  178. this.$utils.navigateTo({
  179. url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
  180. })
  181. }
  182. },
  183. // 加载模拟订单数据
  184. loadMockOrders() {
  185. this.orderList = mockOrders
  186. },
  187. // 根据状态筛选订单
  188. filterOrdersByStatus(index) {
  189. this.loadMockOrders() // 先重置数据
  190. // if (index === 0) return // 全部订单不需要筛选
  191. const statusMap = {
  192. 0: 'pending', // 待支付
  193. 1: 'processing', // 待出餐
  194. 2: 'shipping', // 送餐中
  195. 3: 'delivered', // 待取餐
  196. 4: 'completed' // 已完成
  197. }
  198. const targetStatus = statusMap[index]
  199. if (targetStatus) {
  200. this.orderList = this.orderList.filter(order => order.status === targetStatus)
  201. }
  202. },
  203. // 处理取消订单
  204. handleCancelOrder(orderId) {
  205. uni.showModal({
  206. title: '提示',
  207. content: '确定要取消订单吗?',
  208. success: (res) => {
  209. if (res.confirm) {
  210. // 模拟取消订单API调用
  211. uni.showToast({
  212. title: '订单已取消',
  213. icon: 'success'
  214. })
  215. // 更新订单状态
  216. const orderIndex = this.orderList.findIndex(item => item.id === orderId)
  217. if (orderIndex !== -1) {
  218. this.orderList[orderIndex].status = 'canceled'
  219. // 如果当前标签页不是全部或已取消,则移除该订单
  220. if (this.current !== 0 && this.current !== 5) {
  221. this.orderList.splice(orderIndex, 1)
  222. }
  223. }
  224. }
  225. }
  226. })
  227. },
  228. // 处理支付订单
  229. handlePayOrder(orderId) {
  230. uni.showToast({
  231. title: '正在跳转支付...',
  232. icon: 'loading'
  233. })
  234. // 模拟支付操作,实际项目中应调用支付API
  235. setTimeout(() => {
  236. uni.hideToast()
  237. uni.showToast({
  238. title: '支付成功',
  239. icon: 'success'
  240. })
  241. // 更新订单状态
  242. const orderIndex = this.orderList.findIndex(item => item.id === orderId)
  243. if (orderIndex !== -1) {
  244. this.orderList[orderIndex].status = 'processing'
  245. // 如果当前标签页不是全部或待发货,则移除该订单
  246. if (this.current !== 0 && this.current !== 2) {
  247. this.orderList.splice(orderIndex, 1)
  248. }
  249. }
  250. }, 1500)
  251. }
  252. }
  253. }
  254. </script>
  255. <style scoped lang="scss">
  256. .page {}
  257. .tabs {
  258. background: #fff;
  259. padding-bottom: 4rpx;
  260. }
  261. .order-list {
  262. padding: 0 20rpx;
  263. // position: relative;
  264. }
  265. .list {
  266. .item {
  267. width: calc(100% - 40rpx);
  268. background-color: #fff;
  269. margin: 20rpx;
  270. box-sizing: border-box;
  271. border-radius: 16rpx;
  272. padding: 30rpx;
  273. .content {
  274. .top {
  275. display: flex;
  276. justify-content: space-between;
  277. align-items: center;
  278. font-size: 34rpx;
  279. .status {
  280. font-weight: 600;
  281. color: #FFAC2F;
  282. flex-shrink: 0;
  283. margin-left: 20rpx;
  284. }
  285. }
  286. .main {
  287. display: flex;
  288. margin: 20rpx 0rpx;
  289. .left {
  290. display: flex;
  291. align-items: center;
  292. justify-content: center;
  293. width: 180rpx;
  294. height: 180rpx;
  295. image {
  296. width: 95%;
  297. height: 95%;
  298. border-radius: 10rpx;
  299. }
  300. }
  301. .right {
  302. display: flex;
  303. flex-direction: column;
  304. justify-content: space-between;
  305. width: calc(100% - 200rpx);
  306. color: #777;
  307. font-size: 26rpx;
  308. padding: 30rpx 20rpx;
  309. box-sizing: border-box;
  310. margin-left: 20rpx;
  311. border-radius: 10rpx;
  312. background-color: #F8F8F8;
  313. }
  314. }
  315. }
  316. .bottom {
  317. display: flex;
  318. justify-content: space-between;
  319. font-size: 25rpx;
  320. .price {
  321. .total-title {}
  322. .num {
  323. font-size: 36rpx;
  324. }
  325. .num,
  326. .unit,
  327. .c-unit {
  328. color: $uni-color;
  329. }
  330. }
  331. .btn {
  332. border: 1px solid #C7C7C7;
  333. padding: 10rpx 20rpx;
  334. border-radius: 40rpx;
  335. color: #575757;
  336. }
  337. }
  338. }
  339. }
  340. </style>