main.js 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  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('draw202204.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("draw202204.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/draw202204.html?fes=9ur&sou=26'
  132. // gotoUrl('douyin/15/draw202204')
  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 3:
  699. showAlerta('芒果TV PC移动影视会员周卡')
  700. break;
  701. case 4:
  702. showAlerta('美团外卖5元红包')
  703. break;
  704. case 5:
  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 3:
  764. var vipcode = 50001
  765. break;
  766. case 4:
  767. var vipcode = 13004
  768. break;
  769. default:
  770. // console.log(call)
  771. break;
  772. }
  773. if (vipcode == 60001) {
  774. compnt.showAlert('权益已领完,请选择其他权益!');
  775. $overlay.remove();
  776. $dialog.remove();
  777. $dialog = null;
  778. } else {
  779. console.log(account, vipcode, usermob, name_b, unicom.name_a)
  780. deaw(account, vipcode, usermob, name_b, unicom.name_a)
  781. $("body").css("overflow", "auto");
  782. $overlay.remove();
  783. $dialog.remove();
  784. $dialog = null;
  785. }
  786. })
  787. }
  788. function showAlertat(message, hideButton, buttonLabel, hideTitle) {
  789. var title = '';
  790. var text = '';
  791. if (hideTitle == undefined || hideTitle == false) {
  792. title = '您选择的是:';
  793. text = message
  794. }
  795. var $overlay = $('<div class="overlay overlay-alert"></div>');
  796. var $dialog = $(
  797. '<div class="dialog-alerttt">' +
  798. '<h1 class="text_nn">' + '<span class="text_mm ">' + title + '</span>' + text + '</h1>' +
  799. '<input class="inputot" placeholder="请输入抖音号"/>' +
  800. // '<button class="content">' + message + '</button>' +
  801. '<div class="actions">' +
  802. ' <div class="btns">' + (buttonLabel == null || buttonLabel == "" ? "关闭" : buttonLabel) + '</div>' +
  803. ' <div id="btn_orderss" class="btn btn_orderss">' + (buttonLabel == null || buttonLabel == "" ? "确定" : buttonLabel) + '</div>' +
  804. '</div>' +
  805. '</div>');
  806. $("body").css("overflow", "hidden");
  807. $overlay.appendTo($(document.body));
  808. $dialog.appendTo($(document.body));
  809. $(".btns").click(function() {
  810. $("body").css("overflow", "auto");
  811. $overlay.remove();
  812. $dialog.remove();
  813. $dialog = null;
  814. })
  815. $("#btn_orderss").click(function() {
  816. var account = $dialog.find('.inputot').val();
  817. // console.log(account)
  818. var arr = new Array()
  819. arr = account.split(' ')
  820. if (arr.length != 1) {
  821. compnt.showAlert('抖音短视频账号不能含有空格');
  822. return
  823. }
  824. if (account == null || account == "") {
  825. compnt.showAlert('请输入抖音短视频账号');
  826. return;
  827. } else {
  828. var vipcodes = '20200310'
  829. console.log(account, vipcodes, usermob)
  830. deaw(account, vipcodes, usermob)
  831. $("body").css("overflow", "auto");
  832. $overlay.remove();
  833. $dialog.remove();
  834. $dialog = null;
  835. }
  836. })
  837. }
  838. function getQueryString(name) {
  839. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  840. var r = window.location.search.substr(1).match(reg);
  841. if (r != null) return unescape(r[2]);
  842. return null;
  843. }
  844. function deaw(userid, token, usermob) {
  845. compnt.showLoading('处理中,请稍后...');
  846. unicom.deaw(userid, token, usermob).done(function(response) {
  847. compnt.hideLoading();
  848. // console.log(response.resultCode)
  849. switch (response.resultCode) {
  850. case "0000": //订购成功!跳转到领取会员页面
  851. unicom.saveUserInfo();
  852. showAlerak('领取结果以短信为准!');
  853. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_success' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  854. return;
  855. case "1102":
  856. //showAlertDialog('orderFailure','该号码归属省分2/3G暂未开通此产品!');
  857. compnt.showAlert('用户已领取过权益,不能再领取!');
  858. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  859. break;
  860. case "1015":
  861. // showAlertDialog('orderFailure','错误代码(6611),' + '订购失败,请重试!');
  862. compnt.showAlert('用户未订购此产品!');
  863. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  864. break;
  865. // case "6615":
  866. // //showAlertDialog('orderFailure', '订购失败,请确定用户套餐!');
  867. // showAlerts('订购失败,请确定用户套餐!');
  868. // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  869. // break;
  870. // case "6622": // 用户已订购过此产品!跳转到流量查页面
  871. // // localStorage.setItem('message', '您已经订购了本产品~');
  872. // compnt.showAlert('您已经订购了本产品~');
  873. // unicom.saveUserInfo();
  874. // WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  875. // // showFlowPage();
  876. // break;
  877. default:
  878. //showAlertDialog('orderFailure', response.errorInfo + ',订购失败,请确定用户套餐!');
  879. showAlerts(response.errorInfo + ',订购失败,请确定用户套餐!');
  880. WoAnalytics.addPoint({ ad: $('#nanyanad').val(), ett: 'click', ea: 'order_failure' + $('#nanyanlabel').val(), ct: 'web', pm: parseInt(unicom.query.sou, 32) })
  881. break;
  882. }
  883. }).fail(function(error) {
  884. compnt.hideLoading();
  885. console.log(error);
  886. });
  887. }