invitation_mobile.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. function wxSetup(wxConfig, shareConfig) {
  2. if (wx) {
  3. wx.config(wxConfig);
  4. wx.ready(function(){
  5. appendLog('ready');
  6. wx.checkJsApi({
  7. jsApiList: ['onMenuShareAppMessage'],
  8. success: function (res) {
  9. appendLog(res);
  10. }
  11. })
  12. var shareTitle = shareConfig.shareTile,
  13. shareDesc = shareConfig.shareDesc,
  14. imgUrl = shareConfig.imgUrl
  15. ;
  16. wx.onMenuShareTimeline({
  17. title: shareTitle,
  18. // link: '',
  19. imgUrl: imgUrl,
  20. success: function (res) {
  21. appendLog(res);
  22. },
  23. cancel: function (res) {
  24. appendLog(res);
  25. },
  26. fail: function (res) {
  27. appendLog(res);
  28. }
  29. });
  30. wx.onMenuShareAppMessage({
  31. title: shareTitle,
  32. desc: shareDesc,
  33. link: '',
  34. imgUrl: imgUrl,
  35. type: '',
  36. dataUrl: '',
  37. success: function (res) {
  38. appendLog(res);
  39. },
  40. cancel: function (res) {
  41. appendLog(res);
  42. },
  43. fail: function (res) {
  44. appendLog(res);
  45. },
  46. trigger: function (res) {
  47. appendLog(res);
  48. }
  49. });
  50. });
  51. wx.error(function(res) {
  52. appendLog(res);
  53. });
  54. }
  55. }
  56. function appendLog(log) {
  57. if (window.debug) {
  58. console.log(log);
  59. };
  60. }
  61. function str(obj) {
  62. return JSON.stringify(obj, '', '\t');
  63. }
  64. //解析url,获得传递的参数
  65. function getUrlParam(name){
  66. var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
  67. var r=window.location.search.substr(1).match(reg);
  68. if (r!=null) return decodeURI(r[2]);
  69. return null;
  70. }
  71. function linkJoin(){
  72. var url = targetUrl + '?param=' + param;
  73. window.location.href = url;
  74. }