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