main.js 27 KB

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