main.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. import * as compnt from "../../../../public/js/compnt.js";
  2. import * as unicom from "../../../../public/js/unicom.js";
  3. import "../scss/order.scss";
  4. $(document).ready(function() {
  5. var newVisitor = isNewVisitor(); // 如果是新访客
  6. if (newVisitor === true) {
  7. // 动画弹出消息框
  8. compnt.showAlertlt('订购返话费活动期间成功订购产品,累计可返10元话费。快来参与吧!');
  9. // 标记:已经向该访客弹出过消息。2个月之内不要再弹
  10. setCookie("gznotes-visited5G9", "true", 93);
  11. }
  12. });
  13. function isNewVisitor() {
  14. // 从cookie读取“已经向访客提示过消息”的标志位
  15. var flg = getCookie("gznotes-visited5G9");
  16. if (flg === "") {
  17. return true;
  18. } else {
  19. return false;
  20. }
  21. }
  22. // 写cookie
  23. function setCookie(cname, cvalue, exdays) {
  24. var d = new Date();
  25. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  26. var expires = "expires=" + d.toUTCString();
  27. document.cookie = cname + "=" + cvalue + "; " + expires + ";path=/";
  28. }
  29. // 读cookie
  30. function getCookie(cname) {
  31. var name = cname + "=";
  32. var ca = document.cookie.split(';');
  33. for (var i = 0; i < ca.length; i++) {
  34. var c = ca[i];
  35. while (c.charAt(0) == ' ') c = c.substring(1);
  36. if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
  37. }
  38. return "";
  39. }
  40. var alichannel = getUrlParam("alichannel");
  41. register()
  42. function register() {
  43. if (alichannel == null || alichannel == '') {
  44. console.log('未获取到alichannel参数!');
  45. } else {
  46. console.log('参数获取成功!')
  47. }
  48. }
  49. function getUrlParam(urlprm) {
  50. var reg = new RegExp("(^|&)" + urlprm + "=([^&]*)(&|$)");
  51. var r = window.location.search.substr(1).match(reg);
  52. if (r != null) {
  53. return r[2];
  54. }
  55. }
  56. $(function() {
  57. var isPageHide = false;
  58. window.addEventListener('pageshow', function() {
  59. if (isPageHide) {
  60. window.location.reload();
  61. }
  62. });
  63. window.addEventListener('pagehide', function() {
  64. isPageHide = true;
  65. });
  66. if (window.location.href.indexOf('draw.html') >= 0) {
  67. var user = JSON.parse(localStorage.getItem('user'));
  68. if (user != null) {
  69. $('.usermob').val(user.usermob);
  70. }
  71. }
  72. })
  73. init();
  74. function init() {
  75. var message = localStorage.getItem('message');
  76. if (message != null && message != '') {
  77. compnt.showAlert(message);
  78. localStorage.removeItem('message');
  79. }
  80. compnt.showLoading();
  81. console.log(1)
  82. unicom.init().then(function(response) {
  83. compnt.hideLoading();
  84. console.log(response.product)
  85. if (response.product[0].productid == "2021073001") {
  86. unicom.product = response.product[1]
  87. } else {
  88. unicom.product = response.product[0];
  89. }
  90. unicom.fesname = response.festival;
  91. unicom.loadUserInfo();
  92. if (location.href.indexOf("15/index") >= 0) {
  93. showOrderPage();
  94. } else {
  95. openPage();
  96. }
  97. if (location.href.indexOf('/channel') >= 0) {
  98. unicom.burypointLogId('110002'); // 退订页面pv, pv去重得到uv
  99. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'cancel_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  100. } else if (location.href.indexOf('/draw') >= 0) {
  101. unicom.burypointLogId('110003'); // 领取页面pv, pv去重得到uv
  102. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'draw_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  103. } else if (location.href.indexOf('/flow') >= 0) {
  104. unicom.burypointLogId('110004'); // 流量查询pv, pv去重得到uv
  105. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'flow_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  106. } else if (location.href.indexOf('/active') >= 0) {
  107. unicom.burypointLogId('110005'); // 激活页面pv, pv去重得到uv
  108. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'active_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  109. } else if (location.href.indexOf('/refund') >= 0) {
  110. unicom.burypointLogId('110006'); // 退款
  111. } else if (location.href.indexOf('/channel') >= 0) {
  112. unicom.burypointLogId('110002'); // 退订页面pv, pv去重得到uv
  113. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'cancel_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  114. } else {
  115. unicom.burypointLogId('110001'); // 订购页面pv, pv去重得到uv
  116. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'open', ea: 'order_open' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  117. }
  118. })
  119. }
  120. function openPage(pageName) {
  121. if (pageName == null) {
  122. if (location.href.indexOf("index.html") >= 0) pageName = "order";
  123. if (location.href.indexOf("channel20220704.html") >= 0) pageName = "cancel";
  124. if (location.href.indexOf("channel.html") >= 0) pageName = "cancel";
  125. if (location.href.indexOf("draw.html") >= 0) pageName = "draw";
  126. if (location.href.indexOf("active.html") >= 0) pageName = "active";
  127. if (location.href.indexOf("flow.html") >= 0) pageName = "flow";
  128. }
  129. switch (pageName) {
  130. case "active":
  131. showActivePage();
  132. break;
  133. case "cancel":
  134. showCancelPage();
  135. break;
  136. case "draw":
  137. showDrawPage();
  138. break;
  139. case "flow":
  140. showFlowPage();
  141. break;
  142. default:
  143. showOrderPage();
  144. break;
  145. }
  146. }
  147. $('#btn-cancel').unbind('click').on('click', function() {
  148. showCancelPage();
  149. })
  150. $('#btn-active').unbind('click').on('click', function() {
  151. showActivePage();
  152. })
  153. $('#gotoDrawPage').unbind('click').on('click', function() {
  154. showDrawPage(window.location.href.substring(window.location.href.lastIndexOf('/') + 1, window.location.href.lastIndexOf('.')))
  155. })
  156. function showDrawPage(back) {
  157. if (location.href.indexOf("draw.html") < 0) {
  158. window.location.href = "draw.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou + '&back=' + (back == null ? '' : back);
  159. return;
  160. }
  161. var $container = $('.section-login').find('.form-group');
  162. $container.find('.sendcode').unbind('click').on('click', function() {
  163. var account = $container.find('.account').val();
  164. var arr = new Array()
  165. arr = account.split(' ')
  166. if (arr.length != 1) {
  167. compnt.showAlert('抖音短视频账号不能含有空格');
  168. return
  169. }
  170. if (account == null || account == "") {
  171. compnt.showAlert('请输入抖音短视频账号');
  172. return;
  173. }
  174. unicom.sendSms($container, 'drawlogin');
  175. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  176. })
  177. $container.find('.login').unbind('click').on('click', function() {
  178. var usermob = $container.find('.usermob').val();
  179. var account = $container.find('.account').val();
  180. var smscode = $container.find('.smscode').val();
  181. if (usermob == null || usermob == "") {
  182. compnt.showAlert('请输入联通手机号');
  183. return;
  184. }
  185. var arr = new Array()
  186. arr = account.split(' ')
  187. if (arr.length != 1) {
  188. compnt.showAlert('抖音短视频账号不能含有空格');
  189. return
  190. }
  191. if (account == null || account == "") {
  192. compnt.showAlert('请输入抖音短视频账号');
  193. return;
  194. }
  195. if (account == null || account == "") {
  196. compnt.showAlert('请输入抖音短视频账号');
  197. return;
  198. }
  199. if (smscode == null || smscode == "") {
  200. compnt.showAlert('请输入验证码');
  201. return;
  202. }
  203. var $comfirm = showConfirmDialog(account);
  204. $comfirm.find('.cancel').on('click', function() {
  205. compnt.hideLoading();
  206. });
  207. $comfirm.find('.okay').on('click', function() {
  208. unicom.checkCode($container, true).done(function() {
  209. /*unicom.canDrawCoin(account).then(function (response) {
  210. if (response.resultCode != "0000") {
  211. compnt.hideLoading();
  212. compnt.showAlert(response.errorInfo);
  213. return;
  214. }
  215. drawCoin(account)
  216. })*/
  217. drawCoin(account);
  218. }).fail(function(data) {
  219. compnt.hideLoading();
  220. })
  221. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  222. });
  223. })
  224. }
  225. function drawCoin(account) {
  226. // var $comfirm = showConfirmDialog(account);
  227. // $comfirm.find('.cancel').on('click', function() {
  228. // compnt.hideLoading();
  229. // });
  230. //$comfirm.find('.okay').on('click', function() {
  231. // var $container = $('.section-login').find('.form-group');
  232. // $container.find('.usermob').val('')
  233. // $container.find('.usermob').val('')
  234. // $container.find('.account').val('');
  235. compnt.showLoading();
  236. unicom.drawCoin(account, '').done(function(response) {
  237. compnt.hideLoading();
  238. switch (response.resultCode) {
  239. case "0000":
  240. var $container = $('.section-login').find('.form-group');
  241. $container.find('.usermob').val('');
  242. $container.find('.smscode').val('');
  243. $container.find('.account').val('');
  244. compnt.showAlert('抖币充值中,详情结果以短信形式告知').then(function() {
  245. if (unicom.query.back != null && unicom.query.back != '') {
  246. showOrderPage(unicom.query.back + ".html");
  247. }
  248. });
  249. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  250. break;
  251. case "7605":
  252. compnt.showAlert(response.errorInfo);
  253. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  254. break;
  255. case '6776':
  256. var prefix = '';
  257. compnt.showAlert(prefix + response.errorInfo);
  258. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  259. break;
  260. default:
  261. var prefix = '';
  262. if (response.errorInfo.indexOf('领取失败') < 0) {
  263. prefix = '领取失败,';
  264. }
  265. compnt.showAlert(prefix + response.errorInfo);
  266. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'draw_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  267. break;
  268. }
  269. }).fail(function(data) {
  270. compnt.hideLoading();
  271. })
  272. }
  273. function showOrderPage(backPage) {
  274. // if (location.href.indexOf('30/index') < 0) {
  275. // if (backPage == null || backPage == '') {
  276. // backPage = 'index.html';
  277. // }
  278. // window.location.href = backPage + "?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
  279. // return;
  280. // }
  281. // var yesar = '1';
  282. // $('#nodex').unbind('click').on('click', function(event) {
  283. // //compnt.showAlert('退订成功');
  284. // var yuans = document.querySelector('.yuans')
  285. // if (yuans.style.background == '') {
  286. // yesar = '2'
  287. // console.log(yesar)
  288. // yuans.style.background = "#0064ff"
  289. // yuans.style.backgroundSize = "100% 104% "
  290. // yuans.style.border = "solid 0.04rem #ffff"
  291. // yuans.style.width = "0.18rem"
  292. // yuans.style.height = "0.18rem"
  293. // } else {
  294. // yesar = '1'
  295. // console.log(yesar)
  296. // yuans.style.background = ""
  297. // yuans.style.border = "solid 0.02rem #ffff"
  298. // yuans.style.width = "0.22rem"
  299. // yuans.style.height = "0.22rem"
  300. // }
  301. // })
  302. $('#btn-order').unbind('click').on('click', function(event) {
  303. //compnt.showAlert('退订成功');
  304. if (!compnt.lockClick()) {
  305. return;
  306. }
  307. unicom.showCapPage(null, null, false, false, true).then(function(data) {
  308. compnt.unlockClick();
  309. order(data.userid, data.token, data.usermob, null || unicom.query.ringid, alichannel);
  310. }).fail(function(response) {
  311. compnt.unlockClick();
  312. })
  313. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_click_order_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  314. })
  315. $('#tuid_channel').unbind('click').on('click', function(event) {
  316. unicom.showCancelReasonPages().done(function(cancelReason) {
  317. var k = JSON.stringify(cancelReason)
  318. if (alichannel == undefined) {
  319. var h = JSON.stringify('a')
  320. console.log(h)
  321. window.localStorage.setItem('kye', k)
  322. window.localStorage.setItem('kyes', h)
  323. gotoUrl('douyin/5G9/channel')
  324. } else {
  325. var h = JSON.stringify(alichannel)
  326. window.localStorage.setItem('kye', k)
  327. window.localStorage.setItem('kyes', h)
  328. gotoUrl('douyin/5G9/channel')
  329. }
  330. }).fail(function() {
  331. });
  332. // //compnt.showAlert('退订成功');
  333. // window.location.href = "channel20220704.html?fes=" +
  334. // unicom.query.fes + "&sou=" + unicom.query.sou
  335. // return;
  336. })
  337. }
  338. function showFlowPage() {
  339. if (location.href.indexOf("flow.html") < 0) {
  340. window.location.href = "flow.html?fes=" +
  341. unicom.query.fes + "&sou=" + unicom.query.sou +
  342. "&userid=" + unicom.user.userid + "&usermob=" + unicom.user.usermob +
  343. "&usertime=" + (unicom.user.usertime || (new Date().getTime()));
  344. return;
  345. }
  346. var $container = $('.section-flow');
  347. var usermob = unicom.user.usermob;
  348. $container.find('.phone').html(usermob.substring(0, 3) + 'xxxx' + usermob.substring(7, 11));
  349. $container.find('.btn').unbind('click').on('click', function() {
  350. //if (!compnt.lockClick()) {
  351. // return;
  352. //}
  353. queryFlow().then(function(message) {
  354. compnt.unlockClick()
  355. if (message != null && message != "") {
  356. compnt.showAlert(message);
  357. }
  358. }).fail(function() {
  359. compnt.unlockClick();
  360. });
  361. })
  362. queryFlow();
  363. }
  364. function showActivePage() {
  365. if (location.href.indexOf("active.html") < 0) {
  366. window.location.href = "active.html?fes=" + unicom.query.fes + "&sou=" +
  367. unicom.query.sou;
  368. return;
  369. }
  370. var $container = $('.section-login').find('.form-group');
  371. $container.find('.sendcode').unbind('click').on('click', function() {
  372. if (!checkEquip()) return;
  373. unicom.sendSms($container, 'activelogin');
  374. })
  375. $container.find('.login').unbind('click').on('click', function(event) {
  376. if (!checkEquip()) return;
  377. if (!compnt.lockClick()) {
  378. return;
  379. }
  380. unicom.checkCode($container).then(function() {
  381. compnt.unlockClick()
  382. active()
  383. }).fail(function() {
  384. compnt.unlockClick();
  385. });
  386. })
  387. window.scrollTo(0, 0)
  388. }
  389. function showCancelPage() {
  390. // if (location.href.indexOf("cannel20220313.html") < 0) {
  391. // window.location.href = "cannel20220313.html?fes=" + unicom.query.fes + "&sou=" + unicom.query.sou;
  392. // return;
  393. // }
  394. var cancelReason = JSON.parse(window.localStorage.getItem('kye'))
  395. if (JSON.parse(window.localStorage.getItem('kyes')) != 'a') {
  396. var alichannels = JSON.parse(window.localStorage.getItem('kyes'))
  397. } else {
  398. var alichannels = null
  399. }
  400. var $container = $('.section-login').find('.form-group');
  401. $container.find('.sendcode').unbind('click').on('click', function() {
  402. unicom.sendSms($container, 'cancellogin');
  403. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_send_sms_code_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  404. })
  405. $container.find('.login').unbind('click').on('click', function() {
  406. compnt.showLoading();
  407. console.log(alichannels)
  408. unicom.checkCode($container).done(function() {
  409. unicom.alcancel(null, null, cancelReason.canceltype, cancelReason.cancelmsg, alichannels).done(function(response) {
  410. compnt.hideLoading();
  411. switch (response.resultCode) {
  412. case "0000":
  413. compnt.showAlert('退订成功'); //.then(function(message) {
  414. //showFlowPage();
  415. //});
  416. window.localStorage.removeItem("kye");
  417. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  418. break;
  419. case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
  420. compnt.showAlert(response.errorInfo); //.then(function(message) {
  421. //showFlowPage();
  422. //});
  423. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  424. break;
  425. default:
  426. var prefix = '';
  427. if (response.errorInfo.indexOf('退订失败') < 0) {
  428. prefix = '退订失败,';
  429. }
  430. compnt.showAlert(prefix + response.errorInfo);
  431. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  432. break;
  433. }
  434. }).fail(function(data) {
  435. compnt.hideLoading();
  436. })
  437. }).fail(function(data) {
  438. compnt.hideLoading();
  439. })
  440. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'cancel_click_confirm_btn' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  441. })
  442. window.scrollTo(0, 0)
  443. }
  444. function checkEquip() {
  445. /*if (!baidu.app.baidu) {
  446. compnt.showAlert('请到百度产品客户端中激活免流~')
  447. return false;
  448. }
  449. if (!baidu.checkWeiboVersion()) {
  450. compnt.showAlert('请到升级到最新版百度产品客户端后激活免流~')
  451. return false;
  452. }*/
  453. return true;
  454. }
  455. /**
  456. * 订购
  457. */
  458. function order(userid, token, usermob, ringid, alichannel) {
  459. compnt.showLoading('处理中,请稍后...');
  460. unicom.alorder(userid, token, usermob, ringid, alichannel).done(function(response) {
  461. compnt.hideLoading();
  462. switch (response.resultCode) {
  463. case "0000": //订购成功!跳转到领取会员页面
  464. unicom.saveUserInfo();
  465. if (response.syncstatus == '0') {
  466. compnt.showAlert('业务开通中,结果请以短信提示为准。');
  467. } else {
  468. compnt.showAlert('订购成功!');
  469. }
  470. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  471. return;
  472. case "0013":
  473. //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
  474. compnt.showAlert('该号码归属省分2/3G暂未开通此产品!');
  475. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  476. break;
  477. case "6611":
  478. // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
  479. compnt.showAlert('错误代码(6611),订购失败,请重试!');
  480. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  481. break;
  482. case "6615":
  483. //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
  484. compnt.showAlert('订购失败,请确定用户套餐!');
  485. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  486. break;
  487. case "6622": // 用户已订购过此产品!跳转到流量查页面
  488. // localStorage.setItem('message', '您已经订购了本产品~');
  489. compnt.showAlert('您已经订购了本产品~');
  490. unicom.saveUserInfo();
  491. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  492. // showFlowPage();
  493. break;
  494. case "6634": // 用户已订购过此产品!跳转到流量查页面
  495. // localStorage.setItem('message', '您已经订购了本产品~');
  496. compnt.showAlert('您已经订购了本产品~');
  497. unicom.saveUserInfo();
  498. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  499. // showFlowPage();
  500. break;
  501. default:
  502. //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
  503. compnt.showAlert('网络异常,请稍后再试!');
  504. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  505. break;
  506. }
  507. }).fail(function(error) {
  508. compnt.hideLoading();
  509. console.log(error);
  510. });
  511. }
  512. function showAlertDialog(action, message) {
  513. var className = '';
  514. switch (action) {
  515. case 'orderSuccess':
  516. className = 'dialog-message-order-success';
  517. break;
  518. case 'orderFailure':
  519. className = 'dialog-message-order-failure';
  520. break;
  521. case 'activeSuccess':
  522. className = 'dialog-message-active-success';
  523. break;
  524. case 'activeFailure':
  525. className = 'dialog-message-active-failure';
  526. break;
  527. case 'cancelSuccess':
  528. className = 'dialog-message-cancel-success';
  529. break;
  530. case 'cancelFailure':
  531. className = 'dialog-message-cancel-failure';
  532. break;
  533. default:
  534. break;
  535. }
  536. var $overlay = $('<div class="overlay"></div>');
  537. var $dialog = $(
  538. '<div class="dialog dialog-message ' + className + '">' +
  539. ' <div class="title"></div>' +
  540. ' <div class="content">' + message + '</div>' +
  541. ' <div class="actions">' +
  542. ' <div class="btn">确定</div>' +
  543. ' </div>' +
  544. '</div>');
  545. $overlay.appendTo($(document.body))
  546. $dialog.appendTo($(document.body))
  547. $dialog.find('.btn').unbind('click').on('click', function() {
  548. $dialog.close()
  549. })
  550. $dialog.close = function() {
  551. $overlay.remove();
  552. $dialog.remove();
  553. $dialog = null;
  554. }
  555. return $dialog;
  556. }
  557. /**
  558. * 查询用户剩余流量
  559. */
  560. function queryFlow() {
  561. var $container = $('.section-flow');
  562. //return new Promise(function(resolve, reject) {
  563. var def = $.Deferred();
  564. unicom.queryFlow().then(function(response) {
  565. // var response = JSON.parse(responseText);
  566. // console.log("流量剩余情况:" + response.data)
  567. switch (response.resultCode) {
  568. case "0000":
  569. //compnt.showAlert(JSON.stringify(response.data));
  570. //console.log(response.data)
  571. //console.log(JSON.parse(response.data).surplusFlow)
  572. var surplus = compnt.returnFloat(JSON.parse(response.data).surplusFlow / 1024 / 1024);
  573. $container.find('.surplus').html(surplus + 'GB');
  574. var usedFlowKb = parseInt(JSON.parse(response.data).usedFlow);
  575. if (usedFlowKb > 0 && usedFlowKb < 1024) {
  576. def.resolve("剩余流量更新成功,为您免流了" + usedFlowKb + "KB~");
  577. } else if (usedFlowKb > 1024) {
  578. var useedFlow = compnt.returnFloat(usedFlowKb / 1024);
  579. def.resolve("剩余流量更新成功,为您免流了" + useedFlow + "MB~");
  580. } else {
  581. def.resolve("剩余流量更新成功~");
  582. }
  583. break;
  584. case "9201": //{"resultCode":"9201","errorInfo":"查询失败,请检查是否有订购关系!"}
  585. def.resolve("您未订购百度定向流量包~")
  586. $container.find('.phone').html('用户未订购此产品!');
  587. break;
  588. case "9203": //{"resultCode":"9203","errorInfo":"流量查询失败,没有获取到用户所使用流量信息!"}
  589. //compnt.showAlert("没有获取到用户所使用流量信息!");
  590. def.resolve("剩余流量更新成功~")
  591. $container.find('.suplus').html('本月剩余<br>8.00GB');
  592. break;
  593. default:
  594. def.resolve("剩余流量更新成功~")
  595. break;
  596. }
  597. })
  598. return def;
  599. //})
  600. }
  601. function active() {
  602. baidu.active().then(function() {
  603. //checkActiveResult();
  604. compnt.showAlert('激活成功').then(function() {
  605. unicom.saveUserInfo()
  606. // showFlowPage();
  607. });
  608. })
  609. }
  610. $('.section-agr').find('.footer').on('click', function() {
  611. if ($($('.section-agr .scope').find('li')[2]).hasClass('hidden')) {
  612. $('.section-agr .scope').find('li').each(function(i, ele) {
  613. $(ele).removeClass('hidden');
  614. })
  615. $('.section-agr').find('.footer').html('隐藏<span class="arrow">&gt;');
  616. } else {
  617. $('.section-agr .scope').find('li').each(function(i, ele) {
  618. if (i >= 1) {
  619. $(ele).addClass('hidden');
  620. }
  621. })
  622. $('.section-agr').find('.footer').html('查看更多专属流量适用范围<span class="arrow">&gt;');
  623. }
  624. });
  625. function showConfirmDialog(account) {
  626. var $overlay = $('<div class="overlay"></div>')
  627. var $dialog = $(
  628. '<div class="dialog dialog-confirm">' +
  629. ' <div class="content">请确认是否领取抖音币到' + account + '账号?</div>' +
  630. ' <div class="actions">' +
  631. ' <div class="btn cancel">取消</div>' +
  632. ' <div class="btn okay">确认</div>' +
  633. ' </div>' +
  634. '</div>');
  635. $overlay.appendTo($(document.body))
  636. $dialog.appendTo($(document.body))
  637. $dialog.find('.btn').on('click', function() {
  638. $overlay.remove();
  639. $dialog.remove();
  640. $dialog = null;
  641. })
  642. $dialog.close = function() {
  643. $overlay.remove();
  644. $dialog.remove();
  645. $dialog = null;
  646. }
  647. return $dialog;
  648. }