liubp
2025-12-19 5bdaf416d66b675131004de1aba5d161772a52b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
 
(function (vc) {
    vc.extends({
        data: {
            communityDetailInfo: {
                communityName: '',
                communityCode: '',
                provinceName: '',
                cityName: '',
                areaName: '',
                communityAddress: '',
                completionDate: '',
                takeTime: '',
                outTime: '',
                stateName: '',
                propertyType: '',
                propertyRoomArea: '',
                publicArea: '',
                communityType: '',
                area: '',
                totalArea: '',
                chargeableArea: '',
                multiStoreyArea: '',
                highStoreyArea1: '',
                highStoreyArea2: '',
                commercialArea: '',
                villaArea: '',
                officeArea: '',
                greenArea: '',
                residentialArea: '',
                nonResidentialArea: '',
                areaDetails: '',
                managementAddress: '',
                managementContactName: '',
                managementContactTel: '',
                managementContactDayTel: '',
                managementContactNightTel: '',
                managerName: '',
                managerTel: '',
                managerCert: '',
                managerCertName: '',
                managerCertNo: '',
                committeeName: '',
                committeeAddress: '',
                committeeSecretaryName: '',
                committeeSecretaryTel: '',
                committeeOfficeTel: '',
                committeeChairmanName: '',
                committeeChairmanTel: '',
                fireSprinklerTotal: '',
                fireChannelTotal: '',
                waterTankTotal: '',
                waterPoolTotal: '',
                elevatorTotal: '',
                elevatorType: '',
                elevatorInstallDate: '',
                elevatorUseYears: '',
                elevatorBrand1: '',
                monitorTotal: '',
                monitorMaintenanceUnit: '',
                gateTotal: '',
                gateBrand: '',
                gateSupplierContactName: '',
                gateSupplierContactTel: '',
                pumpTotal: '',
                garbageFixed: '',
                gateGuardTotal: '',
                carTotal: '',
                carGroundTotal: '',
                carUndergroundTotal: '',
                electricCarTotal: '',
                nonElectricCarTotal: '',
                nonElectricCarGroundArea: '',
                nonElectricCarUndergroundArea: '',
                clubArea: '',
                hourlyFee: '',
                dailyFee: '',
                onceFee: '',
                naturalBuildingTotal: '',
                doorBuildingTotal: '',
                highBuildingTotal: '',
                lowBuildingTotal: '',
                totalHousehold: '',
                residentialHousehold: '',
                commercialHousehold: ''
            }
        },
        _initMethod: function () {
            // 确保 vc.component 已完全初始化后再调用
            let retryCount = 0;
            const maxRetries = 20; // 最多重试20次(约1秒)
            const loadData = function() {
                if (vc.component && typeof vc.component._loadCommunityDetail === 'function') {
                    vc.component._loadCommunityDetail();
                } else {
                    retryCount++;
                    if (retryCount >= maxRetries) {
                        console.error('无法找到 _loadCommunityDetail 方法,已重试', maxRetries, '次');
                        return;
                    }
                    // 如果还未初始化,等待一下再试
                    setTimeout(loadData, 50);
                }
            };
            loadData();
        },
        _initEvent: function () {
        },
        methods: {
            _loadCommunityDetail: function () {
                // 优先从 hash 中获取参数(单页应用使用 hash 路由)
                let _communityId = '';
                const hash = location.hash;
                const search = location.search;
                
                // 先尝试从 hash 中获取
                if (hash && hash.indexOf('?') !== -1) {
                    const hashParams = hash.substring(hash.indexOf('?') + 1);
                    const params = hashParams.split('&');
                    for (let i = 0; i < params.length; i++) {
                        const param = params[i].split('=');
                        if (param[0] === 'communityId') {
                            _communityId = decodeURIComponent(param[1] || '');
                            break;
                        }
                    }
                }
                
                // 如果 hash 中没有,尝试从 search 中获取
                if (!_communityId) {
                    _communityId = vc.getParam('communityId') || '';
                }
                
                console.log('获取到的 communityId:', _communityId, '当前 URL:', location.href, 'hash:', hash, 'search:', search);
                
                if (!_communityId) {
                    console.warn('缺少communityId,无法加载小区详情');
                    return;
                }
                const param = {
                    params: {
                        page: 1,
                        row: 1,
                        communityId: _communityId
                    }
                };
                vc.http.apiGet(
                    '/community.listCommunitys',
                    param,
                    function (json, res) {
                        if (res.status !== 200) {
                            return;
                        }
                        const data = JSON.parse(json);
                        const communitys = data.data || data.communitys || [];
                        if (!communitys.length) {
                            console.warn('未获取到小区详情数据');
                            return;
                        }
                        const detail = vc.component._formatCommunityDetail(communitys[0]);
                        vc.component.communityDetailInfo = Object.assign({}, vc.component.communityDetailInfo, detail);
                    },
                    function (errInfo) {
                        console.log('请求失败处理', errInfo);
                    }
                );
            },
            _formatCommunityDetail: function (info) {
                if (!info) {
                    return {};
                }
                const totalHousehold = info.totalHousehold
                    || (info.residentialHouseholdCount && info.shopHouseholdCount
                        ? Number(info.residentialHouseholdCount || 0) + Number(info.shopHouseholdCount || 0)
                        : '');
                return {
                    communityName: info.communityName || info.name || '',
                    communityCode: info.communityCode || info.code || '',
                    provinceName: info.projectAddressProvince || info.provinceName || '',
                    cityName: info.projectAddressCity || info.cityName || '',
                    areaName: info.projectAddressDistrict || info.areaName || '',
                    communityAddress: [info.projectAddressTown, info.projectAddressRoad].filter(Boolean).join(' ') || info.communityAddress || '',
                    completionDate: info.houseCompletionDate || info.completionDate || '',
                    takeTime: info.takeTime || '',
                    outTime: info.outTime || '',
                    stateName: info.stateName || info.state || '',
                    propertyType: info.projectNature || info.propertyType || '',
                    propertyRoomArea: info.propertyRoomArea || '',
                    publicArea: info.publicArea || '',
                    communityType: info.projectType || info.communityType || '',
                    area: info.projectLandArea || info.area || '',
                    totalArea: info.totalConstructionArea || info.totalArea || '',
                    chargeableArea: info.chargeableTotalArea || info.chargeableArea || '',
                    multiStoreyArea: info.chargeableAreaMultilayer || info.multiStoreyArea || '',
                    highStoreyArea1: info.chargeableAreaHighRise1 || info.highStoreyArea1 || '',
                    highStoreyArea2: info.chargeableAreaHighRiseUp || info.highStoreyArea2 || '',
                    commercialArea: info.chargeableAreaShop || info.chargeableAreaCommercialHouse || info.commercialArea || '',
                    villaArea: info.chargeableAreaVilla || info.villaArea || '',
                    officeArea: info.chargeableAreaOffice || info.officeArea || '',
                    greenArea: info.greenArea || '',
                    residentialArea: info.residentialArea || '',
                    nonResidentialArea: info.nonResidentialArea || '',
                    areaDetails: info.areaDetails || '',
                    managementAddress: info.propertyManagementAddress || info.managementAddress || '',
                    managementContactName: info.propertyManagerName || info.managementContactName || '',
                    managementContactTel: info.propertyManagerPhone || info.managementContactTel || '',
                    managementContactDayTel: info.dayRepairPhone || info.managementContactDayTel || '',
                    managementContactNightTel: info.nightRepairPhone || info.managementContactNightTel || '',
                    managerName: info.projectManager || info.managerName || '',
                    managerTel: info.managerPhone || info.managerTel || '',
                    hasManagerCertificate: info.hasManagerCertificate || info.hasManagerCertificate,
                    managerCertName: info.certificateName || info.managerCertName || '',
                    managerCertNo: info.managerCertificateNo || info.managerCertNo || '',
                    committeeName: info.neighborhoodCommitteeName || info.committeeName || '',
                    committeeAddress: info.neighborhoodCommitteeAddress || info.committeeAddress || '',
                    committeeSecretaryName: info.neighborhoodSecretary || info.committeeSecretaryName || '',
                    committeeSecretaryTel: info.secretaryPhone || info.committeeSecretaryTel || '',
                    committeeOfficeTel: info.neighborhoodOfficePhone || info.committeeOfficeTel || '',
                    committeeChairmanName: info.ownersCommitteeChairman || info.committeeChairmanName || '',
                    committeeChairmanTel: info.chairmanPhone || info.committeeChairmanTel || '',
                    fireSprinklerTotal: info.fireHydrantCount || info.fireSprinklerTotal || '',
                    fireChannelTotal: info.fireChannelCount || info.fireChannelTotal || '',
                    waterTankTotal: info.waterTankCount || info.waterTankTotal || '',
                    waterPoolTotal: info.reservoirCount || info.waterPoolTotal || '',
                    elevatorTotal: info.elevatorCount || info.elevatorTotal || '',
                    elevatorType: info.elevatorType || '',
                    elevatorInstallDate: info.elevatorInstallDate || '',
                    elevatorUseYears: info.elevatorServiceLife || info.elevatorUseYears || '',
                    elevatorBrand1: info.elevatorBrand1 || '',
                    monitorTotal: info.monitorCount || info.monitorTotal || '',
                    monitorMaintenanceUnit: info.monitorMaintenanceCompany || info.monitorMaintenanceUnit || '',
                    gateTotal: info.barrierGateCount || info.gateTotal || '',
                    gateBrand: info.barrierGateBrand || info.gateBrand || '',
                    gateSupplierContactName: info.barrierSupplierContact || info.gateSupplierContactName || '',
                    gateSupplierContactTel: info.barrierSupplierPhone || info.gateSupplierContactTel || '',
                    pumpTotal: info.waterPumpCount || info.pumpTotal || '',
                    hasDecorationRubbishPoint: info.hasDecorationRubbishPoint,
                    gateGuardTotal: info.securityEntranceCount || info.gateGuardTotal || '',
                    carTotal: info.totalMotorVehicleSpaces || info.carTotal || '',
                    carGroundTotal: info.groundMotorVehicleSpaces || info.groundParkingSpaces || info.carGroundTotal || '',
                    carUndergroundTotal: info.undergroundMotorVehicleSpaces || info.undergroundParkingSpaces || info.carUndergroundTotal || '',
                    electricCarTotal: info.newEnergyChargingPiles || info.electricCarTotal || '',
                    nonElectricCarTotal: info.nonMotorVehicleChargingPoints || info.nonElectricCarTotal || '',
                    nonElectricCarGroundArea: info.groundNonMotorVehicleArea || info.nonElectricCarGroundArea || '',
                    nonElectricCarUndergroundArea: info.undergroundNonMotorVehicleArea || info.nonElectricCarUndergroundArea || '',
                    clubArea: info.clubhouseArea || info.clubArea || '',
                    hourlyFee: info.temporaryHourlyFee || info.hourlyFee || '',
                    dailyFee: info.temporaryDailyFee || info.dailyFee || '',
                    onceFee: info.temporaryPerTimeFee || info.onceFee || '',
                    naturalBuildingTotal: info.totalBuildingCount || info.naturalBuildingTotal || '',
                    doorBuildingTotal: info.buildingUnitCount || info.doorBuildingTotal || '',
                    highBuildingTotal: info.highRiseBuildingCount || info.highBuildingTotal || '',
                    lowBuildingTotal: info.multilayerVillaBuildingCount || info.lowBuildingTotal || '',
                    totalHousehold: totalHousehold,
                    residentialHousehold: info.residentialHouseholdCount || info.residentialHousehold || '',
                    commercialHousehold: info.shopHouseholdCount || info.commercialHousehold || ''
                };
            },
            goBack() {
                // 跳转回小区管理列表页
                window.location.href = '/#/pages/common/communityManage';
            },
        }
    });
})(window.vc);