main.js 36 KB

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