Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mip-change #1175

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/mip-extensions.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

536 changes: 536 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions src/mip-searchAssociation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# mip-searchAssociation

`<mip-searchAssociation>` 实现搜索联想

标题|内容
----|----
类型|通用
支持布局|N/S
所需脚本|https://c.mipcdn.com/static/v1/mip-searchAssociation/mip-searchAssociation.js

## 示例

### 基本用法

```html
<mip-searchAssociation data-src="XXX" class="result-list-con">
<div class="search-search">
<div class="search-box">
<span></span>
<input class="mip-list-more" type="text" autocomplete="off" />
<span></span>
</div>
<button on="tap:home-right-sidebar.close">取消</button>
</div>
<ul class="result-list"><ul>
</mip-searchAssociation>
\```

##属性
{data-src}
说明:{后台地址}
必选项:{是}
类型:{字符串}
36 changes: 36 additions & 0 deletions src/mip-searchAssociation/mip-searchAssociation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Created by Administrator on 2018/5/28.
*/
define(function(require) {
var customElem = require('customElement').create();
var fetchJsonp = require('fetch-jsonp');
customElem.prototype.firstInviewCallback = function () {
var element = this.element;
var input = element.querySelectorAll('.mip-list-more')[0];
var resultList = element.querySelectorAll('.result-list')[0];
var src = element.getAttribute('data-src');
var inputVal = input.value;
input.onkeyup=function(e){
if(e.keyCode == 13){
window.location.href='/search-kecheng?kw='+inputVal
}
fetchJsonp(src, {
jsonpCallback: inputVal
}).then(function (res) {
var searchData = JSON.parse(res);
var html = '';
for(var value of searchData){
html+=`
<li>
<a href="${value.url}">${value.kwd}</a>
</li>
`
}
resultList.innerHTML = html;
}).catch(function (data) {
console.log(data);
});
}
};
return customElem;
});
13 changes: 13 additions & 0 deletions src/mip-searchAssociation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "mip-searchAssociation",
"version": "1.0.0",

"author": {
"name": "wjb",
"email": "[email protected]"
},

"engines": {
"mip": ">=1.1.0"
}
}