invite.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  6. <title>免费换机</title>
  7. <link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
  8. <link rel="stylesheet" href="../static/js/vender/toastr/toastr.min.css">
  9. <link rel="stylesheet" href="../static/css/changePhoneActivity.css">
  10. <script src="../static/js/vender/jquery-3.4.1.min.js"></script>
  11. <script src="../static/js/vender/toastr/toastr.min.js"></script>
  12. <script src="../static/js/vender/config.js"></script>
  13. </head>
  14. <body>
  15. <div class="container">
  16. <div class="header">
  17. <img class="bg_img" src="../static/img/changePhoneActivity/bg.png" />
  18. <div class="share-node"><img class="share" src="../static/img/changePhoneActivity/share.png" /></div>
  19. <img class="logo" src="../static/img/changePhoneActivity/logo.png" />
  20. <img class="theme" src="../static/img/changePhoneActivity/theme.png" />
  21. <img class="activity-bg" src="../static/img/changePhoneActivity/activity-bg.png" />
  22. <img class="time" src="../static/img/changePhoneActivity/time.png" />
  23. <div class="login-container">
  24. <img class="login-bg" src="../static/img/changePhoneActivity/login-bg.png" />
  25. <div class="login-row-select">
  26. <div class="login-row-title">选择:</div>
  27. <input class="login-row-ipt" id="select" placeholder="请选择兑换时长的平台" disabled="true" />
  28. <img class="icon-down-img" src="../static/img/changePhoneActivity/icon-down.png" />
  29. </div>
  30. <div class="options">
  31. <div class="icon-down-first">
  32. <span class="first-text">多多云</span>
  33. </div>
  34. <div class="icon-down-second">
  35. <span class="second-text">红手指</span>
  36. </div>
  37. </div>
  38. <div class="login-row-account">
  39. <div class="login-row-title">账号:</div>
  40. <input class="login-row-ipt" id="account" placeholder="请输入兑换时长的账号" />
  41. </div>
  42. <div class="login-row-password">
  43. <div class="login-row-title">密码:</div>
  44. <input class="login-row-ipt" type="password" id="password" placeholder="请输入兑换时长的密码" />
  45. </div>
  46. <img class="login-btn" src="../static/img/changePhoneActivity/login-btn.png" />
  47. <img class="login-btn-text" src="../static/img/changePhoneActivity/login-btn-text.png" />
  48. </div>
  49. <div class="read-rule">
  50. <img class="selected" src="../static/img/changePhoneActivity/selected.png" />
  51. <img class="no-selected" src="../static/img/changePhoneActivity/no-selected.png" />
  52. <img class="rule-text" src="../static/img/changePhoneActivity/rule-text.png" />
  53. </div>
  54. <div class="entry-QQ">
  55. <img class="entry-QQ-btn" src="../static/img/changePhoneActivity/entry-QQ-btn.png" />
  56. </div>
  57. </div>
  58. <div class="middle">
  59. <img class="middle_bg_img" src="../static/img/changePhoneActivity/middle_bg_img.png" />
  60. <div class="activity-rule">
  61. <img class="activity-rule-btn" src="../static/img/changePhoneActivity/activity-rule-btn.png" />
  62. <img class="activity-rule-text" src="../static/img/changePhoneActivity/activity-rule-text.png" />
  63. </div>
  64. </div>
  65. <div class="footer">
  66. <img class="footer_bg_img" src="../static/img/changePhoneActivity/footer_bg_img.png" />
  67. <img class="rule4" src="../static/img/changePhoneActivity/rule4.png" />
  68. </div>
  69. <div class="mask">
  70. <div class="dialog">
  71. <img class="dialog-bg" src="../static/img/changePhoneActivity/dialog.png" />
  72. <img class="title" src="../static/img/changePhoneActivity/title.png" />
  73. <img class="content" src="../static/img/changePhoneActivity/content.png" />
  74. <img class="register-btn" src="../static/img/changePhoneActivity/register-btn.png" />
  75. <img class="register-text" src="../static/img/changePhoneActivity/register-text.png" />
  76. </div>
  77. <div class="tip">
  78. <img class="tip-bg" src="../static/img/changePhoneActivity/tip-bg.png" />
  79. <div class="tip-title" id="tip-text"></div>
  80. <img class="sure-btn" src="../static/img/changePhoneActivity/sure-btn.png" />
  81. <img class="sure-text" src="../static/img/changePhoneActivity/sure-text.png" />
  82. </div>
  83. </div>
  84. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="inviteCopy" disabled="true" value="">
  85. </div>
  86. <script>
  87. toastr.options.positionClass = 'toast-center-center';
  88. toastr.options.timeOut = '1500';
  89. </script>
  90. <script type="text/javascript">
  91. let timer,flag = true;
  92. let isShow = true;
  93. let fromType = 0,
  94. account = '',
  95. password = '';
  96. var url = window.location.href;
  97. url = url.split('/')
  98. // var baseUrl = 'http://192.168.31.198'
  99. var loc = window.location.search,
  100. n1 = loc.length,//地址的总长度
  101. n2 = loc.indexOf("="),//取得=号的位置
  102. id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
  103. u = navigator.userAgent,
  104. ua = navigator.userAgent.toLowerCase(),
  105. isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  106. isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
  107. imgs = [[1,'../static/img/changePhoneActivity/rule1.png'],[2,'../static/img/changePhoneActivity/rule2.png'],[3,'../static/img/changePhoneActivity/rule3.png']];
  108. //埋点
  109. operate('dt_yhs_活动页面浏览');
  110. function operate(pointName,type){
  111. $.ajax({
  112. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  113. type: 'post',
  114. data:JSON.stringify({
  115. pointName: pointName
  116. }),
  117. contentType:"application/json",
  118. dataType: 'json',
  119. cache: false,
  120. success: function (res) {
  121. if(type === 'click'){
  122. changePhone();
  123. }
  124. },
  125. })
  126. }
  127. //异步加载图片
  128. async function loadAsync() {
  129. let promise = function(index,url) {
  130. return new Promise((resolve, reject) => {
  131. const image = new Image();
  132. image.src = url;
  133. image.className = 'rule'+index;
  134. image.onload = function() {
  135. $('.middle')[0].appendChild(image);
  136. resolve('ok');
  137. }
  138. })
  139. }
  140. for(let [index,url] of imgs) {
  141. await promise(index,url);
  142. }
  143. }
  144. loadAsync();
  145. //点击分享
  146. $('.share-node')[0].addEventListener('click',()=>{
  147. if(!id){
  148. copyUrl();
  149. } else if (isiOS) {
  150. if(!window.webkit){
  151. copyUrl();
  152. return
  153. }
  154. $.ajax({
  155. url: baseUrl + '/api/user/v1/promote',
  156. type: 'get',
  157. headers: {
  158. 'Authorization': id //id
  159. },
  160. contentType: "application/json",
  161. dataType: 'json',
  162. cache: false,
  163. success: function (res) {
  164. var jsonStr = JSON.stringify(res.data)
  165. var jsonObj = JSON.parse(jsonStr)
  166. // WKWebView使用
  167. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  168. try {
  169. getMessage(jsonObj);
  170. } catch (error) {
  171. console.log(error)
  172. }
  173. try {
  174. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  175. } catch (error) {
  176. console.log(error)
  177. }
  178. }
  179. })
  180. } else if (isAndroid) {
  181. if(window.native){
  182. window.native.onClikWebView()
  183. }else{
  184. copyUrl();
  185. }
  186. }
  187. },false);
  188. //复制
  189. function copyUrl(){
  190. stopManyClick(() => {
  191. //加载数据
  192. var href = window.location.href;
  193. var copyBefore = JSON.stringify(href);
  194. var copyUrl = copyBefore.split('"');
  195. console.log(copyUrl[1])
  196. $('#inviteCopy').val(copyUrl[1]);
  197. var input = document.getElementById("inviteCopy");
  198. // 选中文本
  199. input.select();
  200. // 执行浏览器复制命令
  201. document.execCommand("copy");
  202. toastr.error('复制当前网址成功!');
  203. $('#inviteCopy').blur();
  204. })
  205. }
  206. //点击选择框
  207. $('.login-row-select')[0].addEventListener('click',()=>{
  208. $('.options')[0].className = 'options show';
  209. },false);
  210. //点击多多云
  211. $('.icon-down-first')[0].addEventListener('click',()=>{
  212. $('.options')[0].className = 'options';
  213. $('#select').val('多多云');
  214. fromType = 1;
  215. },false);
  216. //点击红手指
  217. $('.icon-down-second')[0].addEventListener('click',()=>{
  218. $('.options')[0].className = 'options';
  219. $('#select').val('红手指');
  220. fromType = 2;
  221. },false);
  222. //点击协议
  223. $('.read-rule')[0].addEventListener('click',()=>{
  224. if(isShow){
  225. $('.selected')[0].className = 'selected hidden';
  226. }else{
  227. $('.selected')[0].className = 'selected show';
  228. }
  229. isShow = !isShow;
  230. },false);
  231. //点击提示弹窗确定
  232. $('.sure-btn')[0].addEventListener('click',handleClose,false);
  233. $('.sure-text')[0].addEventListener('click',handleClose,false);
  234. function handleClose() {
  235. $('.tip').animate({top: '-6.96rem'},"fast");
  236. $('.mask').hide();
  237. document.documentElement.style.overflow='auto';
  238. }
  239. //点击立即注册
  240. $('.register-text')[0].addEventListener('click',registerHandle,false);
  241. $('.register-btn')[0].addEventListener('click',registerHandle,false);
  242. function registerHandle(){
  243. $('.dialog').animate({top: '-6.96rem'},"fast");
  244. $('.mask').hide();
  245. document.documentElement.style.overflow='auto';
  246. $('#select').val('');
  247. $('#account').val('');
  248. $('#password').val('');
  249. window.location.href = 'http://www.androidscloud.com';
  250. }
  251. //点击免费换机按钮
  252. $('.login-btn-text')[0].addEventListener('click',changePhoneHandle,false);
  253. $('.login-btn')[0].addEventListener('click',changePhoneHandle,false);
  254. function changePhoneHandle(){
  255. account = $('#account').val();
  256. password = $('#password').val();
  257. if(fromType === 0){
  258. $('#tip-text').text('请选择兑换时长的平台');
  259. $('.tip').animate({top: '48vh'},"fast");
  260. $('.mask').show();
  261. $('.dialog').animate({top: '-6.96rem'},"fast");
  262. document.documentElement.style.overflow='hidden';
  263. return
  264. }
  265. if(account === ''){
  266. $('#tip-text').text('请输入兑换时长的账号');
  267. $('.tip').animate({top: '48vh'},"fast");
  268. $('.mask').show();
  269. $('.dialog').animate({top: '-6.96rem'},"fast");
  270. document.documentElement.style.overflow='hidden';
  271. return
  272. }
  273. if(password === ''){
  274. $('#tip-text').text('请输入兑换时长的密码');
  275. $('.tip').animate({top: '48vh'},"fast");
  276. $('.mask').show();
  277. $('.dialog').animate({top: '-6.96rem'},"fast");
  278. document.documentElement.style.overflow='hidden';
  279. return
  280. }
  281. if(!isShow){
  282. $('#tip-text').text('请勾选阅读规则按钮');
  283. $('.tip').animate({top: '48vh'},"fast");
  284. $('.mask').show();
  285. document.documentElement.style.overflow='hidden';
  286. return
  287. }
  288. operate('dt_yhs_点击免费换机按钮','click');
  289. }
  290. //调用免费换机接口
  291. function changePhone(){
  292. let data = {
  293. inviteTime: new Date().Format("yyyy-MM-dd hh:mm:ss"),
  294. type: fromType,
  295. account: account,
  296. password: password
  297. }
  298. if(!id){
  299. delete data.inviteTime
  300. }
  301. let ajaxObj = {
  302. url: baseUrl + '/api/public/v1/activity/change/phone',
  303. type: 'post',
  304. headers: {
  305. 'Authorization': id //id
  306. },
  307. data:JSON.stringify(data),
  308. contentType: "application/json",
  309. dataType: 'json',
  310. cache: false,
  311. success: function (res) {
  312. if(res.status === 0){
  313. $('.dialog').animate({top: '46vh'},"fast");
  314. $('.mask').show();
  315. $('.tip').animate({top: '-6.96rem'},"fast");
  316. document.documentElement.style.overflow='hidden';
  317. }else{
  318. $('#tip-text').text(res.msg);
  319. $('.tip').animate({top: '48vh'},"fast");
  320. $('.mask').show();
  321. $('.dialog').animate({top: '-6.96rem'},"fast");
  322. document.documentElement.style.overflow='hidden';
  323. }
  324. }
  325. }
  326. if(!id){
  327. delete ajaxObj.headers
  328. }
  329. $.ajax(ajaxObj)
  330. }
  331. //防止提示一秒内重复显示
  332. function stopManyClick(fn) {
  333. if (flag) {
  334. fn();
  335. }
  336. flag = false;
  337. if(timer){clearTimeout(timer);}
  338. timer = setTimeout(() => {flag = true}, 1500);
  339. }
  340. Date.prototype.Format = function (fmt) { // author: meizz
  341. var o = {
  342. "M+": this.getMonth() + 1, // 月份
  343. "d+": this.getDate(), // 日
  344. "h+": this.getHours(), // 小时
  345. "m+": this.getMinutes(), // 分
  346. "s+": this.getSeconds(), // 秒
  347. "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  348. "S": this.getMilliseconds() // 毫秒
  349. };
  350. if (/(y+)/.test(fmt))
  351. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  352. for (var k in o)
  353. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  354. return fmt;
  355. }
  356. </script>
  357. </body>
  358. </html>