Outside.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. Namespace.register("U.UF.OT"); //第三方接口
  2. /**
  3. * 生成微信二维码
  4. *
  5. * @bindel {element} 绑定点击的元素 必填
  6. * @href {string} 分享的地址 选填 默认值:当前游览器网页地址
  7. * return {element} 返回创建好得元素
  8. */
  9. U.UF.OT.weChatShareCode = function codeLayout(bindel, href, parent) {
  10. if (typeof bindel != 'object') //判断bindel是否是元素
  11. return false;
  12. parent = parent ? parent : document.body; //parente默认为document.body
  13. var _codeBox;
  14. if (!$('#wxfrom', parent)[0]) {// 判断二维码是否存在
  15. _codeBox = $$('div', { id: "wxfrom", style: { cssText: 'display: none; position:fixed; top:0; left:0; bottom:0; right:0; margin:auto; width:251px; height:332px; padding:10px; background-color: #f4f4f4; border: 1px solid #b9b9b9;'} }, parent || document.body);
  16. $$('span', { innerText: "分享到微信朋友圈", style: { cssText: 'font-weight: bold'} }, _codeBox);
  17. $$('span', { innerText: 'x', style: { cssText: 'margin-left:140px; font-size: 18px; font-weight: bold; cursor:pointer' }, onclick: function () {
  18. _codeBox.style.display = 'none';
  19. }
  20. }, _codeBox);
  21. var _codeShowArea = $$('div', { style: { cssText: "padding:20px 10px;"} }, _codeBox);
  22. // U.UF.QR.generate("230", "235", "black", "#f4f4f4", href || window.location.href, _codeShowArea);
  23. $$('div', { innerHTML: "打开微信,点击底部的“发现”,<br/>使用“扫一扫”即可将网页分享至朋友圈。" }, _codeBox);
  24. } else {
  25. _codeBox = U.selectEl('#wxfrom', parent)[0];
  26. }
  27. U.selectEl(bindel).bind({
  28. click: function () {
  29. U.UF.QR.generate("230", "235", "black", "#f4f4f4", href || window.location.href, _codeShowArea);
  30. _codeBox.style.display = '';
  31. }
  32. })
  33. return _codeBox;
  34. }
  35. /**
  36. * qq好友分享
  37. *
  38. * @url {string} 分享的网页地址
  39. * @title {string} 标题
  40. * @pic {string} 图片绝对路径
  41. * @desc {string} 分享介绍
  42. * @summary {string} 分享内容
  43. */
  44. U.UF.OT.qqFriendShare = function (url, title, pic, desc, summary) {
  45. var _sharesinastring = 'https://connect.qq.com/widget/shareqq/index.html?url=' + encodeURIComponent(url || window.location.href)
  46. + '&title=' + encodeURIComponent(title || '这文件超棒的,分享给你看看!')
  47. + '&pic=' + pic || ""
  48. + '&desc=' + desc || ""
  49. + '&summary=' + summary || "";
  50. window.open(_sharesinastring, 'newwindow', 'height=600,width=864,top=300,left=300');
  51. }
  52. /**
  53. * 新浪微博分享
  54. *
  55. * @url {string} 分享的网页地址
  56. * @title {string} 标题
  57. * @pic {string} 图片绝对路径
  58. */
  59. U.UF.OT.weiboShare = function (url, title, pic) {
  60. var _sharesinastring = 'http://v.t.sina.com.cn/share/share.php?url=' + encodeURIComponent(url || window.location.href)
  61. + '&title=' + encodeURIComponent(title || '这文件超棒的,分享给你看看!') + '&content=utf-8'
  62. + '&pic=' + pic || "";
  63. window.open(_sharesinastring, 'newwindow', 'height=500,width=800,top=300,left=300');
  64. }