main.js 37 KB

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