main.js 39 KB

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