index.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. import * as compnt from "../../../public/js/compnt";
  2. import * as unicom from "../../../public/js/unicom.js";
  3. import * as weibo from "./weibo.js";
  4. weibo.checkClientEnvironment();
  5. compnt.showLoading();
  6. var message = localStorage.getItem('message');
  7. if (message != null && message != '') {
  8. compnt.showAlert(message);
  9. localStorage.removeItem('message');
  10. }
  11. if (weibo.app.weibo) {
  12. function bridgeReady() {
  13. if (weibo.checkWeiboVersion()) {
  14. weibo.getUserInfo().then(function() {
  15. init();
  16. }).fail(function(data) {
  17. init();
  18. });
  19. } else {
  20. weibo.getUserInfo();
  21. init();
  22. }
  23. }
  24. if (window.WeiboJSBridge) {
  25. bridgeReady();
  26. } else {
  27. document.addEventListener('WeiboJSBridgeReady', function () {
  28. bridgeReady();
  29. });
  30. }
  31. } else {
  32. init();
  33. }
  34. function init() {
  35. unicom.init().then(function(response) {
  36. unicom.product = response.product[0];
  37. unicom.fesname = response.festival;
  38. loadUserInfo();
  39. // compnt.showAlert(JSON.stringify(unicom.user))
  40. // compnt.showAlert(weibo.uid)
  41. if (location.href.indexOf("index.html") >= 0) {
  42. if (unicom.user.userid) {
  43. openPage("flow");
  44. } else if (weibo.uid) {
  45. unicom.queryMember(null, null, weibo.uid).then(function(response) {
  46. // compnt.showAlert("queryMember:" + JSON.stringify(response.data))
  47. if (response.resultCode != "0000") {
  48. showOrderPage();
  49. compnt.hideLoading();
  50. return;
  51. }
  52. unicom.user.userid = response.userid;
  53. unicom.user.usermob = response.usermob;
  54. unicom.user.usertime = new Date().getTime();
  55. showFlowPage(response);
  56. compnt.hideLoading();
  57. }).fail(function() {
  58. compnt.showAlert("asdasd");
  59. });
  60. }
  61. compnt.hideLoading();
  62. showOrderPage();
  63. } else {
  64. openPage(unicom.query.page);
  65. compnt.hideLoading();
  66. }
  67. /*unicom.user.userid = "18674842761";
  68. unicom.user.usermob = '17610768237'
  69. showFlowPage();*/
  70. if (location.href.indexOf('/cancel') >= 0) {
  71. unicom.burypointLogId('110002');// 退订页面pv, pv去重得到uv
  72. } else if (location.href.indexOf('/draw') >= 0) {
  73. unicom.burypointLogId('110003');// 领取页面pv, pv去重得到uv
  74. } else if (location.href.indexOf('/flow') >= 0) {
  75. unicom.burypointLogId('110004');// 流量查询pv, pv去重得到uv
  76. } else if (location.href.indexOf('/active') >= 0) {
  77. unicom.burypointLogId('110005');// 激活页面pv, pv去重得到uv
  78. } else if (location.href.indexOf('/refund') >= 0) {
  79. unicom.burypointLogId('110006');// 退款
  80. } else {
  81. // location.href.indexOf('/index') >= 0
  82. // location.href.indexOf('/order') >= 0
  83. unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv
  84. }
  85. }).fail(function() {
  86. compnt.hideLoading();
  87. })
  88. }
  89. function openPage(pageName) {
  90. switch (pageName) {
  91. case "active":
  92. showActivePage();
  93. break;
  94. case "cancel":
  95. showCancelPage();
  96. break;
  97. case "draw":
  98. if (weibo.uid == null || weibo.uid == '') {
  99. weibo.getUserInfo().then(function(response) {
  100. showDrawPage();
  101. })
  102. } else {
  103. showDrawPage();
  104. }
  105. break;
  106. case "flow":
  107. showFlowPage();
  108. break;
  109. default:
  110. showOrderPage();
  111. break;
  112. }
  113. }
  114. function loadUserInfo() {
  115. if (unicom.query.userid) {
  116. unicom.user.userid = unicom.query.userid;
  117. unicom.user.usermob = unicom.query.usermob;
  118. return;
  119. }
  120. try {
  121. var time = localStorage.getItem('time');
  122. if (time) {
  123. var curr = new Date().getTime();
  124. if (curr <= parseFloat(time) + (1000 * 60 * 60)) {
  125. var userString = localStorage.getItem("user");
  126. var user = JSON.parse(userString);
  127. unicom.user.userid = user.userid;
  128. unicom.user.usermob = user.usermob;
  129. if (unicom.user.usermob == "18674842761") {
  130. setTimeout(function() {
  131. alert(time + (1000 * 60 * 60))
  132. }, 100);
  133. }
  134. } else {
  135. localStorage.removeItem("time")
  136. localStorage.removeItem("user")
  137. }
  138. }
  139. } catch (e) {
  140. }
  141. }
  142. $('#btn-cancel').unbind('click').on('click', function () {
  143. showCancelPage();
  144. })
  145. $('#btn-draw').unbind('click').on('click', function () {
  146. if (!checkEquip('draw')) return;
  147. showDrawPage();
  148. })
  149. $('#btn-active').unbind('click').on('click', function () {
  150. if (!checkEquip('active')) return;
  151. showActivePage();
  152. })
  153. /**
  154. * 显示流量查询页面
  155. */
  156. function showFlowPage() {
  157. if (location.href.indexOf("flow.html") < 0) {
  158. window.location.href = "flow.html?fes="
  159. + unicom.query.fes + "&sou=" + unicom.query.sou + "&F=" + unicom.query.F
  160. + "&userid=" + unicom.user.userid + "&usermob=" + unicom.user.usermob
  161. + "&usertime=" + (unicom.user.usertime||(new Date().getTime())) + "&page=flow";
  162. return;
  163. }
  164. if (localStorage.getItem('action') == 'draw') {
  165. if (!checkEquip('draw')) return;
  166. unicom.can(weibo.uid).then(function(response) {
  167. if (response.resultCode == "0000") {
  168. draw();
  169. }
  170. });
  171. localStorage.removeItem('action');
  172. }
  173. var $container = $('#section-flow');
  174. $container.find('.phone').html('免流号码:' + unicom.user.usermob);
  175. queryFlow();
  176. $container.find('.btn').unbind('click').on('click', function (event) {
  177. if (!compnt.lockClick()) {
  178. return;
  179. }
  180. queryFlow().then(function(message) {
  181. compnt.unlockClick()
  182. if (message != null && message != "") {
  183. compnt.showAlert(message);
  184. }
  185. });
  186. })
  187. $container.find('.member a').unbind('click').on('click', function () {
  188. if (!checkEquip('draw')) return;
  189. // alert(weibo.screen_name)
  190. // 如果有用户号码,直接打开领取会员二次确认的提示
  191. unicom.can(weibo.uid).then(function(response) {
  192. switch (response.resultCode) {
  193. case "0000":
  194. if (unicom.user.userid) {
  195. draw();
  196. } else {
  197. showDrawPage();
  198. }
  199. break;
  200. case "1003":
  201. compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
  202. break;
  203. default:
  204. compnt.showAlert(response.resultInfo);
  205. break;
  206. }
  207. });
  208. })
  209. if (weibo.app.weibo && weibo.checkWeiboVersion() && (weibo.uid == null || weibo.uid == '')) {
  210. weibo.getUserInfo().then(function() {
  211. unicom.queryMember().then(function(response) {
  212. showMemberInfo(response)
  213. });
  214. })
  215. } else {
  216. unicom.queryMember().then(function(response) {
  217. showMemberInfo(response)
  218. });
  219. }
  220. function showMemberInfo(response) {
  221. // alert("showMemberInfo:" + JSON.stringify(response.data))
  222. switch (response.resultCode) {
  223. case "0000":
  224. switch (response.sync_code) {
  225. case "0": // 订购关系退订同步成功
  226. case "2": // 订购关系订购同步成功
  227. if (response.screen_name) {
  228. $container.find('.member').html('微博账号:' + response.screen_name);
  229. } else {
  230. $container.find('.member').html('微博会员:已领取');
  231. }
  232. $container.find('.vflag').css({"display": "block"});
  233. $container.find('.member a').unbind('click');
  234. weibo.active(); // 静默激活
  235. break;
  236. default:
  237. $container.find('.member a').html('请点此领取微博会员');
  238. // 隐藏微博会员图标
  239. $container.find('.vflag').css({"display": "none"})
  240. break;
  241. }
  242. break;
  243. case "1015": //{"resultCode":"1015","errorInfo":"用户未订购此产品!"}
  244. compnt.showAlert("未订购此产品!").then(function(message) {
  245. localStorage.removeItem('time');
  246. localStorage.removeItem('user')
  247. showOrderPage();
  248. $container.find('.phone').html('用户未订购此产品!');
  249. });
  250. break;
  251. default:
  252. break;
  253. }
  254. }
  255. }
  256. /**
  257. * 查询用户剩余流量
  258. */
  259. function queryFlow() {
  260. var $container = $('#section-flow');
  261. var def = $.Deferred();
  262. unicom.queryFlow().then(function(response) {
  263. // console.log("流量剩余情况:" + response.data)
  264. switch (response.resultCode) {
  265. case "0000":
  266. //compnt.showAlert(JSON.stringify(response.data));
  267. var surplus = compnt.returnFloat(response.data.surplusFlow/1024/1024);
  268. $container.find('.suplus').html('本月剩余<br>' + surplus + 'GB');
  269. var usedFlowKb = parseInt(response.data.usedFlow);
  270. if (usedFlowKb > 0 && usedFlowKb < 1024) {
  271. def.resolve("剩余流量更新成功,为您免流了" + usedFlowKb + "KB~");
  272. } else if (usedFlowKb > 1024) {
  273. var useedFlow = compnt.returnFloat(usedFlowKb/1024);
  274. def.resolve("剩余流量更新成功,为您免流了" + useedFlow + "MB~");
  275. } else {
  276. def.resolve("剩余流量更新成功~");
  277. }
  278. break;
  279. case "9201": //{"resultCode":"9201","errorInfo":"查询失败,请检查是否有订购关系!"}
  280. def.resolve("您未订购新浪微博畅想会员畅想包~")
  281. $container.find('.phone').html('用户未订购此产品!');
  282. break;
  283. case "9203": //{"resultCode":"9203","errorInfo":"流量查询失败,没有获取到用户所使用流量信息!"}
  284. //compnt.showAlert("没有获取到用户所使用流量信息!");
  285. def.resolve("剩余流量更新成功~")
  286. $container.find('.suplus').html('本月剩余<br>10.00GB');
  287. break;
  288. default:
  289. break;
  290. }
  291. })
  292. return def;
  293. }
  294. /**
  295. * 打开退订页面
  296. */
  297. function showCancelPage() {
  298. if (location.href.indexOf("cancel.html") < 0) {
  299. window.location.href = "cancel.html?fes=" + unicom.query.fes + "&sou="
  300. + unicom.query.sou + "&F=" + unicom.query.F + '&page=cancel';
  301. return;
  302. }
  303. var $container = $('#section-cancel').find('.form-group');
  304. $container.find('.sendcode').unbind('click').on('click', function () {
  305. unicom.sendSms($container, 'cancellogin');
  306. })
  307. $container.find('.login').unbind('click').on('click', function () {
  308. compnt.showLoading();
  309. unicom.checkCode($container).then(function() {
  310. unicom.cancel().then(function(response) {
  311. compnt.hideLoading();
  312. switch (response.resultCode) {
  313. case "0000":
  314. compnt.showAlert('退订成功').then(function(message) {
  315. showFlowPage();
  316. });
  317. break;
  318. case "7605": //应该是已经退订了吧,因此不需要在重复退订啦
  319. compnt.showAlert(response.errorInfo).then(function(message) {
  320. showFlowPage();
  321. });
  322. break;
  323. default:
  324. var prefix = '';
  325. if (response.errorInfo.indexOf('退订失败') < 0) {
  326. prefix = '退订失败,';
  327. }
  328. compnt.showAlert(prefix + response.errorInfo);
  329. break;
  330. }
  331. }).fail(function(data) {
  332. compnt.hideLoading();
  333. })
  334. }).fail(function(data) {
  335. compnt.hideLoading();
  336. })
  337. })
  338. window.scrollTo(0, 0)
  339. }
  340. /**
  341. * 打开领取会员的页面
  342. * 在客户端中才能领取会员
  343. */
  344. function showDrawPage() {
  345. if (location.href.indexOf("draw.html") < 0) {
  346. window.location.href = "draw.html?fes=" + unicom.query.fes + "&sou="
  347. + unicom.query.sou + "&F=" + unicom.query.F + '&page=draw';
  348. return;
  349. }
  350. var $container = $('#section-draw').find('.form-group');
  351. compnt.showLoading();
  352. unicom.queryMember(null, null, weibo.uid).then(function(response) {
  353. // alert("response.data:" + JSON.stringify(response.data))
  354. if (response.resultCode == "0000") {
  355. switch (response.sync_code) {
  356. case "0": // 订购关系退订同步成功
  357. case "2": // 订购关系订购同步成功
  358. localStorage.setItem("message", "当前微博账号已经领取了会员~");
  359. unicom.user.userid = response.userid;
  360. unicom.user.usermob = response.usermob;
  361. unicom.user.usertime = new Date().getTime();
  362. showFlowPage();
  363. break;
  364. }
  365. } else {
  366. unicom.can(weibo.uid).then(function(response) {
  367. compnt.hideLoading();
  368. var hasMonthVip = false;
  369. switch (response.resultCode) {
  370. case "0000":
  371. hasMonthVip = false;
  372. break;
  373. case "1003":
  374. compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
  375. hasMonthVip = true;
  376. break;
  377. default:
  378. compnt.showAlert(response.resultInfo);
  379. break;
  380. }
  381. $container.find('.sendcode').unbind('click').on('click', function () {
  382. if (!checkEquip()) return;
  383. if (hasMonthVip) {
  384. compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
  385. return;
  386. }
  387. unicom.sendSms($container, 'drawlogin');
  388. })
  389. $container.find('.login').unbind('click').on('click', function () {
  390. if (hasMonthVip) {
  391. compnt.showAlert('当前微博账号已开通了新浪微博包月会员,请切换领取会员的账号~');
  392. return;
  393. }
  394. unicom.checkCode($container).then(function() {
  395. draw()
  396. })
  397. })
  398. })
  399. }
  400. })
  401. }
  402. function draw() {
  403. var $dialog = showConfirmDialog();
  404. $dialog.find('.btn-no').on('click', function() {
  405. compnt.showAlert('请切换登录的微博账号后,再领取会员')
  406. })
  407. $dialog.find('.btn-ok').on('click', function(event) {
  408. if (!compnt.lockClick()) return;
  409. unicom.drawMember(weibo.uid, weibo.screen_name).then(function(response) {
  410. compnt.unlockClick();
  411. switch (response.resultCode) {
  412. case "0000":
  413. weibo.active(); // 领取成功,静默激活
  414. compnt.showAlert('微博会员领取成功!').then(function() {
  415. showFlowPage();
  416. });
  417. break;
  418. case "1020":
  419. // 已经领取,领取的账号与当前微博账号一致,静默激活
  420. unicom.queryMember().then(function(response) {
  421. if (response.resultCode == "0000") {
  422. if (response.uid == weibo.uid) {
  423. weibo.active();
  424. compnt.showAlert('已领取过会员~').then(function(message) {
  425. showFlowPage();
  426. });
  427. } else {// 领取到了其他微博账号
  428. compnt.showAlert('该手机号已将会员领取到其他微博账号~')
  429. }
  430. } else {// 查询失败
  431. compnt.showAlert('已领取过会员~');
  432. }
  433. }).fail(function() {
  434. // 查询失败
  435. compnt.showAlert('已领取过会员~');
  436. })
  437. break;
  438. default:
  439. compnt.showAlert('领取失败,' + response.errorInfo);
  440. break;
  441. }
  442. }).fail (function() {
  443. compnt.unlockClick();
  444. });
  445. })
  446. }
  447. /**
  448. * 打开激活免流的页面
  449. * 客户端中才能激活
  450. */
  451. function showActivePage() {
  452. if (location.href.indexOf("active.html") < 0) {
  453. window.location.href = "active.html?fes=" + unicom.query.fes + "&sou="
  454. + unicom.query.sou + "&F=" + unicom.query.F + "&page=active";
  455. return;
  456. }
  457. var $container = $('#section-active').find('.form-group');
  458. $container.find('.sendcode').unbind('click').on('click', function () {
  459. if (!checkEquip('active')) return;
  460. unicom.sendSms($container, 'activelogin');
  461. })
  462. $container.find('.login').unbind('click').on('click', function (event) {
  463. if (!checkEquip('active')) return;
  464. if (!compnt.lockClick()) {
  465. return;
  466. }
  467. unicom.checkCode($container).then(function() {
  468. compnt.unlockClick()
  469. active()
  470. }).fail(function() {
  471. compnt.unlockClick();
  472. });
  473. })
  474. window.scrollTo(0, 0)
  475. }
  476. function checkEquip(action) {
  477. if (action == 'active') {
  478. if (!weibo.app.weibo) {
  479. compnt.showAlert('请到新浪微博客户端中激活免流~')
  480. return false;
  481. }
  482. if (!weibo.checkWeiboVersion()) {
  483. compnt.showAlert('请到升级到最新版新浪微博客户端后激活免流~')
  484. return false;
  485. }
  486. } else {
  487. if (!weibo.app.weibo) {
  488. compnt.showAlert('请到新浪微博客户端中领取会员激活免流~')
  489. return false;
  490. }
  491. if (!weibo.checkWeiboVersion()) {
  492. compnt.showAlert('请到升级到最新版新浪微博客户端后领取会员激活免流~')
  493. return false;
  494. }
  495. }
  496. return true;
  497. }
  498. function active() {
  499. unicom.queryMember().then(function(response) {
  500. switch (response.resultCode) {
  501. case "0000":
  502. break;
  503. case "0002":
  504. compnt.showAlert('激活失败,未领取新浪微博会员~');
  505. return;
  506. default:
  507. compnt.showAlert('激活失败,未领取新浪微博会员~');
  508. return;
  509. }
  510. if (weibo.uid != response.uid) {
  511. compnt.showAlert('激活失败,激活免流的微博账号与领取会员的微博账号不一致~');
  512. return;
  513. }
  514. switch (response.sync_code) {
  515. case "0": // 订购关系退订同步成功
  516. case "2": // 订购关系订购同步成功
  517. weibo.active().then(function() {
  518. //checkActiveResult();
  519. compnt.showAlert('激活成功').then(function() {
  520. localStorage.setItem('user', JSON.stringify(unicom.user));
  521. localStorage.setItem('time', new Date().getTime());
  522. showFlowPage();
  523. });
  524. })
  525. break;
  526. case "1": // 订购关系退订同步失败
  527. case "3": // 订购关系订购同步失败
  528. compnt.showAlert("请领取会员以后再进行激活操作~");
  529. break;
  530. }
  531. });
  532. }
  533. /**
  534. * 打开订购页面
  535. */
  536. function showOrderPage() {
  537. $('.section-banner').removeClass('section-banner-small');
  538. $('#btn-order').unbind('click').on('click', function (event) {
  539. if (!compnt.lockClick()) {
  540. //alert(1)
  541. return;
  542. }
  543. unicom.showCapPage().then(function (data) {
  544. compnt.unlockClick();
  545. order(data.userid, data.token, data.usermob);
  546. }).fail(function(response) {
  547. compnt.unlockClick();
  548. })
  549. })
  550. }
  551. /**
  552. * 订购
  553. */
  554. function order(userid, token, usermob) {
  555. unicom.order(userid, token, usermob).then(function(response) {
  556. // console.log(response)
  557. switch (response.resultCode) {
  558. case "0000": //订购成功!跳转到领取会员页面
  559. // compnt.showAlert('unicom.user.userid:' + unicom.user.userid)
  560. // var versionFulfil = weibo.checkWeiboVersion();
  561. // alert('checkWeiboVersion()' + versionFulfil);
  562. localStorage.setItem('user', JSON.stringify(unicom.user));
  563. localStorage.setItem('time', new Date().getTime());
  564. // 客户端中进入领取页面,非客户端中,提示用户到客户端中去领取
  565. if (weibo.app.weibo && weibo.checkWeiboVersion()) {
  566. // 如果有用户号码,直接打开领取会员二次确认的提示
  567. compnt.showAlert('订购成功~').then(function(message) {
  568. localStorage.setItem('action', 'draw');
  569. showFlowPage();
  570. })
  571. } else {
  572. compnt.showAlert('订购成功,请到新浪微博客户端中领取会员开启免流~').then(function() {
  573. showFlowPage();
  574. })
  575. return;
  576. }
  577. break;
  578. case "0013":
  579. showOrderDialog('该号码归属省分2/3G暂未开通此产品!');
  580. break;
  581. case "6611":
  582. showOrderDialog('错误代码(6611),' + '订购失败,请重试!');
  583. break;
  584. case "6615":
  585. showOrderDialog('订购失败,请确定用户套餐!');
  586. break;
  587. case "6622": // 用户已订购过此产品!跳转到流量查页面
  588. localStorage.setItem('message', '您已经订购了本产品~');
  589. localStorage.setItem('user', JSON.stringify(unicom.user));
  590. localStorage.setItem('time', new Date().getTime());
  591. showFlowPage();
  592. break;
  593. default:
  594. showOrderDialog(response.errorInfo + ',订购失败,请确定用户套餐!');
  595. break;
  596. }
  597. }).fail(function (error) {
  598. console.log(error);
  599. });
  600. }
  601. function showOrderDialog(message) {
  602. var $overlay = $('<div class="overlay"></div>');
  603. var $dialog = $(
  604. '<div class="dialog dialog-order">' +
  605. ' <div class="face">' +
  606. ' <img src="images/face-sad.png">' +
  607. ' </div>' +
  608. ' <h2>对不起,订购失败!</h2>' +
  609. ' <p>' + message + '</p>' +
  610. ' <div class="btn">我知道了</div>' +
  611. '</div>');
  612. $overlay.appendTo($(document.body))
  613. $dialog.appendTo($(document.body))
  614. $dialog.find('.btn').unbind('click').on('click', function () {
  615. $dialog.close()
  616. })
  617. $dialog.close = function () {
  618. $overlay.remove();
  619. $dialog.remove();
  620. $dialog = null;
  621. }
  622. return $dialog;
  623. }
  624. function showConfirmDialog() {
  625. var message = '确认将新浪微博会员领取到您当前登录的账号中吗?';
  626. if (weibo.screen_name) {
  627. message = '请确认将新浪微博会员领取到账号:' + weibo.screen_name
  628. }
  629. var $overlay = $('<div class="overlay"></div>');
  630. var $dialog = $(
  631. '<div class="dialog dialog-confirm">' +
  632. ' <h2>领取会员</h2>' +
  633. ' <p>' + message + '</p>' +
  634. ' <div class="actions" style="display: flex;">' +
  635. ' <div class="btn btn-no">其他账号</div>' +
  636. ' <div class="btn btn-ok">确认</div>' +
  637. ' </div>' +
  638. '</div>');
  639. $overlay.appendTo($(document.body))
  640. $dialog.appendTo($(document.body))
  641. $dialog.find('.btn').on('click', function () {
  642. $dialog.close()
  643. })
  644. $dialog.close = function () {
  645. $overlay.remove();
  646. $dialog.remove();
  647. $dialog = null;
  648. }
  649. return $dialog;
  650. }