Przeglądaj źródła

fix:冲突解决

贾宇博 3 tygodni temu
rodzic
commit
13cec9bad8

Plik diff jest za duży
+ 30050 - 0
components/pickerAddress/address.js


+ 127 - 85
components/pickerAddress/pickerAddress.vue

@@ -1,106 +1,148 @@
 <template>
 	<!-- 地址选择器组件 -->
-	<picker @change="bindPickerChange" @columnchange="columnchange" :range="array" range-key="name" :value="value" mode="multiSelector">
+	<view>
+		<picker @change="bindPickerChange" @columnchange="columnchange" :range="array" range-key="name" :value="value"
+			mode="multiSelector">
 			<slot></slot>
-	</picker>
+		</picker>
+	</view>
 </template>
 
 <script>
-import AllAddress from './areadata.js'
-// import AllAddress from '@/pages_mine/components/pickerAddress/address.js'
-let selectVal = ['','','']
+// import AllAddress from './areadata.js'
+import AllAddress from './address.js'
+let selectVal = ['', '', '']
+let selectCode = ['', '', '']
 export default {
-		data() {
-			return{
-				value: [0,0,0],
-				array: [],
-				index: 0
-			}
-		},
-		props:{
-			selectValue: {
-				type: Array,
-				default: [0,0,0]
+	data() {
+		return {
+			value: [0, 0, 0],
+			array: [],
+			index: 0
+		}
+	},
+	props: {
+		selectValue: {
+			type: Array,
+			default: [0, 0, 0]
+		}
+	},
+	created() {
+		this.value = this.selectValue
+		this.initSelect()
+	},
+	watch: {
+		selectValue: {
+				handler(newVal,old) {
+					if(newVal!== old){
+						console.log('newVal,old',newVal,old);
+						this.value = this.selectValue
+						this.initSelect()
+					}
+					
+				},
+				immediate: true
 			}
 		},
-		created() {
-			this.value = this.selectValue
-			this.initSelect()
-		},
-		methods:{
-			// 初始化地址选项
-			initSelect() {
-				this.updateSourceDate() // 更新源数据
+	methods: {
+		// 初始化地址选项
+		initSelect() {
+			this.updateSourceDate() // 更新源数据
 				.updateAddressDate() // 更新结果数据
 				.$forceUpdate()  // 触发双向绑定
-			},
-			// 地址控件改变控件
-			columnchange(d) {
-				this.updateSelectIndex(d.detail.column, d.detail.value) // 更新选择索引
+		},
+		// 地址控件改变控件
+		columnchange(d) {
+			this.updateSelectIndex(d.detail.column, d.detail.value) // 更新选择索引
 				.updateSourceDate() // 更新源数据
 				.updateAddressDate() // 更新结果数据
 				.$forceUpdate()  // 触发双向绑定
-			},
-			
-			/**
-			 * 更新源数据
-			 * */
-			updateSourceDate() {
-				// console.log(AllAddress, '>>>>>>>AllAddress');
-				this.array = []
-				this.array[0] = AllAddress.map(obj => {
-					return { name: obj.name }
-				})
-				this.array[1] = AllAddress[this.value[0]].city.map(obj => {
-					return { name: obj.name }
-				})
-				this.array[2] = AllAddress[this.value[0]].city[this.value[1]].area.map(obj => { 
-					return { name: obj }
-				})
-				return this
-			},
-			
-			/**
-			 * 更新索引
-			 * */
-			updateSelectIndex(column, value){
-				let arr = JSON.parse(JSON.stringify(this.value)) 
-				arr[column] = value
-				if(column === 0 ) {
-						arr[1] = 0
-						arr[2] = 0
+		},
+
+		/**
+		 * 更新源数据
+		 * */
+		updateSourceDate() {
+			// console.log(AllAddress, '>>>>>>>AllAddress');
+			this.array = []
+			// this.array[0] = AllAddress.map(obj => {
+			// 	return { name: obj.name }
+			// })
+			// this.array[1] = AllAddress[this.value[0]].city.map(obj => {
+			// 	return { name: obj.name }
+			// })
+			// this.array[2] = AllAddress[this.value[0]].city[this.value[1]].area.map(obj => { 
+			// 	return { name: obj }
+			// })
+
+
+			this.array[0] = AllAddress.map(obj => {
+				return {
+					name: obj.name,
+					code: obj.code
+				}
+			})
+			this.array[1] = AllAddress[this.value[0]].children.map(obj => {
+				return {
+					name: obj.name,
+					code: obj.code
 				}
-				if(column === 1 ) {
-						arr[2] = 0
+			})
+			this.array[2] = AllAddress[this.value[0]].children[this.value[1]].children.map(obj => {
+				return {
+					name: obj.name,
+					code: obj.code
 				}
-				this.value = arr
-				return this
-			},
-			
-			/**
-			 * 更新结果数据 
-			 * */
-			updateAddressDate() {
-				selectVal[0] = this.array[0][this.value[0]].name
-				selectVal[1] = this.array[1][this.value[1]].name 
-				selectVal[2] = this.array[2][this.value[2]].name 
-				return this
-			},
-			
-			/**
-			 * 点击确定
-			 * */
-			bindPickerChange(e) {
-				this.$emit('change', {
-					index: this.value,
-					data: selectVal
-				})
-				return this
+			})
+			return this
+		},
+
+		/**
+		 * 更新索引
+		 * */
+		updateSelectIndex(column, value) {
+			let arr = JSON.parse(JSON.stringify(this.value))
+			arr[column] = value
+			if (column === 0) {
+				arr[1] = 0
+				arr[2] = 0
+			}
+			if (column === 1) {
+				arr[2] = 0
 			}
+			this.value = arr
+			return this
+		},
+
+		/**
+		 * 更新结果数据 
+		 * */
+		updateAddressDate() {
+			selectVal[0] = this.array[0][this.value[0]].name
+			selectVal[1] = this.array[1][this.value[1]].name
+			selectVal[2] = this.array[2][this.value[2]].name
+
+			selectCode[0] = this.array[0][this.value[0]].code
+			selectCode[1] = this.array[1][this.value[1]].code
+			selectCode[2] = this.array[2][this.value[2]].code
+
+
+			return this
+		},
+
+		/**
+		 * 点击确定
+		 * */
+		bindPickerChange(e) {
+			this.$emit('change', {
+				index: this.value,
+				data: selectVal,
+				code: selectCode
+			})
+			return this
 		}
+	}
 }
 </script>
 
-<style>
-</style>
-
+<style></style>

+ 3 - 27
pages/classify.vue

@@ -10,8 +10,8 @@
 			</up-tabs>
 			<view class="list">
 				<List :data="data" v-if="data.length > 0" />
-				<view v-else class="empty-null">
-					<img src="/static/empty/订单为空.png" alt="">
+				<view v-else>
+					 <NoneView value="您还没有相关订单"/>
 				</view>
 			</view>
 		</view>
@@ -42,6 +42,7 @@
 		onShow
 	} from '@dcloudio/uni-app';
 	import OrderList from '@/pages/common/classify/orderlist.vue'
+	import NoneView from '@/components/NoneView/index.vue'
 	import {
 		userMainOrderList,
 		systemDictdaTalist
@@ -92,31 +93,6 @@
 		}
 	]
 
-	const column2 = [{
-			name: "全部",
-			value: "",
-		},
-		{
-			name: "待支付",
-			value: "1",
-		},
-		{
-			name: "待服务",
-			value: "2",
-		},
-		{
-			name: "进行中",
-			value: "3",
-		},
-		{
-			name: "已完成",
-			value: "4",
-		},
-		{
-			name: "已取消",
-			value: "5",
-		}
-	]
 
 	//获取用户订单列表状态
 	async function getData() {

+ 4 - 4
pages/common/orderList/listItem.vue

@@ -10,7 +10,7 @@
                     <view class="item-name">
                         {{ data.name }}
                     </view>
-                    <view v-if="data.score || ['0', '1'].includes(String(data.orderStatus))">
+                    <view v-if="data.score || ['0', '1','3'].includes(String(data.orderStatus))">
                         <dict-tag :options="order_status" :value="String(data.orderStatus)" />
                     </view>
                     <text v-else class="color-blue ">
@@ -28,14 +28,14 @@
             </view>
             <view class="item-box">
                 <view class="item-btns">
-                    <view class="btn-m" @click="onClick(1)" v-if="['2', '3'].includes(data.orderStatus)">查看</view>
+                    <view class="btn-m" @click="onClick(1)" v-if="['2','4'].includes(data.orderStatus)">查看</view>
                     <view class="btn-m" @click="onClick(2)">
                         <!-- <up-icon name="chat" color="#ffffff" size="20"></up-icon> -->
                         <text style="margin-left: 8rpx;">沟通</text>
                     </view>
-                    <view class="btn-m" @click="onClick(1)"  v-if="['0', '1'].includes(data.orderStatus)">
+                    <view class="btn-m" @click="onClick(1)"  v-if="['3', '1'].includes(data.orderStatus)">
                         <!-- <up-icon name="chat" color="#ffffff" size="20"></up-icon> -->
-                       {{ data.orderStatus === '0' ? '开始' : '完成' }}服务
+                       {{ data.orderStatus === '1' ? '开始' : '完成' }}服务
                     </view>
                 </view>
             </view>

+ 1 - 2
pages/mine.vue

@@ -2,8 +2,7 @@
 	<view class="mine-container">
 
 		<view class="mine-header">
-			<img :src="userInfo.avatar" alt="" style="width: 136rpx;height: 136rpx;">
-
+			<up-image width="136rpx" height="136rpx"  :show-loading="true" :src="userInfo.avatar" ></up-image>
 			<view class="header-info">
 				<text class="info-name">{{ userInfo.nickName }}</text>
 				<text class="info-id">ID: {{ data.volunteerId }}</text>

+ 1 - 1
pages_classify/pages/handle/index.vue

@@ -107,7 +107,7 @@ const getOrderDetail = async () => {
 
         let data = res.data.secondOrder;
         detaile.value = { ...res.data.secondOrder, ...res.data.address,serveTimes:res.data.secondOrder.updateTime }
-        if (data.orderStatus === '1') {
+        if (data.orderStatus === '3') {
 
             orderStatus.value = true;
         }

+ 6 - 6
pages_classify/pages/order/index.vue

@@ -19,14 +19,14 @@
 				{{ detaile.remark }}
 			</view>
 		</view>
-		<view class="service-info order-card" v-if="detaile.orderStatus === '1'">
+		<view class="service-info order-card" v-if="detaile.orderStatus === '3'">
 			<view class="font-title ">反馈信息</view>
 			<view class="info-list">
 				<up-textarea v-model="detaile.volunteerReview" placeholder="请输入内容" ></up-textarea>
 			</view>
 		</view>
 
-		<view v-if="detaile.orderStatus !== '1'">
+		<view v-if="detaile.orderStatus !== '3'">
 			<view class="user-info order-card">
 				<view class="font-title">志愿者反馈信息</view>
 				<view class="user-box">
@@ -58,22 +58,22 @@
 
 
 
-		<view class="service-info order-card" v-if="detaile.orderStatus === '1'">
+		<view class="service-info order-card" v-if="detaile.orderStatus === '3'">
 			<view class="font-title">图片上传</view>
 			<view class="upload-box">
 				<view class="upload-img-item" v-for="(item, index) in fileList" :key="item.url">
 					<view class="delete-icon" @click="deletePic(index)"><up-icon name="close-circle-fill"
-							color="#f64a1f" size="18" v-if="detaile.orderStatus === '1'"></up-icon></view>
+							color="#f64a1f" size="18" v-if="detaile.orderStatus === '3'"></up-icon></view>
 					<img class="upload-img" :src="item.url" :alt="item.fileName" srcset="">
 				</view>
 				<img src="/static/img/upload.png" alt="" class="upload-img" @click="uploadClick('img')"
-					v-if="fileList.length < 10 && detaile.orderStatus === '1'">
+					v-if="fileList.length < 10 && detaile.orderStatus === '3'">
 			</view>
 		</view>
 
 
 
-		<view class=" footer-g" v-if="detaile.orderStatus === '1'">
+		<view class=" footer-g" v-if="detaile.orderStatus === '3'">
 			<!-- <up-button type="primary" text="确定结束" @click="onSubmit"></up-button> -->
 			<view class="status-btn" @click="onSubmit">确定结束</view>
 		</view>

+ 106 - 10
pages_home/components/cust-form/index.vue

@@ -59,7 +59,7 @@
                     <up-button size="small" type="primary" text="前往人脸识别" @click="startFace"></up-button>
                 </up-form-item>
 
-                <up-form-item v-if="item.type === 'city'" :label="item.label" :prop="item.key" borderBottom
+                <!-- <up-form-item v-if="item.type === 'city'" :label="item.label" :prop="item.key" borderBottom
                     labelWidth="94" :required="item.required">
                     <view @click.self="() => openCity(item)">
                         <up-input v-model="formData[item.key]" disabled disabledColor="#ffffff" placeholder="省、市、区等地区信息"
@@ -68,6 +68,22 @@
                     <template #right>
                         <up-icon name="map" size="22" @click="onCityWx(item)"></up-icon>
                     </template>
+                </up-form-item> -->
+
+                <up-form-item v-if="item.type === 'city'" :label="item.label" :prop="item.key" borderBottom
+                    labelWidth="94" :required="item.required">
+                        <pickerAddress @change="(info)=>addressChange(info,item)"
+                        :selectValue="[ formData.provinceInd, formData.cityInd, formData.districtInd ]">
+                        <view class="inp"
+                            :class="formData.provinceName&&formData.cityName&&formData.districtName?'':'address-inp'">
+                            {{formData.provinceName ? formData.provinceName:'省'}} /
+                            {{formData.cityName ? formData.cityName:'市'}} /
+                            {{formData.districtName ? formData.districtName:'区'}}
+                        </view>
+                    </pickerAddress>
+                    <template #right>
+                        <up-icon name="map" size="22" @click="onCityWx(item)"></up-icon>
+                    </template>
                 </up-form-item>
 
                 <up-form-item v-if="item.type === 'cascader'" :label="item.label" :prop="item.key" borderBottom
@@ -107,7 +123,10 @@ import {
     onShow,
     onUnload
 } from "@dcloudio/uni-app";
-import { splitAddress } from '@/utils/adress'
+import { splitAddress,getCityCode } from '@/utils/adress'
+
+import pickerAddress from '@/components/pickerAddress/pickerAddress.vue'
+
 const props = defineProps({
     column: {
         type: Array,
@@ -122,6 +141,18 @@ const formData = reactive({
     sex: null,
     city: null,
 
+    provinceName: '', // 省
+		provinceCode: '',
+		provinceInd: 21,
+
+		cityName: '', // 市
+		cityCode: '',
+		cityInd: 0,
+
+		districtName: '',
+		districtCode: '',
+		districtInd: 17,
+
     // address: "永川区",
     // age: "1",
     // city: "重庆",
@@ -293,21 +324,86 @@ function clickPick(row) {
     pickerRef.value.show();
 
 }
+
+
+function addressChange(info,row) {
+        actions.value = row
+		console.log(info, '>>>>data');
+
+		if (!info || !info.data) {
+			console.error('Invalid address change info:', info);
+			return;
+		}
+
+		if (!Array.isArray(info.data) || info.data.length < 3) {
+			console.error('Invalid address data:', info.data);
+			return;
+		}
+
+		const code = Array.isArray(info.code) ? info.code : ['', '', ''];
+
+		let indexArray;
+		if (Array.isArray(info.index)) {
+			indexArray = info.index;
+		} else if (info.index && typeof info.index[Symbol.iterator] === 'function') {
+			indexArray = Array.from(info.index);
+		} else {
+			indexArray = [0, 0, 0];
+		}
+
+    
+        Object.assign(formData, {
+            provinceName: info.data[0],
+            provinceCode: info.code[0],
+            provinceInd:indexArray[0] || 0,
+            cityName: info.data[1],
+            cityCode:info.code[1],
+            cityInd:indexArray[1] || 0,
+            districtName: info.data[2],
+            districtCode:info.code[2],
+            districtInd:indexArray[2] || 0
+        })
+        console.log('formData===>',formData);
+        
+    }
 function onCityWx(row) {
     console.log('地区选点',row);
     wx.chooseLocation({
         success: function (res) {
             const result = splitAddress(res.address);
-            console.log(res,result);
-            Object.assign(cityData, {     
-                province: result.province,
-                city: result.city,
-                area:result.district,
-            })
-            Object.assign(formData, {
-                [row.key]: `${result.province}${result.city}${result.district}`,
+            const handlecityData = getCityCode([result.province,result.city,result.district].join(' '))
+            console.log(res,handlecityData);
+            addressChange(handlecityData,row)
+
+             Object.assign(formData, {
+                // [row.key]: `${result.province}${result.city}${result.district}`,
                 address:result.detail
             })
+
+            // Object.assign(cityData, {     
+            //     province: result.province,
+            //     city: result.city,
+            //     area:result.district,
+            // })
+
+            // Object.assign(formData, {
+            // provinceName: result.province,
+            // provinceCode: info.code[0],
+            // provinceInd:indexArray[0] || 0,
+            // cityName: result.city,
+            // cityCode:info.code[1],
+            // cityInd:indexArray[1] || 0,
+            // districtName: result.district,
+            // districtCode:info.code[2],
+            // districtInd:indexArray[2] || 0,
+
+            // address:result.detail
+            // })
+            
+            // Object.assign(formData, {
+            //     [row.key]: `${result.province}${result.city}${result.district}`,
+            //     address:result.detail
+            // })
         },
         fail: function (err) {
             console.log(err);

+ 77 - 11
pages_home/components/tabs/index.vue

@@ -8,14 +8,35 @@
             }" lineColor="rgba(221, 94, 69, 1)" :current="tabKey" keyName="businessName">
             </up-tabs>
         </view>
-        <view>
-            <view scroll-x class="tabs-scroll">
-                <view v-for="item in childrenList" :key="item.id"
-                    :class="item.id === childrenKey ? 'childern-item item-active' : 'childern-item'"
-                    @click="childernChange(item)">
+        <view scroll-x class="tabs-scroll">
+            <!-- <view v-for="item in childrenList" :key="item.id"
+                :class="item.id === childrenKey ? 'childern-item item-active' : 'childern-item'"
+                @click="childernChange(item)">
+                {{ item.businessName }}
+            </view> -->
+
+            <up-tabs :list="childrenList" @change="childernChange" :activeStyle="{
+                color: 'rgba(221, 94, 69, 1)',
+                fontWeight: 'bold',
+                transform: 'scale(1.05)'
+            }" lineColor="rgba(221, 94, 69, 1)" :current="childrenKey" keyName="businessName">
+            </up-tabs>
+        </view>
+        <view class="tabs-scroll-box">
+            <!-- <view class="tabs-scroll2">
+                <view v-for="item in children2List" :key="item.id"
+                    :class="item.id === children2Key ? 'childern2-item item2-active' : 'childern2-item'"
+                    @click="childern2Change(item)">
                     {{ item.businessName }}
                 </view>
-            </view>
+            </view> -->
+
+            <up-tabs :list="children2List" @change="childern2Change" :activeStyle="{
+                color: 'rgba(221, 94, 69, 1)',
+                fontWeight: 'bold',
+                transform: 'scale(1.05)'
+            }" lineColor="rgba(221, 94, 69, 1)" :current="children2Key" keyName="businessName">
+            </up-tabs>
         </view>
     </view>
 </template>
@@ -36,22 +57,39 @@ import {
 const emits = defineEmits(['change'])
 const tabKey = ref(0);//tab的下标
 const childrenKey = ref(null);//二级的id
+const children2Key = ref(null);//三级的id
+
 const list = ref([])
 
 const childrenList = ref([]);//二级的数据
+const children2List = ref([]);//三级的数据
+
 const handlTabs = (e, index) => {
     console.log('e,index', e, index);
+    childrenList.value = e.children ? [{
+        businessName: '全部',
+        id: e.id
+    }, ...e.children] : []
 
-    childrenList.value = e.children
     tabKey.value = index;//记录下标
-    childrenKey.value = null;
+    childrenKey.value = 0;
+    children2Key.value = 0;
+    children2List.value = [];
     emits('change', e)
 }
-const childernChange = (e) => {
-    childrenKey.value = e.id;
+const childernChange = (e, index) => {
+    children2List.value = e.children ? [{
+        businessName: '全部',
+        id: e.id
+    }, ...e.children] : [];
+    children2Key.value = 0;
+    childrenKey.value = index;
+    emits('change', e)
+}
+const childern2Change = (e, index) => {
+    children2Key.value = index;
     emits('change', e)
 }
-
 onMounted(() => {
 })
 
@@ -88,6 +126,34 @@ onLoad((options) => {
     align-items: center;
     margin-top: 16rpx;
     padding: 0 16rpx;
+}
+
+.tabs-scroll-box {
+    width: 100%;
+    overflow: hidden;
+    overflow-x: auto;
+}
+
+.tabs-scroll2 {
+    margin-top: 16rpx;
+    padding: 0 16rpx;
+    width: max-content;
+    display: flex;
+    align-items: center;
+}
+
+.childern2-item {
+    font-size: 24rpx;
+    font-weight: 400;
+    background-color: #f9fafb;
+    padding: 8rpx 28rpx;
+    margin-right: 16rpx;
+    border-radius: 4rpx;
+    color: #656565;
+}
 
+.item2-active {
+    background: rgba(251, 229, 225, 1);
+    color: rgba(221, 94, 69, 1);
 }
 </style>

+ 7 - 1
pages_home/pages/client/details.vue

@@ -20,8 +20,14 @@
 				<view  class="custom-dropdown">
 					<up-tabs :list="list2" @change="clickList2" class="tabs-content" :current="currentTabs2"
 						keyName="businessName" />
+				</view>
+				<view class="tabs-wrapper">
+					<scroll-view scroll-x class="tabs-scroll">
+						<up-tabs :list="list1" @change="handlTabs" keyName="businessName"
+							class="tabs-content" :current="tabKey"></up-tabs>
+					</scroll-view>
 				</view> -->
-
+	
 				<Tabs :list="list1" @change="handlTabs" ref="tabRef" />
 			</view>
 

+ 3 - 2
pages_home/pages/details/index.vue

@@ -13,8 +13,9 @@
                 <view class="card-title">基本信息</view>
                 <view class="card-item" v-for="item in list" :key="item.key">
                     <view class="card-lable">{{ item.label }}</view>
-                    <view class="card-text"> {{ item.key === 'sex' ? sex_status[details[item.key]] || '-' :
-                        details[item.key] || '-'}} </view>
+                    <view class="card-text" v-if=" item.key === 'sex'"> {{ sex_status[details[item.key]] || '-'}} </view>
+                    <view class="card-text" v-else-if=" item.key === 'city'"> {{details['provinceName']+ details['cityName']+details['districtName']}} </view>
+                    <view class="card-text" v-else> {{  details[item.key] || '-'}} </view>
                 </view>
             </view>
 

+ 3 - 3
pages_home/pages/register/data.js

@@ -62,7 +62,7 @@ const rules = {
             trigger: ['blur', 'change']
         }
     ],
-    city: [
+    districtName: [
         {
             type: 'string',
             required: true,
@@ -127,10 +127,10 @@ const column = [
     },
     {
         label: "地区",
-        key: "city",
+        key: "districtName",
         type: "city",
         option: city_option,
-        rules: rules.city,
+        rules: rules.districtName,
         required:true
     },
     {

+ 120 - 12
pages_home/pages/register/index.vue

@@ -23,8 +23,19 @@
 						</view>
 					</view>
 				</view>
+
+				<view v-if="serviceKeys.classKey && serviceItems2 && serviceItems2.length > 0">
+					<view class="font-title">服务项</view>
+					<view class="service-list">
+						<view v-for="item in serviceItems2" :key="item.id" @click="serviceChange(item, 'threeKey')"
+							:class="serviceKeys.threeKey === item.id ? 'servicetab classActive' : 'servicetab'">
+							{{ item.businessName }}
+						</view>
+					</view>
+				</view>
+
 				<view v-if="serviceKeys.itemKeyname || serviceKeys.classKeyname">
-					<view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.itemKeyname ||
+					<view class="font-title">服务时长(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
 						serviceKeys.classKeyname }}</text>)</view>
 					<view class="service-list">
 						<view v-for="item in timeList" :key="item.id" @click="serviceChange(item, 'time')"
@@ -32,7 +43,7 @@
 							{{ item.lable }}
 						</view>
 					</view>
-					<view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.itemKeyname ||
+					<view class="font-title">服务价格(<text class="activeColor">{{ serviceKeys.threeKeyname || serviceKeys.itemKeyname ||
 						serviceKeys.classKeyname }}</text>)</view>
 					<view class="service-list">
 						<up-input v-model="serviceKeys.price" placeholder="请设置服务价格">
@@ -126,11 +137,27 @@ const details = ref({});//详情数据
 const serviceOptions = ref([]);//服务类目
 const serviceItems = ref([]);//服务项目
 
+// const serviceItems = computed(() => { 
+// 	const row = handlerList(serviceOptions.value,serviceKeys.classKey)
+// 	console.log('服务项目',row);
+// 	return row.children || []
+// });
+
+// const serviceItems2 = computed(() => { 
+// 	const row = handlerList(serviceOptions.value,serviceKeys.itemKey)
+// 	console.log('服务项目2',row);
+// 	return row.children || []
+// });
+const serviceItems2 = ref([]);//服务小类目
+
+
 const serviceKeys = reactive({
 	classKey: '',//服务类别
 	classKeyname: '',
 	itemKey: '',//服务项目
 	itemKeyname: '',
+	threeKey: '',//服务项
+	threeKeyname: '',
 	time: '',//时间
 	price: '',//价格
 })
@@ -184,7 +211,7 @@ function onSubmit() {
 				}
 			}
 
-			if (!(serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
+			if (!(serviceKeys.threeKeyname||serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
 				uni.showToast({
 					title: '请选择服务',
 					icon: 'none'
@@ -209,7 +236,7 @@ function onSubmit() {
 			const parmas = {
 				serviceCategory: data.value.key,
 				...file_url,
-				businessManagementId: serviceKeys.itemKey || serviceKeys.classKey,
+				businessManagementId:serviceKeys.threeKey|| serviceKeys.itemKey || serviceKeys.classKey,
 				businessPrice: serviceKeys.price,
 				businessDuration: serviceKeys.time
 			};
@@ -260,7 +287,7 @@ function onChange({ key, url }) {
 	})
 }
 
-function idToIndexs(array, targetId, path = []) {
+function handlerList(array, targetId, path = []) {
 
 	for (let i = 0; i < array.length; i++) {
 		const item = array[i];
@@ -271,7 +298,7 @@ function idToIndexs(array, targetId, path = []) {
 		}
 
 		if (item.children) {
-			const result = idToIndexs(item.children, targetId, currentPath);
+			const result = handlerList(item.children, targetId, currentPath);
 			if (result) {
 				return result;
 			}
@@ -280,18 +307,90 @@ function idToIndexs(array, targetId, path = []) {
 
 	return null; // 如果没有找到对应的项,返回 null
 }
+/**
+ * 根据目标id查找所有父级路径
+ * @param {Array} data 树形数据源(如 serviceOptions.value)
+ * @param {String|Number} targetId 要查找的目标id
+ * @param {String} [idKey='id'] id字段名
+ * @param {String} [childrenKey='children'] 子级字段名
+ * @returns {Object|null}
+ */
+ function findParentPath(data, targetId, idKey = 'id', childrenKey = 'children') {
+    for (const node of data) {
+        // 当前节点匹配
+        if (node[idKey] == targetId) {
+            return {
+                parentIdPath: [node[idKey]],
+                businessTierName: node.businessName || ''
+            };
+        }
+
+        // 搜索子级
+        const result = node[childrenKey]?.length > 0 
+            ? findParentPath(node[childrenKey], targetId, idKey, childrenKey) 
+            : null;
+
+        if (result) {
+            return {
+                parentIdPath: [...result.parentIdPath, node[idKey]],
+                businessTierName: `${result.businessTierName}-${node.businessName || ''}`
+            };
+        }
+    }
+
+    return null;
+}
+function idToIndexs(targetId) {
+    const res = findParentPath(serviceOptions.value, targetId);
+    return res || {
+        parentIdPath: [],
+        businessTierName: ''
+    };
+}
+
+const backfill = {
+	2:'threeKey',
+	1:'itemKey',
+	0:'classKey',
+}
 //重新提交的服务信息回显
 function servesInit() {
-	const indexs = idToIndexs(serviceOptions.value, details.value.businessManagementId + '')
-	const names = indexs.businessTierName.split('-');
+	const indexs = idToIndexs(details.value.businessManagementId + '');
+	const names = indexs.businessTierName.split('-').reverse();
+	const ids = indexs.parentIdPath.reverse();
+	const obj = {};
+	for (let i = 0; i < names.length; i++) {
+		obj[backfill[i]] =  ids[i];
+		obj[backfill[i]+'name'] = names[i];
+	}
+	console.log('obj',obj,names,ids);
+
+
+	console.log('indexs', indexs,names,ids);
+	// const indexs = idToIndexs(serviceOptions.value, details.value.businessManagementId + '')
+	// const names = indexs.businessTierName.split('-');
+	// console.log('indexs',indexs,names);
+	if(obj.itemKey){
+		const row = handlerList(serviceOptions.value,obj.classKey)
+		console.log(1,row);
+		serviceItems.value = row.children;
+	}
+	if(obj.threeKey){
+		const row = handlerList(serviceOptions.value,obj.itemKey)
+		console.log(2,row);
+		serviceItems2.value = row.children;
+	}
 	Object.assign(serviceKeys, {
-		classKey: String(indexs.parentId) === String(data.value.key) ? indexs.id : indexs.parentId,//服务类别
-		classKeyname: names[1],
-		itemKey: indexs.id,//服务项目
-		itemKeyname: indexs.businessName,
 		time: details.value.businessDuration,//时间
 		price: details.value.businessPrice,//价格
+		...obj
 	})
+
+
+	handlerList(serviceOptions.value,serviceKeys.itemKey)
+
+	console.log('serviceKeys',serviceKeys);
+	
 }
 async function getRegister() {
 
@@ -335,6 +434,15 @@ const serviceChange = (item, key) => {
 	if (key === 'classKey') {
 		serviceItems.value = item.children;
 		serviceKeys['itemKey'] = '';
+		serviceKeys['itemKeyname'] = '';
+		serviceKeys['threeKey'] = '';
+		serviceKeys['threeKeyname'] = '';
+		serviceItems2.value = [];
+	}
+	if(key === 'itemKey'){
+		serviceItems2.value = item.children;
+		serviceKeys['threeKey'] = '';
+		serviceKeys['threeKeyname'] = '';
 	}
 	Object.assign(serviceKeys, {
 		[key]: serviceKeys[key] === item.id ? '' : item.id,

BIN
static/serverImg/mine/user.png


+ 1 - 1
store/modules/user.ts

@@ -71,7 +71,7 @@ const user: Module<UserState, UserState> = {
       return new Promise((resolve, reject) => {
         getInfo().then((res: any) => {
           const user = res.user
-          const avatar = (user == null || user.avatar == "" || user.avatar == null) ? "/static/serverImg/mine/user.png" : baseUrl + user.avatar
+          const avatar = (user == null || user.avatar == "" || user.avatar == null) ? "/static/serverImg/mine/user.png" :  user.avatar
           const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
           if (res.roles && res.roles.length > 0) {
             commit('SET_ROLES', res.roles)

+ 120 - 37
utils/adress.js

@@ -2,15 +2,17 @@ import config from '@/config'
 const mapKey = config.mapKey;
 const appName = config.appName;
 
+import addressData from '@/components/pickerAddress/address'
+
 /**
  * 腾讯位置服务地图选点
  */
 const chooseLocationInit = () => {
-    const key = mapKey; //使用在腾讯位置服务申请的key
-    const referer = appName; //调用插件的app的名称
-    wx.navigateTo({
-        url: `plugin://chooseLocation/index?key=${key}&referer=${referer}`,
-    });
+  const key = mapKey; //使用在腾讯位置服务申请的key
+  const referer = appName; //调用插件的app的名称
+  wx.navigateTo({
+    url: `plugin://chooseLocation/index?key=${key}&referer=${referer}`,
+  });
 
 }
 
@@ -19,43 +21,124 @@ const chooseLocationInit = () => {
  * @param {*} city 城市名称
  */
 const citySelectorNavigateTo = (city) => {
-    const key = mapKey; // 使用在腾讯位置服务申请的key
-    const referer = appName; // 调用插件的app的名称
-    const hotCitys = '重庆'; // 用户自定义的的热门城市
+  const key = mapKey; // 使用在腾讯位置服务申请的key
+  const referer = appName; // 调用插件的app的名称
+  const hotCitys = '重庆'; // 用户自定义的的热门城市
 
-    wx.navigateTo({
-        url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}`,
-    })
+  wx.navigateTo({
+    url: `plugin://citySelector/index?key=${key}&referer=${referer}&hotCitys=${hotCitys}`,
+  })
 }
 
 function splitAddress(address) {
-    // 处理直辖市(如北京市朝阳区)
-    const directCityRegex = /^(北京|天津|上海|重庆)(市)?(.+?区)/;
-    const directMatch = address.match(directCityRegex); 
-    if (directMatch) {
-      return {
-        province: directMatch[1],
-        city: directMatch[1]+'市',
-        district: directMatch[3],
-        detail: address.replace(directCityRegex,  '')
-      }
+  // 处理直辖市(如北京市朝阳区)
+  const directCityRegex = /^(北京|天津|上海|重庆)(市)?(.+?区)/;
+  const directMatch = address.match(directCityRegex);
+  if (directMatch) {
+    return {
+      province: directMatch[1],
+      city: directMatch[1] + '市',
+      district: directMatch[3],
+      detail: address.replace(directCityRegex, '')
     }
-  
-    // 常规拆分逻辑 
-    const provinceRegex = /(.+?(省|自治区|行政区|特别行政区))/;
-    const cityRegex = /(.+?(市|自治州|州|盟))/;
-    
-    const province = address.match(provinceRegex)?.[1]  || '';
-    const city = address.replace(province,  '').match(cityRegex)?.[1] || '';
-    const remaining = address.replace(province  + city, '');
-    const district = remaining.match(/(.+?( 区|县|市|旗))/)?.[1] || '';
-    const detail = remaining.replace(district,  '').trim();
-   
-    return {province, city, district, detail};
   }
 
-export  { 
-    chooseLocationInit,
-    citySelectorNavigateTo,
-    splitAddress
+  // 常规拆分逻辑 
+  const provinceRegex = /(.+?(省|自治区|行政区|特别行政区))/;
+  const cityRegex = /(.+?(市|自治州|州|盟))/;
+
+  const province = address.match(provinceRegex)?.[1] || '';
+  const city = address.replace(province, '').match(cityRegex)?.[1] || '';
+  const remaining = address.replace(province + city, '');
+  const district = remaining.match(/(.+?( 区|县|市|旗))/)?.[1] || '';
+  const detail = remaining.replace(district, '').trim();
+
+  return { province, city, district, detail };
+}
+
+
+function normalizeAddress(str) {
+  return str.replace(/(市|区|省)/g, '').trim();
+}
+/**
+ * 根据地址字符串返回 name 数组、code 数组、index 路径
+ * @param {string} address 例如:"重庆 重庆市 永川区"
+ * @returns {Object|null} 包含 data/name、code、index 的对象
+ */
+const getCityCode = (address) => {
+  // //address:重庆市永川区人民大道191号
+  // const names = normalizeAddress(address).split(/\s+/);
+  // let result = [];
+
+  // // 查找省份
+  // let province = addressData.find(p => p.name.includes(names[0]));
+  // if (!province) return [];
+
+  // result.push(province.code);
+
+  // if (names.length < 2) return result;
+
+  // // 查找城市
+  // let city = province.children?.find(c => c.name.includes(names[1]));
+  // if (!city) return result;
+
+  // result.push(city.code);
+
+  // if (names.length < 3) return result;
+
+  // // 查找区县
+  // let district = city.children?.find(d => d.name.includes(names[2]));
+  // if (!district) return result;
+
+  // result.push(district.code);
+
+  // return result;
+
+  const names = address.split(/\s+/)
+  const result = {
+    data: [],
+    code: [],
+    index: []
+  }
+
+  // 查找省份
+  const provinceIndex = addressData.findIndex(p => p.name.includes(names[0]))
+  if (provinceIndex === -1) return null
+
+  const province = addressData[provinceIndex]
+  result.data.push(province.name)
+  result.code.push(province.code)
+  result.index.push(provinceIndex)
+
+  if (names.length < 2) return result
+
+  // 查找城市
+  const cityIndex = province.children.findIndex(c => c.name.includes(names[1]))
+  if (cityIndex === -1) return result
+
+  const city = province.children[cityIndex]
+  result.data.push(city.name)
+  result.code.push(city.code)
+  result.index.push(cityIndex)
+
+  if (names.length < 3) return result
+
+  // 查找区县
+  const districtIndex = city.children.findIndex(d => d.name.includes(names[2]))
+  if (districtIndex === -1) return result
+
+  const district = city.children[districtIndex]
+  result.data.push(district.name)
+  result.code.push(district.code)
+  result.index.push(districtIndex)
+
+  return result
+
+
+}
+export {
+  chooseLocationInit,
+  citySelectorNavigateTo,
+  splitAddress,
+  getCityCode
 }