-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
379b225
commit 2bf13be
Showing
29 changed files
with
18,354 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# mip-258-city | ||
|
||
mip-258-city 返回组件 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|通用 | ||
支持布局|fixed | ||
所需脚本|https://c.mipcdn.com/static/v1/mip-258-city/mip-258-city.js | ||
|
||
## 示例 | ||
### 基本使用 | ||
|
||
```html | ||
<mip-258-city> | ||
<select id="province"> | ||
<option value="1">请选择省</option> | ||
</select> | ||
<select id="city"> | ||
<option value="1">请选择市</option> | ||
</select> | ||
<select id="area"> | ||
<option value="1">请选择区</option> | ||
</select> | ||
</mip-258-city> | ||
``` | ||
## 属性 | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @file mip-258-city 选择城市组件 | ||
* @author | ||
*/ | ||
|
||
define(function (require) { | ||
var customElement = require('customElement').create(); | ||
var $ = require('zepto'); | ||
var provinceList = require('./mip-258-citydata'); | ||
|
||
/** | ||
* 第一次进入可视区回调,只会执行一次 | ||
*/ | ||
customElement.prototype.firstInviewCallback = function () { | ||
var element = $(this.element); | ||
var provinceTag = element.find('#province'); | ||
var cityTag = element.find('#city'); | ||
var areaTag = element.find('#area'); | ||
var provinceArray = []; | ||
var cityArray = []; | ||
var cityList; | ||
for (var i = 0; i < provinceList.length; i++) { | ||
var province = provinceList[i]; | ||
var provinceName = province.name; | ||
provinceArray[i] = provinceName; | ||
provinceTag.append(new Option(provinceName, province.id)); | ||
}; | ||
provinceTag.change(function () { | ||
var th = this; | ||
var index = th.selectedIndex - 1; | ||
var provinceName = provinceArray[index]; | ||
for (var n = 0; n < provinceList.length; n++) { | ||
var provice = provinceList[n]; | ||
if (provice.name === provinceName) { | ||
cityList = provice.cityList; | ||
cityTag.html(''); | ||
for (var c = 0; c < cityList.length; c++) { | ||
var city = cityList[c]; | ||
var cityName = city.name; | ||
cityArray[c] = cityName; | ||
cityTag.append(new Option(cityName, city.id)); | ||
} | ||
} | ||
}; | ||
var cityName = cityArray[0]; | ||
var city1 = cityList[0]; | ||
var areaList = city1.areaList; | ||
areaTag.html(''); | ||
for (var a = 0; a < areaList.length; a++) { | ||
var area = areaList[a]; | ||
areaTag.append(new Option(area.name, area.id)); | ||
} | ||
}); | ||
cityTag.change(function () { | ||
var tag = this; | ||
var index2 = tag.selectedIndex; | ||
var cityName = cityArray[index2]; | ||
for (var m = 0; m < cityList.length; m++) { | ||
var city1 = cityList[m]; | ||
if (city1.name === cityName) { | ||
var areaList = city1.areaList; | ||
areaTag.html(''); | ||
for (var a = 0; a < areaList.length; a++) { | ||
var area = areaList[a]; | ||
areaTag.append(new Option(area.name, area.id)); | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
return customElement; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mip-258-city { | ||
|
||
} | ||
|
Oops, something went wrong.