|
@@ -7,63 +7,59 @@
|
|
<s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单" />
|
|
<s-empty v-if="state.pagination.total === 0" icon="/static/order-empty.png" text="暂无订单" />
|
|
<view v-if="state.pagination.total > 0">
|
|
<view v-if="state.pagination.total > 0">
|
|
<view class="bg-white order-list-card-box ss-r-10 ss-m-t-14 ss-m-20" v-for="order in state.pagination.list"
|
|
<view class="bg-white order-list-card-box ss-r-10 ss-m-t-14 ss-m-20" v-for="order in state.pagination.list"
|
|
- :key="order.id" @tap="onOrderDetail(order.id)">
|
|
|
|
|
|
+ :key="order.id" @tap="onOrderDetail(order.id)">
|
|
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
|
|
<view class="order-card-header ss-flex ss-col-center ss-row-between ss-p-x-20">
|
|
<view class="order-no">订单号:{{ order.no }}</view>
|
|
<view class="order-no">订单号:{{ order.no }}</view>
|
|
<view class="order-state ss-font-26" :class="formatOrderColor(order)">
|
|
<view class="order-state ss-font-26" :class="formatOrderColor(order)">
|
|
- {{ formatOrderStatus(order) }}
|
|
|
|
- </view>
|
|
|
|
|
|
+ {{ formatOrderStatus(order) }}
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
<view class="border-bottom" v-for="item in order.items" :key="item.id">
|
|
<view class="border-bottom" v-for="item in order.items" :key="item.id">
|
|
- <s-goods-item
|
|
|
|
- :img="item.picUrl"
|
|
|
|
- :title="item.spuName"
|
|
|
|
- :skuText="item.properties.map((property) => property.valueName).join(' ')"
|
|
|
|
- :price="item.price"
|
|
|
|
- :num="item.count"
|
|
|
|
- />
|
|
|
|
|
|
+ <s-goods-item :img="item.picUrl" :title="item.spuName"
|
|
|
|
+ :skuText="item.properties.map((property) => property.valueName).join(' ')" :price="item.price"
|
|
|
|
+ :num="item.count" />
|
|
</view>
|
|
</view>
|
|
<view class="pay-box ss-m-t-30 ss-flex ss-row-right ss-p-r-20">
|
|
<view class="pay-box ss-m-t-30 ss-flex ss-row-right ss-p-r-20">
|
|
<view class="ss-flex ss-col-center">
|
|
<view class="ss-flex ss-col-center">
|
|
<view class="discounts-title pay-color">共 {{ order.productCount }} 件商品,总金额:</view>
|
|
<view class="discounts-title pay-color">共 {{ order.productCount }} 件商品,总金额:</view>
|
|
<view class="discounts-money pay-color">
|
|
<view class="discounts-money pay-color">
|
|
¥{{ fen2yuan(order.payPrice) }}
|
|
¥{{ fen2yuan(order.payPrice) }}
|
|
- </view>
|
|
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="order-card-footer ss-flex ss-col-center ss-p-x-20"
|
|
<view class="order-card-footer ss-flex ss-col-center ss-p-x-20"
|
|
- :class="order.buttons.length > 3 ? 'ss-row-between' : 'ss-row-right'">
|
|
|
|
|
|
+ :class="order.buttons.length > 3 ? 'ss-row-between' : 'ss-row-right'">
|
|
<view class="ss-flex ss-col-center">
|
|
<view class="ss-flex ss-col-center">
|
|
<button v-if="order.buttons.includes('combination')" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('combination')" class="tool-btn ss-reset-button"
|
|
@tap.stop="onOrderGroupon(order)">
|
|
@tap.stop="onOrderGroupon(order)">
|
|
- 拼团详情
|
|
|
|
|
|
+ 拼团详情
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.length === 0" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.length === 0" class="tool-btn ss-reset-button"
|
|
- @tap.stop="onOrderDetail(order.id)">
|
|
|
|
- 查看详情
|
|
|
|
|
|
+ @tap.stop="onOrderDetail(order.id)">
|
|
|
|
+ 查看详情
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.includes('confirm')" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('confirm')" class="tool-btn ss-reset-button"
|
|
- @tap.stop="onConfirm(order)">
|
|
|
|
- 确认收货
|
|
|
|
|
|
+ @tap.stop="onConfirm(order)">
|
|
|
|
+ 确认收货
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.includes('express')" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('express')" class="tool-btn ss-reset-button"
|
|
- @tap.stop="onExpress(order.id)">
|
|
|
|
|
|
+ @tap.stop="onExpress(order.id)">
|
|
查看物流
|
|
查看物流
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.includes('cancel')" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('cancel')" class="tool-btn ss-reset-button"
|
|
- @tap.stop="onCancel(order.id)">
|
|
|
|
|
|
+ @tap.stop="onCancel(order.id)">
|
|
取消订单
|
|
取消订单
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.includes('comment')" class="tool-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('comment')" class="tool-btn ss-reset-button"
|
|
- @tap.stop="onComment(order.id)">
|
|
|
|
|
|
+ @tap.stop="onComment(order.id)">
|
|
评价
|
|
评价
|
|
</button>
|
|
</button>
|
|
<button v-if="order.buttons.includes('delete')" class="delete-btn ss-reset-button"
|
|
<button v-if="order.buttons.includes('delete')" class="delete-btn ss-reset-button"
|
|
- @tap.stop="onDelete(order.id)">
|
|
|
|
|
|
+ @tap.stop="onDelete(order.id)">
|
|
删除订单
|
|
删除订单
|
|
</button>
|
|
</button>
|
|
- <button v-if="order.buttons.includes('pay')" class="tool-btn ss-reset-button ui-BG-Main-Gradient"
|
|
|
|
- @tap.stop="onPay(order.payOrderId)">
|
|
|
|
|
|
+ <button v-if="order.buttons.includes('pay')"
|
|
|
|
+ class="tool-btn ss-reset-button ui-BG-Main-Gradient" @tap.stop="onPay(order.payOrderId)">
|
|
继续支付
|
|
继续支付
|
|
</button>
|
|
</button>
|
|
</view>
|
|
</view>
|
|
@@ -79,34 +75,42 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
- import { reactive } from 'vue';
|
|
|
|
- import { onLoad, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
|
|
|
|
- import {
|
|
|
|
- fen2yuan,
|
|
|
|
- formatOrderColor, formatOrderStatus, handleOrderButtons,
|
|
|
|
- } from '@/sheep/hooks/useGoods';
|
|
|
|
|
|
+ import {
|
|
|
|
+ reactive
|
|
|
|
+ } from 'vue';
|
|
|
|
+ import {
|
|
|
|
+ onLoad,
|
|
|
|
+ onReachBottom,
|
|
|
|
+ onPullDownRefresh
|
|
|
|
+ } from '@dcloudio/uni-app';
|
|
|
|
+ import {
|
|
|
|
+ fen2yuan,
|
|
|
|
+ formatOrderColor,
|
|
|
|
+ formatOrderStatus,
|
|
|
|
+ handleOrderButtons,
|
|
|
|
+ } from '@/sheep/hooks/useGoods';
|
|
import sheep from '@/sheep';
|
|
import sheep from '@/sheep';
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
import {
|
|
import {
|
|
isEmpty
|
|
isEmpty
|
|
} from 'lodash';
|
|
} from 'lodash';
|
|
- import OrderApi from '@/sheep/api/trade/order';
|
|
|
|
|
|
+ import OrderApi from '@/sheep/api/trade/order';
|
|
|
|
|
|
const paginationNull = {
|
|
const paginationNull = {
|
|
list: [],
|
|
list: [],
|
|
- total: 0,
|
|
|
|
|
|
+ total: 0,
|
|
pageNo: 1,
|
|
pageNo: 1,
|
|
- pageSize: 5,
|
|
|
|
|
|
+ pageSize: 5,
|
|
};
|
|
};
|
|
|
|
|
|
// 数据
|
|
// 数据
|
|
const state = reactive({
|
|
const state = reactive({
|
|
currentTab: 0, // 选中的 tabMaps 下标
|
|
currentTab: 0, // 选中的 tabMaps 下标
|
|
pagination: {
|
|
pagination: {
|
|
- list: [],
|
|
|
|
- total: 0,
|
|
|
|
- pageNo: 1,
|
|
|
|
- pageSize: 5,
|
|
|
|
|
|
+ list: [],
|
|
|
|
+ total: 0,
|
|
|
|
+ pageNo: 1,
|
|
|
|
+ pageSize: 5,
|
|
},
|
|
},
|
|
loadStatus: ''
|
|
loadStatus: ''
|
|
});
|
|
});
|
|
@@ -135,9 +139,9 @@
|
|
// 切换选项卡
|
|
// 切换选项卡
|
|
function onTabsChange(e) {
|
|
function onTabsChange(e) {
|
|
if (state.currentTab === e.index) {
|
|
if (state.currentTab === e.index) {
|
|
- return;
|
|
|
|
- }
|
|
|
|
- // 重头加载代码
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 重头加载代码
|
|
state.pagination = paginationNull;
|
|
state.pagination = paginationNull;
|
|
state.currentTab = e.index;
|
|
state.currentTab = e.index;
|
|
getOrderList();
|
|
getOrderList();
|
|
@@ -189,7 +193,9 @@
|
|
}
|
|
}
|
|
|
|
|
|
// 正常的确认收货流程
|
|
// 正常的确认收货流程
|
|
- const { code } = await OrderApi.receiveOrder(order.id);
|
|
|
|
|
|
+ const {
|
|
|
|
+ code
|
|
|
|
+ } = await OrderApi.receiveOrder(order.id);
|
|
if (code === 0) {
|
|
if (code === 0) {
|
|
state.pagination = paginationNull;
|
|
state.pagination = paginationNull;
|
|
await getOrderList();
|
|
await getOrderList();
|
|
@@ -231,7 +237,7 @@
|
|
// 查看物流
|
|
// 查看物流
|
|
async function onExpress(id) {
|
|
async function onExpress(id) {
|
|
sheep.$router.go('/pages/order/express/log', {
|
|
sheep.$router.go('/pages/order/express/log', {
|
|
- id,
|
|
|
|
|
|
+ id,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -242,16 +248,18 @@
|
|
content: '确定要取消订单吗?',
|
|
content: '确定要取消订单吗?',
|
|
success: async function(res) {
|
|
success: async function(res) {
|
|
if (!res.confirm) {
|
|
if (!res.confirm) {
|
|
- return;
|
|
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const {
|
|
|
|
+ code
|
|
|
|
+ } = await OrderApi.cancelOrder(orderId);
|
|
|
|
+ if (code === 0) {
|
|
|
|
+ // 修改数据的状态
|
|
|
|
+ let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
|
|
+ const orderInfo = state.pagination.list[index];
|
|
|
|
+ orderInfo.status = 40;
|
|
|
|
+ handleOrderButtons(orderInfo);
|
|
}
|
|
}
|
|
- const { code } = await OrderApi.cancelOrder(orderId);
|
|
|
|
- if (code === 0) {
|
|
|
|
- // 修改数据的状态
|
|
|
|
- let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
|
|
- const orderInfo = state.pagination.list[index];
|
|
|
|
- orderInfo.status = 40;
|
|
|
|
- handleOrderButtons(orderInfo);
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -263,9 +271,11 @@
|
|
content: '确定要删除订单吗?',
|
|
content: '确定要删除订单吗?',
|
|
success: async function(res) {
|
|
success: async function(res) {
|
|
if (res.confirm) {
|
|
if (res.confirm) {
|
|
- const { code } = await OrderApi.deleteOrder(orderId);
|
|
|
|
|
|
+ const {
|
|
|
|
+ code
|
|
|
|
+ } = await OrderApi.deleteOrder(orderId);
|
|
if (code === 0) {
|
|
if (code === 0) {
|
|
- // 删除数据
|
|
|
|
|
|
+ // 删除数据
|
|
let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
let index = state.pagination.list.findIndex((order) => order.id === orderId);
|
|
state.pagination.list.splice(index, 1);
|
|
state.pagination.list.splice(index, 1);
|
|
}
|
|
}
|
|
@@ -277,20 +287,26 @@
|
|
// 获取订单列表
|
|
// 获取订单列表
|
|
async function getOrderList() {
|
|
async function getOrderList() {
|
|
state.loadStatus = 'loading';
|
|
state.loadStatus = 'loading';
|
|
- let { code, data } = await OrderApi.getOrderPage({
|
|
|
|
- pageNo: state.pagination.pageNo,
|
|
|
|
- pageSize: state.pagination.pageSize,
|
|
|
|
- status: tabMaps[state.currentTab].value,
|
|
|
|
|
|
+ let {
|
|
|
|
+ code,
|
|
|
|
+ data
|
|
|
|
+ } = await OrderApi.getOrderPage({
|
|
|
|
+ pageNo: state.pagination.pageNo,
|
|
|
|
+ pageSize: state.pagination.pageSize,
|
|
|
|
+ status: tabMaps[state.currentTab].value,
|
|
commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
|
|
commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
|
|
});
|
|
});
|
|
- if (code !== 0) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- data.list.forEach(order => handleOrderButtons(order));
|
|
|
|
- state.pagination.list = _.concat(state.pagination.list, data.list)
|
|
|
|
- state.pagination.total = data.total;
|
|
|
|
- state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
|
|
|
|
- }
|
|
|
|
|
|
+ if (code !== 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ data.list.forEach(order => handleOrderButtons(order));
|
|
|
|
+ // state.pagination.list = _.concat(state.pagination.list, data.list)
|
|
|
|
+ state.pagination.list = (data.list)
|
|
|
|
+ // console.log("未经过处理前:",state.pagination.list)
|
|
|
|
+ state.pagination.total = data.total;
|
|
|
|
+ state.loadStatus = state.pagination.list.length < state.pagination.total ? 'more' : 'noMore';
|
|
|
|
+ }
|
|
|
|
|
|
onLoad(async (options) => {
|
|
onLoad(async (options) => {
|
|
if (options.type) {
|
|
if (options.type) {
|
|
@@ -302,11 +318,11 @@
|
|
// 加载更多
|
|
// 加载更多
|
|
function loadMore() {
|
|
function loadMore() {
|
|
if (state.loadStatus === 'noMore') {
|
|
if (state.loadStatus === 'noMore') {
|
|
- return
|
|
|
|
|
|
+ return
|
|
}
|
|
}
|
|
- state.pagination.pageNo++;
|
|
|
|
- getOrderList();
|
|
|
|
- }
|
|
|
|
|
|
+ state.pagination.pageNo++;
|
|
|
|
+ getOrderList();
|
|
|
|
+ }
|
|
|
|
|
|
// 上拉加载更多
|
|
// 上拉加载更多
|
|
onReachBottom(() => {
|
|
onReachBottom(() => {
|