浏览代码

fix: 分类跳转注册(优化)

chenjj 3 周之前
父节点
当前提交
cd39b93393
共有 4 个文件被更改,包括 71 次插入192 次删除
  1. 8 4
      components/Client/new_file.vue
  2. 7 5
      pages/mallMenu.vue
  3. 2 117
      pages_home/pages/register/data.js
  4. 54 66
      pages_home/pages/register/index.vue

+ 8 - 4
components/Client/new_file.vue

@@ -259,11 +259,15 @@
 					})
 					})
 					return
 					return
 				}
 				}
-				[1, 2].includes(service.key) ? uni.navigateTo({
+				// [1, 2].includes(service.key) ? uni.navigateTo({
+				// 	url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(service))}`
+				// }) : uni.showToast({
+				// 	title: '敬请期待',
+				// 	icon: 'none'
+				// })
+
+				uni.navigateTo({
 					url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(service))}`
 					url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(service))}`
-				}) : uni.showToast({
-					title: '敬请期待',
-					icon: 'none'
 				})
 				})
 				return;
 				return;
 			}
 			}

+ 7 - 5
pages/mallMenu.vue

@@ -18,7 +18,7 @@
                         <view class="item-container">
                         <view class="item-container">
                                 <view class="thumb-box"
                                 <view class="thumb-box"
                                     v-for="(item1, index1) in  (item.children?item.children:[item])"
                                     v-for="(item1, index1) in  (item.children?item.children:[item])"
-                                    :key="index1" @click="clickMenu(item)">
+                                    :key="index1" @click="clickMenu(item,item1)">
                                     <view class="item-menu-name">{{ item1.businessName }}</view>
                                     <view class="item-menu-name">{{ item1.businessName }}</view>
                                 </view>
                                 </view>
                             </view>
                             </view>
@@ -164,23 +164,25 @@ export default {
                 }
                 }
             }, 10)
             }, 10)
         },
         },
-        async clickMenu(service) {
-            console.log(service);
+        async clickMenu(service,record) {
+            console.log(service,record);
             const { id } = service;
             const { id } = service;
             const key = id;
             const key = id;
             if (this.userType == '2') {
             if (this.userType == '2') {
                 const res = await getVolunteerInfo({
                 const res = await getVolunteerInfo({
                     serviceCategory: key
                     serviceCategory: key
                 });
                 });
+                const parmas = { ...service, key,name:service.businessName,record };
+                
                 if (res.code === 200 && res.data) {
                 if (res.code === 200 && res.data) {
                     //已有注册,跳转详情页面
                     //已有注册,跳转详情页面
                     uni.navigateTo({
                     uni.navigateTo({
-                        url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify({ ...service, key }))}`
+                        url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify(parmas))}`
                     })
                     })
                     return
                     return
                 }
                 }
                 [1, 2] ? uni.navigateTo({
                 [1, 2] ? uni.navigateTo({
-                    url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify({ ...service, key }))}`
+                    url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify(parmas))}`
                 }) : uni.showToast({
                 }) : uni.showToast({
                     title: '敬请期待',
                     title: '敬请期待',
                     icon: 'none'
                     icon: 'none'

+ 2 - 117
pages_home/pages/register/data.js

@@ -96,77 +96,8 @@ const rules = {
     ]
     ]
 }
 }
 
 
-//陪伴陪聊注册 1
-const chatting = [
-    {
-        label: "姓名",
-        key: "name",
-        type: "input",
-        rules: rules.name,
-        required:true
-    },
-    {
-        label: "性别",
-        key: "sex",
-        type: "select",
-        option: sex_option,
-        rules: rules.sex,
-        required:true
-    },
-    {
-        label: "年龄",
-        key: "age",
-        type: "input",
-        rules: rules.age,
-        required:true
-    },
-    {
-        label: "手机号",
-        key: "phonenumber",
-        type: "phone-code",
-    },
-    // {
-    //     label: "服务项目",
-    //     key: "businessManagementId",
-    //     type: "cascader",
-    //     cascaderKey:'0',
-    //     rules: rules.businessManagementId,
-    //     required:true,
-    //     apifun: ()=>{
-    //         return new Promise((resolve, reject) => {
-    //             getTreeList({ parentId: "1" }).then(res => {
-    //                 resolve(res.data)
-    //             })
-    //         })
-    //     },
-    //     optionKey:'businessManagementOption'
-    // },
-    {
-        label: "地区",
-        key: "city",
-        type: "city",
-        option: city_option,
-        rules: rules.city,
-        required:true
-    },
-    {
-        label: "详细地址",
-        key: "address",
-        type: "input",
-        rules: rules.address,
-        required:true
-    },
-    {
-        label: "技能简介",
-        key: "skillDescribe",
-        type: "textarea",
-        rules: rules.skillDescribe,
-        required:true
-    },
-]
 
 
-//孩子陪护(教育)2
-const education = [
+const column = [
     {
     {
         label: "姓名",
         label: "姓名",
         key: "name",
         key: "name",
@@ -194,29 +125,6 @@ const education = [
         key: "phonenumber",
         key: "phonenumber",
         type: "phone-code",
         type: "phone-code",
     },
     },
-    // {
-    //     label: "服务项目",
-    //     key: "businessManagementId",
-    //     type: "cascader",
-    //     cascaderKey:'0',
-    //     rules: rules.businessManagementId,
-    //     required:true,
-    //     apifun: ()=>{
-    //         return new Promise((resolve, reject) => {
-    //             getTreeList({ parentId: "2" }).then(res => {
-    //                 resolve(res.data)
-    //             })
-    //         })
-    //     },
-    //     optionKey:'businessManagementOption'
-    // },
-    // {
-    //     label: "证件号",
-    //     key: "idCard",
-    //     type: "input",
-    //     rules: rules.idCard,
-    //     required:true
-    // },
     {
     {
         label: "地区",
         label: "地区",
         key: "city",
         key: "city",
@@ -224,7 +132,6 @@ const education = [
         option: city_option,
         option: city_option,
         rules: rules.city,
         rules: rules.city,
         required:true
         required:true
-
     },
     },
     {
     {
         label: "详细地址",
         label: "详细地址",
@@ -241,26 +148,4 @@ const education = [
         required:true
         required:true
     },
     },
 ]
 ]
-
-// 健康管理
-const health  = [
-    {
-        label: "地区",
-        key: "city",
-        type: "city",
-        option: city_option,
-        rules: rules.city,
-        required:true
-    },
-    {
-        label: "详细地址",
-        key: "address",
-        type: "input",
-        rules: rules.address,
-        required:true
-    },
-]
-
-
-
-export { chatting, education,health}
+export {  column}

+ 54 - 66
pages_home/pages/register/index.vue

@@ -58,7 +58,7 @@
 
 
 		<view v-for="item in updata_list" :key="item.key" class="updata-imgs">
 		<view v-for="item in updata_list" :key="item.key" class="updata-imgs">
 			<UpdataImgs :fileList="file_url[item.key]" :data="item" ref="zsImg"
 			<UpdataImgs :fileList="file_url[item.key]" :data="item" ref="zsImg"
-				v-if="item.permission.includes(data.key)" @onSubmit="onChange" />
+				 @onSubmit="onChange" />
 		</view>
 		</view>
 
 
 
 
@@ -75,7 +75,7 @@ import { onLoad } from '@dcloudio/uni-app';
 import FontTitle from "@/pages_home/components/font-title/index.vue";
 import FontTitle from "@/pages_home/components/font-title/index.vue";
 import CustForm from "@/pages_home/components/cust-form/index";
 import CustForm from "@/pages_home/components/cust-form/index";
 import UpdataImgs from "@/pages_home/components/updata-imgs/index.vue";
 import UpdataImgs from "@/pages_home/components/updata-imgs/index.vue";
-import { chatting, education, health } from "./data";
+import { column } from "./data";
 import { add, getVolunteerInfo } from "@/api/volunteer";
 import { add, getVolunteerInfo } from "@/api/volunteer";
 import { computed } from 'vue';
 import { computed } from 'vue';
 import { getTreeList } from '@/api/volunteer'
 import { getTreeList } from '@/api/volunteer'
@@ -91,7 +91,7 @@ const updata_list = [
 		img: '/static/img/updata-user-img.png',
 		img: '/static/img/updata-user-img.png',
 		key: 'volunteerPicture',
 		key: 'volunteerPicture',
 		ref: userImg,
 		ref: userImg,
-		permission: [1, 2],
+		// permission: [1, 2],
 		required: true
 		required: true
 	},
 	},
 	{
 	{
@@ -100,7 +100,7 @@ const updata_list = [
 		img: '/static/img/updata-user-img.png',
 		img: '/static/img/updata-user-img.png',
 		key: 'idCardPicture',
 		key: 'idCardPicture',
 		ref: zsImg,
 		ref: zsImg,
-		permission: [1, 2],
+		// permission: [1, 2],
 		required: true
 		required: true
 	},
 	},
 	{
 	{
@@ -109,7 +109,7 @@ const updata_list = [
 		img: '/static/img/updata-user-img.png',
 		img: '/static/img/updata-user-img.png',
 		key: 'certificationPicture',
 		key: 'certificationPicture',
 		ref: zsImg,
 		ref: zsImg,
-		permission: [1, 2],
+		// permission: [1, 2],
 		required: false
 		required: false
 	}
 	}
 ]
 ]
@@ -131,8 +131,8 @@ const serviceKeys = reactive({
 	classKeyname: '',
 	classKeyname: '',
 	itemKey: '',//服务项目
 	itemKey: '',//服务项目
 	itemKeyname: '',
 	itemKeyname: '',
-	time:'',//时间
-	price:'',//价格
+	time: '',//时间
+	price: '',//价格
 })
 })
 
 
 const timeList = [
 const timeList = [
@@ -154,16 +154,10 @@ const sex_status = {
 	'男': 0,
 	'男': 0,
 	'女': 1
 	'女': 1
 }
 }
-const register_column = {
-	1: chatting,
-	2: education,
-	3: health
-
-}
 
 
 //根据类型获取表单item 值
 //根据类型获取表单item 值
 const com_column = computed(() => {
 const com_column = computed(() => {
-	let column_list = data.value ? register_column[data.value.key] : [];
+	let column_list = data.value ?column : [];
 	return column_list
 	return column_list
 })
 })
 
 
@@ -173,16 +167,13 @@ function onSubmit() {
 		// return;
 		// return;
 		// 校验表单并获取数据
 		// 校验表单并获取数据
 		cust_form_ref.value.onSubmit().then(async (res) => {
 		cust_form_ref.value.onSubmit().then(async (res) => {
-			console.log('===res===>', res, file_url);
 
 
 			//文件必传校验
 			//文件必传校验
 			for (let i = 0; i < updata_list.length; i++) {
 			for (let i = 0; i < updata_list.length; i++) {
 				const element = updata_list[i];
 				const element = updata_list[i];
-				console.log(element.required, element.permission.includes(data.value.key), file_url[element.key]);
 
 
 
 
 				const type = element.required && element.permission.includes(data.value.key) && !file_url[element.key];
 				const type = element.required && element.permission.includes(data.value.key) && !file_url[element.key];
-				console.log('element', element, type);
 
 
 				if (type) {
 				if (type) {
 					uni.showToast({
 					uni.showToast({
@@ -192,33 +183,33 @@ function onSubmit() {
 					return;
 					return;
 				}
 				}
 			}
 			}
-		
-			if(!(serviceKeys.itemKeyname || serviceKeys.classKeyname)){
+
+			if (!(serviceKeys.itemKeyname || serviceKeys.classKeyname)) {
 				uni.showToast({
 				uni.showToast({
-						title: '请选择服务',
-						icon: 'none'
-					})
+					title: '请选择服务',
+					icon: 'none'
+				})
 				return
 				return
 			}
 			}
-			if(!serviceKeys.time){
+			if (!serviceKeys.time) {
 				uni.showToast({
 				uni.showToast({
-						title: '请选择服务时长',
-						icon: 'none'
-					})
+					title: '请选择服务时长',
+					icon: 'none'
+				})
 				return
 				return
 			}
 			}
-			if(!serviceKeys.price){
+			if (!serviceKeys.price) {
 				uni.showToast({
 				uni.showToast({
-						title: '请输入服务价格',
-						icon: 'none'
-					})
+					title: '请输入服务价格',
+					icon: 'none'
+				})
 				return
 				return
 			}
 			}
 
 
 			const parmas = {
 			const parmas = {
 				serviceCategory: data.value.key,
 				serviceCategory: data.value.key,
 				...file_url,
 				...file_url,
-				businessManagementId:serviceKeys.itemKey || serviceKeys.classKey,
+				businessManagementId: serviceKeys.itemKey || serviceKeys.classKey,
 				businessPrice: serviceKeys.price,
 				businessPrice: serviceKeys.price,
 				businessDuration: serviceKeys.time
 				businessDuration: serviceKeys.time
 			};
 			};
@@ -251,7 +242,6 @@ function onSubmit() {
 				title: res.msg,
 				title: res.msg,
 				icon: 'none'
 				icon: 'none'
 			})
 			})
-			console.log('==submit_res====>', submit_res);
 		})
 		})
 
 
 
 
@@ -265,7 +255,6 @@ function onSubmit() {
 }
 }
 
 
 function onChange({ key, url }) {
 function onChange({ key, url }) {
-	console.log('onChange', key, url);
 	Object.assign(file_url, {
 	Object.assign(file_url, {
 		[key]: url
 		[key]: url
 	})
 	})
@@ -273,37 +262,36 @@ function onChange({ key, url }) {
 
 
 function idToIndexs(array, targetId, path = []) {
 function idToIndexs(array, targetId, path = []) {
 
 
-    for (let i = 0; i < array.length; i++) {
-        const item = array[i];
-        const currentPath = path.concat(i);
+	for (let i = 0; i < array.length; i++) {
+		const item = array[i];
+		const currentPath = path.concat(i);
 
 
-        if (item.id === targetId) {
-			console.log('indexs',item);
-            return item
-        }
+		if (item.id === targetId) {
+			return item
+		}
 
 
-        if (item.children) {
-            const result = idToIndexs(item.children, targetId, currentPath);
-            if (result) {
-                return result;
-            }
-        }
-    }
+		if (item.children) {
+			const result = idToIndexs(item.children, targetId, currentPath);
+			if (result) {
+				return result;
+			}
+		}
+	}
 
 
-    return null; // 如果没有找到对应的项,返回 null
+	return null; // 如果没有找到对应的项,返回 null
 }
 }
 //重新提交的服务信息回显
 //重新提交的服务信息回显
-function servesInit(){
-	const indexs =  idToIndexs(serviceOptions.value,details.value.businessManagementId +'')
+function servesInit() {
+	const indexs = idToIndexs(serviceOptions.value, details.value.businessManagementId + '')
 	const names = indexs.businessTierName.split('-');
 	const names = indexs.businessTierName.split('-');
 	Object.assign(serviceKeys, {
 	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,//价格
-				})
+		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,//价格
+	})
 }
 }
 async function getRegister() {
 async function getRegister() {
 
 
@@ -320,12 +308,15 @@ async function getRegister() {
 				idCardPicture: res.data.idCardPicture,
 				idCardPicture: res.data.idCardPicture,
 				certificationPicture: res.data.certificationPicture
 				certificationPicture: res.data.certificationPicture
 			})
 			})
-
-			 servesInit(data)
-
-		
+			servesInit(data)
 			isAdd.value = false;
 			isAdd.value = false;
-			
+		}
+
+		if (data.value.record) {
+			Object.assign(serviceKeys, {
+				classKey: data.value.record.id,//服务类别
+				classKeyname: data.value.record.businessName,
+			})
 		}
 		}
 	} catch (error) {
 	} catch (error) {
 		console.log('error', error);
 		console.log('error', error);
@@ -341,7 +332,6 @@ async function getRegister() {
 
 
 
 
 const serviceChange = (item, key) => {
 const serviceChange = (item, key) => {
-	console.log('----', item);
 	if (key === 'classKey') {
 	if (key === 'classKey') {
 		serviceItems.value = item.children;
 		serviceItems.value = item.children;
 		serviceKeys['itemKey'] = '';
 		serviceKeys['itemKey'] = '';
@@ -354,7 +344,6 @@ const serviceChange = (item, key) => {
 }
 }
 const getTreeListInit = () => {
 const getTreeListInit = () => {
 	getTreeList({ parentId: data.value.key }).then(res => {
 	getTreeList({ parentId: data.value.key }).then(res => {
-		console.log('----', res.data);
 		serviceOptions.value = res.data;
 		serviceOptions.value = res.data;
 	})
 	})
 }
 }
@@ -365,7 +354,7 @@ onMounted(() => {
 onLoad((options) => {
 onLoad((options) => {
 	const option = JSON.parse(decodeURIComponent(options.data));
 	const option = JSON.parse(decodeURIComponent(options.data));
 	data.value = option;
 	data.value = option;
-	console.log("option", option);
+	console.log("option", data.value);
 
 
 	uni.setNavigationBarTitle({
 	uni.setNavigationBarTitle({
 		title: option.name  // 根据业务逻辑调整 
 		title: option.name  // 根据业务逻辑调整 
@@ -373,7 +362,6 @@ onLoad((options) => {
 
 
 	setTimeout(() => {
 	setTimeout(() => {
 		getRegister();
 		getRegister();
-
 	}, 500);
 	}, 500);
 
 
 })
 })