main.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  1. import * as compnt from "../../../../public/js/compnt.js";
  2. import * as unicom from "../../../../public/js/unicom.js";
  3. import "../scss/order.scss";
  4. // var usermob = getQueryString("userid");
  5. // var spid = 'b0ecd218570506ac3337d1925de043bb';
  6. // var spid = getQueryString("spid");
  7. // var productidas = '';
  8. // var productid = getQueryString("productid");
  9. // var name_b = null;
  10. $(function() {
  11. var isPageHide = false;
  12. window.addEventListener('pageshow', function() {
  13. if (isPageHide) {
  14. window.location.reload();
  15. }
  16. });
  17. window.addEventListener('pagehide', function() {
  18. isPageHide = true;
  19. });
  20. if (window.location.href.indexOf('draw20220313.html') >= 0) {
  21. var user = JSON.parse(localStorage.getItem('user'));
  22. if (user != null) {
  23. $('.usermob').val(user.usermob);
  24. }
  25. }
  26. if (window.location.href.indexOf('draw202203132.html') >= 0) {
  27. var user = JSON.parse(localStorage.getItem('user'));
  28. if (user != null) {
  29. $('.usermob').val(user.usermob);
  30. }
  31. }
  32. })
  33. init();
  34. function init() {
  35. var message = localStorage.getItem('message');
  36. if (message != null && message != '') {
  37. compnt.showAlertarxe(message);
  38. localStorage.removeItem('message');
  39. }
  40. compnt.showLoading();
  41. unicom.init().then(function(response) {
  42. compnt.hideLoading();
  43. unicom.product = response.product[0];
  44. unicom.fesname = response.festival;
  45. unicom.loadUserInfo();
  46. if (location.href.indexOf("15/index") >= 0) {
  47. showOrderPage();
  48. } else {
  49. openPage();
  50. }
  51. if (location.href.indexOf('/cancel') >= 0) {
  52. unicom.burypointLogId('110002'); // 退订页面pv, pv去重得到uv
  53. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'cancel_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  54. } else
  55. if (location.href.indexOf('/draw') >= 0) {
  56. unicom.burypointLogId('110003'); // 领取页面pv, pv去重得到uv
  57. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'draw_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  58. } else
  59. if (location.href.indexOf('/flow') >= 0) {
  60. unicom.burypointLogId('110004'); // 流量查询pv, pv去重得到uv
  61. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'flow_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  62. } else if (location.href.indexOf('/active') >= 0) {
  63. unicom.burypointLogId('110005'); // 激活页面pv, pv去重得到uv
  64. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'active_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  65. } else if (location.href.indexOf('/refund') >= 0) {
  66. unicom.burypointLogId('110006'); // 退款
  67. } else {
  68. unicom.burypointLogId('110001'); // 订购页面pv, pv去重得到uv
  69. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'order_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  70. }
  71. })
  72. }
  73. function openPage(pageName) {
  74. if (pageName == null) {
  75. if (location.href.indexOf("index.html") >= 0) pageName = "order";
  76. if (location.href.indexOf("cannel.html") >= 0) pageName = "cancel";
  77. if (location.href.indexOf("draw.html") >= 0) pageName = "draw";
  78. if (location.href.indexOf("active.html") >= 0) pageName = "active";
  79. if (location.href.indexOf("flow.html") >= 0) pageName = "flow";
  80. }
  81. switch (pageName) {
  82. case "active":
  83. showActivePage();
  84. break;
  85. case "cancel":
  86. showCancelPage();
  87. break;
  88. case "draw":
  89. showDrawPage();
  90. break;
  91. case "flow":
  92. showFlowPage();
  93. break;
  94. default:
  95. showOrderPage();
  96. break;
  97. }
  98. }
  99. $('#btn_cannel').unbind('click').on('click', function() {
  100. unicom.showCancelReasonPage().done(function(cancelReason) {
  101. var k = JSON.stringify(cancelReason)
  102. window.localStorage.setItem('kye', k)
  103. gotoUrl('google/baidu/cannel')
  104. }).fail(function() {
  105. });
  106. })
  107. // $('#btn_l').unbind('click').on('click', function() {
  108. // window.location.href = 'https://account.bol.wo.cn/cuuser/unity/redirectOnekeyLogin?clientId=directflow&redirectUrl=' + 'http://100.0.4.69:3344/orderchannel/douyin/15/draw20220313.html?fes=9ur&sou=26'
  109. // gotoUrl('douyin/15/draw20220313')
  110. // })
  111. $('#btn-cancel').unbind('click').on('click', function() {
  112. showCancelPage();
  113. })
  114. $('#btn-active').unbind('click').on('click', function() {
  115. showActivePage();
  116. })
  117. $('#gotoDrawPage').unbind('click').on('click', function() {
  118. showDrawPage(window.location.href.substring(window.location.href.lastIndexOf('/') + 1, window.location.href.lastIndexOf('.')))
  119. })
  120. function showDrawPage(back) {
  121. // if (location.href.indexOf("draw202203013.html") < 0) {
  122. // window.location.href = "draw202203013.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou + '&back=' + (back == null ? '' : back);
  123. // return;
  124. // }
  125. var $container = $('.section-setting').find('.form-group');
  126. var $containers = $('.section-setting').find('.actions');
  127. $container.find('.sendcode').unbind('click').on('click', function() {
  128. var account = $container.find('.account').val();
  129. if (account == null || account == "") {
  130. compnt.showAlertarxe('请输入领取号码');
  131. return;
  132. }
  133. unicom.sendSmsarr($container, 'drawlogin');
  134. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  135. })
  136. $containers.find('.login').unbind('click').on('click', function() {
  137. var usermob = $container.find('.usermob').val();
  138. var account = $container.find('.account').val();
  139. var smscode = $container.find('.smscode').val();
  140. if (usermob == null || usermob == "") {
  141. compnt.showAlertarxe('请输入联通手机号');
  142. return;
  143. }
  144. if (account == null || account == "") {
  145. compnt.showAlertarxe('请输入领取号码');
  146. return;
  147. }
  148. if (smscode == null || smscode == "") {
  149. compnt.showAlertarxe('请输入验证码');
  150. return;
  151. }
  152. var $comfirm = showConfirmDialog(account);
  153. $comfirm.find('.cancel').on('click', function() {
  154. compnt.hideLoading();
  155. });
  156. $comfirm.find('.okay').on('click', function() {
  157. unicom.checkCodearr($container, true).done(function(response) {
  158. // console.log(response)
  159. // console.log(response.userid)
  160. var usermobsr = response
  161. /*unicom.canDrawCoin(account).then(function (response) {
  162. if (response.resultCode != "0000") {
  163. compnt.hideLoading();
  164. compnt.showAlertarxe(response.errorInfo);
  165. return;
  166. }
  167. drawCoin(account)
  168. })*/
  169. var name_ax = '2022071807'
  170. var vipcode = "90001"
  171. var productid = ''
  172. deaw(account, vipcode, usermobsr, '', name_ax, productid);
  173. console.log(account, vipcode, usermobsr, '', name_ax)
  174. }).fail(function(data) {
  175. compnt.hideLoading();
  176. })
  177. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  178. });
  179. })
  180. }
  181. function drawCoin(account) {
  182. // var $comfirm = showConfirmDialog(account);
  183. // $comfirm.find('.cancel').on('click', function() {
  184. // compnt.hideLoading();
  185. // });
  186. //$comfirm.find('.okay').on('click', function() {
  187. // var $container = $('.section-login').find('.form-group');
  188. // $container.find('.usermob').val('')
  189. // $container.find('.usermob').val('')
  190. // $container.find('.account').val('');
  191. compnt.showLoading();
  192. unicom.drawCoin(account, '').done(function(response) {
  193. compnt.hideLoading();
  194. switch (response.resultCode) {
  195. case "0000":
  196. var $container = $('.section-login').find('.form-group');
  197. $container.find('.usermob').val('');
  198. $container.find('.smscode').val('');
  199. $container.find('.account').val('');
  200. compnt.showAlertarxe('抖币充值中,详情结果以短信形式告知').then(function() {
  201. if (unicom.query.back != null && unicom.query.back != '') {
  202. showOrderPage(unicom.query.back + ".html");
  203. }
  204. });
  205. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  206. break;
  207. case "7605":
  208. compnt.showAlertarxe(response.errorInfo);
  209. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  210. break;
  211. case '6776':
  212. var prefix = '';
  213. compnt.showAlertarxe(prefix + response.errorInfo);
  214. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  215. break;
  216. default:
  217. var prefix = '';
  218. if (response.errorInfo.indexOf('领取失败') < 0) {
  219. prefix = '领取失败,';
  220. }
  221. compnt.showAlertarxe(prefix + response.errorInfo);
  222. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  223. break;
  224. }
  225. }).fail(function(data) {
  226. compnt.hideLoading();
  227. })
  228. }
  229. function showOrderPage(backPage) {
  230. // if (location.href.indexOf('15/index') < 0) {
  231. // if (backPage == null || backPage == '') {
  232. // backPage = 'index.html';
  233. // }
  234. // window.location.href = backPage + "?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
  235. // return;
  236. // }
  237. $('#btn-order').unbind('click').on('click', function(event) {
  238. //compnt.showAlertarxe('退订成功');
  239. // return;
  240. // console.log(1)
  241. if (!compnt.lockClick()) {
  242. return;
  243. }
  244. unicom.showCapPage(null, null, false, false, true).then(function(data) {
  245. compnt.unlockClick();
  246. order(data.userid, data.token, data.usermob);
  247. }).fail(function(response) {
  248. compnt.unlockClick();
  249. })
  250. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_click_order_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  251. })
  252. }
  253. function showFlowPage() {
  254. if (location.href.indexOf("flow.html") < 0) {
  255. window.location.href = "flow.html?fes=" +
  256. unicom.query.fes + "&sou=" + unicom.query.sou +
  257. "&userid=" + unicom.user.userid + "&usermob=" + unicom.user.usermob +
  258. "&usertime=" + (unicom.user.usertime || (new Date().getTime()));
  259. return;
  260. }
  261. var $container = $('.section-flow');
  262. var usermob = unicom.user.usermob;
  263. $container.find('.phone').html(usermob.substring(0, 3) + 'xxxx' + usermob.substring(7, 11));
  264. $container.find('.btn').unbind('click').on('click', function() {
  265. //if (!compnt.lockClick()) {
  266. // return;
  267. //}
  268. queryFlow().then(function(message) {
  269. compnt.unlockClick()
  270. if (message != null && message != "") {
  271. compnt.showAlertarxe(message);
  272. }
  273. }).fail(function() {
  274. compnt.unlockClick();
  275. });
  276. })
  277. queryFlow();
  278. }
  279. function showActivePage() {
  280. if (location.href.indexOf("active.html") < 0) {
  281. window.location.href = "active.html?fes=" + unicom.query.fes + "&sou=" +
  282. unicom.query.sou;
  283. return;
  284. }
  285. var $container = $('.section-login').find('.form-group');
  286. $container.find('.sendcode').unbind('click').on('click', function() {
  287. if (!checkEquip()) return;
  288. unicom.sendSms($container, 'activelogin');
  289. })
  290. $container.find('.login').unbind('click').on('click', function(event) {
  291. if (!checkEquip()) return;
  292. if (!compnt.lockClick()) {
  293. return;
  294. }
  295. unicom.checkCode($container).then(function() {
  296. compnt.unlockClick()
  297. active()
  298. }).fail(function() {
  299. compnt.unlockClick();
  300. });
  301. })
  302. window.scrollTo(0, 0)
  303. }
  304. function showCancelPage() {
  305. if (location.href.indexOf("cannel.html") < 0) {
  306. window.location.href = "cannel.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
  307. return;
  308. }
  309. var cancelReason = JSON.parse(window.localStorage.getItem('kye'))
  310. var $container = $('.section-login').find('.form-group');
  311. $container.find('.sendcode').unbind('click').on('click', function() {
  312. unicom.sendSmsarr($container, 'cancellogin');
  313. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  314. })
  315. $container.find('.login').unbind('click').on('click', function() {
  316. compnt.showLoading();
  317. unicom.checkCodearr($container).done(function() {
  318. unicom.cancel(null, null, cancelReason.canceltype, cancelReason.cancelmsg).done(function(response) {
  319. console.log(response)
  320. compnt.hideLoading();
  321. switch (response.resultCode) {
  322. case "0000":
  323. compnt.showAlertarxe('退订成功'); //.then(function(message) {
  324. //showFlowPage();
  325. //});
  326. window.localStorage.removeItem("kye");
  327. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  328. break;
  329. case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
  330. compnt.showAlertarxe(response.errorInfo); //.then(function(message) {
  331. //showFlowPage();
  332. //});
  333. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  334. break;
  335. default:
  336. var prefix = '';
  337. if (response.errorInfo.indexOf('退订失败') < 0) {
  338. prefix = '退订失败,';
  339. }
  340. compnt.showAlertarxe(prefix + response.errorInfo);
  341. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  342. break;
  343. }
  344. }).fail(function(data) {
  345. compnt.hideLoading();
  346. })
  347. }).fail(function(data) {
  348. compnt.hideLoading();
  349. })
  350. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  351. })
  352. window.scrollTo(0, 0)
  353. }
  354. function checkEquip() {
  355. /*if (!baidu.app.baidu) {
  356. compnt.showAlertarxe('请到百度产品客户端中激活免流~')
  357. return false;
  358. }
  359. if (!baidu.checkWeiboVersion()) {
  360. compnt.showAlertarxe('请到升级到最新版百度产品客户端后激活免流~')
  361. return false;
  362. }*/
  363. return true;
  364. }
  365. /**
  366. * 订购
  367. */
  368. function order(userid, token, usermob) {
  369. compnt.showLoading('处理中,请稍后...');
  370. unicom.order(userid, token, usermob).done(function(response) {
  371. compnt.hideLoading();
  372. switch (response.resultCode) {
  373. case "0000": //订购成功!跳转到领取会员页面
  374. unicom.saveUserInfo();
  375. compnt.showAlertarxe('订购成功');
  376. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  377. return;
  378. case "0013":
  379. //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
  380. compnt.showAlertarxe('该号码归属省分2/3G暂未开通此产品!');
  381. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  382. break;
  383. case "6611":
  384. // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
  385. compnt.showAlertarxe('错误代码(6611),订购失败,请重试!');
  386. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  387. break;
  388. case "6615":
  389. //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
  390. compnt.showAlertarxe('订购失败,请确定用户套餐!');
  391. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  392. break;
  393. case "6622": // 用户已订购过此产品!跳转到流量查页面
  394. // localStorage.setItem('message', '您已经订购了本产品~');
  395. compnt.showAlertarxe('您已经订购了本产品~');
  396. unicom.saveUserInfo();
  397. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  398. // showFlowPage();
  399. break;
  400. default:
  401. //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
  402. compnt.showAlertarxe(response.errorInfo + '订购失败,请确定用户套餐!');
  403. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  404. break;
  405. }
  406. }).fail(function(error) {
  407. compnt.hideLoading();
  408. console.log(error);
  409. });
  410. }
  411. function showAlert(message, hideButton, buttonLabel, hideTitle) {
  412. var title = '';
  413. if (hideTitle == undefined || hideTitle == false) {
  414. title = message;
  415. }
  416. var $overlay = $('<div class="overlay overlay-alert"></div>');
  417. var $dialog = $(
  418. '<div class="dialog-alerts dialog-alert">' +
  419. '<h1>' + title + '</h1>' +
  420. '<div class="contents">' + '</div>' +
  421. '<div class="actionss actions">' +
  422. ' <div class="btn">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  423. '</div>' +
  424. '</div>');
  425. $("body").css("overflow", "hidden");
  426. $overlay.appendTo($(document.body));
  427. $dialog.appendTo($(document.body));
  428. if (hideButton == true) {
  429. $dialog.find('.btn').remove();
  430. }
  431. $dialog.close = function() {
  432. $("body").css("overflow", "auto");
  433. $overlay.remove();
  434. $dialog.remove();
  435. $dialog = null;
  436. }
  437. var def = $.Deferred();
  438. $dialog.find('.btn').on('click', function() {
  439. $dialog.close()
  440. def.resolve($dialog);
  441. })
  442. return def;
  443. }
  444. function showAlerak(message, hideButton, buttonLabel, hideTitle) {
  445. var title = '';
  446. if (hideTitle == undefined || hideTitle == false) {
  447. title = message;
  448. }
  449. var $overlay = $('<div class="overlay overlay-alert"></div>');
  450. var $dialog = $(
  451. '<div class="dialog-alerts dialog-alert">' +
  452. '<h1>' + title + '</h1>' +
  453. '<div class="contentsak">' + '</div>' +
  454. '<div class="actionss actions">' +
  455. ' <div class="btn">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  456. '</div>' +
  457. '</div>');
  458. $("body").css("overflow", "hidden");
  459. $overlay.appendTo($(document.body));
  460. $dialog.appendTo($(document.body));
  461. if (hideButton == true) {
  462. $dialog.find('.btn').remove();
  463. }
  464. $dialog.close = function() {
  465. $("body").css("overflow", "auto");
  466. $overlay.remove();
  467. $dialog.remove();
  468. $dialog = null;
  469. }
  470. var def = $.Deferred();
  471. $dialog.find('.btn').on('click', function() {
  472. $dialog.close()
  473. def.resolve($dialog);
  474. if (productidas != '2020010201') {
  475. console.log(productidas)
  476. var a = getQueryString("cpid");
  477. var b = getQueryString("userid");
  478. var c = getQueryString("usermob");
  479. var fes = getQueryString("fes");
  480. var sou = getQueryString("sou");
  481. var cbUrl;
  482. if (window.location.href.indexOf("https://800.wo.cn/orderchannel") >= 0) {
  483. cbUrl = "https://800.wo.cn/orderchannel/douyin/15/draw20220313.html?fes=jjd&sou=1m&cpid=" + a + '&userid=' + b + '&usermob=' + c;
  484. } else if (window.location.href.indexOf("http://100.0.4.69:3344") >= 0) {
  485. cbUrl = "http://100.0.4.69:3344/orderchannel/douyin/15/draw20220313.html?fes=" + fes + "&sou=" + sou + '&cpid=' + a + '&userid=' + b + '&usermob=' + c;
  486. }
  487. location.href = cbUrl;
  488. }
  489. })
  490. return def;
  491. }
  492. function showAlerts(message, hideButton, buttonLabel, hideTitle) {
  493. var title = '';
  494. if (hideTitle == undefined || hideTitle == false) {
  495. title = message;
  496. }
  497. var $overlay = $('<div class="overlay overlay-alert"></div>');
  498. var $dialog = $(
  499. '<div class="dialog-alerts dialog-alert">' +
  500. '<h1>' + title + '</h1>' +
  501. '<div class="contentss">' + '</div>' +
  502. '<div class="actionss actions">' +
  503. ' <div class="btn">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  504. '</div>' +
  505. '</div>');
  506. $("body").css("overflow", "hidden");
  507. $overlay.appendTo($(document.body));
  508. $dialog.appendTo($(document.body));
  509. if (hideButton == true) {
  510. $dialog.find('.btn').remove();
  511. }
  512. $dialog.close = function() {
  513. $("body").css("overflow", "auto");
  514. $overlay.remove();
  515. $dialog.remove();
  516. $dialog = null;
  517. }
  518. var def = $.Deferred();
  519. $dialog.find('.btn').on('click', function() {
  520. $dialog.close()
  521. def.resolve($dialog);
  522. })
  523. return def;
  524. }
  525. function showAlertDialog(action, message) {
  526. var className = '';
  527. switch (action) {
  528. case 'orderSuccess':
  529. className = 'dialog-message-order-success';
  530. break;
  531. case 'orderFailure':
  532. className = 'dialog-message-order-failure';
  533. break;
  534. case 'activeSuccess':
  535. className = 'dialog-message-active-success';
  536. break;
  537. case 'activeFailure':
  538. className = 'dialog-message-active-failure';
  539. break;
  540. case 'cancelSuccess':
  541. className = 'dialog-message-cancel-success';
  542. break;
  543. case 'cancelFailure':
  544. className = 'dialog-message-cancel-failure';
  545. break;
  546. default:
  547. break;
  548. }
  549. var $overlay = $('<div class="overlay"></div>');
  550. var $dialog = $(
  551. '<div class="dialog dialog-message ' + className + '">' +
  552. ' <div class="title"></div>' +
  553. ' <div class="content">' + message + '</div>' +
  554. ' <div class="actions">' +
  555. ' <div class="btn">确定</div>' +
  556. ' </div>' +
  557. '</div>');
  558. $overlay.appendTo($(document.body))
  559. $dialog.appendTo($(document.body))
  560. $dialog.find('.btn').unbind('click').on('click', function() {
  561. $dialog.close()
  562. })
  563. $dialog.close = function() {
  564. $overlay.remove();
  565. $dialog.remove();
  566. $dialog = null;
  567. }
  568. return $dialog;
  569. }
  570. /**
  571. * 查询用户剩余流量
  572. */
  573. function queryFlow() {
  574. var $container = $('.section-flow');
  575. //return new Promise(function(resolve, reject) {
  576. var def = $.Deferred();
  577. unicom.queryFlow().then(function(response) {
  578. // var response = JSON.parse(responseText);
  579. // console.log("流量剩余情况:" + response.data)
  580. switch (response.resultCode) {
  581. case "0000":
  582. //compnt.showAlertarxe(JSON.stringify(response.data));
  583. //console.log(response.data)
  584. //console.log(JSON.parse(response.data).surplusFlow)
  585. var surplus = compnt.returnFloat(JSON.parse(response.data).surplusFlow / 1024 / 1024);
  586. $container.find('.surplus').html(surplus + 'GB');
  587. var usedFlowKb = parseInt(JSON.parse(response.data).usedFlow);
  588. if (usedFlowKb > 0 && usedFlowKb < 1024) {
  589. def.resolve("剩余流量更新成功,为您免流了" + usedFlowKb + "KB~");
  590. } else if (usedFlowKb > 1024) {
  591. var useedFlow = compnt.returnFloat(usedFlowKb / 1024);
  592. def.resolve("剩余流量更新成功,为您免流了" + useedFlow + "MB~");
  593. } else {
  594. def.resolve("剩余流量更新成功~");
  595. }
  596. break;
  597. case "9201": //{"resultCode":"9201","errorInfo":"查询失败,请检查是否有订购关系!"}
  598. def.resolve("您未订购百度定向流量包~")
  599. // $container.find('.phone').html('用户未订购此产品!');
  600. break;
  601. case "9203": //{"resultCode":"9203","errorInfo":"流量查询失败,没有获取到用户所使用流量信息!"}
  602. //compnt.showAlertarxe("没有获取到用户所使用流量信息!");
  603. def.resolve("剩余流量更新成功~")
  604. $container.find('.suplus').html('本月剩余<br>8.00GB');
  605. break;
  606. default:
  607. def.resolve("剩余流量更新成功~")
  608. break;
  609. }
  610. })
  611. return def;
  612. //})
  613. }
  614. function active() {
  615. baidu.active().then(function() {
  616. //checkActiveResult();
  617. compnt.showAlertarxe('激活成功').then(function() {
  618. unicom.saveUserInfo()
  619. // showFlowPage();
  620. });
  621. })
  622. }
  623. $('.section-agr').find('.footer').on('click', function() {
  624. if ($($('.section-agr .scope').find('li')[2]).hasClass('hidden')) {
  625. $('.section-agr .scope').find('li').each(function(i, ele) {
  626. $(ele).removeClass('hidden');
  627. })
  628. $('.section-agr').find('.footer').html('隐藏<span class="arrow">&gt;');
  629. } else {
  630. $('.section-agr .scope').find('li').each(function(i, ele) {
  631. if (i >= 1) {
  632. $(ele).addClass('hidden');
  633. }
  634. })
  635. $('.section-agr').find('.footer').html('查看更多专属流量适用范围<span class="arrow">&gt;');
  636. }
  637. });
  638. function showConfirmDialog(account) {
  639. var $overlay = $('<div class="overlay"></div>')
  640. var $dialog = $(
  641. '<div class="dialog dialog-confirm">' +
  642. ' <div class="content">请确认是否领取到' + account + '号码?</div>' +
  643. ' <div class="actions">' +
  644. ' <div class="btn cancel">取消</div>' +
  645. ' <div class="btn okay">确认</div>' +
  646. ' </div>' +
  647. '</div>');
  648. $overlay.appendTo($(document.body))
  649. $dialog.appendTo($(document.body))
  650. $dialog.find('.btn').on('click', function() {
  651. $overlay.remove();
  652. $dialog.remove();
  653. $dialog = null;
  654. })
  655. $dialog.close = function() {
  656. $overlay.remove();
  657. $dialog.remove();
  658. $dialog = null;
  659. }
  660. return $dialog;
  661. }
  662. var call = 0
  663. $(".beijing_a").click(function() {
  664. if ($(this)) {
  665. $(this).addClass("beijing_b").siblings().removeClass('beijing_b');
  666. call = $(this).index()
  667. // console.log($(this).index())
  668. }
  669. });
  670. $('.order_a').click(function() {
  671. // console.log(call)
  672. switch (call) {
  673. case 0:
  674. showAlerta('优酷视频会员周卡')
  675. break;
  676. case 1:
  677. showAlerta('爱奇艺视频会员周卡')
  678. break;
  679. case 2:
  680. showAlerta('腾讯视频会员周卡')
  681. break;
  682. case 3:
  683. showAlerta('蜻蜓FM超级会员周卡')
  684. break;
  685. case 4:
  686. showAlerta('芒果TV PC移动影视会员周卡')
  687. break;
  688. case 5:
  689. showAlerta('美团外卖5元红包')
  690. break;
  691. case 6:
  692. showAlertat('抖音币50个')
  693. break;
  694. default:
  695. // console.log(call)
  696. break;
  697. }
  698. })
  699. function showAlerta(message, hideButton, buttonLabel, hideTitle) {
  700. var title = '';
  701. var text = '';
  702. var texts = '';
  703. if (hideTitle == undefined || hideTitle == false) {
  704. title = '您选择的是:';
  705. text = message
  706. texts = unicom.name_a
  707. }
  708. var $overlay = $('<div class="overlay overlay-alert"></div>');
  709. var $dialog = $(
  710. '<div class="dialog-alerttt">' +
  711. '<h1 class="text_nn">' + '<span class="text_mm ">' + title + '</span>' + text + '</h1>' +
  712. '<h1 class="text_nn text_nns">' + '<span class="text_mm ">' + '产品:' + '</span>' + texts + '</h1>' +
  713. '<input class="inputot" type="tel" maxlength="11" name="phone" placeholder="请输入领取权益的手机号码"/>' +
  714. // '<button class="content">' + message + '</button>' +
  715. '<div class="actions">' +
  716. ' <div class="btns">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
  717. ' <div id="btn_orderss" class="btn btn_orderss">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  718. '</div>' +
  719. '</div>');
  720. $("body").css("overflow", "hidden");
  721. $overlay.appendTo($(document.body));
  722. $dialog.appendTo($(document.body));
  723. if (hideButton == true) {
  724. $dialog.find('.btn').remove();
  725. }
  726. $(".btns").click(function() {
  727. $("body").css("overflow", "auto");
  728. $overlay.remove();
  729. $dialog.remove();
  730. $dialog = null;
  731. })
  732. $("#btn_orderss").click(function() {
  733. var account = $dialog.find('.inputot').val();
  734. if (account == null || account == "") {
  735. compnt.showAlertarxe('请输入手机号码');
  736. return;
  737. }
  738. // console.log(account)
  739. // console.log(usermob, account)
  740. switch (call) {
  741. case 0:
  742. var vipcode = 10001
  743. break;
  744. case 1:
  745. var vipcode = 20001
  746. break;
  747. case 2:
  748. var vipcode = 30001
  749. break;
  750. case 3:
  751. var vipcode = 60001
  752. break;
  753. case 4:
  754. var vipcode = 50001
  755. break;
  756. case 5:
  757. var vipcode = 13004
  758. break;
  759. default:
  760. // console.log(call)
  761. break;
  762. }
  763. // console.log(account, vipcode, usermob, name_b, unicom.name_a)
  764. deaw(account, vipcode, usermob, name_b, unicom.name_a)
  765. $("body").css("overflow", "auto");
  766. $overlay.remove();
  767. $dialog.remove();
  768. $dialog = null;
  769. })
  770. }
  771. function showAlertat(message, hideButton, buttonLabel, hideTitle) {
  772. var title = '';
  773. var text = '';
  774. if (hideTitle == undefined || hideTitle == false) {
  775. title = '您选择的是:';
  776. text = message
  777. }
  778. var $overlay = $('<div class="overlay overlay-alert"></div>');
  779. var $dialog = $(
  780. '<div class="dialog-alerttt">' +
  781. '<h1 class="text_nn">' + '<span class="text_mm ">' + title + '</span>' + text + '</h1>' +
  782. '<input class="inputot" placeholder="请输入抖音号"/>' +
  783. // '<button class="content">' + message + '</button>' +
  784. '<div class="actions">' +
  785. ' <div class="btns">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
  786. ' <div id="btn_orderss" class="btn btn_orderss">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  787. '</div>' +
  788. '</div>');
  789. $("body").css("overflow", "hidden");
  790. $overlay.appendTo($(document.body));
  791. $dialog.appendTo($(document.body));
  792. $(".btns").click(function() {
  793. $("body").css("overflow", "auto");
  794. $overlay.remove();
  795. $dialog.remove();
  796. $dialog = null;
  797. })
  798. $("#btn_orderss").click(function() {
  799. var account = $dialog.find('.inputot').val();
  800. // console.log(account)
  801. var arr = new Array()
  802. arr = account.split(' ')
  803. if (arr.length != 1) {
  804. compnt.showAlertarxe('抖音短视频账号不能含有空格');
  805. return
  806. }
  807. if (account == null || account == "") {
  808. compnt.showAlertarxe('请输入抖音短视频账号');
  809. return;
  810. } else {
  811. var vipcodes = '20200310'
  812. console.log(account, vipcodes, usermob, name_b)
  813. deaw(account, vipcodes, usermob, name_b)
  814. $("body").css("overflow", "auto");
  815. $overlay.remove();
  816. $dialog.remove();
  817. $dialog = null;
  818. }
  819. })
  820. }
  821. function getQueryString(name) {
  822. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  823. var r = window.location.search.substr(1).match(reg);
  824. if (r != null) return unescape(r[2]);
  825. return null;
  826. }
  827. // console.log(account, vipcode, usermob, name_b, name_ax)
  828. function deaw(usermob, token, userid, spid, name_ax, productid) {
  829. compnt.showLoading('处理中,请稍后...');
  830. unicom.deaws(usermob, token, userid, spid, name_ax, productid).done(function(response) {
  831. compnt.hideLoading();
  832. // console.log(response.resultCode)
  833. switch (response.resultCode) {
  834. case "0000": //订购成功!跳转到领取会员页面
  835. unicom.saveUserInfo();
  836. compnt.showAlertarxe('领取结果以短信为准!');
  837. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  838. return;
  839. case "1102":
  840. //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
  841. compnt.showAlertarxe('用户已领取过权益,不能再领取!');
  842. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  843. break;
  844. case "1015":
  845. // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
  846. compnt.showAlertarxe('用户未订购此产品!');
  847. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  848. break;
  849. // case "6615":
  850. // //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
  851. // showAlerts('订购失败,请确定用户套餐!');
  852. // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  853. // break;
  854. // case "6622": // 用户已订购过此产品!跳转到流量查页面
  855. // // localStorage.setItem('message', '您已经订购了本产品~');
  856. // compnt.showAlertarxe('您已经订购了本产品~');
  857. // unicom.saveUserInfo();
  858. // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  859. // // showFlowPage();
  860. // break;
  861. default:
  862. //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
  863. compnt.showAlertarxe(response.errorInfo + ',订购失败,请确定用户套餐!');
  864. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  865. break;
  866. }
  867. }).fail(function(error) {
  868. compnt.hideLoading();
  869. console.log(error);
  870. });
  871. }