htc hai 16 horas
pai
achega
484ad0a5b7

+ 0 - 77
components/pages/activityArea/city-data.js

@@ -1,77 +0,0 @@
-// 模拟的省市区数据
-// 真实项目中建议使用完整的城市数据JS或JSON文件
-export const cityData = [
-  {
-    "name": "北京",
-    "children": [
-      {
-        "name": "北京市",
-        "children": [
-          { "name": "东城区" },
-          { "name": "西城区" },
-          { "name": "朝阳区" },
-          { "name": "海淀区" }
-        ]
-      }
-    ]
-  },
-  {
-    "name": "浙江省",
-    "children": [
-      {
-        "name": "杭州市",
-        "children": [
-          { "name": "上城区" },
-          { "name": "下城区" },
-          { "name": "江干区" },
-          { "name": "拱墅区" },
-          { "name": "西湖区" },
-          { "name": "滨江区" }
-        ]
-      },
-      {
-        "name": "宁波市",
-        "children": [
-          { "name": "海曙区" },
-          { "name": "江北区" },
-          { "name": "镇海区" },
-          { "name": "北仑区" }
-        ]
-      },
-      {
-        "name": "温州市",
-        "children": [
-          { "name": "鹿城区" },
-          { "name": "龙湾区" },
-          { "name": "瓯海区" },
-          { "name": "萧山区" }
-        ]
-      }
-    ]
-  },
-  {
-    "name": "江苏省",
-    "children": [
-      {
-        "name": "南京市",
-        "children": [
-          { "name": "玄武区" },
-          { "name": "秦淮区" },
-          { "name": "建邺区" }
-        ]
-      },
-      {
-        "name": "苏州市",
-        "children": [
-          { "name": "姑苏区" },
-          { "name": "虎丘区" },
-          { "name": "吴中区" }
-        ]
-      }
-    ]
-  },
-  // ... 其他省份
-];
-
-// 热门城市
-export const hotCities = ['北京', '上海', '广州', '深圳', '杭州', '南京'];

+ 50 - 17
components/pages/activityArea/index.vue

@@ -73,29 +73,29 @@
 </template>
 
 <script setup>
-import { ref, watch, computed } from 'vue';
-import { cityData, hotCities } from './city-data.js';
-
+import { ref, watch, computed, onMounted, getCurrentInstance } from 'vue';
+const { proxy } = getCurrentInstance()
 const emit = defineEmits(['update:show', 'confirm']);
-
-// --- Data ---
-const provinces = ref(cityData);
+
+const hotCities = ['武汉','南京','郑州','杭州','上海','苏州','厦门','深圳','北京','广州','长沙','成都'];
+const cityData = ref([])
+const provinces = ref([]);
 const cities = ref([]);
 const areas = ref([]);
-
 const pickerValue = ref([0, 0, 0]);
-
 const selectedProvince = computed(() => provinces.value[pickerValue.value[0]] || {});
 const selectedCity = computed(() => cities.value[pickerValue.value[1]] || {});
 const selectedArea = computed(() => areas.value[pickerValue.value[2]] || {});
 
-
 // 确认选择
 const handleConfirm = () => {
   const result = {
     province: selectedProvince.value.name,
     city: selectedCity.value.name,
     area: selectedArea.value.name,
+    provinceId: selectedProvince.value.id,
+    cityId: selectedCity.value.id,
+    areaId: selectedArea.value.id,
   };
   emit('confirm', result);
 };
@@ -173,20 +173,53 @@ const handleHotCityClick = (cityName) => {
       icon: 'none'
     });
   }
-};
+};
+
+const getTreeData = () => {
+	return new Promise(resolve=>{
+		proxy.$api.get('/tree').then(({data:res})=>{
+			cityData.value = dealTreeData(res.data);
+			resolve(cityData.value)
+		})
+	})
+}
+
+const dealTreeData = (data) => {
+	try{
+		const nodeMap = new Map()
+		const result = [];
+		data.forEach(d=>{
+			nodeMap.set(d.id,{...d,children:[]})
+		})
+		
+		data.forEach(d=>{
+			const node = nodeMap.get(d.id);
+			const parent = nodeMap.get(d.pid)
+			
+			if(parent) parent.children.push(node)
+			else result.push(node)
+		})
+		
+		return result
+	}catch(e){
+		return []
+	}
+}
 
 // 初始化数据
-const initialize = () => {
-  const [pIndex, cIndex] = pickerValue.value;
-  cities.value = provinces.value[pIndex]?.children || [];
-  areas.value = cities.value[cIndex]?.children || [];
+const initialize = async () => {
+	provinces.value = await getTreeData();
+	const [pIndex, cIndex] = pickerValue.value;
+	cities.value = provinces.value[pIndex]?.children || [];
+	areas.value = cities.value[cIndex]?.children || [];
 };
 
-// 初始化
-initialize();
-
 defineExpose({
 	initialize
+})
+
+onMounted(()=>{
+	initialize();
 })
 </script>
 

+ 23 - 0
components/pages/nonprofitActivety/index.vue

@@ -3,6 +3,7 @@
 		<div class="na-top adf">
 			<div class="na-top-left">
 				<image :src="item.coverFile"></image>
+				<div class="na-top-left-status">{{statusCfg[item.activeState]}}</div>
 			</div>
 			<div class="na-top-right">
 				<p>{{item.activityName||''}}</p>
@@ -42,6 +43,12 @@
 	import { ref } from 'vue'
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
+	const statusCfg = ref({
+		0:'未开始',
+		1:'报名中',
+		2:'进行中',
+		3:'已结束'
+	})
 	
 	const handleDetail = item => {
 		uni.navigateTo({
@@ -65,10 +72,26 @@
 			&-left{
 				width: 158rpx;
 				height: 214rpx;
+				position: relative;
 				image{
 					width: 100%;
 					height: 100%;
 				}
+				&-status{
+					width: 108rpx;
+					height: 40rpx;
+					background: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/11/17/301153c2-1142-48cd-be9e-26c97220436c.png') no-repeat;
+					background-size: 100% 100%;
+					font-family: PingFang-SC, PingFang-SC;
+					font-weight: bold;
+					font-size: 24rpx;
+					color: #151B29;
+					line-height: 36rpx;
+					padding-left: 12rpx;
+					position: absolute;
+					left: 0;
+					top: 0;
+				}
 			}
 			&-right{
 				width: calc(100% - 158rpx);