Pārlūkot izejas kodu

feat: 地址接入

chenjj 3 nedēļas atpakaļ
vecāks
revīzija
88041ace14

+ 1 - 1
components/Client/new_file.vue

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

+ 51 - 42
manifest.json

@@ -1,28 +1,28 @@
 {
-    "name" : "lrr-mini-program",
-    "appid" : "__UNI__3DD118D",
-    "description" : "",
-    "versionName" : "1.0.0",
-    "versionCode" : "100",
-    "transformPx" : false,
+    "name": "lrr-mini-program",
+    "appid": "__UNI__3DD118D",
+    "description": "",
+    "versionName": "1.0.0",
+    "versionCode": "100",
+    "transformPx": false,
     /* 5+App特有相关 */
-    "app-plus" : {
-        "usingComponents" : true,
-        "nvueStyleCompiler" : "uni-app",
-        "compilerVersion" : 3,
-        "splashscreen" : {
-            "alwaysShowBeforeRender" : true,
-            "waiting" : true,
-            "autoclose" : true,
-            "delay" : 0
+    "app-plus": {
+        "usingComponents": true,
+        "nvueStyleCompiler": "uni-app",
+        "compilerVersion": 3,
+        "splashscreen": {
+            "alwaysShowBeforeRender": true,
+            "waiting": true,
+            "autoclose": true,
+            "delay": 0
         },
         /* 模块配置 */
-        "modules" : {},
+        "modules": {},
         /* 应用发布信息 */
-        "distribute" : {
+        "distribute": {
             /* android打包配置 */
-            "android" : {
-                "permissions" : [
+            "android": {
+                "permissions": [
                     "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                     "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                     "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
@@ -41,38 +41,47 @@
                 ]
             },
             /* ios打包配置 */
-            "ios" : {},
+            "ios": {},
             /* SDK配置 */
-            "sdkConfigs" : {}
+            "sdkConfigs": {}
         }
     },
     /* 快应用特有相关 */
-    "quickapp" : {},
+    "quickapp": {},
     /* 小程序特有相关 */
-    "mp-weixin" : {
-        "appid" : "wxe8a05852410396cf",
-        "setting" : {
-            "urlCheck" : false,
-            "postcss" : true,
-            "minified" : false
+    "mp-weixin": {
+        "appid": "wxe8a05852410396cf",
+        "setting": {
+            "urlCheck": false,
+            "postcss": true,
+            "minified": false
         },
-        "usingComponents" : true,
-        "optimization" : {
-            "subPackages" : true
+        "usingComponents": true,
+        "optimization": {
+            "subPackages": true
         },
-        "lazyCodeLoading" : "requiredComponents"
+        "lazyCodeLoading": "requiredComponents",
+        "requiredPrivateInfos": [
+            "getLocation",
+            "chooseLocation"
+          ],
+         "permission": {
+            "scope.userLocation": {
+              "desc": "你的位置信息将用于警情上报"
+            }
+          }
     },
-    "mp-alipay" : {
-        "usingComponents" : true
+    "mp-alipay": {
+        "usingComponents": true
     },
-    "mp-baidu" : {
-        "usingComponents" : true
+    "mp-baidu": {
+        "usingComponents": true
     },
-    "mp-toutiao" : {
-        "usingComponents" : true
+    "mp-toutiao": {
+        "usingComponents": true
     },
-    "uniStatistics" : {
-        "enable" : false
+    "uniStatistics": {
+        "enable": false
     },
-    "vueVersion" : "3"
-}
+    "vueVersion": "3"
+}

+ 52 - 34
pages.json

@@ -55,7 +55,8 @@
 			}
 		}
 	],
-	"subPackages": [{
+	"subPackages": [
+		{
 			"root": "pages_home/",
 			"pages": [
 				{
@@ -74,7 +75,6 @@
 					"path": "pages/details/index",
 					"style": {
 						"navigationBarTitleText": "注册详情"
-						
 					}
 				},
 				{
@@ -83,11 +83,21 @@
 						"navigationBarTitleText": "详情"
 					}
 				},
-				{"path": "components/cc-selectDity/cc-selectDity"},
-				{"path": "components/cust-form/index"},
-				{"path": "components/font-title/index"},
-				{"path": "components/picker/index"},
-				{"path": "components/updata-imgs/index"},
+				{
+					"path": "components/cc-selectDity/cc-selectDity"
+				},
+				{
+					"path": "components/cust-form/index"
+				},
+				{
+					"path": "components/font-title/index"
+				},
+				{
+					"path": "components/picker/index"
+				},
+				{
+					"path": "components/updata-imgs/index"
+				},
 				{
 					"path": "pages/login/index",
 					"style": {
@@ -104,7 +114,8 @@
 		},
 		{
 			"root": "pages_orderuser/pages",
-			"pages": [{
+			"pages": [
+				{
 					"path": "order/orderdetails",
 					"style": {
 						"navigationBarTitleText": "消息"
@@ -240,12 +251,15 @@
 						"navigationBarTitleText": "添加用户地址"
 					}
 				},
-				{"path": "components/u-city-select/u-city-select"}
+				{
+					"path": "components/u-city-select/u-city-select"
+				}
 			]
 		},
 		{
 			"root": "pages_classify",
-			"pages": [{
+			"pages": [
+				{
 					"path": "pages/handle/index",
 					"style": {
 						"navigationBarTitleText": "订单处理"
@@ -263,19 +277,22 @@
 						"navigationBarTitleText": "详情"
 					}
 				},
-				{"path": "components/PositioningMap/index"},
-				{"path": "components/Slide/index"}
-
+				{
+					"path": "components/PositioningMap/index"
+				},
+				{
+					"path": "components/Slide/index"
+				}
 			]
 		}
-		
 	],
 	"tabBar": {
 		"color": "#000000",
 		"selectedColor": "#000000",
 		"borderStyle": "white",
 		"backgroundColor": "#ffffff",
-		"list": [{
+		"list": [
+			{
 				"pagePath": "pages/index",
 				"iconPath": "static/images/tabbar/home.png",
 				"selectedIconPath": "static/images/tabbar/home_.png",
@@ -285,7 +302,8 @@
 				"pagePath": "pages/mallMenu",
 				"iconPath": "static/images/tabbar/class.png",
 				"selectedIconPath": "static/images/tabbar/class_.png",
-				"text": "分类"
+				"text": "分类",
+				"visible": false
 			},
 			{
 				"pagePath": "pages/classify",
@@ -305,23 +323,23 @@
 		"navigationBarTextStyle": "black",
 		"navigationBarTitleText": "RuoYi",
 		"navigationBarBackgroundColor": "#FFFFFF"
+	},
+	"plugins": {
+		"citySelector": {
+			"version": "1.0.2",
+			"provider": "wx63ffb7b7894e99ae"
+		}
+		// "chooseLocation": {
+		// 	"version": "1.1.1",
+		// 	"provider": "wx76a9a06e5b4e693e"
+		// }
+	},
+	"permission": {
+		"scope.userFuzzyLocation": {
+			"desc": "你的位置信息将用于小程序定位"
+		},
+		"scope.userLocation": {
+			"desc": "你的位置信息将用于小程序定位"
+		}
 	}
-// 	"plugins":{
-// 		"chooseLocation": {
-// 			"version": "1.1.1",
-// 			"provider": "wx76a9a06e5b4e693e"
-// 		},
-// 		"citySelector": {
-// 			"version": "1.0.2",
-// 			"provider": "wx63ffb7b7894e99ae"
-// 		}
-// 	},
-// 	"permission": {
-//     "scope.userLocation": {
-//       "desc": "你的位置信息将用于小程序定位"
-//     },
-// 	"scope.userFuzzyLocation": {
-// 		"desc": "你的位置信息将用于小程序定位"
-// 	  }
-//   }
 }

+ 1 - 3
pages/UserSelection.vue

@@ -42,14 +42,12 @@ const list = [
 		bgcColor: ' rgba(233, 91, 93, 1)'
 	}
 ]
-
 function handleBtn(userType = 0) { // 默认值 0
 	const params = {
 		userType: userType // 使用传入的 userType
 	};
 	// 把 userType 存入本地存储
 	uni.setStorageSync('userType', userType);
-
 	userOrWorker(params)
 		.then(res => {
 			// 重新拉取用户信息,储存本地
@@ -62,6 +60,7 @@ function handleBtn(userType = 0) { // 默认值 0
 		.catch(err => {
 			console.error('设置失败:', err);
 		});
+
 }
 </script>
 
@@ -142,5 +141,4 @@ function handleBtn(userType = 0) { // 默认值 0
 	color: rgba(107, 114, 128, 1);
 	margin-top: 36rpx;
 }
-
 </style>

+ 11 - 12
pages/index.vue

@@ -1,8 +1,7 @@
 <template>
 	<view class="main-content">
 		<view class="home-banner" :style="`height: ${globalData.navBarHeight}px `">
-			<view class="home-banner-left">
-				<!-- @click="cityClick" -->
+			<view class="home-banner-left" @click="cityClick">
 				<up-icon name="map" color="#fff" size="25"></up-icon>
 				<text>{{ data.address }}</text>
 			</view>
@@ -79,7 +78,7 @@ import { citySelectorNavigateTo } from '@/utils/adress'
 
 
 
-// const citySelector = requirePlugin('citySelector');
+const citySelector = requirePlugin('citySelector');
 
 const total = ref(0)
 const listData = ref([])
@@ -215,19 +214,19 @@ onShow(() => {
 		}
 	});
 
-	// if (citySelector) {
-	// 	const selectedCity = citySelector.getCity(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
-	// 	console.log('citySelector', selectedCity,selectedCity.name)
-	// 	data.address = selectedCity.name;
-	// }
+	if (citySelector) {
+		const selectedCity = citySelector.getCity(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
+		console.log('citySelector', selectedCity,selectedCity.name)
+		data.address = selectedCity.name;
+	}
 
 })
 
 onUnload(() => {
-	// if (citySelector) {
-	// 	// 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
-	// 	citySelector.setLocation(null);
-	// }
+	if (citySelector) {
+		// 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
+		citySelector.setLocation(null);
+	}
 
 })
 </script>

+ 51 - 5
pages/mallMenu.vue

@@ -19,7 +19,7 @@
                             <view class="item-container">
                                 <view class="thumb-box"
                                     v-for="(item1, index1) in (classItem.children ? classItem.children : [classItem])"
-                                    :key="index1" @click="clickMenu(item1)">
+                                    :key="index1" @click="clickMenu(item1, classItem.parentId)">
                                     <!-- <image class="item-menu-image" src="https://cdn.uviewui.com/uview/common/classify/1/1.jpg" mode=""></image> -->
                                     <view class="item-menu-name">{{ item1.businessName }}</view>
                                 </view>
@@ -33,6 +33,8 @@
 </template>
 <script>
 import { getTreeList } from '@/api/volunteer'
+import { volunteerSeachgetTreeList } from "@/api/volunteerDetailsApi/details.js"
+import { getVolunteerInfo } from '@/api/volunteer.js'
 export default {
     data() {
         return {
@@ -47,6 +49,7 @@ export default {
             arr: [],
             scrollRightTop: 0, // 右边栏目scroll-view的滚动条高度
             timer: null, // 定时器
+            userType: uni.getStorageSync('userType')
 
         }
     },
@@ -164,9 +167,51 @@ export default {
                 }
             }, 10)
         },
-        clickMenu(menu) {
-            console.log(menu);
+        async clickMenu(service, key) {
+            console.log(service, key);
+
+            if (this.userType == '2') {
+                const res = await getVolunteerInfo({
+                    serviceCategory: key
+                });
+                if (res.code === 200 && res.data) {
+                    //已有注册,跳转详情页面
+                    uni.navigateTo({
+                        url: `/pages_home/pages/details/index?data=${encodeURIComponent(JSON.stringify({ ...service, key }))}`
+                    })
+                    return
+                }
+                [1, 2] ? uni.navigateTo({
+                    url: `/pages_home/pages/register/index?data=${encodeURIComponent(JSON.stringify({ ...service, key }))}`
+                }) : uni.showToast({
+                    title: '敬请期待',
+                    icon: 'none'
+                })
+                return;
+
+            }
+
+            // 动态获取 parentId
+            const params = {
+                parentId: key
+            }
+            const res = await volunteerSeachgetTreeList(params)
+            // 只有第一条和第二条可以跳转
+            if (key === '1' || key === '2') {
+                uni.navigateTo({
+                    url: `/pages_home/pages/client/details?dataList=${encodeURIComponent(JSON.stringify(res.data))}`
+                });
+            } else {
+                // 其他条目提示“敬请期待”
+                uni.showToast({
+                    title: '敬请期待',
+                    icon: 'none'
+                });
+            }
+
         }
+
+
     }
 }
 </script>
@@ -230,6 +275,7 @@ export default {
     font-weight: 600;
     background: #fff;
 }
+
 .u-tab-item-active::before {
     border-left: 4px solid rgba(221, 94, 69, 1) !important;
 }
@@ -284,9 +330,9 @@ export default {
 .item-container {
     // display: flex;
     // flex-wrap: wrap;
-    display:grid;
+    display: grid;
     grid-template-columns: repeat(3, 1fr);
-	gap: 12rpx;
+    gap: 12rpx;
     margin: 24rpx 0;
 }
 

+ 7 - 3
pages_classify/pages/order/index.vue

@@ -278,15 +278,19 @@ onLoad((options) => {
 	}
 
 	.upload-img {
-		height: 68px;
-		width: 68px;
+		// height: 68px;
+		// width: 68px;
 		margin-right: 12px;
 		margin-bottom: 12px;
 	}
 
 	.upload-box {
+		// display: flex;
+		// flex-wrap: wrap;
 		display: flex;
-		flex-wrap: wrap;
+		flex-direction: column;
+		align-items: center;
+		justify-content: center;
 
 		.upload-img-item {
 			position: relative;

+ 43 - 32
pages_home/components/cust-form/index.vue

@@ -28,7 +28,8 @@
                             trigger: ['blur']
                         }
                     ]" :required="true">
-                        <up-input v-model="formData.phonenumber" border="none" placeholder="请输入手机号" :disabled="!isCode"></up-input>
+                        <up-input v-model="formData.phonenumber" border="none" placeholder="请输入手机号"
+                            :disabled="!isCode"></up-input>
                     </up-form-item>
 
                     <up-form-item label="验证码" prop="code" labelWidth="94" borderBottom :rules="[
@@ -39,7 +40,7 @@
                             message: '请填写4位验证码',
                             trigger: ['blur']
                         }
-                    ]" :required="true" >
+                    ]" :required="true">
                         <up-input v-model="formData.code" border="none" placeholder="请填写验证码"></up-input>
                         <template #right>
                             <up-button @tap="getCode" :text="code_data.tips" type="success" size="mini"
@@ -61,11 +62,11 @@
                 <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="省、市、区等地区信息" border="none"></up-input>
+                        <up-input v-model="formData[item.key]" disabled disabledColor="#ffffff" placeholder="省、市、区等地区信息"
+                            border="none"></up-input>
                     </view>
                     <template #right>
-                        <up-icon name="map"  size="22"  @click="onCityWx"></up-icon>
+                        <up-icon name="map" size="22" @click="onCityWx(item)"></up-icon>
                     </template>
                 </up-form-item>
 
@@ -103,10 +104,10 @@ import CcSelectDity from '@/pages_home/components/cc-selectDity/cc-selectDity.vu
 import Picker from '@/pages_home/components/picker/index.vue'
 import { sendCode } from '@/api/sm.js';
 import {
-	onShow,
-	onUnload
+    onShow,
+    onUnload
 } from "@dcloudio/uni-app";
-import { chooseLocationInit } from '@/utils/adress'
+import { splitAddress } from '@/utils/adress'
 const props = defineProps({
     column: {
         type: Array,
@@ -117,7 +118,6 @@ const props = defineProps({
         default: true
     }
 });
-// const chooseLocation = requirePlugin('chooseLocation');
 const formData = reactive({
     sex: null,
     city: null,
@@ -216,13 +216,13 @@ async function getCode() {
             })
             const res = await sendCode(formData.phonenumber);
             console.log(res);
-            
+
             if (res.code == 200) {
                 uni.hideLoading();
                 uCode.value.start();
                 uni.$u.toast('验证码已发送');
             }
-        }else{
+        } else {
             uni.$u.toast('请输入手机号');
         }
     } else {
@@ -243,26 +243,26 @@ function startFace() {
 function setData(data) {
     console.log('setData=>data', data);
     Object.assign(formData, {
-                ...data,
-                sex: data.sex === 0 ? '男' : '女',
+        ...data,
+        sex: data.sex === 0 ? '男' : '女',
     })
     for (let i = 0; i < props.column.length; i++) {
         const element = props.column[i];
 
-       
+
         if (element.type === 'cascader') {
             const key = data[element.key]
             // const key ='7'
 
             const lable = pickerRef.value.piceInit(key);
-            console.log('element.type', lable, key,element.key);
+            console.log('element.type', lable, key, element.key);
             Object.assign(formData, {
                 [element.key]: lable,
                 [element.key + 'key']: key
             })
             console.log('eformData', formData);
-        }else {
-            
+        } else {
+
         }
 
     }
@@ -293,25 +293,36 @@ function clickPick(row) {
     pickerRef.value.show();
 
 }
-
-function onCityWx(){
-    console.log('地区选点');
-    // chooseLocationInit();
-    
+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}`,
+                address:result.detail
+            })
+        },
+        fail: function (err) {
+            console.log(err);
+            uni.showToast({
+			title:'获取地址失败',
+			icon: 'error',
+		});
+        },
+    })
 }
 
-onShow(()=>{
-    // if(chooseLocation){
-    //     const location = chooseLocation.getLocation(); // 如果点击确认选点按钮,则返回选点结果对象,否则返回null
-    //     Object.assign(formData, {     
-    //     })
-    // }
+onShow(() => {
+ 
 })
 onUnload(() => {
-	// if (chooseLocation) {
-	// 	// 页面卸载时设置插件选点数据为null,防止再次进入页面,geLocation返回的是上次选点结果
-	// 	chooseLocation.setLocation(null);
-	// }
 
 })
 onMounted(async () => {

+ 8 - 5
pages_home/pages/details/index.vue

@@ -354,14 +354,17 @@ onLoad((options) => {
 
     .card-imgs {
         display: flex;
-        flex-wrap: wrap;
-        margin-right: 32rpx;
+        // flex-wrap: wrap;
+        flex-direction: column;
+        align-items: center;
+        justify-content: center;
+
     }
 
     .upload-img {
-        height: 136rpx;
-        width: 136rpx;
-        margin-right: 24rpx;
+        // height: 136rpx;
+        // width: 136rpx;
+        margin-bottom: 24rpx;
     }
 }
 </style>

+ 7 - 1
pages_home/pages/register/data.js

@@ -251,7 +251,13 @@ const health  = [
         option: city_option,
         rules: rules.city,
         required:true
-
+    },
+    {
+        label: "详细地址",
+        key: "address",
+        type: "input",
+        rules: rules.address,
+        required:true
     },
 ]
 

+ 27 - 1
utils/adress.js

@@ -28,8 +28,34 @@ const citySelectorNavigateTo = (city) => {
     })
 }
 
+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 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
+    citySelectorNavigateTo,
+    splitAddress
 }