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 5, 2018
1 parent 7072839 commit 237a55b
Show file tree
Hide file tree
Showing 9 changed files with 433 additions and 210 deletions.
2 changes: 1 addition & 1 deletion mip-360docreward/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mip-360docreward 是360doc打赏组件。
----|----
类型|业务,广告
支持布局|N/S
所需脚本|https://c.mipcdn.com/extensions/platform/v1/mip-360docstat-script/mip-360docstat-script.js
所需脚本|https://c.mipcdn.com/extensions/platform/v1/mip-360docreward/mip-360docreward.js

## 示例

Expand Down
403 changes: 203 additions & 200 deletions mip-360docreward/mip-360docreward.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mip-360docreward/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mip-360docreward",
"version": "1.0.0",
"version": "1.0.1",
"description": "360doc打赏组件",
"contributors": [
{
Expand Down
64 changes: 64 additions & 0 deletions mip-fetch-comment/README.md
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>
```


105 changes: 105 additions & 0 deletions mip-fetch-comment/mip-fetch-comment.js
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;
});
14 changes: 14 additions & 0 deletions mip-fetch-comment/package.json
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"
}
}
4 changes: 2 additions & 2 deletions mip-ilaw66-baidu-couponPay/mip-ilaw66-baidu-couponPay.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ define(function (require) {
data: data,
success: function (data) {
if (data && data.cashier_url) {
// window.top.location.href = data.cashier_url;
locahost(data.cashier_url, '电话咨询');
window.top.location.href = data.cashier_url;
// locahost(data.cashier_url, '电话咨询');
}
else {
$el.find('.popUp_sysErr').fadeIn();
Expand Down
2 changes: 1 addition & 1 deletion mip-ilaw66-baidu-couponPay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mip-ilaw66-baidu-couponPay",
"version": "1.0.9",
"version": "1.1.0",
"description": "百度支付页",
"contributors": [
{
Expand Down
47 changes: 42 additions & 5 deletions mip-xxd-logic-form/mip-xxd-logic-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define(function (require) {

var customElement = require('customElement').create();
var fetchJsonp = require('fetch-jsonp');
var viewer = require('viewer');

/**
* 创建tip元素
Expand Down Expand Up @@ -88,6 +89,7 @@ define(function (require) {
}).then(function (data) {
if (data.status === 0) {
submitData.response = data.data;
submitData = Object.assign({}, submitData, element.extraData);
var token = data.token;
var redirectUrl = redirect.replace(/#([^#]*)#/g, function ($0, $1) {
return submitData[$1] || defaultValue;
Expand Down Expand Up @@ -146,6 +148,7 @@ define(function (require) {
}
else {

submitData = Object.assign({}, submitData, element.extraData);
// 直接转跳
var redirectUrl = redirect.replace(/#([^#]*)#/g, function ($0, $1) {
return submitData[$1] || '';
Expand All @@ -162,8 +165,9 @@ define(function (require) {
* 提交表单
*
* @param {dom} element dom元素
* @param {Event} event 事件对象
*/
function onSubmit(element) {
function onSubmit(element, event) {
if (element.submitting) {
return;
}
Expand All @@ -181,7 +185,17 @@ define(function (require) {
if (!validateForm.call(element)) {
return;
}
onRedirect.call(element, data);

// 判断是否需要百度授权登录
var loginEleId = element.dataset.loginId || '';

if (!loginEleId || element.extraData.sessionId) {
onRedirect.call(element, data);
}
else {
var loginEle = document.getElementById(loginEleId);
viewer.eventAction.execute('login', loginEle, event);
}
}

/**
Expand Down Expand Up @@ -261,6 +275,20 @@ define(function (require) {
return result;
}

/**
* 读取localStorage
*
* @param {string} key 要读取的key
* @return {string} 存储的值
*/
function readStorage(key) {
var result = '';
if (localStorage) {
result = localStorage.getItem(key);
}
return result;
}

/**
* 展示tips
*
Expand Down Expand Up @@ -289,8 +317,8 @@ define(function (require) {

element.id = 'mip-xxd-logic-form';
var submitElement = element.querySelector('#submit');
submitElement.addEventListener('click', function () {
onSubmit(element);
submitElement.addEventListener('click', function (event) {
onSubmit(element, event);
});

var bindRecordBtnEvent = function (recordElement) {
Expand All @@ -309,7 +337,6 @@ define(function (require) {
}

var data = {};
var inputs = element.querySelectorAll('mip-xxd-input-item');
Array.prototype.forEach.call(inputs, function (child) {
var key = child.dataset.key;
var value = child.dataset.value;
Expand Down Expand Up @@ -348,6 +375,16 @@ define(function (require) {
showTip.call(element, text);
return;
});

// 记录登录后的额外信息
element.extraData = {};
self.addEventAction('saveData', function () {
var info = JSON.parse(element.dataset.info || '{}');
var sessionStorageId = element.dataset.sessionStorageId;
var extraData = Object.assign({}, info, {sessionId: readStorage(sessionStorageId)});
element.extraData = extraData;
onSubmit(element, event);
});
};

return customElement;
Expand Down

0 comments on commit 237a55b

Please sign in to comment.