const app = getApp(); const userDistrict = app.globalData.userConfig ? app.globalData.userConfig.ucDistrictName : undefined; const _districts = [ { label: '静安区', value: '310106' }, { label: '徐汇区', value: '310104' }, { label: '金山区', value: '310116' }, { label: '普陀区', value: '310107' }, { label: '闵行区', value: '310112' }, { label: '长宁区', value: '310105' }, ]; // 服务器获取的区县信息 const remoteDistricts = []; function getDistrictTypes() { if (userDistrict) { return _districts.filter(item => { return item.label == userDistrict; }); } else { return _districts; } // return _districts; } function toLabel(value) { const r = _districts.find(item => { return item.value == value; }); return r.label; } function toValue(label) { const r = _districts.find(item => { return item.label == label; }); return r.value; } export { getDistrictTypes, toLabel, toValue };