tuil-nogetstyle.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. $(function () {
  2. ncode = false;
  3. curCount = 0;
  4. SetRemainTime();
  5. fes = getUrlParam("fes");
  6. sou = getUrlParam("sou");
  7. $("#useraccount_tt").attr("value", getUrlParam("freeflow_token"));
  8. if (sou != 29 & sou != 33) {
  9. $("#jh").remove();
  10. }
  11. });
  12. var fes;
  13. var sou;
  14. var uidc;
  15. var derice = "";
  16. var pattern = /^1[345678]\d{9}$/;
  17. var ncode = false;
  18. function getUrlParam(urlprm) {
  19. var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)");
  20. var r = window.location.search.substr(1).match(reg);
  21. if (r != null) {
  22. return r[2];
  23. } else {
  24. switch (urlprm) {
  25. case "con":
  26. return "1";
  27. break;
  28. case "freeflow_token":
  29. return "";
  30. break;
  31. default:
  32. var url = getRootPath() + "/404.html";
  33. $(location).attr('href', url);
  34. }
  35. }
  36. }
  37. function getRootPath() {
  38. var curWwwPath = window.document.location.href;
  39. var pathName = window.document.location.pathname;
  40. var pos = curWwwPath.indexOf(pathName);
  41. var localhostPath = curWwwPath.substring(0, pos);
  42. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  43. return (localhostPath + projectName);
  44. }
  45. function getHref() {
  46. var curWwwPath = window.document.location.href;
  47. var pathName = window.document.location.pathname;
  48. var pos = curWwwPath.indexOf(pathName);
  49. var localhostPath = curWwwPath.substring(0, pos);
  50. var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
  51. return (localhostPath + pathName);
  52. }
  53. function getMemoValbyId(product, type) {
  54. var val = "";
  55. switch (type) {
  56. case "phone":
  57. val = $("#input_100_" + product).val();
  58. break;
  59. case "code":
  60. val = $("#input_50_" + product).val();
  61. break;
  62. case "fog":
  63. val = $("#fog_" + product).val();
  64. break;
  65. case "useraccount":
  66. val = $("#useraccount_" + product).val();
  67. break;
  68. case "sendsmsorder":
  69. val = $("#sendsms_order_" + product).val();
  70. break;
  71. case "sendsmscancel":
  72. val = $("#sendsms_cancel_" + product).val();
  73. break;
  74. case "sendsmsyuyue":
  75. val = $("#sendsms_yuyue_" + product).val();
  76. break;
  77. case "sendsmsacti":
  78. val = $("#sendsms_acti_" + product).val();
  79. break;
  80. }
  81. if (val == null) {
  82. return "";
  83. } else {
  84. return val;
  85. }
  86. }
  87. var InterValObj;
  88. var curCount = 0;
  89. function coderun(product) {
  90. curCount = 59;
  91. $(".again_send_btn").removeAttr("style");
  92. $(".send_btn").attr("style", "display:none;");
  93. InterValObj = window.setInterval(SetRemainTime, 1000);
  94. }
  95. function SetRemainTime() {
  96. if (curCount == 0) {
  97. ncode = false;
  98. window.clearInterval(InterValObj);
  99. $(".again_send_btn").removeAttr("disabled");
  100. $(".send_btn").removeAttr("style");
  101. $(".again_send_btn").attr("style", "display:none;");
  102. $(".again_send_btn").text("重新发送(60S)");
  103. } else {
  104. $(".again_send_btn").text("请在" + curCount + "秒内输入");
  105. curCount--;
  106. }
  107. }
  108. function theme(title, icon) {
  109. $("title").text(title);
  110. $("#icon").attr("href", icon + ".ico");
  111. var sou = getUrlParam("sou");
  112. var fes = getUrlParam("fes");
  113. if (fes == "9om" && sou == "2e") {
  114. $("title").text("免流量看皮皮虾");
  115. }
  116. }
  117. function hint(inc, product, message) {
  118. $("#warning_" + inc + "_" + product).removeAttr("style");
  119. $("#warning_" + inc + "_" + product).text(message);
  120. }
  121. function goto404() {
  122. var url = getRootPath() + "/404.html";
  123. $(location).attr('href', url);
  124. }
  125. function pro_bounced(headmg, textmg, buttonmg, state) {
  126. emptyM();
  127. $(".layer").removeAttr("style");
  128. $(".head").append("<h2>" + headmg + "</h2>");
  129. $(".coupon").append("<p>" + textmg + "</p>");
  130. if (state) {
  131. $(".coupon").append("<input type='button' value='" + buttonmg + "' class='red_btn' onclick='closeSe()'>");
  132. } else {
  133. $(".coupon").append("<input type='button' value='" + buttonmg + "' class='red_btn' onclick='closeSe()'>");
  134. }
  135. }
  136. function gotosucc() {
  137. var url = getRootPath() + "/tt/orderSucc.html" +
  138. "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") +
  139. "&phone=" + getMemoValbyId('tt', 'phone') + "&fog=" + getMemoValbyId('tt', 'fog') + "&fog=" + getMemoValbyId('tt', 'fog') + "&use=" + getMemoValbyId('tt', 'useraccount');
  140. $(location).attr('href', url);
  141. }
  142. function gotorder() {
  143. var url = getRootPath() + "/tt/order.html" +
  144. "?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") +
  145. "&con=0";
  146. $(location).attr('href', url);
  147. }
  148. function gotoUrl(html) {
  149. var url = getRootPath() + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount');
  150. $(location).attr('href', url);
  151. }
  152. function gotoUrlC(html) {
  153. var url = getRootPath().replace(/https/ig, "http") + "/" + html + ".html?fes=" + getUrlParam("fes") + "&sou=" + getUrlParam("sou") + "&use=" + getMemoValbyId('tt', 'useraccount');
  154. $(location).attr('href', url);
  155. }
  156. function emptyM() {
  157. $(".head").empty();
  158. $(".coupon").empty();
  159. }
  160. function closeSe() {
  161. $(".warning").attr("style", "display:none;");
  162. $(".layer").attr("style", "display:none;");
  163. }
  164. function postini() {
  165. $.ajax({
  166. url: getRootPath() + "-s1api" + '/ini/getstyle',
  167. type: "POST", // 用POST方式传输
  168. contentType: "application/json; charset=utf-8",
  169. dataType: "Json",
  170. data: JSON.stringify(postiniDate()),
  171. success:
  172. function (msg) {
  173. var resCode = msg["resultCode"];
  174. if (resCode == "0000") {
  175. var festival = msg["festival"];
  176. theme(festival["title"], festival["icon"]);//加载页面信息头,图标
  177. var productlist = msg["product"];
  178. for (var i = 0, l = productlist.length; i < l; i++) {
  179. $("#fog_" + productlist[i].url).attr("value", productlist[i].fog);
  180. var smslist = productlist[i].icon.split(",");
  181. for (var int = 0; int < smslist.length; int++) {
  182. if (int == 0) {
  183. $("#sendsms_order_" + productlist[i].url).attr("value", smslist[int]);
  184. }
  185. if (int == 1) {
  186. $("#sendsms_cancel_" + productlist[i].url).attr("value", smslist[int]);
  187. }
  188. if (int == 2) {
  189. $("#sendsms_yuyue_" + productlist[i].url).attr("value", smslist[int]);
  190. }
  191. }
  192. }
  193. } else {//未取出对应渠道与活动组数据
  194. goto404();
  195. }
  196. if (location.href.indexOf('/cancel') >= 0) {
  197. burypointLogId('110002');// 退订页面pv, pv去重得到uv
  198. } else if (location.href.indexOf('/draw') >= 0) {
  199. burypointLogId('110003');// 领取页面pv, pv去重得到uv
  200. } else if (location.href.indexOf('/flow') >= 0) {
  201. burypointLogId('110004');// 流量查询pv, pv去重得到uv
  202. } else if (location.href.indexOf('/active') >= 0) {
  203. burypointLogId('110005');// 激活页面pv, pv去重得到uv
  204. } else {
  205. // location.href.indexOf('/index') >= 0
  206. // location.href.indexOf('/order') >= 0
  207. burypointLogId('110001');// 订购页面pv, pv去重得到uv
  208. }
  209. },
  210. error:
  211. function (XMLHttpRequest, textStatus, errorThrown) {//加载请求失败
  212. goto404();
  213. },
  214. });
  215. }
  216. function sendSms(product, mode) {
  217. $(".send_btn").removeAttr("onclick");
  218. if (getMemoValbyId("tt", "phone") != "") {//判断号码是否输入
  219. if (pattern.test(getMemoValbyId("tt", "phone"))) {//判断号码格式
  220. $.ajax({
  221. type: "POST",
  222. contentType: "application/json; charset=utf-8",
  223. dataType: "Json",
  224. url: getRootPath() + "-s1api" + '/smsc',//目标地址
  225. data: JSON.stringify(sendSmsDate(product, mode)),
  226. success: function (msg) {
  227. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  228. var resCode = eval(msg["resultCode"]);
  229. if (resCode == "0000") {
  230. ncode = true;
  231. coderun("");
  232. } else {
  233. hint("code", product, msg["errorInfo"]);
  234. }
  235. },
  236. error: function (XMLHttpRequest, textStatus, errorThrown) {
  237. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  238. hint("code", product, "数据提交失败");
  239. },
  240. });
  241. } else {
  242. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  243. hint("phone", product, "请输入正确的中国联通手机号码");
  244. }
  245. } else {
  246. $(".send_btn").attr("onclick", "sendSms('" + product + "','" + mode + "')");
  247. hint("phone", product, "手机号码未输入");
  248. }
  249. }
  250. function postiniDate() {
  251. var data = {
  252. fes: getUrlParam("fes"),
  253. sou: getUrlParam("sou"),
  254. };
  255. return data;
  256. }
  257. function sendSmsDate(product, mode) {
  258. var data = {
  259. "fog": getMemoValbyId(product, "fog"),
  260. "usermob": getMemoValbyId(product, "phone"),
  261. "smstype": getMemoValbyId(product, "sendsms" + mode),
  262. "sou": getUrlParam("sou"),
  263. };
  264. return data;
  265. }
  266. function GetMasData(product) {
  267. var data = {
  268. "code": getMemoValbyId(product, "code"),
  269. "fog": getMemoValbyId(product, "fog"),
  270. "usermob": getMemoValbyId(product, "phone"),
  271. "useraccount": getMemoValbyId(product, "useraccount"),
  272. "fes": getUrlParam("fes"),
  273. "sou": getUrlParam("sou"),
  274. };
  275. return data;
  276. }
  277. function GetFlowJsonData(product) {
  278. var data = {
  279. "fog": fog,
  280. "usermob": phone,
  281. };
  282. return data;
  283. }
  284. function GetDevData(device) {
  285. var data = {
  286. "device_id": device,
  287. };
  288. return data;
  289. }
  290. var se = 0;
  291. function seuid() {
  292. se = se + 1;
  293. if (se == 5) {
  294. se = 0;
  295. alert(getMemoValbyId("tt", "useraccount"));
  296. }
  297. }
  298. function getDecice() {
  299. getDeviceId(function (device_id) {
  300. return device_id;
  301. })
  302. }
  303. function getDeviceId(cb) {
  304. var client_id = '7376a4d6da8df222';
  305. window.ToutiaoJSBridge.call('config', {
  306. client_id: client_id,
  307. }, function () {
  308. toutiao.appInfo({
  309. success: function (res) {
  310. if (cb) {
  311. cb(res.device_id || '')
  312. }
  313. },
  314. fail: function (res) {
  315. return "4001";
  316. },
  317. error: function (res) {
  318. return "4001";
  319. },
  320. });
  321. });
  322. }
  323. (function () {
  324. Date.prototype.from = function (dateString) {
  325. var pattern2 = /(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
  326. var str = dateString.replace(/-/g, '/');
  327. str = str.replace(pattern2, '$1/$2/$3 $4:$5:$6')
  328. return new Date(str)
  329. }
  330. Date.prototype.format = function (fmt) {
  331. var o = {
  332. "M+": this.getMonth() + 1,
  333. "d+": this.getDate(),
  334. "h+": this.getHours(),
  335. "m+": this.getMinutes(),
  336. "s+": this.getSeconds(),
  337. "q+": Math.floor((this.getMonth() + 3) / 3),
  338. "S": this.getMilliseconds()
  339. };
  340. if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  341. for (var k in o)
  342. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  343. return fmt;
  344. }
  345. })();
  346. function getTodaySurplusMillis() {
  347. var time1 = new Date();
  348. var time2 = time1.from(time1.getFullYear() + '-' + (time1.getMonth() + 1) + '-' + time1.getDate() + ' 23:59:59');
  349. console.log(time2.getTime() - time1)
  350. return time2.getTime() - time1.getTime();
  351. }
  352. function burypointLogId(operid, remark, url) {
  353. var uuid = getCookie('uuid');
  354. var vvid = getCookie('vvid');
  355. if (uuid == null || uuid.trim() == '') {
  356. uuid = guid();
  357. setCookie('uuid', uuid, getTodaySurplusMillis());
  358. }
  359. if (vvid == null || vvid.trim() == '') {
  360. vvid = guid();
  361. setCookie('vvid', vvid, -1);
  362. }
  363. if (operid == null || operid == '') {
  364. return;
  365. }
  366. var param = {
  367. operid: operid,
  368. uuid: uuid,
  369. vvid: vvid,
  370. fog: getMemoValbyId('tt', 'fog'),
  371. userid: '',
  372. fes: getUrlParam("fes"),
  373. sou: getUrlParam("sou"),
  374. url: encodeURIComponent(url||window.location.href),
  375. remark: encodeURIComponent(remark||'')
  376. }
  377. $.ajax({
  378. type: "POST",
  379. contentType: "application/json; charset=utf-8",
  380. dataType: "Json",
  381. url: getRootPath() + "-s1api" + '/burypoint/logid',//目标地址
  382. data: JSON.stringify(param),
  383. success: function () {},
  384. error: function () {},
  385. });
  386. }
  387. function getCookie(name) {
  388. var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
  389. if(arr=document.cookie.match(reg))
  390. return unescape(arr[2]);
  391. else
  392. return null;
  393. }
  394. function setCookie(name, value, millis) {
  395. millis = (millis == undefined ? 0 : millis);
  396. var exp = new Date();
  397. if (millis < 0) {
  398. document.cookie = name + "=" + escape(value);
  399. } else {
  400. exp.setTime(exp.getTime() + millis);
  401. document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
  402. }
  403. }
  404. function guid() {
  405. return 'xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
  406. var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
  407. return v.toString(16);
  408. });
  409. }