This commit is contained in:
mkm 2024-08-08 17:16:48 +08:00
parent 5b6d14c85b
commit 551b0b49b5
5 changed files with 623 additions and 30 deletions

View File

@ -3,9 +3,9 @@ let WSS_URL
import store from "@/store/user.js" import store from "@/store/user.js"
// 环境 // 环境
// let env = "dev" // let env = "dev"
let env = "prod" // let env = "prod"
// let env = "release"; // let env = "release";
// let env = "local"; let env = "local";
switch (env) { switch (env) {
case 'dev': case 'dev':

View File

@ -197,6 +197,13 @@
"navigationBarTitleText": "设置密码", "navigationBarTitleText": "设置密码",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},
{
"path" : "delivery/index",
"style" :
{
"navigationBarTitleText" : "配送员订单"
}
} }
] ]
}, },

View File

@ -123,6 +123,8 @@
<up-cell title="我的地址" :isLink="true" url="/pagesOrder/addressList/addressList"></up-cell> <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="/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="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-group> </up-cell-group>
</view> </view>

View File

@ -0,0 +1,596 @@
<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"
:actionStyle="{color: '#20b128'}"></up-search>
</view>
<up-tabs :current="tabsActive" :list="tablist" lineColor="#20b128" :scrollable="false"
:activeStyle=" { color: '#20b128', fontWeight: 'bold' }" @change="changeTab"></up-tabs>
</up-sticky>
<swiper class="swiper-box" :current="swiperCurrent" @animationfinish="animationfinish">
<swiper-item class="swiper-item" v-for="(list, k) in orderList" :key="k">
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="loadMoreGood"
@refresherrefresh="refresherrefresh(1)" :refresher-triggered="triggered" refresher-enabled
refresher-background="#F6F6F6">
<view class="page-box">
<view v-if="list.length>0" class="list">
<good v-for="(item, index) in list" :datas="item" :key="index" :type="k" :status="status"
:order_id='item.order_id' @cancleOrder="cancleOrder" @takeOrder="takeOrder"
@rePay="rePay" @purchaseAgain="purchaseAgain" @applyAfterSales="applyAfterSales"
@showVerifyFn='showVerifyFn'></good>
</view>
<view v-if="!where[k].loading&&list.length==0" style="padding-top: 100rpx;">
<up-empty text="订单空空如也"
icon="https://lihai001.oss-cn-chengdu.aliyuncs.com/def/29955202404260944367594.png">
</up-empty>
</view>
<view v-else-if="where[k].loadend" style="padding-top: 100rpx;">
<view style="text-align: center;color: #999;">没有更多了</view>
</view>
<view v-if="where[k].loading"
style="padding-top: 100rpx;display: flex;flex-direction: column;align-items: center;">
<up-loading-icon mode="circle"></up-loading-icon>
<view style="margin-top: 20rpx;color: #999;">加载中</view>
</view>
<view style="width: 100%;height: 300rpx;"></view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
<orderCanclePopup :show="showCancel" @close="showCancel=false" @change="submitCancel" />
<modal :show="showTake" title="确认收货" content="请确认您已收到货" @close="showTake=false" @change="confirmReceipt" />
</template>
<script setup>
import {
onLoad,
onUnload,
onPullDownRefresh
} from "@dcloudio/uni-app"
import {
ref
} from 'vue';
import good from "../order/component/good.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';
import {
cancelOrderApi,
rePaymentApi,
confirmReceiptApi,
orderListApi,
purchaseAgainApi
} from "@/api/order.js"
import {
userInfoApi
} from "@/api/user.js"
const tabsActive = ref(0)
const changeTab = ({
index
}) => {
tabsActive.value = index;
swiperCurrent.value = index;
}
const tablist = ref([{
name: '全部'
}, {
name: '退款/售后'
}]);
const swiperCurrent = ref(0);
const animationfinish = ({
detail: {
current
}
}) => {
swiperCurrent.value = current;
tabsActive.value = current;
if (swiperCurrent.value == 0 && orderList.value[0].length == 0) getOrderList(0, '', ''); //
if (swiperCurrent.value == 4 && orderList.value[4].length == 0) getOrderList(4, -1, 1); //退
}
const showVerifyPop = ref(false)
const orderData = ref({})
const showVerifyFn = (e) => {
showVerifyPop.value = true
orderData.value = e
}
//
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);
let takeId = "";
const takeOrder = (e) => {
takeId = e.id;
showTake.value = true;
}
//
const confirmReceipt = () => {
confirmReceiptApi({
order_id: takeId
}).then(res => {
showTake.value = false;
uni.$u.toast('确认收货成功');
reloadAll();
})
}
//
const purchaseAgain = (e) => {
purchaseAgainApi({
order_id: e.id
}).then(res => {
uni.$u.toast('已加入购物车');
uni.navigateTo({
url: '/pages/cart/cart'
})
})
}
// <!--sb-->
const refundShow = ref(false);
const goodsList = ref([]); //
const afterSalesType = ref(''); // 0 1 2
const orderId = ref('');
//
const applyAfterSales = (item) => {
refundShow.value = true;
goodsList.value = item.goods_list;
orderId.value = item.id;
}
//
const onPageToAfterSales = () => {
if (afterSalesType.value === '') return uni.$u.toast('请选择售后类型');
if (!goodsList.value || goodsList.value.length == 0) return uni.$u.toast('暂无可申请售后的商品');
let goods = goodsList.value.find(i => i.isSelected);
if (goods == undefined) return uni.$u.toast('请选择需要申请售后的商品');
let ids = [];
let goodsListSel = [];
goodsList.value.map(i => {
if (i.isSelected) {
ids.push(i.old_cart_id);
goodsListSel.push(i);
}
});
uni.navigateTo({
url: "/pages/afterSales/afterSales",
success(res) {
refundShow.value = false; // close modal
res.eventChannel.emit('orderDetail', {
id: orderId.value, //id
old_cart_id: ids,
refund_type: afterSalesType.value,
goodsList: goodsListSel
})
}
})
}
//
const onChooseGoods = (item) => {
if (item.hasOwnProperty('isSelected')) {
item.isSelected = !item.isSelected;
} else {
item.isSelected = true;
}
}
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("不是微信支付")
}
//
const where = ref([{
page_no: 1,
page_size: 25,
loading: false,
loadend: false
}, {
page_no: 1,
page_size: 25,
loading: false,
loadend: false
},
{
page_no: 1,
page_size: 25,
loading: false,
loadend: false
},
{
page_no: 1,
page_size: 25,
loading: false,
loadend: false
},
{
page_no: 1,
page_size: 25,
loading: false,
loadend: false
}
])
const keyword = ref('')
const orderList = ref([
[],
[],
[],
[],
[]
])
const getOrderList = (type = 0, status = '', paid = 1, ifPullReFresh = false) => {
if (where.value[type].loadend) return;
where.value[type].loading = true;
orderListApi({
page_no: where.value[type].page_no,
page_size: where.value[type].page_size,
order_id: keyword.value,
status: status,
paid: paid
}).then(res => {
if (where.value[type].page_no == 1) orderList.value[type] = [];
orderList.value[type] = [...orderList.value[type], ...res.data.lists];
if (res.data.lists.length < where.value[type].page_size) where.value[type].loadend = true;
where.value[type].page_no++;
where.value[type].loading = false;
if (ifPullReFresh) uni.stopPullDownRefresh();
}).catch(err => {
where.value[type].loading = false;
})
}
const loadMoreGood = () => {
if (swiperCurrent.value == 0) getOrderList(0, '', ''); //
if (swiperCurrent.value == 1) getOrderList(1, '', 0); //
if (swiperCurrent.value == 2) getOrderList(2, 1, 1); //
if (swiperCurrent.value == 3) getOrderList(3, 2, 1); //
if (swiperCurrent.value == 4) getOrderList(4, -1, 1); //退
}
//
const searchOn = (ifPullReFresh = false) => {
orderList.value[+swiperCurrent.value] = [];
console.log(swiperCurrent.value)
where.value[+swiperCurrent.value].page_no = 1;
where.value[+swiperCurrent.value].loadend = false;
if (swiperCurrent.value == 0) getOrderList(0, '', '', ifPullReFresh); //
if (swiperCurrent.value == 1) getOrderList(1, '', 0, ifPullReFresh); //
if (swiperCurrent.value == 2) getOrderList(2, 1, 1, ifPullReFresh); //
if (swiperCurrent.value == 3) getOrderList(3, 2, 1, ifPullReFresh); //
if (swiperCurrent.value == 4) getOrderList(4, -1, 1, ifPullReFresh); //退
}
let back = 0;
const navBack = () => {
uni.navigateBack({
delta: back ? +back : 0
})
}
const reloadAll = () => { //
where.value.forEach(item => {
item.page_no = 1;
item.loadend = false;
});
getOrderList(0, '', ''); //
getOrderList(1, '', 0); //
getOrderList(2, 1, 1); //
getOrderList(3, 2, 1); //
getOrderList(4, -1, 1); //退
}
onLoad((options) => {
if (options.type) {
tabsActive.value = +options.type;
swiperCurrent.value = +options.type;
searchOn();
}
if (options.back) back = options.back;
uni.$on('reLoadOrderList', reloadAll);
})
onUnload(() => {
uni.$off('reLoadOrderList', reloadAll)
})
const triggered = ref(false);
let flag = false
const refresherrefresh = (type = 1) => {
if (flag) return
flag = true
triggered.value = true;
searchOn()
console.log("别恶心我了")
setTimeout(() => {
triggered.value = false;
flag = false
}, 500)
}
</script>
<style lang="scss">
.wrap {
display: flex;
flex-direction: column;
height: calc(100vh - var(--window-top));
width: 100%;
}
.swiper-box {
flex: 1;
}
.swiper-item {
height: 100%;
}
.page-box {
margin: 20rpx;
}
.address-popup {
// padding: 30rpx;
background-color: #F6F6F6;
.head-title {
font-weight: bold;
text-align: center;
margin-bottom: 20rpx;
padding: 20rpx;
}
.afterSales-type {
margin: 0 20rpx 20rpx;
background: #FFFFFF;
border-radius: 16rpx;
padding: 20rpx;
box-sizing: border-box;
.afterSales-type-title {
font-size: 32rpx;
color: #444444;
margin-bottom: 28rpx;
}
.afterSales-type-con {
display: flex;
align-items: center;
margin-bottom: 20rpx;
.afterSales-type-item {
width: 200rpx;
height: 70rpx;
line-height: 70rpx;
border-radius: 12rpx;
color: #777777;
border: 2rpx solid #D3D3D3;
font-size: 28rpx;
text-align: center;
&:not(:nth-last-child(1)) {
margin-right: 24rpx;
}
}
.fuck-active {
color: #FC452F;
border: 2rpx solid #FC452F;
font-weight: 600;
}
}
.afterSales-type-tip {
font-size: 20rpx;
color: #FC452F;
}
}
.scroll-wrap {
margin: 0 20rpx;
background: #FFFFFF;
border-radius: 16rpx;
padding: 20rpx 20rpx 1rpx;
box-sizing: border-box;
.goods {
.goods-item {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 30rpx;
.goods-item-left {
display: flex;
align-items: center;
.goods-item-left-img {
margin-right: 20rpx;
}
.goods-item-left-info {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 164rpx;
.goods_name {
font-size: 28rpx;
color: #060606;
max-width: 400rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.goods_detail {
display: flex;
align-items: center;
.goods-detail_num {
margin-right: 30rpx;
font-size: 28rpx;
color: #333333;
}
.goods_detail_price {
display: flex;
.symbol {
align-self: flex-end;
font-size: 22rpx;
color: #333333;
}
.numbers {
font-size: 32rpx;
color: #333333;
}
}
}
}
}
.goods-item-right {
image {
width: 48rpx;
height: 48rpx;
}
}
}
}
}
}
@keyframes disappear {
to {
opacity: 0;
/* 渐隐 */
transform: scale(0);
/* 缩小 */
}
}
.mask {
position: fixed;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, .5);
top: 0;
left: 0;
z-index: 99999 !important;
}
</style>

View File

@ -83,13 +83,17 @@
</view> </view>
</view> </view>
</view> </view>
<view class="m-card good-info"> <view class="m-card good-info">
<view class="head-title">价格明细</view> <view class="head-title">价格明细</view>
<view class="row"> <view class="row">
<view>商品总价 <text>共计{{ cartList.length }}款商品</text></view> <view>商品总价 <text>共计{{ cartList.length }}款商品</text></view>
<view> <view v-if="orderInfo.pay_price">
<text>¥</text>{{ c_price(orderInfo.pay_price, 0) }}<text>.{{ c_price(orderInfo.pay_price, 1) }}</text> <text>¥</text>{{ c_price(orderInfo.pay_price, 0) }}<text>.{{ c_price(orderInfo.pay_price, 1) }}</text>
</view> </view>
<view v-else>
<up-skeleton :loading="true" :animate="true" ></up-skeleton>
</view>
</view> </view>
<view class="row"> <view class="row">
<view>运费</view> <view>运费</view>
@ -255,10 +259,13 @@
import ZyPasswordboard from '@/uni_modules/zy-passwordboard/components/zy-passwordboard/zy-passwordboard.vue'; import ZyPasswordboard from '@/uni_modules/zy-passwordboard/components/zy-passwordboard/zy-passwordboard.vue';
const userInfo = useUserStore().userInfo; const userInfo = useUserStore().userInfo;
const shop_Info = ref({})
// //
let STORE_INFO = uni.getStorageSync('STORE_INFO'); let STORE_INFO = uni.getStorageSync('STORE_INFO');
if (STORE_INFO) if (STORE_INFO){
STORE_INFO = JSON.parse(STORE_INFO) shop_Info.value = JSON.parse(STORE_INFO)
}
const cartStore = useCartStore(); const cartStore = useCartStore();
const reservation_time = ref('') const reservation_time = ref('')
@ -344,23 +351,6 @@
}) })
} }
// getMerchantList();
//
// const LoadAddress = () => {
// uni.getLocation({
// success: (res) => {},
// fail: (err) => {
// uni.$u.toast(', !')
// },
// complete: (res) => {
// myAddressInfo.value.long = res.longitude || "";
// myAddressInfo.value.lat = res.latitude || "";
// getMerchantList();
// }
// })
// }
// LoadAddress();
const changeShop = (e) => { const changeShop = (e) => {
shopInfo.value = e; shopInfo.value = e;
shopListShow.value = false; shopListShow.value = false;
@ -412,13 +402,12 @@
long: "", long: "",
}; };
let reservation = ref(0); let reservation = ref(0);
const shop_Info = ref({})
const cartList = ref([]); const cartList = ref([]);
const orderInfo = ref({}); const orderInfo = ref({});
const checkOrder = (store_id) => { const checkOrder = (store_id) => {
checkOrderApi({ checkOrderApi({
cart_id: cartStore.cartList, cart_id: cartStore.cartList,
store_id: STORE_INFO.id || 0, store_id: shop_Info.value.id || 0,
...location ...location
}).then(res => { }).then(res => {
cartList.value = res.data.cart_list; cartList.value = res.data.cart_list;
@ -447,7 +436,7 @@
}).then(res => { }).then(res => {
reservation.value = res.data.reservation reservation.value = res.data.reservation
}) })
checkOrder(datas.id)
// formData.store_id = datas.id // formData.store_id = datas.id
// formData.store_name = datas.name // formData.store_name = datas.name
}) })
@ -483,7 +472,6 @@
cart_id: cartStore.cartList, cart_id: cartStore.cartList,
address_id: addressInfo.value.address_id, address_id: addressInfo.value.address_id,
pay_type: pay_type.value, pay_type: pay_type.value,
store_id: STORE_INFO.id || 0,
store_id: shop_Info.value.id, store_id: shop_Info.value.id,
shipping_type: orderInfo.value.shipping_type, shipping_type: orderInfo.value.shipping_type,
mark: formData.value.remark, mark: formData.value.remark,
@ -564,8 +552,8 @@
price = price + ''; price = price + '';
return price.split('.')[index] || (index ? '00' : '0'); return price.split('.')[index] || (index ? '00' : '0');
} }
const toastAddressoff=()=>{ const toastAddressoff = () => {
toastAddressShow.value=false; toastAddressShow.value = false;
uni.redirectTo({ uni.redirectTo({
url: '/pagesOrder/settle/settle' url: '/pagesOrder/settle/settle'
}); });
@ -607,7 +595,7 @@
const userLocationfalse = () => { const userLocationfalse = () => {
LocationShow.value = false; LocationShow.value = false;
uni.$u.toast('获取位置当前失败,为你推荐当前门店') uni.$u.toast('获取位置当前失败,为你推荐当前门店')
checkOrder(STORE_INFO.id); checkOrder(shop_Info.value.id);
} }
const opensettings = (a = false) => { const opensettings = (a = false) => {
if (a == false) { if (a == false) {