replacementActivities.html 13 KB

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