main.js 37 KB

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