From 5837de0c1316d5456478b43265e827573283d096 Mon Sep 17 00:00:00 2001 From: Renpc-kilig <308442850@qq.com> Date: Wed, 29 Jul 2020 16:34:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=8C=BA=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BF=A1=E6=81=AF=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/newTeam/newTeam.js | 55 ++++++++++++++++++-- pages/volunteerRegister/volunteerRegister.js | 55 ++++++++++++++++++-- 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/pages/newTeam/newTeam.js b/pages/newTeam/newTeam.js index 3c05d8c..09b67b6 100644 --- a/pages/newTeam/newTeam.js +++ b/pages/newTeam/newTeam.js @@ -96,7 +96,7 @@ Page({ teamAreaArray: [] }) - this.getDataFromDict(self.data.teamCity[self.data.teamCityIndex].dictionaryId, 2).then(result => { + this.getDataFromArea(self.data.teamCity[self.data.teamCityIndex].areaId, 2).then(result => { if(self.data.tempObj.length > 0) { self.setData({ teamCounty: self.data.tempObj, @@ -122,7 +122,7 @@ Page({ teamCountyIndex: e.detail.value }) - this.getDataFromDict(self.data.teamCounty[self.data.teamCountyIndex].dictionaryId, 2).then(result => { + this.getDataFromArea(self.data.teamCounty[self.data.teamCountyIndex].areaId, 2).then(result => { if(self.data.tempObj.length > 0) { self.setData({ teamArea: self.data.tempObj, @@ -256,13 +256,62 @@ Page({ }) }) }, + /** + *从区域表拉取数据 + */ + getDataFromArea: function(dictId, type) { + var self = this; + return new Promise(resolve => { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + '/app/dataarea/listareabyparentidrelease/' + dictId, []), + {}, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + if(data || type === 2) { + var array = []; + for(var item of data) { + delete item.areaParentId; + delete item.areaParentName; + delete item.areaCode; + delete item.areaCityCode; + delete item.areaMergerName; + delete item.areaShortName; + delete item.areaZipCode; + delete item.areaLevel; + delete item.areaLng; + delete item.areaLat; + delete item.areaPinyin; + delete item.areaFirst; + delete item.subArea; + delete item.parent; + + array.push(item.areaName); + } + self.setData({ + tempArray: array + }) + } + self.setData({ + tempObj: data + }) + } + return resolve(); + }, function() { + + }, function() { + + }) + }) + }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var self = this; this.getToken().then(result => { - this.getDataFromDict('4a03e904-81e2-48e9-9006-e15ea4a6bc69', 2).then(result => { + this.getDataFromArea('640332', 2).then(result => { self.setData({ teamCity: self.data.tempObj, teamCityArray: self.data.tempArray, diff --git a/pages/volunteerRegister/volunteerRegister.js b/pages/volunteerRegister/volunteerRegister.js index 6d61ce0..f8d17c6 100644 --- a/pages/volunteerRegister/volunteerRegister.js +++ b/pages/volunteerRegister/volunteerRegister.js @@ -58,7 +58,7 @@ Page({ teamAreaArray: [] }) - this.getDataFromDict(self.data.teamCity[self.data.teamCityIndex].dictionaryId, 2).then(result => { + this.getDataFromArea(self.data.teamCity[self.data.teamCityIndex].areaId, 2).then(result => { if(self.data.tempObj.length > 0) { self.setData({ teamCounty: self.data.tempObj, @@ -84,7 +84,7 @@ Page({ teamCountyIndex: e.detail.value }) - this.getDataFromDict(self.data.teamCounty[self.data.teamCountyIndex].dictionaryId, 2).then(result => { + this.getDataFromArea(self.data.teamCounty[self.data.teamCountyIndex].areaId, 2).then(result => { if(self.data.tempObj.length > 0) { self.setData({ teamArea: self.data.tempObj, @@ -280,6 +280,55 @@ Page({ }) }) }, + /** + *从区域表拉取数据 + */ + getDataFromArea: function(dictId, type) { + var self = this; + return new Promise(resolve => { + app.restAjax.get(app.restAjax.path(app.volunteerUrl + '/app/dataarea/listareabyparentidrelease/' + dictId, []), + {}, { + headers: { + 'token': self.data.token + } + }, function(code, data) { + if('200' == code) { + if(data || type === 2) { + var array = []; + for(var item of data) { + delete item.areaParentId; + delete item.areaParentName; + delete item.areaCode; + delete item.areaCityCode; + delete item.areaMergerName; + delete item.areaShortName; + delete item.areaZipCode; + delete item.areaLevel; + delete item.areaLng; + delete item.areaLat; + delete item.areaPinyin; + delete item.areaFirst; + delete item.subArea; + delete item.parent; + + array.push(item.areaName); + } + self.setData({ + tempArray: array + }) + } + self.setData({ + tempObj: data + }) + } + return resolve(); + }, function() { + + }, function() { + + }) + }) + }, getVolunteerMsg() { var self = this; return new Promise(resolve => { @@ -323,7 +372,7 @@ Page({ }) }) }).then(result => { - this.getDataFromDict('4a03e904-81e2-48e9-9006-e15ea4a6bc69', 2).then(result => { + this.getDataFromArea('640332', 2).then(result => { self.setData({ teamCity: self.data.tempObj, teamCityArray: self.data.tempArray,