上传代码

This commit is contained in:
2025-08-18 14:20:34 +08:00
commit 527fd07910
2408 changed files with 427370 additions and 0 deletions

View File

@ -0,0 +1,293 @@
<script setup lang="ts">
import { onLoad } from '@dcloudio/uni-app'
import { ref, reactive, onMounted } from 'vue'
import { apiImageUrl } from '../../API/api'
import orderStateVue from './orderState.vue';
import orderStateZeroVue from './orderStateZero.vue';
import orderStateOneNvue from './orderStateOne.nvue';
import orderStateThree from './orderStateThree.vue';
import orderStateFiveVue from './orderStateFive.vue';
const currentIndex = ref(0);
const tabs = ref([
{ name: '未支付' }, // 对应type=1
{ name: '已支付' }, // 对应type=2
{ name: '已退款' }, // 对应type=3
{ name: '已出餐' }, // 对应type=4
{ name: '已完成' } // 对应type=5
]);
onLoad((options) => {
if (options.type) {
const typeNumber = parseInt(options.type)
currentIndex.value = typeNumber - 1 // 将type值转为数组索引
}
})
const switchTab = (index) => {
currentIndex.value = index;
};
const { safeAreaInsets } = uni.getSystemInfoSync()
</script>
<template>
<view class="tab-menu">
<view class="tab-item"
v-for="(tab, index) in tabs"
:key="index"
:class="{active: currentIndex === index}"
@click="switchTab(index)">
{{ tab.name }}
</view>
</view>
<view class="content">
<block v-if="currentIndex === 0">
<orderStateVue></orderStateVue>
</block>
<block v-if="currentIndex === 1">
<orderStateZeroVue></orderStateZeroVue>
</block>
<block v-if="currentIndex === 2">
<orderStateOneNvue></orderStateOneNvue>
</block>
<block v-if="currentIndex === 3">
<orderStateThree></orderStateThree>
</block>
<block v-if="currentIndex === 4">
<orderStateFiveVue></orderStateFiveVue>
</block>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,431 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { apiImageUrl } from '../../API/api';
const currentPage = ref(1);
const pageSize = ref(10); // 每页显示的数据条数
const totalPage = ref(1); // 总页数
const orderList = ref([]);
// 获取订单列表函数
const getOrder = (page: number) => {
uni.request({
url: `${apiImageUrl}/api/orders/my/page`,
method: 'POST',
data: {
current: page,
endTime: "",
id: "",
pageSize: pageSize.value,
pickupMethod: "",
sortField: "createTime",
sortOrder: "dscend",
startTime: "",
state: 0
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
if (res.data.code === 0) {
const records = res.data.data.records;
orderList.value = records; // 假设你希望反转列表
totalPage.value = Math.ceil(res.data.data.total / pageSize.value);
console.log('订单数据:', orderList.value);
}
},
fail() {
console.log('出错啦');
}
});
};
// 组件挂载时获取第一页订单数据
onMounted(() => {
getOrder(currentPage.value);
});
// 分页器页面变化事件处理
const onPageChange = (e: any) => {
currentPage.value = e.current;
getOrder(e.current);
};
const closeOrder=(order)=>{
console.log(order);
console.log(order.id);
uni.request({
url:apiImageUrl+'/api/orders/cancel',
method:'POST',
data:{
id:order.id
},
success(res) {
console.log("成功");
console.log(res);
},
fail() {
console.log("失败");
}
})
}
const goToPay=(order)=>{
console.log(order);
uni.request({
url:apiImageUrl+'/api/Alipay/payment/create',
method:'GET',
data:{
id:order
},
header: {
'Content-Type': 'application/json', // 确保设置正确的 Content-Type
'cookie': uni.getStorageSync("cookie") || ''
},
success: function (result) {
console.log(result);
console.log(result.data.data);
uni.setStorageSync("tradeNo",result.data.data)
my.tradePay({
tradeNO: result.data.data,
success: (res) => {
console.log('成功调用')
console.log(res);
console.log(res.resultCode);
if(res.resultCode==6001){
console.log("我是6001");
uni.setStorageSync("notPay",orderId);
uni.navigateTo({
url: '/pages/goToPay/goToPay'
});
}
else if(res.resultCode==9000){
uni.setStorageSync('orderId', orderId);
uni.navigateTo({
url: '/pages/testFive/testFive'
});
}
},
fail: (res) => {
my.alert({
content: JSON.stringify(res),
})
console.log('失败');
console.log(res);
}
});
}
})
}
const merchantDetail=(order)=>{
console.log(order.businessVO?.id);
uni.setStorageSync("businessItem",order.businessVO?.id)
const merchantId = order.businessVO?.id;
uni.navigateTo({
url: `/pages/merchant/merchant?merchantId=${merchantId}`,
});
}
</script>
<template>
<view class="viewport">
<!-- 订单列表 -->
<scroll-view scroll-y class="orders">
<view class="card" v-for="(order, index) in orderList" :key="index">
<view class="status">
<text class="title" @click="merchantDetail(order)"> {{ order.businessVO?.businessName}}</text>
<!-- <text>{{ order.totalPrice}}</text> -->
<text>{{ order.id}}</text>
<text class="icon-delete"></text>
</view>
<navigator
v-for="sku in 1"
:key="sku"
class="goods"
:url="`/pagesOrder/detail/detail?id=1`"
hover-class="none"
>
<view class="cover">
<image
mode="aspectFit"
:src="order.businessVO?.businessAvatar"
></image>
</view>
<view class="meta" v-for="(item,index) in order.orderDetailsVOList">
<view class="type">{{item.dishesVO?.dishesName}}--{{item.attributeNames}}</view>
<text class="type">下单即送20积分</text>
</view>
</navigator>
<view class="action">
<template v-if="true">
<view class="button primary" @click="() => closeOrder(order)">取消订单</view>
<view class="button primary" @click="goToPay(order.id)">
去支付
</view>
</template>
<template v-else>
<navigator
class="button secondary"
:url="`/pagesOrder/create/create?orderId=id`"
hover-class="none"
>
再次购买
</navigator>
<view v-if="false" class="button primary">确认收货</view>
</template>
</view>
</view>
<view class="loading-text" :style="{ paddingBottom: safeAreaInsets?.bottom + 'px' }">
{{ true ? '没有更多数据~' : '正在加载...' }}
</view>
</scroll-view>
<!-- 分页组件 -->
<uni-pagination
title="订单列表"
show-icon
:current="currentPage"
:total="totalPage * pageSize"
@change="onPageChange"
/>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,393 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { apiImageUrl } from '../../API/api';
const currentPage = ref(1);
const pageSize = ref(10); // 每页显示的数据条数
const totalPage = ref(1); // 总页数
const orderList = ref([]);
// 获取订单列表函数
const getOrder = (page: number) => {
uni.request({
url: `${apiImageUrl}/api/orders/my/page`,
method: 'POST',
data: {
current: page,
endTime: "",
id: "",
pageSize: pageSize.value,
pickupMethod: "",
sortField: "createTime",
sortOrder: "dscend",
startTime: "",
state: 5
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
if (res.data.code === 0) {
const records = res.data.data.records;
orderList.value = records
totalPage.value = Math.ceil(res.data.data.total / pageSize.value);
console.log('订单数据:', orderList.value);
}
},
fail() {
console.log('出错啦');
}
});
};
onMounted(() => {
getOrder(currentPage.value);
});
// 分页器页面变化事件处理
const onPageChange = (e: any) => {
currentPage.value = e.current;
getOrder(e.current);
};
// 删除订单
const deleteOrder = (order) => {
const orderId = order.id;
uni.request({
url: `${apiImageUrl}/api/orders/delete`,
method: 'POST',
data: {
id: orderId
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
console.log(res);
getOrder(currentPage.value); // 刷新当前页的数据
},
fail(Error) {
console.log(Error);
}
});
};
// 评价订单
const evaluation = (order) => {
uni.setStorageSync("evaluationOrderID",order.id)
uni.navigateTo({
url: '/pages/orderEvaluation/orderEvaluation'
});
};
// 组件挂载时获取第一页订单数据
onMounted(() => {
getOrder(currentPage.value);
});
const tell=(phone)=>{
console.log(phone);
uni.makePhoneCall({
phoneNumber: phone
})
}
const merchantDetail=(order)=>{
console.log(order.businessVO?.id);
uni.setStorageSync("businessItem",order.businessVO?.id)
const merchantId = order.businessVO?.id;
uni.navigateTo({
url: `/pages/merchant/merchant?merchantId=${merchantId}`,
});
}
</script>
<template>
<view class="viewport">
<!-- 订单列表 -->
<scroll-view scroll-y class="orders">
<view class="card" v-for="(order, index) in orderList" :key="index">
<view class="status">
<text class="title" @click="merchantDetail(order)">{{ order.businessVO?.businessName }}</text>
<text>{{ order.id }}</text>
<text class="icon-delete"></text>
</view>
<navigator
v-for="sku in 1"
:key="sku"
class="goods"
:url="`/pagesOrder/detail/detail?id=1`"
hover-class="none"
>
<view class="cover">
<image mode="aspectFit" :src="order.businessVO?.businessAvatar"></image>
</view>
<view class="meta" v-for="(item,index) in order.orderDetailsVOList">
<view class="type">{{ item.dishesVO?.dishesName }}--{{ item.attributeNames }}</view>
<text class="type">下单即送20积分</text>
</view>
</navigator>
<view>
<uni-steps :options="list1" :active="active" />
</view>
<view class="action">
<template v-if="true">
<view class="button primary" @click="() => deleteOrder(order)">删除订单</view>
<view class="button primary" @click="() => tell(order.businessVO?.businessPhone)">拨打电话</view>
<view class="button primary" @click="() => evaluation(order)">去评价</view>
</template>
<template v-else>
<navigator class="button secondary" :url="`/pagesOrder/create/create?orderId=id`" hover-class="none">
再次购买
</navigator>
<view v-if="false" class="button primary">确认收货</view>
</template>
</view>
</view>
<view class="loading-text" :style="{ paddingBottom: safeAreaInsets?.bottom + 'px' }">
{{ true ? '没有更多数据~' : '正在加载...' }}
</view>
</scroll-view>
<!-- 分页组件 -->
<uni-pagination
title="订单列表"
show-icon
:current="currentPage"
:total="totalPage * pageSize"
@change="onPageChange"
/>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,401 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { apiImageUrl } from '../../API/api'
const currentPage = ref(1);
const pageSize = ref(10); // 每页显示的数据条数
const totalItems = ref(0); // 总数据条数
const active = ref(1)
const list1 = reactive([
{ title: '备餐中' },
{ title: '已出餐' },
{ title: '已完成' }
])
const orderList = ref([]);
// 获取订单列表函数
const getOrder = (page: number) => {
uni.request({
url: `${apiImageUrl}/api/orders/my/page`,
method: 'POST',
data: {
current: page,
endTime: "",
id: "",
pageSize: pageSize.value,
pickupMethod: "",
sortField: "createTime",
sortOrder: "dscend",
startTime: "",
state: 2
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
if (res.data.code === 0) {
const records = res.data.data.records;
orderList.value = records; // 假设你希望反转列表
totalItems.value = res.data.data.total; // 更新总数据条数
console.log('订单数据:', orderList.value);
}
},
fail() {
console.log('出错啦');
}
});
};
// 删除订单的方法
const deleteOrder = async (orderId: number | string) => {
try {
const response = await uni.request({
url: `${apiImageUrl}/api/orders/delete`,
method: 'POST',
header: {
'Content-Type': 'application/json',
},
data: JSON.stringify({ id: orderId }),
});
if (response.statusCode === 200) {
console.log(`成功取消订单:${orderId}`);
uni.showModal({
title: '提示',
content: '删除订单成功',
showCancel: false,
success: (res) => {
if (res.confirm) {
getOrder();
}
}
});
} else {
console.error(`无法取消订单:${orderId},错误码:${response.statusCode}`);
}
} catch (error) {
console.error(`发生错误:${error.message}`);
}
};
const onPageChange = (e: any) => {
currentPage.value = e.current;
getOrder(e.current);
};
// 组件挂载时获取第一页订单数据
onMounted(() => {
getOrder(currentPage.value);
});
const orderDetail=(order)=>{
console.log(order);
}
const merchantDetail=(order)=>{
console.log(order.businessVO?.id);
uni.setStorageSync("businessItem",order.businessVO?.id)
const merchantId = order.businessVO?.id;
uni.navigateTo({
url: `/pages/merchant/merchant?merchantId=${merchantId}`,
});
}
</script>
<template>
<view class="viewport">
<!-- 订单列表 -->
<scroll-view scroll-y class="orders">
<view class="card" v-for="(order, index) in orderList" :key="index" @click="orderDetail(order)">
<view class="status">
<text class="title" @click="merchantDetail(order)">{{ order.businessVO?.businessName }}</text>
<text>{{ order.id }}</text>
<text class="icon-delete"></text>
</view>
<navigator
v-for="sku in 1"
:key="sku"
class="goods"
:url="`/pagesOrder/detail/detail?id=1`"
hover-class="none"
>
<view class="cover">
<image mode="aspectFit" :src="order.businessVO?.businessAvatar"></image>
</view>
<view class="meta" v-for="(item,index) in order.orderDetailsVOList">
<view class="type">{{ item.dishesVO?.dishesName }}--{{ item.attributeNames }}</view>
<text class="type">下单即送20积分</text>
</view>
</navigator>
<view>
<uni-steps :options="list1" :active="active" />
</view>
<view class="action">
<template v-if="true">
<view class="button primary" @click="() => deleteOrder(order.id)">删除订单</view>
<view class="button primary">在线联系</view>
</template>
<template v-else>
<navigator class="button secondary" :url="`/pagesOrder/create/create?orderId=id`" hover-class="none">
再次购买
</navigator>
<view v-if="false" class="button primary">确认收货</view>
</template>
</view>
</view>
<view class="loading-text" :style="{ paddingBottom: safeAreaInsets?.bottom + 'px' }">
{{ true ? '没有更多数据~' : '正在加载...' }}
</view>
</scroll-view>
<!-- 分页组件 -->
<uni-pagination
title="订单列表"
show-icon
:current="currentPage"
:total="totalItems"
:pageSize="pageSize"
@change="onPageChange"
/>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,373 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue'
import { apiImageUrl } from '../../API/api'
// 分页相关变量
const currentPage = ref(1); // 当前页码
const pageSize = ref(10); // 每页显示的数据条数
const totalItems = ref(0); // 总数据条数
const orderList = ref([]);
// 拨打电话
const tell = (phone: string) => {
console.log(phone);
uni.makePhoneCall({
phoneNumber: phone
});
};
// 确认收货
const obtion = (order: any) => {
console.log(order.id);
uni.request({
url: `${apiImageUrl}/api/orders/update/state/user`,
method: 'POST',
data: {
id: order.id
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
};
// 获取订单列表函数
const getOrder = (page: number) => {
uni.request({
url: `${apiImageUrl}/api/orders/my/page`,
method: 'POST',
data: {
current: page,
endTime: "",
id: "",
pageSize: pageSize.value,
pickupMethod: "",
sortField: "createTime",
sortOrder: "dscend",
startTime: "",
state: 4
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
if (res.data.code === 0) {
const records = res.data.data.records;
orderList.value = records // 假设你希望反转列表
totalItems.value = res.data.data.total; // 更新总数据条数
console.log('订单数据:', orderList.value);
}
},
fail() {
console.log('出错啦');
}
});
};
// 组件挂载时获取订单数据
const onPageChange = (e: any) => {
currentPage.value = e.current;
getOrder(e.current);
};
// 组件挂载时获取第一页订单数据
onMounted(() => {
getOrder(currentPage.value);
});
const merchantDetail=(order)=>{
console.log(order.businessVO?.id);
uni.setStorageSync("businessItem",order.businessVO?.id)
const merchantId = order.businessVO?.id;
uni.navigateTo({
url: `/pages/merchant/merchant?merchantId=${merchantId}`,
});
}
</script>
<template>
<view class="viewport">
<!-- 订单列表 -->
<scroll-view scroll-y class="orders">
<view class="card" v-for="(order, index) in orderList" :key="index">
<view class="status">
<text class="title" @click="merchantDetail(order)">{{ order.businessVO?.businessName }}</text>
<text>{{ order.id }}</text>
<text class="icon-delete"></text>
</view>
<navigator
v-for="sku in 1"
:key="sku"
class="goods"
:url="`/pagesOrder/detail/detail?id=1`"
hover-class="none"
>
<view class="cover">
<image mode="aspectFit" :src="order.businessVO?.businessAvatar"></image>
</view>
<view class="meta" v-for="(item,index) in order.orderDetailsVOList">
<view class="type">{{ item.dishesVO?.dishesName }}--{{ item.attributeNames }}</view>
<text class="type">下单即送20积分</text>
</view>
</navigator>
<view>
<uni-steps :options="list1" :active="active" />
</view>
<view class="action">
<view class="button primary" @click="() => obtion(order)">确认收货</view>
<view class="button primary" @click="() => tell(order.businessVO?.businessPhone)">拨打电话</view>
</view>
</view>
<view class="loading-text" :style="{ paddingBottom: safeAreaInsets?.bottom + 'px' }">
{{ true ? '没有更多数据~' : '正在加载...' }}
</view>
</scroll-view>
<!-- 分页组件 -->
<uni-pagination
title="订单列表"
show-icon
:current="currentPage"
:total="totalItems"
:pageSize="pageSize"
@change="onPageChange"
/>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>

View File

@ -0,0 +1,429 @@
<script setup lang="ts">
import { ref, reactive, onMounted, onUnmounted, computed } from 'vue';
import { apiImageUrl } from '../../API/api';
// 分页相关变量
const currentPage = ref(1); // 当前页码
const pageSize = ref(10); // 每页显示的数据条数
const totalItems = ref(0); // 总数据条数
const active = ref(1);
const list1 = reactive([
{ title: '备餐中' },
{ title: '已出餐' },
{ title: '已完成' }
]);
const orderList = ref([]);
// 获取订单列表函数
const getOrder = (page: number) => {
uni.request({
url: `${apiImageUrl}/api/orders/my/page`,
method: 'POST',
data: {
current: page,
endTime: "",
id: "",
pageSize: pageSize.value,
pickupMethod: "",
sortField: "createTime",
sortOrder: "dscend",
startTime: "",
state: 1
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
if (res.data.code === 0) {
const records = res.data.data.records;
orderList.value = records// 假设你希望反转列表
totalItems.value = res.data.data.total; // 更新总数据条数
console.log('订单数据:', orderList.value);
}
},
fail() {
console.log('出错啦');
}
});
};
// 分页器页面变化事件处理
const onPageChange = (e: any) => {
currentPage.value = e.current;
getOrder(e.current);
};
// 组件挂载时获取第一页订单数据
onMounted(() => {
getOrder(currentPage.value);
});
// 退款
const refund = (order: any) => {
console.log(order.pickupCode);
uni.setStorageSync('pickupCode', order.pickupCode);
uni.setStorageSync('refundId', order.id);
uni.navigateTo({
url: '/pages/refund/refund'
});
};
// 定义属性
const showButton = ref(true);
const countdownTime = ref(180); // 三分钟以秒为单位
// 创建计时器
let intervalId;
onMounted(() => {
intervalId = setInterval(() => {
if (countdownTime.value > 0) {
countdownTime.value--;
} else {
clearInterval(intervalId);
showButton.value = false;
}
}, 1000);
});
onUnmounted(() => {
clearInterval(intervalId);
});
// 拨打电话
const tell = (phone: string) => {
console.log(phone);
uni.makePhoneCall({
phoneNumber: phone
});
};
// 确认收货
const obtion = (order: any) => {
console.log(order.id);
uni.request({
url: `${apiImageUrl}/api/orders/update/state/user`,
method: 'POST',
data: {
id: order.id
},
header: {
'Content-Type': 'application/json',
'cookie': uni.getStorageSync("cookie") || ''
},
success(res) {
console.log(res);
},
fail(err) {
console.log(err);
}
});
};
const merchantDetail=(order)=>{
console.log(order.businessVO?.id);
uni.setStorageSync("businessItem",order.businessVO?.id)
const merchantId = order.businessVO?.id;
uni.navigateTo({
url: `/pages/merchant/merchant?merchantId=${merchantId}`,
});
}
</script>
<template>
<view class="viewport">
<!-- 订单列表 -->
<scroll-view scroll-y class="orders">
<view class="card" v-for="(order, index) in orderList" :key="index">
<view class="status">
<text class="title" @click="merchantDetail(order)">{{ order.businessVO?.businessName }}</text>
<text>{{ order.id }}</text>
<text class="icon-delete"></text>
</view>
<navigator
v-for="sku in 1"
:key="sku"
class="goods"
:url="`/pagesOrder/detail/detail?id=1`"
hover-class="none"
>
<view class="cover">
<image mode="aspectFit" :src="order.businessVO?.businessAvatar"></image>
</view>
<view class="meta" v-for="(item, index) in order.orderDetailsVOList">
<view class="type">{{ item.dishesVO?.dishesName }}--{{ item.attributeNames }}</view>
<text class="type">下单即送20积分</text>
</view>
</navigator>
<view>
<uni-steps :options="list1" :active="active" />
</view>
<view class="action">
<template v-if="true">
<view class="button primary" @click="() => obtion(order)">确认收货</view>
<view class="button primary" @click="() => tell(order.businessVO?.businessPhone)">拨打电话</view>
<view class="button primary" v-if="showButton" @click="() => refund(order)">
去退款
</view>
</template>
<template v-else>
<navigator class="button secondary" :url="`/pagesOrder/create/create?orderId=id`" hover-class="none">
再次购买
</navigator>
<view v-if="false" class="button primary">确认收货</view>
</template>
</view>
</view>
<view class="loading-text" :style="{ paddingBottom: safeAreaInsets?.bottom + 'px' }">
{{ true ? '没有更多数据~' : '正在加载...' }}
</view>
</scroll-view>
<!-- 分页组件 -->
<uni-pagination
title="订单列表"
show-icon
:current="currentPage"
:total="totalItems"
:pageSize="pageSize"
@change="onPageChange"
/>
</view>
</template>
<style lang="scss">
page {
height: 100%;
overflow: hidden;
}
.viewport {
height: 100%;
display: flex;
flex-direction: column;
background-color: #fff;
}
.tabs {
display: flex;
justify-content: space-around;
line-height: 60rpx;
margin: 0 10rpx;
background-color: #fff;
box-shadow: 0 4rpx 6rpx rgba(240, 240, 240, 0.6);
position: relative;
z-index: 9;
.item {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #262626;
}
.cursor {
position: absolute;
left: 0;
bottom: 0;
width: 20%;
height: 6rpx;
padding: 0 50rpx;
background-color: #4095e5;
transition: all 0.4s;
}
}
.swiper {
background-color: #4095e5;
}
.orders {
.card {
min-height: 100rpx;
padding: 20rpx;
margin: 20rpx 20rpx 0;
border-radius: 10rpx;
background-color: #fff;
&:last-child {
padding-bottom: 40rpx;
}
}
.status {
display: flex;
align-items: center;
justify-content: space-between;
font-size: 28rpx;
color: #999;
margin-bottom: 15rpx;
.title {
color: #343434;
font-weight: 700;
flex: 1;
}
.primary {
color: #ff9240;
}
.icon-delete {
line-height: 1;
margin-left: 10rpx;
padding-left: 10rpx;
border-left: 1rpx solid #e3e3e3;
}
}
.goods {
display: flex;
margin-bottom: 20rpx;
.cover {
width: 170rpx;
height: 170rpx;
margin-right: 20rpx;
border-radius: 10rpx;
overflow: hidden;
position: relative;
}
.quantity {
position: absolute;
bottom: 0;
right: 0;
line-height: 1;
padding: 6rpx 4rpx 6rpx 8rpx;
font-size: 24rpx;
color: #fff;
border-radius: 10rpx 0 0 0;
background-color: rgba(0, 0, 0, 0.6);
}
.meta {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
}
.name {
height: 80rpx;
font-size: 26rpx;
color: #444;
}
.type {
line-height: 1.8;
padding: 0 15rpx;
margin-top: 10rpx;
font-size: 24rpx;
align-self: flex-start;
border-radius: 4rpx;
color: #888;
background-color: #f7f7f8;
}
.more {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 22rpx;
color: #333;
}
}
.action {
display: flex;
justify-content: flex-end;
align-items: center;
padding-top: 20rpx;
.button {
width: 180rpx;
height: 60rpx;
display: flex;
justify-content: center;
align-items: center;
margin-left: 20rpx;
border-radius: 60rpx;
border: 1rpx solid #ccc;
font-size: 26rpx;
color: #444;
}
.secondary {
color: #4095e5;
border-color: #4095e5;
}
.primary {
color: #fff;
background-color: #4095e5;
}
}
.loading-text {
text-align: center;
font-size: 28rpx;
color: #666;
padding: 20rpx 0;
}
}
image {
width: 100%;
height: 100%;
border-radius: 20px;
}
.status-btn {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
height: 92rpx;
margin: 30rpx;
background-color: #007AFF;
}
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 15px;
flex-direction: row;
}
.tab-menu {
display: flex;
justify-content: space-around;
padding: 10px 0;
background-color: #f5f5f5;
}
.tab-item {
padding: 10px;
cursor: pointer;
}
.tab-item.active {
color: #007aff;
font-weight: bold;
}
</style>