From 0d78d2308840c7f787eca2d967733d2510c7052e Mon Sep 17 00:00:00 2001
From: weipengfei <2187978347@qq.com>
Date: Tue, 2 Jul 2024 13:45:58 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0,=E6=96=B0=E5=A2=9E=E5=9C=B0?=
=?UTF-8?q?=E5=8C=BA=E7=AD=9B=E9=80=89=E7=94=A8=E6=88=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/user/component/order.vue | 125 +++++++++++++++++++++++++++--
1 file changed, 118 insertions(+), 7 deletions(-)
diff --git a/src/views/user/component/order.vue b/src/views/user/component/order.vue
index 8ba11d4..1f6d6ba 100644
--- a/src/views/user/component/order.vue
+++ b/src/views/user/component/order.vue
@@ -10,6 +10,7 @@ import { useRouter } from "vue-router";
import mitt from "@/utils/mitt.js";
import moment from "moment";
import add from './add.vue';
+import { apiProvince, apiCity, apiArea, apiStreet, apiVillage, apiBrigade } from '@/api/public'
const userStore = useUserStore();
const props = defineProps({
@@ -29,7 +30,8 @@ const where = ref({
page_no: 1,
page_size: 20,
mobile: "",
- user_ship: ""
+ user_ship: "",
+ street: null
});
const loading = ref(false);
@@ -42,6 +44,9 @@ const getOrderList = (reload = false) => {
if (reload) where.value.page_no = 1;
else if (loadEnd.value || loading.value) return;
loading.value = true;
+ if(where.value.mobile == '' && where.value.user_ship == ''){
+ where.value.store_id = userStore.userInfo.store_id;
+ } else where.value.store_id = null;
userListsApi(where.value)
.then((res) => {
if (reload) orderList.value = res.data.lists;
@@ -83,9 +88,110 @@ const getUserShip = () => {
}
getUserShip()
+const resetWhere = ()=>{
+ where.value.mobile = "";
+ where.value.user_ship = "";
+ where.value.street = null;
+ selectedValues.value = [];
+ getOrderList(true);
+}
+
+
+const selectedValues = ref([])
+const options = ref([]);
+// 异步加载数据的方法
+const loadOptions = async (node, resolve) => {
+ const level = node.level;
+ let response;
+ if (level !== 0 && !node.data.code) return resolve([]);
+ // if (level === 0) {
+ // response = await apiProvince();
+ // response = response.data.map((item) => {
+ // return {
+ // code: item.province_code,
+ // name: item.province_name
+ // }
+ // })
+ // } else
+ if (level === 0) {
+ response = await apiCity({
+ province_code: 510000 // 四川省
+ });
+ response = response.data.map((item) => {
+ return {
+ code: item.city_code,
+ name: item.city_name
+ }
+ })
+ } else if (level === 1) {
+ response = await apiArea({
+ city_code: node.data.code
+ });
+ response = response.data.map((item) => {
+ return {
+ code: item.area_code,
+ name: item.area_name
+ }
+ })
+ }
+ else if (level === 2) {
+ response = await apiStreet({
+ area_code: node.data.code
+ });
+ response = response.data.map((item) => {
+ return {
+ code: item.street_code,
+ name: item.street_name,
+ leaf: true
+ }
+ })
+ }
+ else if (level === 3) {
+ response = await apiVillage({
+ street_code: node.data.code
+ });
+ response = response.data.map((item) => {
+ return {
+ code: item.village_code,
+ name: item.village_name,
+ }
+ })
+ }
+ else if (level === 4) {
+ response = await apiBrigade({
+ village_code: node.data.code
+ });
+ response = response.data.map((item) => {
+ return {
+ code: item.id,
+ name: item.brigade_name,
+ leaf: true
+ }
+ })
+ }
+
+ resolve(response);
+};
+const propOptions = {
+ value: 'code',
+ label: 'name',
+ children: 'children',
+ multiple: false,
+ lazy: true,
+ lazyLoad: loadOptions
+};
+const changeAddress = ()=>{
+ if(selectedValues.value.length){
+ where.value.street = selectedValues.value[selectedValues.value.length - 1];
+ }else{
+ where.value.street = "";
+ }
+ getOrderList(true);
+}
+
onMounted(() => {
- mitt.on('re-load-user-list', () => {
- getOrderList(true);
+ mitt.on('re-load-user-list', (e) => {
+ if(e) getOrderList(true);
})
})
onUnmounted(() => {
@@ -108,10 +214,15 @@ onUnmounted(() => {