-
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
7072839
commit 237a55b
Showing
9 changed files
with
433 additions
and
210 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,64 @@ | ||
# mip-fetch-comment | ||
|
||
mip-fetch-comment 根据点击的年份异步加载酒款的评价信息 | ||
|
||
标题|内容 | ||
----|---- | ||
类型|通用 | ||
支持布局|container | ||
所需脚本|https://mipcache.bdstatic.com/static/v1/mip-fetch-comment/mip-fetch-comment.js | ||
|
||
## 示例 | ||
|
||
```html | ||
<mip-fetch-comment> | ||
<div class="pingjia"> | ||
<!--评价中的年份--> | ||
<input type="hidden" value="53563719-5bd7-4f82-b842-0060f7318701" id="wineId"> | ||
<div id="wine-assess"> | ||
<div class="goodsblock"> | ||
<div class="wtit"><p>年份</p><span class="rgt-data more-vt" on="tap:year-lightbox.open">全部年份<i class="iconfont icon-arrow-right"></i></span></div> | ||
<div class="vtwrap"> | ||
<div class="vintage swiper-container"> | ||
<div class="swiper-wrapper divItems"> | ||
<mip-scrollbox class="demo1" layout="fixed-height"> | ||
<div data-wrapper> | ||
<div data-inner> | ||
<div data-scroller> | ||
<div class="vtcell swiper-slide"><a class="nianfen currVintage" data-vintage="" data-wineId='53563719-5bd7-4f82-b842-0060f7318701' data-yvalue=''>概览</a></div> | ||
<div class="vtcell swiper-slide"><a class="nianfen" data-vintage="ed42228a-961c-4fd1-a8bc-339d70cd0540" data-wineId="53563719-5bd7-4f82-b842-0060f7318701" data-yvalue='2016'>2016</a></div> | ||
<div class="vtcell swiper-slide"><a class="nianfen" data-vintage="b5b4ae54-313b-488a-8f5f-b5482cab4846" data-wineId="53563719-5bd7-4f82-b842-0060f7318701" data-yvalue='2015'>2015</a></div> | ||
<div class="vtcell swiper-slide"><a class="nianfen" data-vintage="13cf2141-8996-49a8-83f6-727e71dd7959" data-wineId="53563719-5bd7-4f82-b842-0060f7318701" data-yvalue='2014'>2014</a></div> | ||
<div class="vtcell swiper-slide"><a class="nianfen" data-vintage="748f238e-9f88-4d59-90d3-a9c2f553716d" data-wineId="53563719-5bd7-4f82-b842-0060f7318701" data-yvalue='2013'>2013</a></div> | ||
<div class="vtcell swiper-slide"><a class="nianfen" data-vintage="775E3C22-6B1B-4A29-888B-F1F34273F4E5" data-wineId="53563719-5bd7-4f82-b842-0060f7318701" data-yvalue='2012'>2012</a></div> | ||
</div> | ||
</div> | ||
</div> | ||
</mip-scrollbox> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="goodsblock gradeContent" id="gradeContent"> | ||
<div class="wtit">评分</div> | ||
<div class="grade" id="pjgrade"> | ||
</div> | ||
</div> | ||
|
||
<div class="goodsblock awardsContent" id="awardsContent"> | ||
<div class="wtit">获奖</div> | ||
<div class="awards" id="pjawards"> | ||
|
||
</div> | ||
</div> | ||
|
||
<div class="goodsblock wineContent" id="wineContent"> | ||
<div class="wtit">酒评</div> | ||
<ul class="jiuping wineComment" id="pjjiuping"></ul> | ||
</div> | ||
</div> | ||
</mip-fetch-comment> | ||
``` | ||
|
||
|
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,105 @@ | ||
/** | ||
* @file mip-fetch-comment 组件 | ||
* @author | ||
*/ | ||
|
||
define(function (require) { | ||
var customElement = require('customElement').create(); | ||
customElement.prototype.firstInviewCallback = function () { | ||
var element = this.element; | ||
var wineId = element.querySelector('#wineId').value; | ||
loadData(wineId, ''); | ||
var arr = element.querySelectorAll('.nianfen'); | ||
for (var i = 0; i < arr.length; i++) { | ||
arr[i].onclick = function () { | ||
loadData(wineId, this.dataset.vintage); | ||
for (var j = 0; j < arr.length; j++) { | ||
arr[j].className = 'nianfen'; | ||
if (arr[j].dataset.yvalue === this.dataset.yvalue) { | ||
arr[j].className = 'nianfen currVintage'; | ||
} | ||
}; | ||
}; | ||
}; | ||
function loadData(wineid, year) { | ||
var url = 'https://mip-test.wine-world.com/wine/GetWineInfo?wineid=' + wineid + '&vintageid=' + year; | ||
fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Content-type': 'application/json' | ||
} | ||
}).then(function (res) { | ||
return res.json(); | ||
}).then(function (json) { | ||
if (json.hj.length > 0) { | ||
var awardsContent = element.querySelector('#awardsContent'); | ||
awardsContent.style = 'display:block'; | ||
var awardsHtml = element.querySelector('#pjawards'); | ||
awardsHtml.innerHTML = ''; | ||
var hjhtml = ''; | ||
for (var i = 0; i < json.hj.length; i++) { | ||
hjhtml += '<div class="scores bdb-t-1px"><div class="scoreVal"><div class="score-r"> 获奖时间:' | ||
+ json.hj[i].year + '</div><div class="score-l"><div class="score-i"><span class="scoreV">' | ||
+ json.hj[i].grade | ||
+ '</span></div></div></div><div class="scoreVal"><div class="wine-nf">葡萄酒年份:' | ||
+ json.hj[i].year + '</div><div class="wineOrg"><div class="org-t">颁奖组织:' | ||
+ json.hj[i].agency + '</div><i class="rater" >?</i></div></div></div>'; | ||
} | ||
awardsHtml.innerHTML += hjhtml; | ||
} | ||
else { | ||
var awardsContent = element.querySelector('#awardsContent'); | ||
awardsContent.style = 'display:none'; | ||
} | ||
if (json.pf.length > 0) { | ||
var gradeContent = element.querySelector('#gradeContent'); | ||
gradeContent.style = 'display:block'; | ||
var gradeHtml = element.querySelector('#pjgrade'); | ||
gradeHtml.innerHTML = ''; | ||
var pfhtml = ''; | ||
for (var i = 0; i < json.pf.length; i++) { | ||
var showStr = ''; | ||
if (json.pf[i].score.indexOf('/100') > -1) { | ||
showStr = '<span class=\"scoreV\">' + json.pf[i].score.replace('/100', '') | ||
+ '</span><span class=\"score-zf\">/100</span><br />'; | ||
} else if (json.pf[i].score.indexOf('/20') > -1) { | ||
showStr = '<span class=\"scoreV\">' + json.pf[i].score.replace('/20', '') | ||
+ '</span><span class=\"score-zf\">/20</span><br />'; | ||
} else if (json.pf[i].score.indexOf('/5') > -1) { | ||
showStr = '<span class=\"scoreV\">' + json.pf[i].score.replace('/5', '') | ||
+ '</span><span class=\"score-zf\">/5</span><br />'; | ||
} else { | ||
showStr = '<span class=\"scoreV\">' + json.pf[i].score + '</span><br />'; | ||
} | ||
pfhtml += '<div class="scores bdb-t-1px"><div class="scoreVal"><div class="score-r"> 适饮时间:' | ||
+ json.pf[i].date == null ? '' : json.pf[i].date | ||
+ '</div><div class="score-l"><div class="score-i">' | ||
+ showStr + '</div></div></div><div class="scoreVal"><div class="wine-nf">葡萄酒年份:' | ||
+ json.pf[i].year + '</div><div class="wineOrg"><div class="org-t">评分者:' | ||
+ json.pf[i].critic + '</div> <i class="rater" >?</i></div></div></div>'; | ||
} | ||
gradeHtml.innerHTML += pfhtml; | ||
} else { | ||
var gradeContent = element.querySelector('#gradeContent'); | ||
gradeContent.style = 'display:none'; | ||
} | ||
if (json.taste.length > 0) { | ||
var wineContent = element.querySelector('#wineContent'); | ||
wineContent.style = 'display:block'; | ||
var jiupingHtml = element.querySelector('#pjjiuping'); | ||
jiupingHtml.innerHTML = ''; | ||
var jphtml = ''; | ||
for (var i = 0; i < json.taste.length; i++) { | ||
jphtml += '<li class=\"bdb-t-1px\">' + json.taste[i].tastenote + '<span class=\"jpOrg\">—— ' | ||
+ json.taste[i].critic + '</span></li>'; | ||
} | ||
jiupingHtml.innerHTML += jphtml; | ||
} else { | ||
var wineContent = element.querySelector('#wineContent'); | ||
wineContent.style = 'display:none'; | ||
} | ||
}); | ||
} | ||
}; | ||
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,14 @@ | ||
{ | ||
"name": "mip-fetch-comment", | ||
"version": "1.0.1", | ||
"description": "根据点击的年份异步加载酒款的相关评价信息", | ||
"contributors": [ | ||
{ | ||
"name": "chenwenkai", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"engines": { | ||
"mip": ">=1.1.0" | ||
} | ||
} |
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
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
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