|
|
- <template>
- <view class="page">
- <!-- 导航栏 -->
- <navbar title=" " bgColor="#019245" color="#fff" />
-
- <!-- 搜索框 -->
- <view class="search-box" style="background-color: #fff; padding: 12rpx 20rpx 0rpx; ">
- <uv-search placeholder="搜索商品名" v-model="keyword" :showAction="false" actionText="" height="80rpx" animation
- bgColor="#F5F5F5" inputAlign="center" color="#000" placeholderColor="#979797"
- searchIconSize="50rpx"></uv-search>
- </view>
-
- <!-- 订单筛选 -->
- <view class="tabs">
- <uv-tabs :list="tabs" :activeStyle="{ color: '#019245'}" lineColor="#019245" :scrollable="false"
- :inactiveStyle="{color: 'black'}" lineHeight="6rpx" lineWidth="55rpx" :current="current"
- @click="clickTabs"></uv-tabs>
- </view>
-
- <!-- 订单列表 -->
- <view class="order-list">
- <OrderItem v-for="(order, index) in orderList" :key="order.id" :order="order" @cancel="handleCancelOrder"
- @pay="handlePayOrder" @click="goToOrderDetail(order)" />
- <view style="
- margin-top: 200rpx;
- min-width: 700rpx;">
- <uv-empty mode="order" v-if="orderList.length == 0"></uv-empty>
- </view>
- </view>
-
- <!-- <view class="list">
- <view class="item" v-for="(item, index) in list" @click="toOrderDetail(item.id)" :key="index">
- <view class="content" :key="index" v-for="(good, index) in item.commonOrderSkuList">
- <view class="top">
- <view class="service">
- {{ good.title }}
- </view>
- <view class="status">
- <text> {{ tabs[Number(item.state) + 1].name }}</text>
- </view>
- </view>
-
- <view class="main">
- <view class="left">
- <image mode="aspectFill" :src="good.image && good.image.split(',')[0]"></image>
- </view>
-
- <view class="right">
- <view class="text-hidden-1">
- 客户姓名:{{item.name}}
- </view>
- <view class="text-hidden-1">
- 下单时间:{{item.createTime}}
- </view>
- <view class="text-hidden-1">
- 联系电话:{{item.phone}}
- </view>
-
- </view>
- </view>
-
- </view>
-
- <view class="bottom">
- <view class="price">
- <text class="total-title">总价格:</text>
- <text class="unit">¥</text>
- <text class="num">{{item.price}}</text>
- <text class="c-unit">元</text>
- </view>
-
- <view @click.stop="toPayOrder(item)" class="btn" v-if="item.state == 0">
- 立即付款
- </view>
-
- <view @click.stop="cancelOrder(item)" class="btn" v-if="item.state == 0">
- 取消订单
- </view>
-
- <view class="btn" @click.stop="confirmOrder(item)" v-if="item.state == 2">
- 确认收货
- </view>
-
- <view @click.stop="$refs.customerServicePopup.open()" class="btn" v-if="item.state > 0">
- 联系客服
- </view>
- </view>
-
- </view>
- <view style="
- margin-top: 20rpx;
- min-width: 700rpx;">
- <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
- </view>
- </view> -->
-
- <customerServicePopup ref="customerServicePopup" />
-
- <tabber select="order" />
- </view>
- </template>
-
- <script>
- import {
- mapGetters
- } from 'vuex'
- import mixinsList from '@/mixins/list.js'
- import mixinsOrder from '@/mixins/order.js'
- import tabber from '@/components/base/tabbar.vue'
- import customerServicePopup from '@/components/config/customerServicePopup.vue'
- import OrderItem from '@/components/order/OrderItem.vue'
- import mockOrders from '@/static/js/mockOrders.js'
-
- export default {
- mixins: [mixinsList, mixinsOrder],
- components: {
- tabber,
- customerServicePopup,
- OrderItem
- },
- computed: {},
- data() {
- return {
- keyword: '',
- // tabs: [{
- // name: '全部'
- // },
- // {
- // name: '待付款'
- // },
- // {
- // name: '待发货'
- // },
- // {
- // name: '待收货'
- // },
- // {
- // name: '已完成'
- // },
- // {
- // name: '已取消'
- // }
- // ],
- tabs: [{
- name: '待支付'
- },
- {
- name: '待出餐'
- },
- {
- name: '送餐中'
- },
- {
- name: '待取餐'
- },
- {
- name: '已完成'
- }
- ],
- current: 0,
- mixinsListApi: 'getOrderPageList',
- orderList: [],
- }
- },
- onLoad(args) {
- this.current = args.type || 0
- this.clickTabs({
- index: this.current
- })
-
- // 加载模拟订单数据
- this.loadMockOrders()
- this.filterOrdersByStatus(this.current)
- },
- methods: {
- //点击tab栏
- clickTabs({
- index
- }) {
- if (index == 0) {
- delete this.queryParams.state
- } else {
- this.queryParams.state = index - 1
- }
- // 关闭请求
- // this.getData()
-
- // 模拟根据状态筛选订单
- this.filterOrdersByStatus(index)
- },
- // 跳转到新订单详情页
- goToOrderDetail(order) {
- if (order.status === 'completed') {
- tthis.$utils.navigateTo({
- url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
- })
- } else {
- this.$utils.navigateTo({
- url: '/pages_order/order/newOrderDetail?id=' + order.id + '&status=' + order.status
- })
- }
- },
- // 加载模拟订单数据
- loadMockOrders() {
- this.orderList = mockOrders
- },
- // 根据状态筛选订单
- filterOrdersByStatus(index) {
- this.loadMockOrders() // 先重置数据
-
- // if (index === 0) return // 全部订单不需要筛选
-
- const statusMap = {
- 0: 'pending', // 待支付
- 1: 'processing', // 待出餐
- 2: 'shipping', // 送餐中
- 3: 'delivered', // 待取餐
- 4: 'completed' // 已完成
- }
-
- const targetStatus = statusMap[index]
- if (targetStatus) {
- this.orderList = this.orderList.filter(order => order.status === targetStatus)
- }
- },
- // 处理取消订单
- handleCancelOrder(orderId) {
- uni.showModal({
- title: '提示',
- content: '确定要取消订单吗?',
- success: (res) => {
- if (res.confirm) {
- // 模拟取消订单API调用
- uni.showToast({
- title: '订单已取消',
- icon: 'success'
- })
-
- // 更新订单状态
- const orderIndex = this.orderList.findIndex(item => item.id === orderId)
- if (orderIndex !== -1) {
- this.orderList[orderIndex].status = 'canceled'
-
- // 如果当前标签页不是全部或已取消,则移除该订单
- if (this.current !== 0 && this.current !== 5) {
- this.orderList.splice(orderIndex, 1)
- }
- }
- }
- }
- })
- },
- // 处理支付订单
- handlePayOrder(orderId) {
- uni.showToast({
- title: '正在跳转支付...',
- icon: 'loading'
- })
-
- // 模拟支付操作,实际项目中应调用支付API
- setTimeout(() => {
- uni.hideToast()
-
- uni.showToast({
- title: '支付成功',
- icon: 'success'
- })
-
- // 更新订单状态
- const orderIndex = this.orderList.findIndex(item => item.id === orderId)
- if (orderIndex !== -1) {
- this.orderList[orderIndex].status = 'processing'
-
- // 如果当前标签页不是全部或待发货,则移除该订单
- if (this.current !== 0 && this.current !== 2) {
- this.orderList.splice(orderIndex, 1)
- }
- }
- }, 1500)
- }
- }
- }
- </script>
-
- <style scoped lang="scss">
- .page {}
-
- .tabs {
- background: #fff;
- padding-bottom: 4rpx;
- }
-
- .order-list {
- padding: 0 20rpx;
- // position: relative;
- }
-
- .list {
- .item {
- width: calc(100% - 40rpx);
- background-color: #fff;
- margin: 20rpx;
- box-sizing: border-box;
- border-radius: 16rpx;
- padding: 30rpx;
-
- .content {
- .top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-size: 34rpx;
-
- .status {
- font-weight: 600;
- color: #FFAC2F;
- flex-shrink: 0;
- margin-left: 20rpx;
- }
- }
-
- .main {
- display: flex;
- margin: 20rpx 0rpx;
-
- .left {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 180rpx;
- height: 180rpx;
-
- image {
- width: 95%;
- height: 95%;
- border-radius: 10rpx;
- }
- }
-
- .right {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- width: calc(100% - 200rpx);
- color: #777;
- font-size: 26rpx;
- padding: 30rpx 20rpx;
- box-sizing: border-box;
- margin-left: 20rpx;
- border-radius: 10rpx;
- background-color: #F8F8F8;
- }
- }
- }
-
- .bottom {
- display: flex;
- justify-content: space-between;
- font-size: 25rpx;
-
- .price {
- .total-title {}
-
- .num {
- font-size: 36rpx;
- }
-
- .num,
- .unit,
- .c-unit {
- color: $uni-color;
- }
- }
-
- .btn {
- border: 1px solid #C7C7C7;
- padding: 10rpx 20rpx;
- border-radius: 40rpx;
- color: #575757;
- }
- }
- }
- }
- </style>
|