import { communitySelfOrgDetail, getServiceTypeRelationByHobbyCode, icpartyunitDetail, residentEduInfo, residentHobbyInfo, staffdetailv2, volunteerDetail } from "../../utils/statisticsApi"; Component({ properties: { visible: { type: Boolean, value: false }, data: { type: Object, value: () => { }, observer: function ({id, type, data}) { console.log(id, type, data) this.setData({ id, type, rowData: data }) this.getData(type) } } }, data: { detail: {}, education: {}, hobby: {}, typeList: { 1: '志愿者', 2: '联建单位', 3: '社区自组织', 4: '网格员', 5: '公益岗' }, id: '', type: '', rowData: '', }, ready: function () { }, methods: { close() { this.triggerEvent('close') }, getData(type) { if (type === 1) { this.getVolunteer() } if (type === 2) { this.getCompany() } if (type === 3) { this.getCommunity() } if (type === 4) { this.getGridOperator() } if (type === 5) { this.getVolunteer() } }, getAgeByDateOfBirth(birthDate) { var currentDate = new Date(); var yearDiff = currentDate.getFullYear() - birthDate.getFullYear(); var monthDiff = currentDate.getMonth() - birthDate.getMonth(); var dayDiff = currentDate.getDate() - birthDate.getDate(); if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) { yearDiff--; } console.log(yearDiff, 'yearDiff') return yearDiff; }, // 志愿者 公益岗 getVolunteer() { volunteerDetail(this.data.id).then(({data}) => { data.age = data.birthday ? this.getAgeByDateOfBirth(new Date(data.birthday)) : '未知' this.setData({ detail: data || {} }) }) residentEduInfo(this.data.id).then(({data}) => { this.setData({ education: data || {} }) }) residentHobbyInfo(this.data.id).then(({data}) => { this.setData({ hobby: data || {} }) }) }, // 单位 getCompany() { icpartyunitDetail({id: this.data.id}).then(({data}) => { data.serviceMatterNameList = data.serviceMatterNameList ? data.serviceMatterNameList.join('、') : '' this.setData({ detail: data || {} }) }) }, // 社区 getCommunity() { communitySelfOrgDetail(this.data.id).then(({data}) => { this.setData({ detail: data || {} }) }) }, // 网格 getGridOperator() { staffdetailv2({staffId: this.data.id}).then(({data}) => { this.setData({ detail: data || {} }) }) }, } });