portal html css js resource

shareCom.js 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. function GetQueryString(name) {
  2. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  3. var r = window.location.search.substr(1).match(reg);
  4. var context = "";
  5. if(r != null)
  6. context = r[2];
  7. reg = null;
  8. r = null;
  9. return context == null || context == "" || context == "undefined" ? "" : decodeURI(context);
  10. }
  11. /*标志*/
  12. function autho() {
  13. if(arguments[0] == 1) {
  14. return {
  15. "sty": "authicon-pro",
  16. "title": "科袖认证专家"
  17. }
  18. } else {
  19. if(arguments[1] == 1) {
  20. return {
  21. "sty": "authicon-staff-ok",
  22. "title": "企业认证员工"
  23. }
  24. } else {
  25. if(arguments[2] == 3) {
  26. return {
  27. "sty": "authicon-real",
  28. "title": "实名认证用户"
  29. }
  30. } else {
  31. return {
  32. "sty": "e",
  33. "title": " "
  34. }
  35. }
  36. }
  37. }
  38. }
  39. //时间显示规则
  40. function commenTime(startTime) {
  41. var nowTimg = new Date();
  42. var startdate = new Date();
  43. startdate.setFullYear(parseInt(startTime.substring(0, 4)));
  44. startdate.setMonth(parseInt(startTime.substring(4, 6)) - 1);
  45. startdate.setDate(parseInt(startTime.substring(6, 8)));
  46. startdate.setHours(parseInt(startTime.substring(8, 10)));
  47. startdate.setMinutes(parseInt(startTime.substring(10, 12)));
  48. startdate.setSeconds(parseInt(startTime.substring(12, 14)));
  49. var date3 = nowTimg.getTime() - startdate.getTime(); //时间差的毫秒数
  50. var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  51. var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
  52. if(date3 < 60000) {
  53. return "刚刚";
  54. } else if(date3 >= 60000 && date3 < 3600000) {
  55. return minutes + "分钟前";
  56. } else if(date3 >= 3600000 && date3 < 86400000) {
  57. return hours + "小时前";
  58. } else if(date3 >= 86400000) {
  59. if(nowTimg.getFullYear() == startTime.substring(0, 4)) {
  60. return startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
  61. } else {
  62. return startTime.substring(0, 4) + "年" + startTime.substring(4, 6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6, 8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8, 10) + ":" + startTime.substring(10, 12);
  63. }
  64. }
  65. }
  66. /*时间转换*/
  67. function TimeTr(dealtime) {
  68. var myDate = new Date();
  69. var s = dealtime;
  70. var y = s.substr(0, 4);
  71. var m = s.substr(4, 2);
  72. var d = s.substr(6, 2);
  73. var h = s.substr(8, 2);
  74. var minute = s.substr(10, 2);
  75. var formatTime;
  76. if(s.length <= 6) {
  77. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月";
  78. } else if(s.length > 6 && s.length <= 8) {
  79. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 ";
  80. } else {
  81. formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  82. if(y != myDate.getFullYear()) {
  83. formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
  84. }
  85. }
  86. return formatTime;
  87. }
  88. function shareWays(){
  89. /*微信分享*/
  90. $.ajax({
  91. url: "../ajax/weixin/jsapiTicket",
  92. type: 'get',
  93. dataType: 'json',
  94. contentType: "application/x-www-form-urlencoded; charset=utf-8",
  95. data: {
  96. 'url': location.href.split('#')[0]
  97. },
  98. success: function(data) {
  99. if(data.data) {
  100. wx.config({
  101. debug: false, //调试模式好犀利
  102. appId: data.data.appId,
  103. timestamp: data.data.timestamp,
  104. nonceStr: data.data.nonceStr,
  105. signature: data.data.signature,
  106. jsApiList: [ // 所有要调用的 API 都要加到这个列表中
  107. "onMenuShareAppMessage",
  108. "onMenuShareTimeline",
  109. "onMenuShareQQ",
  110. "onMenuShareQZone",
  111. "scanQRCode",
  112. ]
  113. });
  114. wx.ready(function() {
  115. // 在这里调用 API
  116. wx.onMenuShareAppMessage({ //分享给朋友
  117. title: shareTitle, // 分享标题
  118. desc: descContent, // 分享描述
  119. link: lineLink, // 分享链接
  120. imgUrl: imgUrl, // 分享图标
  121. success: share_success_callback,
  122. cancel: share_cancel_callback
  123. });
  124. wx.onMenuShareTimeline({ //分享到朋友圈
  125. title: shareTitle, // 分享标题
  126. desc: descContent, // 分享描述
  127. link: lineLink, // 分享链接
  128. imgUrl: imgUrl, // 分享图标
  129. success: share_success_callback,
  130. cancel: share_cancel_callback
  131. });
  132. wx.onMenuShareQQ({ //分享到QQ
  133. title: shareTitle, // 分享标题
  134. desc: descContent, // 分享描述
  135. link: lineLink, // 分享链接
  136. imgUrl: imgUrl, // 分享图标
  137. success: share_success_callback,
  138. cancel: share_cancel_callback
  139. });
  140. wx.onMenuShareQZone({ //分享到QQ空间
  141. title: shareTitle, // 分享标题
  142. desc: descContent, // 分享描述
  143. link: lineLink, // 分享链接
  144. imgUrl: imgUrl, // 分享图标
  145. success: share_success_callback,
  146. cancel: share_cancel_callback
  147. });
  148. });
  149. //分享成功后的回调函数
  150. function share_success_callback() {}
  151. //用户取消分享后执行的回调函数
  152. function share_cancel_callback() {}
  153. }
  154. }
  155. });
  156. }