replacementActivities.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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/replacementActivities.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="share-node">
  17. <img class="qq" src="../static/img/replacementActivities/qq.png" alt="">
  18. <div class="line"></div>
  19. <img class="cs" src="../static/img/replacementActivities/cs.png" alt="">
  20. </div>
  21. <div class="date">2022.1.4-2022.2.8</div>
  22. <div class="header">
  23. <div class="login-container">
  24. <div class="login-bar">仅限2000份</div>
  25. <div class="ipt"></div>
  26. <div class="input-container">
  27. <div class="login-row-select">
  28. <div class="login-row-title">选择</div>
  29. <input class="login-row-ipt" id="select" placeholder="请选择平台" disabled="true" />
  30. <img class="icon-down-img" src="../static/img/replacementActivities/arrow.png" />
  31. </div>
  32. <div class="options">
  33. <div class="icon-down-second">红手指</div>
  34. <div class="icon-down-first">多多云</div>
  35. <div class="icon-down-third">爱云兔</div>
  36. </div>
  37. <div class="login-row-account">
  38. <div class="login-row-title">账户</div>
  39. <input class="login-row-ipt" id="account" placeholder="请输入11位手机号码" />
  40. </div>
  41. <div class="tip-text1"></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. <div class="tip-text2"></div>
  47. <div class="form-btn"></div>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="mt55">
  52. <img class="w666h874" src="../static/img/replacementActivities/activityReward.png" alt="">
  53. </div>
  54. <div class="mt50">
  55. <img class="w670h476" src="../static/img/replacementActivities/inviteeReward.png" alt="">
  56. </div>
  57. <div class="mt50">
  58. <img class="w666h864" src="../static/img/replacementActivities/mattersNeedAttention.png" alt="">
  59. </div>
  60. </div>
  61. <script>
  62. toastr.options.positionClass = 'toast-center-center';
  63. toastr.options.timeOut = '1500';
  64. </script>
  65. <script type="text/javascript">
  66. Date.prototype.Format = function (fmt) { // author: meizz
  67. var o = {
  68. "M+": this.getMonth() + 1, // 月份
  69. "d+": this.getDate(), // 日
  70. "h+": this.getHours(), // 小时
  71. "m+": this.getMinutes(), // 分
  72. "s+": this.getSeconds(), // 秒
  73. "q+": Math.floor((this.getMonth() + 3) / 3), // 季度
  74. "S": this.getMilliseconds() // 毫秒
  75. };
  76. if (/(y+)/.test(fmt))
  77. fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
  78. for (var k in o)
  79. if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  80. return fmt;
  81. }
  82. let timer, flag = true;
  83. let isShow = true;
  84. let entryPageTime = new Date().Format("yyyy-MM-dd hh:mm:ss");
  85. let fromType = 0,
  86. account = '',
  87. password = '';
  88. var url = window.location.href;
  89. url = url.split('/')
  90. var loc = window.location.search,
  91. n1 = loc.length,//地址的总长度
  92. n2 = loc.indexOf("="),//取得=号的位置
  93. id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
  94. u = navigator.userAgent,
  95. ua = navigator.userAgent.toLowerCase(),
  96. isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  97. isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
  98. imgs = [[1, '../static/img/changePhoneActivity/rule1.png'], [6, '../static/img/changePhoneActivity/rule6.png'], [2, '../static/img/changePhoneActivity/rule2.png'], [3, '../static/img/changePhoneActivity/rule3.png']];
  99. //埋点
  100. // operate('dt_yhs_活动页面浏览');
  101. function operate(pointName, type) {
  102. $.ajax({
  103. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  104. type: 'post',
  105. data: JSON.stringify({
  106. pointName: pointName
  107. }),
  108. contentType: "application/json",
  109. dataType: 'json',
  110. cache: false,
  111. success: function (res) {
  112. if (type === 'click') {
  113. changePhone();
  114. }
  115. },
  116. })
  117. }
  118. //异步加载图片
  119. async function loadAsync() {
  120. let promise = function (index, url) {
  121. return new Promise((resolve, reject) => {
  122. const image = new Image();
  123. image.src = url;
  124. image.className = 'rule' + index;
  125. image.onload = function () {
  126. $('.middle')[0].appendChild(image);
  127. resolve('ok');
  128. }
  129. })
  130. }
  131. for (let [index, url] of imgs) {
  132. await promise(index, url);
  133. }
  134. }
  135. // loadAsync();
  136. //点击分享
  137. $('.share-node')[0].addEventListener('click', () => {
  138. if (!id) {
  139. copyUrl();
  140. } else if (isiOS) {
  141. $.ajax({
  142. url: baseUrl + '/api/user/v1/promote',
  143. type: 'get',
  144. headers: {
  145. 'Authorization': id //id
  146. },
  147. contentType: "application/json",
  148. dataType: 'json',
  149. cache: false,
  150. success: function (res) {
  151. var jsonStr = JSON.stringify(res.data)
  152. var jsonObj = JSON.parse(jsonStr)
  153. // WKWebView使用
  154. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  155. try {
  156. getMessage(jsonObj);
  157. } catch (error) {
  158. console.log(error)
  159. }
  160. try {
  161. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  162. } catch (error) {
  163. copyUrl();
  164. }
  165. }
  166. })
  167. } else if (isAndroid) {
  168. if (window.native) {
  169. window.native.onClikWebView()
  170. } else {
  171. copyUrl();
  172. }
  173. } else {
  174. copyUrl();
  175. }
  176. }, false);
  177. //复制
  178. function copyUrl() {
  179. stopManyClick(() => {
  180. var oInput = document.createElement('input'); //创建一个input
  181. oInput.setAttribute("readonly", "readonly");//设置只读,否则移动端使用复制功能时可能会造成软件盘弹出
  182. oInput.value = window.location.href || 'https://client.androidscloud.com/h5/microserviceUserH5/vcloud/invite.html';
  183. $('.ipt')[0].appendChild(oInput);//将input插入到body
  184. // oInput.select(); // 选择对象 ios不支持
  185. selectText(oInput, 0, oInput.value.length);
  186. document.execCommand("Copy"); // 执行浏览器复制命令
  187. toastr.error('复制当前网址成功!');
  188. oInput.style.display = 'none'; // 将input隐藏
  189. oInput.blur();
  190. oInput.remove(); // 将input销毁
  191. })
  192. }
  193. // input自带的select()方法在苹果端无法进行选择,所以需要自己去写一个类似的方法
  194. // 选择文本。createTextRange(setSelectionRange)是input方法
  195. function selectText(textbox, startIndex, stopIndex) {
  196. if (textbox.createTextRange) {//ie
  197. const range = textbox.createTextRange();
  198. range.collapse(true);
  199. range.moveStart('character', startIndex);//起始光标
  200. range.moveEnd('character', stopIndex - startIndex);//结束光标
  201. range.select();//不兼容苹果
  202. } else {//firefox/chrome
  203. textbox.setSelectionRange(startIndex, stopIndex);
  204. textbox.focus();
  205. }
  206. }
  207. // 默认选中红手指
  208. function handleClick() {
  209. $('.options')[0].className = 'options';
  210. $('#select').val('红手指');
  211. fromType = 2;
  212. };
  213. handleClick();
  214. //点击选择框
  215. $('.login-row-select')[0].addEventListener('click', () => {
  216. $('.options')[0].className = 'options show';
  217. }, false);
  218. //点击多多云
  219. $('.icon-down-first')[0].addEventListener('click', () => {
  220. $('.options')[0].className = 'options';
  221. $('#select').val('多多云');
  222. fromType = 1;
  223. }, false);
  224. //点击红手指
  225. $('.icon-down-second')[0].addEventListener('click', () => {
  226. $('.options')[0].className = 'options';
  227. $('#select').val('红手指');
  228. fromType = 2;
  229. }, false);
  230. //点击爱云兔
  231. $('.icon-down-third')[0].addEventListener('click', () => {
  232. $('.options')[0].className = 'options';
  233. $('#select').val('爱云兔');
  234. fromType = 3;
  235. }, false);
  236. //点击提示弹窗确定
  237. // $('.sure-btn')[0].addEventListener('click', handleClose, false);
  238. function handleClose() {
  239. $('.tip').animate({ top: '-6.96rem' }, "fast");
  240. $('.mask').hide();
  241. document.documentElement.style.overflow = 'auto';
  242. }
  243. //点击立即注册
  244. // $('.register-text')[0].addEventListener('click', registerHandle, false);
  245. // $('.register-btn')[0].addEventListener('click', registerHandle, false);
  246. function registerHandle() {
  247. $('.dialog').animate({ top: '-6.96rem' }, "fast");
  248. $('.mask').hide();
  249. document.documentElement.style.overflow = 'auto';
  250. $('#select').val('');
  251. $('#account').val('');
  252. $('#password').val('');
  253. window.location.href = 'https://www.androidscloud.com';
  254. }
  255. //点击免费换机按钮
  256. $('.form-btn')[0].addEventListener('click', changePhoneHandle, false);
  257. function changePhoneHandle() {
  258. stopManyClick(() => {
  259. account = $('#account').val();
  260. account = account.replace(/\s+/g, "");
  261. password = $('#password').val();
  262. password = password.replace(/\s+/g, "");
  263. if (!account) {
  264. $('.tip-text1').text('账号格式不正确,请重新输入!');
  265. $('#account').addClass('br');
  266. return
  267. } else {
  268. $('.tip-text1').text('');
  269. $('#account').removeClass('br')
  270. }
  271. if (!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(account)) {
  272. $('.tip-text1').text('账号格式不正确,请重新输入!');
  273. $('#account').addClass('br');
  274. return
  275. } else {
  276. $('.tip-text1').text('');
  277. $('#account').removeClass('br')
  278. }
  279. if (!password) {
  280. $('.tip-text2').text('密码为空,请重新输入!');
  281. $('#password').addClass('br');
  282. return
  283. } else {
  284. $('.tip-text2').text('');
  285. $('#password').removeClass('br')
  286. }
  287. operate('dt_yhs_点击免费换机按钮', 'click');
  288. })
  289. }
  290. //调用免费换机接口
  291. function changePhone() {
  292. let data = {
  293. inviteTime: entryPageTime,
  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. </script>
  341. </body>
  342. </html>