feat: 添加新订单列表和支付功能,优化订单获取逻辑

This commit is contained in:
mkm 2024-08-13 18:03:39 +08:00
parent 551b0b49b5
commit b11e4aa681
7 changed files with 244 additions and 113 deletions

View File

@ -9,6 +9,10 @@ export const createOrderApi = (data) => {
export const orderListApi = (data) => {
return request.get('/order/order/order_list', data);
}
//门店订单列表
export const storeOrderListApi = (data) => {
return request.get('/order/order/store_order_list', data);
}
//订单详情
export const orderDetailApi = (data) => {

View File

@ -3,9 +3,9 @@ let WSS_URL
import store from "@/store/user.js"
// 环境
// let env = "dev"
// let env = "prod"
let env = "prod"
// let env = "release";
let env = "local";
// let env = "local";
switch (env) {
case 'dev':
@ -17,7 +17,7 @@ switch (env) {
WSS_URL = 'wss://ceshi-multi-store.lihaink.cn/pull'
break;
case 'local':
BASE_URL = 'http://192.168.1.231:8545';
BASE_URL = 'http://192.168.1.22:8545';
WSS_URL = 'wss://ceshi-multi-store.lihaink.cn/pull'
break;
default:

View File

@ -202,7 +202,7 @@
"path" : "delivery/index",
"style" :
{
"navigationBarTitleText" : "配送员订单"
"navigationBarTitleText" : "门店订单"
}
}
]

View File

@ -123,7 +123,7 @@
<up-cell title="我的地址" :isLink="true" url="/pagesOrder/addressList/addressList"></up-cell>
<up-cell title="支付密码" :isLink="true" url="/pagesOrder/setPayPassword/index"></up-cell>
<up-cell title="商品列表" :isLink="true" url="pages/product/product" v-if="userInfo.system_store_id>0"></up-cell>
<up-cell title="配送员订单" :isLink="true" url="pagesOrder/delivery/index" v-if="userInfo.system_store_id>0"></up-cell>
<up-cell title="订单列表" :isLink="true" url="pagesOrder/delivery/index" v-if="userInfo.system_store_id>0"></up-cell>
</up-cell-group>
</view>

View File

@ -55,7 +55,7 @@
const frequentlyList = ref([]);
let text = '没有商品'
let status = ref('loadmore')
let list1 = ['零售', '商户', '会员']
let list1 = ['零售', '商户', '供货价']
let keyword = ref('');
let enable_flex=ref(true)
const where = ref({

View File

@ -0,0 +1,220 @@
<template>
<view class="shop-item">
<view class="item-title" @click="navTo">
<view>{{order_id}}</view>
<view v-if="datas.paid==0">
<text>待付款</text>
</view>
<view v-else>
<text v-if="datas.status==0">待核销</text>
<text v-if="datas.status==1">待核销</text>
<text v-if="datas.status==2||datas.status==3">已完成</text>
</view>
</view>
<view class="item-body" @click="navTo">
<view class="body-content">
<view>
<view v-for="(item,index) in datas.goods_list" :key="index"
style="display: flex;margin-bottom: 20rpx;">
<image class="image" :src="item.image"></image>
<view style="width: 520rpx;">
<view class="" style="display: flex;justify-content: space-between;">
<view>
{{item.store_name}}
</view>
<view style="font-size: 32rpx;">
{{item.price}}
</view>
</view>
<view class="" style="display: flex;justify-content: space-between;">
<view>
{{item.unit_name}}
</view>
<view style="font-size: 32rpx;">
x{{item.cart_num}}
</view>
</view>
</view>
</view>
</view>
<!-- <view
style="display: flex;flex-direction: column;align-items: center;justify-content: center;width: 100rpx;">
<up-icon name="arrow-right-double" color="#20B128"></up-icon>
</view> -->
</view>
<view class="all"> {{datas.goods_count}} 件商品, 总金额 <text>¥{{datas.pay_price}}</text> </view>
</view>
<view class="item-btn">
<view @click="navTo" style="width: 80px;">
<up-button size="small" plain color="#20B128" shape="circle">查看详情</up-button>
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
nextTick
} from "vue"
// 0123)
const props = defineProps({
type: {
type: Number,
default: 0
},
datas: {
type: Object,
default: () => {}
},
status: {
type: String,
default: ''
},
order_id: {
type: String,
default: '0'
}
})
const navTo = () => {
if (props.datas.status == -1) {
uni.navigateTo({
url: "/pages/afterSales/afterSalesOrderDetail",
success(res) {
res.eventChannel.emit('afterSalesDetail', props.datas)
}
})
} else {
uni.navigateTo({
url: `/pagesOrder/detail/detail?type=${props.datas.paid}&id=${props.datas.id}`
})
}
}
const emit = defineEmits(['cancleOrder', 'rePay', 'takeOrder', 'purchaseAgain']);
const cancleOrder = () => {
emit('cancleOrder', props.datas)
}
const takeOrder = () => {
emit('takeOrder', props.datas)
}
const purchaseAgain = () => {
emit('purchaseAgain', props.datas)
}
const rePay = () => {
emit('rePay', props.datas)
}
const applySh = () => {
emit('applyAfterSales', props.datas)
}
const showVerifyFn = () => {
emit('showVerifyFn', props.datas)
}
const showVerifyPop = ref(false)
const options = reactive({
width: 500, // rpx
height: 100, // rpx
code: props.datas.verify_code, //
}, )
</script>
<style lang="scss">
.shop-item {
width: 710rpx;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 14rpx;
padding: 20rpx;
box-sizing: border-box;
.item-title {
display: flex;
justify-content: space-between;
}
.item-body {
margin: 20rpx 0;
.body-content {
display: flex;
justify-content: space-between;
color: #989898;
.image {
width: 120rpx;
height: 120rpx;
margin-right: 20rpx;
border-radius: 14rpx;
}
.title {
display: flex;
justify-content: space-between;
font-size: 28rpx;
color: #444;
}
.tips {
display: flex;
justify-content: space-between;
font-size: 24rpx;
margin-top: 10rpx;
}
}
.all {
text-align: right;
font-size: 26rpx;
text {
color: #F55726;
}
}
}
.item-btn {
display: flex;
justify-content: flex-end;
view {
width: 80rpx;
margin-left: 20rpx;
}
}
.item-close {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #F6F6F6;
padding: 15rpx;
border-radius: 14rpx;
.title {
display: flex;
.type {
font-weight: 600;
margin-right: 20rpx;
}
}
}
}
</style>

View File

@ -1,10 +1,6 @@
<template>
<view class="wrap">
<up-navbar placeholder style="z-index: 100800;" @leftClick="navBack">
<template #center>
<view>订单</view>
</template>
</up-navbar>
<up-sticky bgColor="#fff">
<view style="padding: 10rpx 20rpx 0 20rpx;">
<up-search shape="round" v-model="keyword" @custom="searchOn" @search="searchOn" @clear="searchOn"
@ -58,7 +54,7 @@
import {
ref
} from 'vue';
import good from "../order/component/good.vue";
import good from "./component/goods.vue";
import orderCanclePopup from "@/components/orderCanclePopup.vue"
import modal from "@/components/modal.vue"
import ZyPasswordboard from '@/uni_modules/zy-passwordboard/components/zy-passwordboard/zy-passwordboard.vue';
@ -66,7 +62,7 @@
cancelOrderApi,
rePaymentApi,
confirmReceiptApi,
orderListApi,
storeOrderListApi,
purchaseAgainApi
} from "@/api/order.js"
import {
@ -84,6 +80,10 @@
}
const tablist = ref([{
name: '全部'
},{
name: '待核销'
}, {
name: '已核销'
}, {
name: '退款/售后'
}]);
@ -98,6 +98,8 @@
tabsActive.value = current;
if (swiperCurrent.value == 0 && orderList.value[0].length == 0) getOrderList(0, '', ''); //
if (swiperCurrent.value == 2 && orderList.value[2].length == 0) getOrderList(2, 1, 1); //
if (swiperCurrent.value == 3 && orderList.value[3].length == 0) getOrderList(3, 2, 1); //
if (swiperCurrent.value == 4 && orderList.value[4].length == 0) getOrderList(4, -1, 1); //退
}
@ -109,28 +111,6 @@
}
//
const showCancel = ref(false);
let cancelId = '';
const submitCancel = (e) => {
showCancel.value = false;
cancelOrderApi({
order_id: cancelId,
value: e.name
}).then(res => {
uni.showToast({
title: '取消成功',
icon: 'none'
})
orderList.value[1] = orderList.value[1].filter(item => item.id !== cancelId)
})
}
//
const cancleOrder = (e) => {
cancelId = e.id;
showCancel.value = true;
}
//
const showTake = ref(false);
@ -151,17 +131,7 @@
})
}
//
const purchaseAgain = (e) => {
purchaseAgainApi({
order_id: e.id
}).then(res => {
uni.$u.toast('已加入购物车');
uni.navigateTo({
url: '/pages/cart/cart'
})
})
}
// <!--sb-->
const refundShow = ref(false);
@ -215,78 +185,14 @@
}
}
const pay_type = ref('3')
const rePay = async (e) => {
payFn(e)
return
if (!pay_type.value) return uni.$u.toast('请选择支付方式');
if (pay_type.value == 3 || pay_type.value == 18) {
let res = await userInfoApi()
return res.data.pay_password ? passwordBoardVisible.value = true : showModal.value = true
}
}
//
const password = ref(''); //
const passwordBoardVisible = ref(false);
const passwordBoardProps = {
title: '输入支付密码',
onComplete(value) {
password.value = value
passwordBoardVisible.value = false
console.log(password.value)
// payFn()
}
};
const closeKeyBord = () => {
password.value = ''
}
const payFn = (e) => {
rePaymentApi({
order_id: e.id,
address_id: e.address_id,
mer_id: e.merchant,
pay_type: e.pay_type
}).then(res => {
if (res.data?.nonceStr) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: res.data.signType,
paySign: res.data.paySign,
success: (e) => {
if (e.errMsg == 'requestPayment:ok') {
uni.showToast({
title: '订单支付成功',
icon: 'success'
})
reloadAll();
} else uni.$u.toast('支付失败')
},
fail: (e) => {
uni.$u.toast('用户取消支付')
}
})
} else {
uni.showToast({
title: '订单支付成功',
icon: 'success'
})
reloadAll();
}
}).catch(err => {
uni.$u.toast(err.msg || '网络错误')
})
}
const notWxPay = () => {
alert("不是微信支付")
}
//
@ -331,7 +237,7 @@
const getOrderList = (type = 0, status = '', paid = 1, ifPullReFresh = false) => {
if (where.value[type].loadend) return;
where.value[type].loading = true;
orderListApi({
storeOrderListApi({
page_no: where.value[type].page_no,
page_size: where.value[type].page_size,
order_id: keyword.value,
@ -400,6 +306,7 @@
if (options.back) back = options.back;
uni.$on('reLoadOrderList', reloadAll);
getOrderList(0, '', ''); //
})
onUnload(() => {