invite2.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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/invite.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="invite-container pr">
  16. <div class="rules" onclick="handleShow()">活动规则</div>
  17. <div class="h658">
  18. <img src="../static/img/invite/inviteTop.png" class="bottom-img" alt="">
  19. <div class="recv-cont">
  20. <div class="title" id="title">
  21. </div>
  22. <div class="recv-btn-container">
  23. <div onclick="appDown()" class="recv-btn"></div>
  24. </div>
  25. <div class="recv-ipt" id="recv_ipt">
  26. <span class="fl">
  27. <span>我的邀请码:</span>
  28. <span class="fw500" id="invitationCode"></span>
  29. </span>
  30. <span class="copy-btn-style btn-code-copy fr">点击复制</span>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="load-menu">
  35. <div class="center-reward-con">
  36. <div class="top-title">我的奖励</div>
  37. <div id="goode">
  38. <div class="reward-second-title"></div>
  39. <ul class="goodFriend-title-list">
  40. <li class="tac">被邀好友帐号</li>
  41. <li class="tac">获时长数(小时)</li>
  42. <li class="tac">邀请时间</li>
  43. </ul>
  44. </div>
  45. </div>
  46. <div class="center-reward-con mt40">
  47. <div class="top-title">邀请榜TOP10</div>
  48. <div id="rank">
  49. <ul class="goodFriend-title-list">
  50. <li class="tac">排名</li>
  51. <li class="tac">用户名</li>
  52. <li class="tac">邀请数量</li>
  53. <li class="tac">奖励(时长)</li>
  54. </ul>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="mask">
  59. <div class="dialog">
  60. <div class="code-title-font"></div>
  61. <div class="tb-codes">
  62. <p class="fw500">好友购机,买一送一</p>
  63. <p>被邀好友购买任意套餐,您可获其等额时长返现(仅限首单);邀请越多返现越多,返现无上限。请用户参与活动前认真阅读规则,若因未按规则参与活动而造成的损失,由用户自行承担。</p>
  64. <p class="fw500">规则</p>
  65. <p>1、好友购机前,邀请人账户内无云手机(无云手机购买记录者),或仅有免费试用时长的用户,则无法获时长奖励;</p>
  66. <p>2、邀请成功后,双方自动成为好友,邀请奖励将通过好友消息的方式进行发放,邀请方需要点击【领取】,才可领取成功,时长奖励返现至您账户内时长最多的云手机。邀请奖励领取期限为24小时,超过领取期限则无法领取奖励。</p>
  67. <p>3、如发现有刷单等行为用户,将对该账号及其所关联账号进行冻结处理;</p>
  68. <p>4、本活动最终解释权归双子星云手机所有。</p>
  69. </div>
  70. </div>
  71. <div class="close" onclick="handleClose()"></div>
  72. </div>
  73. </div>
  74. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="passwordCopy" value="">
  75. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="inviteCopy" value="">
  76. <script>
  77. toastr.options.positionClass = 'toast-center-center';
  78. toastr.options.timeOut = '1500';
  79. </script>
  80. <script type="text/javascript">
  81. let timer, flag = true;
  82. var url = window.location.href;
  83. url = url.split('/')
  84. // var baseUrl = url[0] + '//' + url[2]
  85. var loc = window.location.search;
  86. var n1 = loc.length;//地址的总长度
  87. var n2 = loc.indexOf("=");//取得=号的位置
  88. // var id = loc.substr(n2 + 1, n1 - n2);//从=号后面的内容
  89. var id = loc.substr(n2 + 1, n1 - n2);//从=号后面的内容
  90. var u = navigator.userAgent;
  91. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  92. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  93. if (!id) {
  94. if (isAndroid) {
  95. window.native.toGame('noToken');
  96. } else if (isiOS) {
  97. window.webkit.messageHandlers.getPackageName.postMessage('noToken');
  98. } else {
  99. toastr.error('请登录')
  100. }
  101. }
  102. $.ajax({
  103. url: baseUrl + '/api/activity/v3/invitation/getInvitationInfo',
  104. type: 'get',
  105. headers: {
  106. 'Authorization': id //id
  107. },
  108. contentType: "application/json",
  109. dataType: 'json',
  110. cache: false,
  111. success: function (res) {
  112. $('#invitationCode').text(res.data.invitationCode)
  113. //加载数据
  114. $('#passwordCopy').val($('#invitationCode').text());
  115. //复制按钮
  116. $('.btn-code-copy').on('click', function () {
  117. stopManyClick(() => {
  118. var input = document.getElementById("passwordCopy");
  119. // 选中文本
  120. input.select();
  121. // 执行浏览器复制命令
  122. // document.activeElement.blur();
  123. document.execCommand("copy");
  124. toastr.error('复制成功', 0)
  125. })
  126. });
  127. if (res.data.friendList.length > 0) {
  128. var str = ''
  129. for (var i = 0; i < res.data.friendList.length; i++) {
  130. var phone = res.data.friendList[i].newPhone
  131. var inviteMsg = res.data.friendList[i].duration
  132. var registerTime = res.data.friendList[i].createTime
  133. var nPhone = phone.substr(0, 3) + '****' + phone.substring(7, 11)
  134. str += '<div class="goodFriend-item">'
  135. str += '<span class="tal">' + nPhone + '</span>'
  136. str += Number(inviteMsg) && inviteMsg > 0 ? '<span class="tac cF04646">' + inviteMsg + '</span>' : '<span class="tac">' + inviteMsg + '</span>'
  137. str += '<span class="tar">' + registerTime + '</span>'
  138. str += '</div>';
  139. }
  140. } else if (res.data.friendList.length === 0) {
  141. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  142. }
  143. $('#goode').append(str);
  144. },
  145. error: function () {
  146. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  147. $('#goode').append(str)
  148. }
  149. })
  150. $("#recv_ipt").bind('input propertychange', function (e) {
  151. stopManyClick(() => {
  152. var ipt_phones = $('#recv_ipt').val();
  153. var c = $(this);
  154. if (/[^\d]/.test(c.val())) {//替换非数字字符
  155. var temp_amount = c.val().replace(/[^\d]/g, '');
  156. $(this).val(temp_amount);
  157. toastr.error('请输入正确的手机号')
  158. }
  159. if (ipt_phones.length >= 12) {
  160. toastr.error('请输入正确的手机号')
  161. var recvstr = ipt_phones.substring(0, 11)
  162. $("#recv_ipt").val(recvstr);
  163. }
  164. })
  165. });
  166. function handleShow() {
  167. $('.dialog').animate({ top: '2.4rem' }, "fast");
  168. $('.close').animate({ top: '10.56rem' }, "fast");
  169. $('.mask').show();
  170. document.documentElement.style.overflow = 'hidden';
  171. }
  172. function handleClose() {
  173. $('.dialog').animate({ top: '-6.96rem' }, "fast");
  174. $('.close').animate({ top: '-0.68rem' }, "fast");
  175. $('.mask').hide();
  176. document.documentElement.style.overflow = 'auto';
  177. }
  178. function appDown() {
  179. var u = navigator.userAgent;
  180. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  181. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  182. if (!id) {
  183. if (isAndroid) {
  184. window.native.toGame('noToken');
  185. } else if (isiOS) {
  186. window.webkit.messageHandlers.getPackageName.postMessage('noToken');
  187. } else {
  188. toastr.error('请登录')
  189. }
  190. return
  191. }
  192. $.ajax({
  193. url: baseUrl + '/api/activity/v1/promote/getImPromoteUrl',
  194. type: 'get',
  195. headers: {
  196. 'Authorization': id //id
  197. },
  198. contentType: "application/json",
  199. dataType: 'json',
  200. cache: false,
  201. success: function (res) {
  202. var jsonStr = JSON.stringify(res.data)
  203. var jsonObj = JSON.parse(jsonStr)
  204. if (isiOS) {
  205. // WKWebView使用
  206. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  207. try {
  208. getMessage(jsonObj);
  209. } catch (error) {
  210. console.log(error)
  211. }
  212. try {
  213. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  214. } catch (error) {
  215. console.log(error)
  216. }
  217. } else if (isAndroid) {
  218. window.native.onClikWebView()
  219. } else {
  220. stopManyClick(() => {
  221. //加载数据
  222. var copyBefore = JSON.stringify(res.data.url);
  223. var copyUrl = copyBefore.split('"');
  224. console.log(copyUrl[1])
  225. $('#inviteCopy').val(copyUrl[1]);
  226. var input = document.getElementById("inviteCopy");
  227. // 选中文本
  228. input.select();
  229. // 执行浏览器复制命令
  230. document.execCommand("copy");
  231. toastr.error('复制成功')
  232. })
  233. }
  234. }
  235. })
  236. }
  237. // 查询季度排行榜
  238. function getInvitationRankList() {
  239. $.ajax({
  240. url: baseUrl + '/api/activity/v3/invitation/getInvitationRankList',
  241. type: 'get',
  242. headers: {
  243. 'Authorization': id //id
  244. },
  245. contentType: "application/json",
  246. dataType: 'json',
  247. cache: false,
  248. success: function (res) {
  249. var str = '';
  250. if (res.status === 0) {
  251. res.data.forEach(function (item, index) {
  252. var surfaceName = /^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(item.surfaceName) ? item.surfaceName.substr(0, 3) + '****' + item.surfaceName.substring(7, 11) : item.surfaceName
  253. if (index === 0) {
  254. str += '<div class="rank-item">';
  255. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no1.png" alt=""></span>'
  256. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  257. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  258. str += '<span class="tac cF04646">' + item.duration + '</span>'
  259. str += '</div>';
  260. } else if (index === 1) {
  261. str += '<div class="rank-item">';
  262. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no2.png" alt=""></span>'
  263. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  264. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  265. str += '<span class="tac cF04646">' + item.duration + '</span>'
  266. str += '</div>';
  267. } else if (index === 2) {
  268. str += '<div class="rank-item">';
  269. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no3.png" alt=""></span>'
  270. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  271. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  272. str += '<span class="tac cF04646">' + item.duration + '</span>'
  273. str += '</div>';
  274. } else if (index < 10) {
  275. str += '<div class="rank-item">';
  276. str += '<span class="tac c333">' + (index + 1) + '</span>'
  277. str += '<span class="tac">' + surfaceName + '</span>'
  278. str += '<span class="tac">' + item.invitationNum + '</span>'
  279. str += '<span class="tac">' + item.duration + '</span>'
  280. str += '</div>';
  281. }
  282. });
  283. }
  284. $('#rank').append(str);
  285. }
  286. })
  287. }
  288. getInvitationRankList()
  289. // 查询最新获得奖励
  290. function getInvitationRecently() {
  291. $.ajax({
  292. url: baseUrl + '/api/activity/v3/invitation/getInvitationRecently',
  293. type: 'get',
  294. headers: {
  295. 'Authorization': id //id
  296. },
  297. contentType: "application/json",
  298. dataType: 'json',
  299. cache: false,
  300. success: function (res) {
  301. if (res.status === 0) {
  302. console.log(res.data)
  303. if(res.data.length <= 10){
  304. let datas = ['173', '134', '152', '136', '138', '173', '134', '152', '136', '138'];
  305. var str = '<ul class="list">'
  306. datas.forEach(function (item) {
  307. str += '<li>恭喜' + item + '*******成功获得时长' + (item - 100) + '小时</li>'
  308. })
  309. str += '</ul>'
  310. } else {
  311. var str = '<ul class="list">'
  312. res.data.forEach(function (item) {
  313. str += '<li>恭喜' + item.username.substr(0, 3) + '*******成功获得时长' + item.duration + '小时</li>'
  314. })
  315. str += '</ul>'
  316. }
  317. $('#title').append(str);
  318. }
  319. }
  320. })
  321. }
  322. getInvitationRecently()
  323. //防止提示一秒内重复显示
  324. function stopManyClick(fn) {
  325. if (flag) {
  326. fn();
  327. }
  328. flag = false;
  329. if (timer) { clearTimeout(timer); }
  330. timer = setTimeout(() => { flag = true }, 1500);
  331. }
  332. </script>
  333. </body>
  334. </html>