riku
2024-11-13 af930887f9972b7dd21c80599e697e44f5e5a579
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
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' },
];
// 服务器获取的区县信息
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 };