Skip to content

Commit

Permalink
update extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mip-platform committed Sep 6, 2018
1 parent 379b225 commit 2bf13be
Show file tree
Hide file tree
Showing 29 changed files with 18,354 additions and 35 deletions.
28 changes: 28 additions & 0 deletions mip-258-city/README.md
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 added mip-258-city/mip-258-city.css
Empty file.
72 changes: 72 additions & 0 deletions mip-258-city/mip-258-city.js
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;
});
4 changes: 4 additions & 0 deletions mip-258-city/mip-258-city.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mip-258-city {

}

Loading

0 comments on commit 2bf13be

Please sign in to comment.