diff --git a/api/goods/index.js b/api/goods/index.js index c4db7c1..ecaea5e 100644 --- a/api/goods/index.js +++ b/api/goods/index.js @@ -41,7 +41,7 @@ export const skuInfo = (goodsId, goodsSkuId, param) => { // 获取商品列表 export const apiGetCommodityList = (data) => { return httpRequest.post( - `${baseUrl}/app/index/page/list`, + `${baseUrl}/index/page/list`, data ); } diff --git a/api/order.js b/api/order.js index 52d6f07..5cede54 100644 --- a/api/order.js +++ b/api/order.js @@ -58,3 +58,22 @@ export const apiOrderAdd = (data) => { data ); } + +// 获取订单列表 +export const apiGetOrderList = (data) => { + return httpRequest.post( + `${baseUrl}/order/list`, + data + ); + } + +// 订单操作 +export const apiActionOrder = (url, data) => { + url = url.startsWith('/app') ? url.substring(4) : url + return httpRequest.post( + `${baseUrl}${url}`, + data + ); + } + + diff --git a/pages/order/index.vue b/pages/order/index.vue index f13d401..a606b5c 100644 --- a/pages/order/index.vue +++ b/pages/order/index.vue @@ -9,25 +9,25 @@ - {{ item.create_time }} + {{ new Date(item.tradeOrderEntity.createTime).toLocaleString() }} - {{ item.state_text }} + {{ item.tradeOrderEntity.statusText }} - - + + - + - {{ goods.goods_name }} + {{ goods.productName }} - - {{ props.value.name }} + + {{ prop }} @@ -35,49 +35,50 @@ - {{ goods.is_user_grade ? goods.grade_goods_price : goods.goods_price }} + {{ goods.promotionPrice }} - ×{{ goods.total_num }} + ×{{ goods.num }} - 共{{ item.total_num }}件商品,总金额 + 共{{ item.tradeOrderEntity.num }}件商品,总金额 - {{ item.pay_price }} + {{ item.tradeOrderEntity.payAmount }} + + {{ action.desc }} + - + - + - 取消申请中 + --> - + - 确认收货 - + --> - + @@ -107,16 +108,20 @@ // tab栏数据 const tabs = [{ name: `全部`, - value: 'all' + value: 'all', + status: '' }, { name: `待支付`, - value: 'payment' + value: 'wait_pay', + status: 'wait_pay' }, { name: `待发货`, - value: 'delivery' + value: 'wait_shipping', + status: 'wait_shipping' }, { name: `待收货`, - value: 'received' + value: 'shipping', + status: 'shipping' }, { name: `待评价`, value: 'comment' @@ -138,7 +143,7 @@ ReceiptStatusEnum, PayMethodEnum, // 当前页面参数 - options: { dataType: 'all', orderSource: null }, + options: { dataType: 'all' }, // tab栏数据 tabs, // 当前标签索引 @@ -232,9 +237,8 @@ getOrderList(pageNo = 1) { const app = this return new Promise((resolve, reject) => { - OrderApi.list({ - dataType: app.getTabValue(), - orderSource: app.options.orderSource, + /* OrderApi.list({ + status: this.tabs[this.curTab].value, page: pageNo, }, { load: false }) .then(result => { @@ -242,6 +246,23 @@ const newList = app.initList(result.data.list) app.list.data = getMoreListData(newList, app.list, pageNo) resolve(newList) + }) */ + OrderApi.apiGetOrderList({ + status: app.tabs[app.curTab].status, + page: pageNo, + }) + .then(result => { + const newList = result.data + newList.forEach(item => { + item.tradeOrderEntity.statusText = (app.tabs.find(tab => tab.value == item.vvTradeOrderLineDOList[0].status)|| {}).name + item.tradeOrderEntity.tradeOrderId = item.vvTradeOrderLineDOList[0].tradeOrderId + item.vvTradeOrderLineDOList.forEach(good => { + good.skuInfo = JSON.parse(good.skuInfo).map(sku => `${sku.propertyName}: ${sku.propertyValue}`) + }) + item.orderActionList = item.orderActionList.filter(action => action.interfaceUri.startsWith('/app')) + }) + app.list.data = getMoreListData({ data: newList }, app.list, pageNo) + resolve(newList) }) }) }, @@ -257,11 +278,6 @@ return newList }, - // 获取当前标签项的值 - getTabValue() { - return this.tabs[this.curTab].value - }, - // 切换标签项 onChangeTab(index) { const app = this @@ -279,18 +295,31 @@ }, 120) }, + onClickBtn(orderId, action) { + console.warn('----- my data is orderId, action: ', orderId, action) + if (action.interfaceUri === '/app/order/applyCancel') { + this.onCancel(orderId, action.interfaceUri) + } else if (action.interfaceUri.includes('/pay')) { + this.onPay(orderId) + } else if (action.interfaceUri.includes('/receipt')) { + this.onReceipt(orderId, action.interfaceUri) + } else if (action.interfaceUri.includes('/comment')) { + this.handleTargetComment(orderId) + } + }, + // 取消订单 - onCancel(orderId) { + onCancel(orderId, url) { const app = this uni.showModal({ title: '友情提示', content: '确认要取消该订单吗?', success(o) { if (o.confirm) { - OrderApi.cancel(orderId) + OrderApi.apiActionOrder(url, { tradeOrderId: orderId }) .then(result => { // 显示成功信息 - app.$toast(result.message) + app.$toast(result.msg) // 刷新订单列表 app.onRefreshList() }) @@ -298,7 +327,39 @@ } }); }, + // 点击去支付 + onPay(orderId) { + this.$navTo('pages/checkout/cashier/index', { tradeOrderId: orderId }) + }, + // 跳转到订单详情页 + handleTargetDetail(orderId) { + this.$navTo('pages/order/detail', { tradeOrderId: orderId }) + }, + + // 跳转到订单评价页 + handleTargetComment(orderId) { + this.$navTo('pages/order/comment/index', { tradeOrderId: orderId }) + }, + onReceipt(orderId, url) { + const app = this + uni.showModal({ + title: '友情提示', + content: '确认要确认收货吗?', + success(o) { + if (o.confirm) { + OrderApi.apiActionOrder(url, { tradeOrderId: orderId }) + .then(result => { + // 显示成功信息 + app.$toast(result.msg) + // 刷新订单列表 + app.onRefreshList() + }) + } + } + }); + } +/* // 确认收货 async onReceipt(orderIndex) { const app = this @@ -391,23 +452,7 @@ // 刷新订单列表 app.onRefreshList() }) - }, - - // 点击去支付 - onPay(orderId) { - this.$navTo('pages/checkout/cashier/index', { orderId }) - }, - - // 跳转到订单详情页 - handleTargetDetail(orderId) { - this.$navTo('pages/order/detail', { orderId }) - }, - - // 跳转到订单评价页 - handleTargetComment(orderId) { - this.$navTo('pages/order/comment/index', { orderId }) - } - + }, */ }, } @@ -477,11 +522,14 @@ color: #ababab; font-size: 24rpx; overflow: hidden; + display: flex; + align-items: center; + gap: 10rpx; .goods-props-item { padding: 4rpx 16rpx; border-radius: 12rpx; - background-color: #fcfcfc; + background-color: #f5f5f5; } } @@ -533,18 +581,21 @@ // 订单操作 .order-handle { .btn-group { + display: flex; + align-items: center; + justify-content: flex-end; .btn-item { border-radius: 10rpx; padding: 8rpx 20rpx; - margin-left: 15rpx; + margin-right: 15rpx; font-size: 26rpx; - float: right; + float: left; color: #383838; border: 1rpx solid #a8a8a8; &:last-child { - margin-left: 0; + margin-right: 0; } &.active {