invite.html 11 KB

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