action.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. $(function(){
  2. postini();
  3. });
  4. function postini(){
  5. $.ajax({
  6. url : getRootPath() + "-s1api" + '/ini/getstyle',
  7. type : "POST", // 用POST方式传输
  8. contentType : "application/json; charset=utf-8",
  9. dataType : "Json",
  10. data: JSON.stringify(postiniDate()),
  11. success:
  12. function(msg) {
  13. var resCode = msg["resultCode"];
  14. if(resCode == "0000"){
  15. //var festival = msg["festival"];
  16. //theme(festival["title"], festival["icon"]);加载页面信息头,图标
  17. var productlist = msg["product"];
  18. for(var i=0,l=productlist.length;i<l;i++){
  19. $("#fog_"+productlist[i].url).attr("value",productlist[i].fog);
  20. var smslist = productlist[i].icon.split(",");
  21. for (var int = 0; int < smslist.length; int++) {
  22. if(int==0){
  23. $("#sendsms_order_"+productlist[i].url).attr("value",smslist[int]);
  24. }
  25. if(int==1){
  26. $("#sendsms_cancel_"+productlist[i].url).attr("value",smslist[int]);
  27. }
  28. if(int==2){
  29. $("#sendsms_yuyue_"+productlist[i].url).attr("value",smslist[int]);
  30. }
  31. }
  32. }
  33. }else{//未取出对应渠道与活动组数据
  34. goto404();
  35. }
  36. if (location.href.indexOf('/cancel') >= 0) {
  37. burypointLogId('110002');// 退订页面pv, pv去重得到uv
  38. } else if (location.href.indexOf('/draw') >= 0) {
  39. burypointLogId('110003');// 领取页面pv, pv去重得到uv
  40. } else if (location.href.indexOf('/flow') >= 0) {
  41. burypointLogId('110004');// 流量查询pv, pv去重得到uv
  42. } else if (location.href.indexOf('/active') >= 0) {
  43. burypointLogId('110005');// 激活页面pv, pv去重得到uv
  44. } else {
  45. // location.href.indexOf('/index') >= 0
  46. // location.href.indexOf('/order') >= 0
  47. burypointLogId('110001');// 订购页面pv, pv去重得到uv
  48. }
  49. },
  50. error:
  51. function(XMLHttpRequest, textStatus,errorThrown){//加载请求失败
  52. goto404();
  53. },
  54. });
  55. }
  56. function postiniDate() {
  57. var data = {
  58. fes : getUrlParam("fes"),
  59. sou : getUrlParam("sou"),
  60. };
  61. return data;
  62. }
  63. (function () {
  64. Date.prototype.from = function (dateString) {
  65. var pattern2 = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
  66. var str = dateString.replace(/-/g, '/');
  67. str = str.replace(pattern2, '$1/$2/$3 $4:$5:$6')
  68. return new Date(str)
  69. }
  70. // 对Date的扩展,将 Date 转化为指定格式的String
  71. // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
  72. // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
  73. // 例子:
  74. // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
  75. // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
  76. Date.prototype.format = function (fmt) { //author: meizz
  77. var o = {
  78. "M+": this.getMonth() + 1, //月份
  79. "d+": this.getDate(), //日
  80. "h+": this.getHours(), //小时
  81. "m+": this.getMinutes(), //分
  82. "s+": this.getSeconds(), //秒
  83. "q+": Math.floor((this.getMonth() + 3) / 3), //季度
  84. "S": this.getMilliseconds() //毫秒
  85. };
  86. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  87. for (var k in o)
  88. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  89. return fmt;
  90. }
  91. })();
  92. function getTodaySurplusMillis() {
  93. var time1 = new Date();
  94. var time2 = time1.from(time1.getFullYear() + '-' + (time1.getMonth() + 1) + '-' + time1.getDate() + ' 23:59:59');
  95. console.log(time2.getTime() - time1)
  96. return time2.getTime() - time1.getTime();
  97. }
  98. function burypointLogId(operid, remark, url) {
  99. var uuid = getCookie('uuid');// uv
  100. var vvid = getCookie('vvid');// vv
  101. if (uuid == null || uuid.trim() == '') {
  102. uuid = guid();
  103. setCookie('uuid', uuid, getTodaySurplusMillis());
  104. }
  105. if (vvid == null || vvid.trim() == '') {
  106. vvid = guid();
  107. setCookie('vvid', vvid, -1);
  108. }
  109. if (operid == null || operid == '') {
  110. // 页面的埋点不通过/burypoint/logid接口实现,通过文件日志入库方式
  111. return;
  112. }
  113. var param = {
  114. operid: operid,
  115. uuid: uuid,
  116. vvid: vvid,
  117. fog: getMemoValbyId('xx', 'fog'),//学习强国
  118. userid: '',
  119. fes: getUrlParam("fes"),
  120. sou: getUrlParam("sou"),
  121. url: encodeURIComponent(url||window.location.href),
  122. remark: encodeURIComponent(remark||'')
  123. }
  124. $.ajax({
  125. type: "POST",
  126. contentType: "application/json; charset=utf-8",
  127. dataType: "Json",
  128. url: getRootPath() + "-s1api" + '/burypoint/logid',//目标地址
  129. data: JSON.stringify(param),
  130. success: function () {},
  131. error: function () {},
  132. });
  133. }
  134. function getCookie(name) {
  135. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  136. if(arr=document.cookie.match(reg))
  137. return unescape(arr[2]);
  138. else
  139. return null;
  140. }
  141. /**
  142. * 如果没有设置时间
  143. */
  144. function setCookie(name, value, millis) {
  145. millis = (millis == undefined ? 0 : millis);
  146. var exp = new Date();
  147. if (millis < 0) {
  148. document.cookie = name + "=" + escape(value);
  149. } else {
  150. exp.setTime(exp.getTime() + millis);
  151. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  152. }
  153. }
  154. function guid() {
  155. return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  156. var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
  157. return v.toString(16);
  158. });
  159. }