✨ 订单列表:接入 95%
parent
3180f97cbd
commit
163996ca90
|
@ -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
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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',
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue