main.js 43 KB

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