订单搜索

parent 5603a2bb
<template> <template>
<view class="container"> <view class="container">
<Header title="全部订单"></Header> <!-- 顶部搜索框-->
<view class="tabs"> <view class="top">
<wd-tabs v-model="tab" animated :lineWidth="38" :lineHeight="3" @change="handleChange"> <wd-icon
class="icon"
name="thin-arrow-left"
color="#000"
size="32rpx"
@click="handleBack"
></wd-icon>
<view class="searchBox">
<view class="search">
<wd-icon name="search" size="30rpx" color="#999"></wd-icon>
<input
type="text"
:value="catalog.keyword"
class="text"
placeholder="搜索我的订单"
placeholder-style="font-size:28rpx;"
@confirm="handleSearch"
@input="handleInput"
confirm-type="搜索"
/>
</view>
<wd-icon
name="error-fill"
size="30rpx"
color="#999"
v-if="catalog.keyword"
@tap="handleClear"
></wd-icon>
</view>
</view>
<view class="tabs" v-if="orderDic">
<wd-tabs v-model="tab" animated :lineWidth="38" :lineHeight="3" @change="handleChange" sticky>
<block v-for="item in tabs" :key="item.value"> <block v-for="item in tabs" :key="item.value">
<wd-tab :title="`${item.name}`" :name="item.value"> <wd-tab :title="`${item.name}`" :name="item.value">
<view class="content" v-if="dataList.length > 0"> <view class="content" v-if="dataList.length > 0">
<view class="box" v-for="(item, index) in dataList" :key="index"> <view class="box" v-for="(item, index) in dataList" :key="index">
<view class="header" @click="toShopDetail(item)"> <view class="header" @click="handleDetail(item)">
<view class="left"> <view class="left">
<image src="@/static/order/shop.png" /> <text
class="icon"
:style="{ 'background-color': iconList[item.orderType].color }"
>
{{ iconList[item.orderType].text }}
</text>
<!-- <image src="@/static/order/shop.png" /> -->
<view class="title">{{ item.shopName }}</view> <view class="title">{{ item.shopName }}</view>
</view> </view>
<view class="right"> <view class="right">
<span class="status">{{ stateList[item.status].label }}</span> <span class="status">{{ stateList[item.orderType][item.status].label }}</span>
<wd-count-down <wd-count-down
:time="item.countDown" :time="item.countDown"
:format="format" :format="format"
...@@ -23,7 +60,7 @@ ...@@ -23,7 +60,7 @@
</view> </view>
</view> </view>
<view class="info" @click="handleDetail(item.orderNumber)"> <view class="info" @click="handleDetail(item)">
<image mode="aspectFill" :src="fileDomain + item.orderItems[0].pic" /> <image mode="aspectFill" :src="fileDomain + item.orderItems[0].pic" />
<view class="info-box"> <view class="info-box">
<view class="text">下单时间:{{ item.createTime.slice(0, 16) }}</view> <view class="text">下单时间:{{ item.createTime.slice(0, 16) }}</view>
...@@ -122,7 +159,7 @@ ...@@ -122,7 +159,7 @@
</template> </template>
<script setup> <script setup>
import Header from './components/Header/index.vue'; // import Header from './components/Header/index.vue';
import Payment from './components/Payment/index.vue'; import Payment from './components/Payment/index.vue';
import { import {
getOrderList, getOrderList,
...@@ -132,19 +169,32 @@ import { ...@@ -132,19 +169,32 @@ import {
getOrderDetail, getOrderDetail,
} from '@/api/order'; } from '@/api/order';
import { getOrderDic } from '@/utils/orderDic'; import { getOrderDic } from '@/utils/orderDic';
import { orderStatus, signIn } from '@/utils/signIn';
import testJson from '@/static/json/test.json';
import { getTokenUser } from '@/api/index';
import { getToken } from '@/utils/auth';
const fileDomain = import.meta.env.VITE_APP_IMG_URL; const fileDomain = import.meta.env.VITE_APP_IMG_URL;
const stateList = ref(); const stateList = ref({});
onLoad((options) => { const orderDic = ref();
const orderDic = getOrderDic(); onLoad(async (options) => {
stateList.value = orderDic.reduce((obj, item) => { // await signIn();
obj[item.baseStatus] = item; if (!getToken()) await signIn2();
return obj; if (!getOrderDic()) await orderStatus();
}, {}); orderDic.value = getOrderDic();
orderDic.value.baseOrder[0].value = 'all';
for (const key in orderDic.value) {
const data = orderDic.value[key].reduce((obj, item) => {
obj[item.baseStatus] = item;
return obj;
}, {});
stateList.value[key] = data;
}
if (options.status) { if (options.status) {
tab.value = options.status; tab.value = options.status;
} }
getList(); await getList();
}); });
const tabs = ref([ const tabs = ref([
...@@ -164,10 +214,10 @@ const tabs = ref([ ...@@ -164,10 +214,10 @@ const tabs = ref([
name: '待评价', name: '待评价',
value: 'not_eval', value: 'not_eval',
}, },
{ // {
name: '已完成', // name: '已完成',
value: 'complete', // value: 'complete',
}, // },
{ {
name: '退款/售后', name: '退款/售后',
value: 'after_sales', value: 'after_sales',
...@@ -175,6 +225,21 @@ const tabs = ref([ ...@@ -175,6 +225,21 @@ const tabs = ref([
]); ]);
const tab = ref('all'); const tab = ref('all');
const iconList = ref({
logistics: {
color: '#FF0909',
text: '物流',
},
store: {
color: '#FF4C0D',
text: '到店',
},
takeaway: {
color: '#FFB023',
text: '外卖',
},
});
onShow(() => { onShow(() => {
if (pendingPaymentOrder.value) { if (pendingPaymentOrder.value) {
// 查询订单状态决定是否支付 // 查询订单状态决定是否支付
...@@ -292,6 +357,26 @@ const initDataList = () => { ...@@ -292,6 +357,26 @@ const initDataList = () => {
}); });
}; };
/**
* 搜索订单
*/
const handleSearch = (e) => {
catalog.keyword = e.detail.value;
initDataList().then(() => {
getList();
});
};
const handleInput = (e) => {
catalog.keyword = e.detail.value;
};
const handleClear = () => {
catalog.keyword = '';
initDataList().then(() => {
getList();
});
};
/** /**
* 删除订单 * 删除订单
* @param {*} orderNumber * @param {*} orderNumber
...@@ -415,11 +500,16 @@ const onFinish = async (orderNumber) => { ...@@ -415,11 +500,16 @@ const onFinish = async (orderNumber) => {
}); });
}; };
const handleDetail = (id) => { const handleDetail = (item) => {
// 清空查询待付款状态 // 清空查询待付款状态
pendingPaymentOrder.value = null; pendingPaymentOrder.value = null;
if (item.orderType === 'logistics') {
uni.navigateTo({
url: `pages/assistingAgriculture/order/detail?orderNumber=${item.orderNumber}`,
});
}
uni.navigateTo({ uni.navigateTo({
url: `/pages/order/detail?orderNumber=${id}`, url: `/pages/order/detail?orderNumber=${item.orderNumber}`,
}); });
}; };
...@@ -489,6 +579,25 @@ const toShopDetail = (item) => { ...@@ -489,6 +579,25 @@ const toShopDetail = (item) => {
url: `/pages/shop/shop?shopId=${item.shopId}`, url: `/pages/shop/shop?shopId=${item.shopId}`,
}); });
}; };
// 登录
const signIn2 = () => {
xma.showLoading({
title: '加载中',
mask: true,
});
return getTokenUser(testJson).then((res) => {
const token = res.data.access_token;
const userInfo = res.data.user_info;
xma.setStorageSync('Authorization', token);
xma.setStorageSync('userInfo', userInfo);
console.log('登录...');
});
};
const handleBack = () => {
uni.navigateBack();
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
...@@ -501,9 +610,9 @@ page { ...@@ -501,9 +610,9 @@ page {
margin: 0 auto; margin: 0 auto;
.tabs { .tabs {
padding-top: 88rpx; padding-top: 108rpx;
.wd-tabs { &:deep(.wd-tabs) {
background-color: #f5f5f5; background-color: #f5f5f5;
} }
...@@ -518,12 +627,52 @@ page { ...@@ -518,12 +627,52 @@ page {
} }
} }
.top {
height: 108rpx;
position: fixed;
width: 100%;
z-index: 999;
display: flex;
background-color: #f5f5f5;
margin: 0 auto;
align-items: center;
padding: 0 30rpx;
gap: 14rpx;
.searchBox {
width: 492rpx;
height: 66rpx;
background: #f3f3f3;
border-radius: 33rpx;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0rpx 28rpx;
background-color: #fff;
.search {
gap: 10rpx;
display: flex;
align-items: center;
.text {
margin-left: 10rpx;
font-family:
PingFang SC,
PingFang SC;
font-weight: 500;
font-size: 28rpx;
}
}
}
}
.content { .content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 20rpx; padding: 10rpx 20rpx 20rpx;
gap: 24rpx; gap: 24rpx;
.box { .box {
...@@ -544,7 +693,7 @@ page { ...@@ -544,7 +693,7 @@ page {
.left { .left {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 6rpx; gap: 12rpx;
font-weight: bold; font-weight: bold;
image { image {
...@@ -552,6 +701,15 @@ page { ...@@ -552,6 +701,15 @@ page {
width: 38rpx; width: 38rpx;
} }
.icon {
font-family: PingFang SC;
font-weight: 500;
font-size: 24rpx;
color: #ffffff;
border-radius: 8rpx;
padding: 2rpx 8rpx;
}
.title { .title {
color: #333; color: #333;
font-size: 32rpx; font-size: 32rpx;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment