invite.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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" 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. stopManyClick(() => {
  149. //加载数据
  150. var href = window.location.href;
  151. var copyBefore = JSON.stringify(href);
  152. var copyUrl = copyBefore.split('"');
  153. console.log(copyUrl[1])
  154. $('#inviteCopy').val(copyUrl[1]);
  155. var input = document.getElementById("inviteCopy");
  156. // 选中文本
  157. input.select();
  158. // 执行浏览器复制命令
  159. document.execCommand("copy");
  160. toastr.error('复制成功当前网址成功!')
  161. })
  162. } else if (isiOS) {
  163. $.ajax({
  164. url: baseUrl + '/api/user/v1/promote',
  165. type: 'get',
  166. headers: {
  167. 'Authorization': id //id
  168. },
  169. contentType: "application/json",
  170. dataType: 'json',
  171. cache: false,
  172. success: function (res) {
  173. var jsonStr = JSON.stringify(res.data)
  174. var jsonObj = JSON.parse(jsonStr)
  175. // WKWebView使用
  176. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  177. try {
  178. getMessage(jsonObj);
  179. } catch (error) {
  180. console.log(error)
  181. }
  182. try {
  183. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  184. } catch (error) {
  185. console.log(error)
  186. }
  187. }
  188. })
  189. } else if (isAndroid) {
  190. window.native.onClikWebView()
  191. }
  192. },false);
  193. //点击选择框
  194. $('.login-row-select')[0].addEventListener('click',()=>{
  195. $('.options')[0].className = 'options show';
  196. },false);
  197. //点击多多云
  198. $('.icon-down-first')[0].addEventListener('click',()=>{
  199. $('.options')[0].className = 'options';
  200. $('#select').val('多多云');
  201. fromType = 1;
  202. },false);
  203. //点击红手指
  204. $('.icon-down-second')[0].addEventListener('click',()=>{
  205. $('.options')[0].className = 'options';
  206. $('#select').val('红手指');
  207. fromType = 2;
  208. },false);
  209. //点击协议
  210. $('.read-rule')[0].addEventListener('click',()=>{
  211. if(isShow){
  212. $('.selected')[0].className = 'selected hidden';
  213. $('.no-selected')[0].className = 'no-selected show';
  214. }else{
  215. $('.no-selected')[0].className = 'no-selected hidden';
  216. $('.selected')[0].className = 'selected show';
  217. }
  218. isShow = !isShow;
  219. },false);
  220. //点击提示弹窗确定
  221. $('.sure-btn')[0].addEventListener('click',handleClose,false);
  222. $('.sure-text')[0].addEventListener('click',handleClose,false);
  223. function handleClose() {
  224. $('.tip').animate({top: '-6.96rem'},"fast");
  225. $('.mask').hide();
  226. document.documentElement.style.overflow='auto';
  227. }
  228. //点击立即注册
  229. $('.register-text')[0].addEventListener('click',registerHandle,false);
  230. $('.register-btn')[0].addEventListener('click',registerHandle,false);
  231. function registerHandle(){
  232. $('.dialog').animate({top: '-6.96rem'},"fast");
  233. $('.mask').hide();
  234. document.documentElement.style.overflow='auto';
  235. $('#select').val('');
  236. $('#account').val('');
  237. window.location.href = 'http://www.androidscloud.com';
  238. }
  239. //点击免费换机按钮
  240. $('.login-btn-text')[0].addEventListener('click',changePhoneHandle,false);
  241. $('.login-btn')[0].addEventListener('click',changePhoneHandle,false);
  242. function changePhoneHandle(){
  243. account = $('#account').val();
  244. password = $('#password').val();
  245. if(fromType === 0){
  246. $('#tip-text').text('请选择兑换时长的平台');
  247. $('.tip').animate({top: '7.27rem'},"fast");
  248. $('.mask').show();
  249. $('.dialog').hide();
  250. document.documentElement.style.overflow='hidden';
  251. return
  252. }
  253. if(account === ''){
  254. $('#tip-text').text('请输入兑换时长的账号');
  255. $('.tip').animate({top: '7.27rem'},"fast");
  256. $('.mask').show();
  257. $('.dialog').hide();
  258. document.documentElement.style.overflow='hidden';
  259. return
  260. }
  261. if(password === ''){
  262. $('#tip-text').text('请输入兑换时长的密码');
  263. $('.tip').animate({top: '7.27rem'},"fast");
  264. $('.mask').show();
  265. $('.dialog').hide();
  266. document.documentElement.style.overflow='hidden';
  267. return
  268. }
  269. if(!isShow){
  270. $('#tip-text').text('请勾选阅读规则按钮');
  271. $('.tip').animate({top: '7.27rem'},"fast");
  272. $('.mask').show();
  273. document.documentElement.style.overflow='hidden';
  274. return
  275. }
  276. operate('dt_yhs_点击免费换机按钮','click');
  277. }
  278. //调用免费换机接口
  279. function changePhone(){
  280. let data = {
  281. inviteTime: new Date().Format("yyyy-MM-dd hh:mm:ss"),
  282. type: fromType,
  283. account: account,
  284. password: password
  285. }
  286. if(!id){
  287. delete data.inviteTime
  288. }
  289. let ajaxObj = {
  290. url: baseUrl + '/api/public/v1/activity/change/phone',
  291. type: 'post',
  292. headers: {
  293. 'Authorization': id //id
  294. },
  295. data:JSON.stringify(data),
  296. contentType: "application/json",
  297. dataType: 'json',
  298. cache: false,
  299. success: function (res) {
  300. if(res.status === 0){
  301. $('.dialog').animate({top: '4.2rem'},"fast");
  302. $('.mask').show();
  303. $('.tip').hide();
  304. document.documentElement.style.overflow='hidden';
  305. }else{
  306. $('#tip-text').text(res.msg);
  307. $('.tip').animate({top: '7.27rem'},"fast");
  308. $('.mask').show();
  309. $('.dialog').hide();
  310. document.documentElement.style.overflow='hidden';
  311. }
  312. }
  313. }
  314. if(!id){
  315. delete ajaxObj.headers
  316. }
  317. $.ajax(ajaxObj)
  318. }
  319. //防止提示一秒内重复显示
  320. function stopManyClick(fn) {
  321. if (flag) {
  322. fn();
  323. }
  324. flag = false;
  325. if(timer){clearTimeout(timer);}
  326. timer = setTimeout(() => {flag = true}, 1500);
  327. }
  328. Date.prototype.Format = function (fmt) { // author: meizz
  329. var o = {
  330. "M+": this.getMonth() + 1, // 月份
  331. "d+": this.getDate(), // 日
  332. "h+": this.getHours(), // 小时
  333. "m+": this.getMinutes(), // 分
  334. "s+": this.getSeconds(), // 秒
  335. "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  336. "S": this.getMilliseconds() // 毫秒
  337. };
  338. if (/(y+)/.test(fmt))
  339. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  340. for (var k in o)
  341. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  342. return fmt;
  343. }
  344. </script>
  345. </body>
  346. </html>