diff --git a/mip-360docreward/README.md b/mip-360docreward/README.md index 16fd3301..bb32a1de 100644 --- a/mip-360docreward/README.md +++ b/mip-360docreward/README.md @@ -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 ## 示例 diff --git a/mip-360docreward/mip-360docreward.js b/mip-360docreward/mip-360docreward.js index 82ee5bda..2059befb 100644 --- a/mip-360docreward/mip-360docreward.js +++ b/mip-360docreward/mip-360docreward.js @@ -7,231 +7,234 @@ define(function (require) { var customElem = require('customElement').create(); // build 方法,元素插入到文档时执行,仅会执行一次 customElem.prototype.build = function () { + var element = $(this.element); try { - if ($('.yc_user').length !== 0) { - if ($('#hiddenoriginal').val() === 1) { - $('.yc_user').show(); + if ($(element.find('.yc_user')).length !== 0) { + if ($(element.find('.hiddenoriginal')).val() === 1) { + $(element.find('.yc_user')).show(); rewardlist.original = 1; - rewardlist.artid = $('#hiddenartid').val(); - rewardlist.userid = $('#hiddenuserid').val(); + rewardlist.artid = $(element.find('.hiddenartid')).val(); + rewardlist.userid = $(element.find('.hiddenuserid')).val(); rewardlist.showRewardDiv(); } } } catch (e) { } - }; - var rewardlist = { - type: 'mip', - queryStartID: 0, - lastRewarUserID: 0, - showRewardLoading: false, - rewardLoading: false, - orderid: 0, - paytype: 9, - artid: '', - userid: '', - original: '', - IntervalunQuery: null, + var rewardlist = { + type: 'mip', + queryStartID: 0, + lastRewarUserID: 0, + showRewardLoading: false, + rewardLoading: false, + orderid: 0, + paytype: 9, + artid: '', + userid: '', + original: '', + IntervalunQuery: null, + + // 显示赞赏列表div + showRewardDiv: function () { + if (!rewardlist.showRewardLoading) { + rewardlist.showRewardLoading = true; + var sign = rewardlist.xfejh({ + 'op': 'getartuserinfo', 'type': rewardlist.type, 'artuserid': + rewardlist.userid + }); + $.ajax({ + url: 'https://account.360doc.com/ajax/QueryHandler.ashx?op=getartuserinfo', + dataType: 'jsonp', + data: {artuserid: rewardlist.userid, type: rewardlist.type, sign: sign}, + success: function (result) { + rewardlist.showRewardLoading = false; + // decodeURIComponent + if (result.status === 1) { + $(element.find('.yc_user')).show(); - // 显示赞赏列表div - showRewardDiv: function () { - if (!rewardlist.showRewardLoading) { - rewardlist.showRewardLoading = true; + var user1html = '
' + decodeURIComponent(result.username) + '
'; + user1html += '你的赞赏是我坚持原创的动力!' + + '
' + + '赞赏').show(); + rewardlist.getRewardUserList(); + } + } + }); + } + }, + // 获取前10个赞赏用户列表 + getRewardUserList: function () { var sign = rewardlist.xfejh({ - 'op': 'getartuserinfo', 'type': rewardlist.type, 'artuserid': - rewardlist.userid + 'op': 'gettipuserlist', + 'type': rewardlist.type, + 'aid': rewardlist.artid, + 'dn': '10', + 'id': '0' }); $.ajax({ - url: 'https://account.360doc.com/ajax/QueryHandler.ashx?op=getartuserinfo', + url: 'https://account.360doc.com/ajax/QueryHandler.ashx?op=gettipuserlist', dataType: 'jsonp', - data: {artuserid: rewardlist.userid, type: rewardlist.type, sign: sign}, + data: {aid: rewardlist.artid, dn: 10, id: 0, type: rewardlist.type, sign: sign}, success: function (result) { - rewardlist.showRewardLoading = false; - // decodeURIComponent - if (result.status === 1) { - $('.yc_user').show(); - - var user1html = '' + decodeURIComponent(result.username) + '
'; - user1html += '你的赞赏是我坚持原创的动力!' - + '
' - + '赞赏').show(); - rewardlist.getRewardUserList(); - } - } - }); - } - }, - // 获取前10个赞赏用户列表 - getRewardUserList: function () { - var sign = rewardlist.xfejh({ - 'op': 'gettipuserlist', - 'type': rewardlist.type, - 'aid': rewardlist.artid, - 'dn': '10', - 'id': '0' - }); - $.ajax({ - url: 'https://account.360doc.com/ajax/QueryHandler.ashx?op=gettipuserlist', - dataType: 'jsonp', - data: {aid: rewardlist.artid, dn: 10, id: 0, type: rewardlist.type, sign: sign}, - success: function (result) { - // $('#rewarduserslist').remove(); //先清空 - if (result.status === 1 && result.count > 0 && result.userlist.length > 0) { - $('#rewarduserslist').html('共' - + ' ' + result.count + ' 人赞赏'); - var rewarduserhref = ''; - var rewardusername = ''; - var rewarduserphoto = ''; - for (var i = 0; i < result.userlist.length; i++) { - if (result.userlist[i].userid === -1) { - rewarduserhref = 'javascript:void(0);'; - rewardusername = '游客'; - rewarduserphoto = ''; + // $('#rewarduserslist').remove(); //先清空 + if (result.status === 1 && result.count > 0 && result.userlist.length > 0) { + $(element.find('.rewarduserslist')).html('共' + + ' ' + result.count + ' 人赞赏'); + var rewarduserhref = ''; + var rewardusername = ''; + var rewarduserphoto = ''; + for (var i = 0; i < result.userlist.length; i++) { + if (result.userlist[i].userid === -1) { + rewarduserhref = 'javascript:void(0);'; + rewardusername = '游客'; + rewarduserphoto = ''; + } + else { + rewarduserhref = 'http://www.360doc.cn/userhome.aspx?userid=' + result.userlist[i].userid; + rewardusername = rewardlist.autoAddEllipsis(result.userlist[i].nickname, 14); + rewarduserphoto = ''; + } + $(element.find('.spantotalrewardcount')).before('' + rewarduserphoto + ''); } - else { - rewarduserhref = 'http://www.360doc.cn/userhome.aspx?userid=' + result.userlist[i].userid; - rewardusername = rewardlist.autoAddEllipsis(result.userlist[i].nickname, 14); - rewarduserphoto = ''; - } - $('#spantotalrewardcount').before('' + rewarduserphoto + ''); } } + }); + }, + // 星级 + getStarrank: function (strStarrank) { + var html = ''; + var s1 = 0; + var s2 = 0; + if (strStarrank % 2 === 0) { + s1 = parseInt(strStarrank / 2, 10); + } + else { + s1 = parseInt(strStarrank / 2, 10); + s2 = 1; + } + for (var i = 0; i < s1; i++) { + html += ''; + } + for (var i = 0; i < s2; i++) { + html += ''; + } + for (var i = 0; i < (5 - s1 - s2); i++) { + html += ''; } - }); - }, - // 星级 - getStarrank: function (strStarrank) { - var html = ''; - var s1 = 0; - var s2 = 0; - if (strStarrank % 2 === 0) { - s1 = parseInt(strStarrank / 2, 10); - } - else { - s1 = parseInt(strStarrank / 2, 10); - s2 = 1; - } - for (var i = 0; i < s1; i++) { - html += ''; - } - for (var i = 0; i < s2; i++) { - html += ''; - } - for (var i = 0; i < (5 - s1 - s2); i++) { - html += ''; - } - return html; - }, - // 展示赞赏弹出层 - showRewardAlert: function () { + return html; + }, + // 展示赞赏弹出层 + showRewardAlert: function () { - var jsondata = 'url=' + encodeURIComponent(window.location.href) + '&aid=' + rewardlist.artid; - window.location.href = 'http://www.360doc.cn/weixinreward/mipreward.aspx?' + jsondata; - return; - }, - // 处理过长的字符串,截取并添加省略号 - autoAddEllipsis: function (pStr, pLen) { - var ret = rewardlist.cutString(pStr, pLen); - var cutFlag = ret.cutflag; - var cutStringn = ret.cutstring; + var jsondata = 'url=' + encodeURIComponent(window.location.href) + '&aid=' + rewardlist.artid; + window.location.href = 'http://www.360doc.cn/weixinreward/mipreward.aspx?' + jsondata; + return; + }, + // 处理过长的字符串,截取并添加省略号 + autoAddEllipsis: function (pStr, pLen) { + var ret = rewardlist.cutString(pStr, pLen); + var cutFlag = ret.cutflag; + var cutStringn = ret.cutstring; - if ('1' === cutFlag) { - return cutStringn + '...'; - } - else { - return cutStringn; - } - }, - // 取得指定长度的字符串 - cutString: function (pStr, pLen) { - // 原字符串长度 - var strLen = pStr.length; - var tmpCode; - var cutString; - // 默认情况下,返回的字符串是原字符串的一部分 - var cutFlag = '1'; - var lenCount = 0; - var ret = false; - if (strLen <= pLen / 2) { - cutString = pStr; - ret = true; - } - if (!ret) { - for (var i = 0; i < strLen; i++) { - if (rewardlist.isFull(pStr.charAt(i))) { - lenCount += 2; - } - else { - lenCount += 1; - } - if (lenCount > pLen) { - cutString = pStr.substring(0, i); - ret = true; - break; + if ('1' === cutFlag) { + return cutStringn + '...'; + } + else { + return cutStringn; + } + }, + // 取得指定长度的字符串 + cutString: function (pStr, pLen) { + // 原字符串长度 + var strLen = pStr.length; + var tmpCode; + var cutString; + // 默认情况下,返回的字符串是原字符串的一部分 + var cutFlag = '1'; + var lenCount = 0; + var ret = false; + if (strLen <= pLen / 2) { + cutString = pStr; + ret = true; + } + if (!ret) { + for (var i = 0; i < strLen; i++) { + if (rewardlist.isFull(pStr.charAt(i))) { + lenCount += 2; + } + else { + lenCount += 1; + } + if (lenCount > pLen) { + cutString = pStr.substring(0, i); + ret = true; + break; + } + else if (lenCount === pLen) { + cutString = pStr.substring(0, i + 1); + ret = true; + break; + } } - else if (lenCount === pLen) { - cutString = pStr.substring(0, i + 1); - ret = true; - break; + } + if (!ret) { + cutString = pStr; + ret = true; + } + if (cutString.length === strLen) { + cutFlag = '0'; + } + return {'cutstring': cutString, 'cutflag': cutFlag}; + }, + // 判断是否为全角 + isFull: function (pChar) { + if ((pChar.charCodeAt(0) > 128)) { + return true; + } + else { + return false; + } + }, + xfejh: function (param) { + var signStr = ''; + for (var key in param) { + if (!(typeof (param[key]) === 'string' && param[key] === '')) { + signStr += key + '=' + param[key] + '&'; } } - } - if (!ret) { - cutString = pStr; - ret = true; - } - if (cutString.length === strLen) { - cutFlag = '0'; - } - return {'cutstring': cutString, 'cutflag': cutFlag}; - }, - // 判断是否为全角 - isFull: function (pChar) { - if ((pChar.charCodeAt(0) > 128)) { - return true; - } - else { - return false; - } - }, - xfejh: function (param) { - var signStr = ''; - for (var key in param) { - if (!(typeof (param[key]) === 'string' && param[key] === '')) { - signStr += key + '=' + param[key] + '&'; + if (signStr.substr(signStr.length - 1, 1) === '&') { + signStr = signStr.substr(0, signStr.length - 1); } + var array = signStr.split('&'); + array.sort(); + var rel = ''; + for (var i = 0; i < array.length; i++) { + rel += array[i]; + } + var array = rel.split('='); + array.sort(); + var rel = ''; + for (i = 0; i < array.length; i++) { + rel += array[i]; + } + return rel + Date.parse(new Date()); } - if (signStr.substr(signStr.length - 1, 1) === '&') { - signStr = signStr.substr(0, signStr.length - 1); - } - var array = signStr.split('&'); - array.sort(); - var rel = ''; - for (var i = 0; i < array.length; i++) { - rel += array[i]; - } - var array = rel.split('='); - array.sort(); - var rel = ''; - for (i = 0; i < array.length; i++) { - rel += array[i]; - } - return rel + Date.parse(new Date()); - } + }; }; return customElem; }); diff --git a/mip-360docreward/package.json b/mip-360docreward/package.json index f9c61571..0540bbb0 100644 --- a/mip-360docreward/package.json +++ b/mip-360docreward/package.json @@ -1,6 +1,6 @@ { "name": "mip-360docreward", - "version": "1.0.0", + "version": "1.0.1", "description": "360doc打赏组件", "contributors": [ { diff --git a/mip-fetch-comment/README.md b/mip-fetch-comment/README.md new file mode 100644 index 00000000..ea435c8a --- /dev/null +++ b/mip-fetch-comment/README.md @@ -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 +年份
全部年份