订单列表:接入 95%

pull/28/head
YunaiV 2023-12-13 20:54:57 +08:00
parent 3180f97cbd
commit 163996ca90
6 changed files with 82 additions and 82 deletions

View File

@ -200,7 +200,7 @@
确认收货 确认收货
</button> </button>
<button class="ss-reset-button cancel-btn" v-if="state.orderInfo.buttons?.includes('comment')" <button class="ss-reset-button cancel-btn" v-if="state.orderInfo.buttons?.includes('comment')"
@tap="onComment(state.orderInfo.id,state.orderInfo)"> @tap="onComment(state.orderInfo.id, state.orderInfo)">
评价 评价
</button> </button>
</view> </view>
@ -304,12 +304,9 @@
} }
// //
const { const { code } = await OrderApi.receiveOrder(orderId);
error, if (code === 0) {
data await getOrderDetail(orderId);
} = await sheep.$api.order.confirm(orderId);
if (error === 0) {
getOrderDetail(data.order_sn);
} }
} }
@ -354,11 +351,6 @@
// //
function onComment(orderSN, orderId) { function onComment(orderSN, orderId) {
console.log(orderId);
// return;
uni.$once('SELECT_INVOICE', (e) => {
state.invoiceInfo = e.invoiceInfo;
});
sheep.$router.go('/pages/goods/comment/add', { sheep.$router.go('/pages/goods/comment/add', {
orderSN, orderSN,
orderId orderId

View File

@ -6,7 +6,7 @@
</su-sticky> </su-sticky>
<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.data" <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>
@ -75,7 +75,7 @@
<!-- 加载更多 --> <!-- 加载更多 -->
<uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{ <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{
contentdown: '上拉加载更多', contentdown: '上拉加载更多',
}" @tap="loadmore" /> }" @tap="loadMore" />
</s-layout> </s-layout>
</template> </template>
@ -100,23 +100,23 @@
} from 'lodash'; } from 'lodash';
import OrderApi from '@/sheep/api/trade/order'; import OrderApi from '@/sheep/api/trade/order';
const pagination = { const paginationNull = {
data: [], list: [],
current_page: 1, total: 0,
total: 1 pageNo: 1,
pageSize: 5,
}; };
// //
const state = reactive({ const state = reactive({
currentTab: 0, // tabMaps currentTab: 0, // tabMaps
pagination: { pagination: {
data: [], list: [],
current_page: 1, total: 0,
total: 1 pageNo: 1,
pageSize: 5,
}, },
loadStatus: '', loadStatus: ''
deleteOrderId: 0,
error: 0,
}); });
const tabMaps = [{ const tabMaps = [{
@ -142,11 +142,12 @@
// //
function onTabsChange(e) { function onTabsChange(e) {
if (state.currentTab === e.index) return; if (state.currentTab === e.index) {
return;
state.pagination = pagination; }
//
state.pagination = paginationNull;
state.currentTab = e.index; state.currentTab = e.index;
getOrderList(); getOrderList();
} }
@ -196,11 +197,9 @@
} }
// //
const { const { code } = await OrderApi.receiveOrder(order.id);
error if (code === 0) {
} = await sheep.$api.order.confirm(order.id); state.pagination = paginationNull;
if (error === 0) {
state.pagination = pagination;
await getOrderList(); await getOrderList();
} }
} }
@ -256,8 +255,8 @@
const { code } = await OrderApi.cancelOrder(orderId); const { code } = await OrderApi.cancelOrder(orderId);
if (code === 0) { if (code === 0) {
// //
let index = state.pagination.data.findIndex((order) => order.id === orderId); let index = state.pagination.list.findIndex((order) => order.id === orderId);
const orderInfo = state.pagination.data[index]; const orderInfo = state.pagination.list[index];
orderInfo.status = 40; orderInfo.status = 40;
handleOrderButtons(orderInfo); handleOrderButtons(orderInfo);
} }
@ -275,38 +274,30 @@
const { code } = await OrderApi.deleteOrder(orderId); const { code } = await OrderApi.deleteOrder(orderId);
if (code === 0) { if (code === 0) {
// //
let index = state.pagination.data.findIndex((order) => order.id === orderId); let index = state.pagination.list.findIndex((order) => order.id === orderId);
state.pagination.data.splice(index, 1); state.pagination.list.splice(index, 1);
} }
} }
}, },
}); });
} }
// TODO //
async function getOrderList(page = 1, list_rows = 5) { async function getOrderList() {
state.loadStatus = 'loading'; state.loadStatus = 'loading';
let res = await sheep.$api.order.list({ let { code, data } = await OrderApi.getOrderPage({
pageNo: state.pagination.pageNo,
pageSize: state.pagination.pageSize,
status: tabMaps[state.currentTab].value, status: tabMaps[state.currentTab].value,
pageSize: list_rows, commentStatus: tabMaps[state.currentTab].value === 30 ? false : null
pageNo: page,
commentStatus: tabMaps[state.currentTab].value == 30 ? false : null
}); });
state.error = res.code; if (code !== 0) {
if (res.code === 0) { return;
res.data.list.forEach(order => handleOrderButtons(order));
let orderList = _.concat(state.pagination.data, res.data.list);
state.pagination = {
...res.data,
data: orderList,
};
console.log(state.pagination)
if (state.pagination.data.length < state.pagination.total) {
state.loadStatus = 'more';
} else {
state.loadStatus = 'noMore';
}
} }
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';
} }
onLoad(async (options) => { onLoad(async (options) => {
@ -317,20 +308,22 @@
}); });
// //
function loadmore() { function loadMore() {
if (state.loadStatus !== 'noMore') { if (state.loadStatus === 'noMore') {
getOrderList(parseInt((state.pagination.data.length / 5) + 1)); return
} }
state.pagination.pageNo++;
getOrderList();
} }
// //
onReachBottom(() => { onReachBottom(() => {
loadmore(); loadMore();
}); });
// //
onPullDownRefresh(() => { onPullDownRefresh(() => {
state.pagination = pagination; state.pagination = paginationNull;
getOrderList(); getOrderList();
setTimeout(function() { setTimeout(function() {
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();

View File

@ -37,16 +37,7 @@ export default {
showLoading: false, showLoading: false,
}, },
}), }),
// 订单列表
list: (params) =>
request({
url: '/app-api/trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) => // list: (params) =>
// request({ // request({
// url: 'order/order', // url: 'order/order',

View File

@ -1,4 +1,5 @@
import request2 from '@/sheep/request2'; import request2 from '@/sheep/request2';
import request from '@/sheep/request';
const OrderApi = { const OrderApi = {
// 计算订单信息 // 计算订单信息
@ -48,6 +49,27 @@ const OrderApi = {
}, },
}); });
}, },
// 订单列表
getOrderPage: (params) => {
return request({
url: '/app-api/trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
});
},
// 确认收货
receiveOrder: (id) => {
return request2({
url: `/app-api/trade/order/receive`,
method: 'PUT',
params: {
id,
},
});
},
// 取消订单 // 取消订单
cancelOrder: (id) => { cancelOrder: (id) => {
return request2({ return request2({
@ -67,7 +89,7 @@ const OrderApi = {
id, id,
}, },
}); });
} },
}; };
export default OrderApi; export default OrderApi;

View File

@ -94,6 +94,7 @@ http.interceptors.request.use(
if (config.url.indexOf('/app-api/') !== -1) { if (config.url.indexOf('/app-api/') !== -1) {
config.header['Accept'] = '*/*' config.header['Accept'] = '*/*'
config.header['tenant-id'] = '1'; config.header['tenant-id'] = '1';
config.header['terminal'] = '20';
config.header['Authorization'] = 'Bearer test247'; config.header['Authorization'] = 'Bearer test247';
} }
return config; return config;
@ -212,8 +213,8 @@ const request = (config) => {
} }
// TODO 芋艿:额外拼接 // TODO 芋艿:额外拼接
if (config.url.indexOf('/app-api/') >= 0) { if (config.url.indexOf('/app-api/') >= 0) {
config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 // config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
} }
return http.middleware(config); return http.middleware(config);
}; };

View File

@ -96,6 +96,7 @@ http.interceptors.request.use(
if (config.url.indexOf('/app-api/') !== -1) { if (config.url.indexOf('/app-api/') !== -1) {
config.header['Accept'] = '*/*' config.header['Accept'] = '*/*'
config.header['tenant-id'] = '1'; config.header['tenant-id'] = '1';
config.header['terminal'] = '20';
config.header['Authorization'] = 'Bearer test247'; config.header['Authorization'] = 'Bearer test247';
} }
// console.log(config, '看参数') // console.log(config, '看参数')
@ -216,9 +217,9 @@ const request = (config) => {
// TODO 芋艿:额外拼接 // TODO 芋艿:额外拼接
if (config.url.indexOf('/app-api/') >= 0) { if (config.url.indexOf('/app-api/') >= 0) {
// 设置接口地址 // 设置接口地址
config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】 // config.url = 'http://api-dashboard.yudao.iocoder.cn' + config.url; // 调用【云端】
// config.url = 'https://app.test.huizhizao.vip/prod-api' + config.url; // 调用【云端】 // config.url = 'https://app.test.huizhizao.vip/prod-api' + config.url; // 调用【云端】
// config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】 config.url = 'http://127.0.0.1:48080' + config.url; // 调用【本地】
} }
return http.middleware(config); return http.middleware(config);
}; };