invite.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.execCommand("copy");
  110. toastr.error('复制成功', 0)
  111. })
  112. });
  113. if (res.data.friendList.length > 0) {
  114. var str = ''
  115. for (var i = 0; i < res.data.friendList.length; i++) {
  116. var phone = res.data.friendList[i].newPhone
  117. var inviteMsg = res.data.friendList[i].duration
  118. var registerTime = res.data.friendList[i].createTime
  119. var nPhone = phone.substr(0, 3) + '****' + phone.substring(7, 11)
  120. str += '<div class="goodFriend-item">'
  121. str += '<span class="tal">' + nPhone + '</span>'
  122. str += Number(inviteMsg) && inviteMsg > 0 ? '<span class="tac cF04646">' + inviteMsg + '</span>' : '<span class="tac">' + inviteMsg + '</span>'
  123. str += '<span class="tar">' + registerTime + '</span>'
  124. str += '</div>';
  125. }
  126. } else if (res.data.friendList.length === 0) {
  127. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  128. }
  129. $('#goode').append(str);
  130. },
  131. error: function () {
  132. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  133. $('#goode').append(str)
  134. }
  135. })
  136. $("#recv_ipt").bind('input propertychange', function (e) {
  137. stopManyClick(() =>{
  138. var ipt_phones = $('#recv_ipt').val();
  139. var c = $(this);
  140. if (/[^\d]/.test(c.val())) {//替换非数字字符 v1/promote
  141. var temp_amount = c.val().replace(/[^\d]/g, '');
  142. $(this).val(temp_amount);
  143. toastr.error('请输入正确的手机号')
  144. }
  145. if (ipt_phones.length >= 12) {
  146. toastr.error('请输入正确的手机号')
  147. var recvstr = ipt_phones.substring(0, 11)
  148. $("#recv_ipt").val(recvstr);
  149. }
  150. })
  151. });
  152. function handleShow() {
  153. $('.dialog').animate({top: '2.4rem'},"fast");
  154. $('.close').animate({top: '10.56rem'},"fast");
  155. $('.mask').show();
  156. document.documentElement.style.overflow='hidden';
  157. }
  158. function handleClose() {
  159. $('.dialog').animate({top: '-6.96rem'},"fast");
  160. $('.close').animate({top: '-0.68rem'},"fast");
  161. $('.mask').hide();
  162. document.documentElement.style.overflow='auto';
  163. }
  164. function appDown() {
  165. var u = navigator.userAgent;
  166. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  167. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  168. if (isiOS) {
  169. $.ajax({
  170. url: baseUrl + '/api/user/v1/promote',
  171. type: 'get',
  172. headers: {
  173. 'Authorization': id //id
  174. },
  175. contentType: "application/json",
  176. dataType: 'json',
  177. cache: false,
  178. success: function (res) {
  179. var jsonStr = JSON.stringify(res.data)
  180. var jsonObj = JSON.parse(jsonStr)
  181. // WKWebView使用
  182. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  183. try {
  184. getMessage(jsonObj);
  185. } catch (error) {
  186. console.log(error)
  187. }
  188. try {
  189. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  190. } catch (error) {
  191. console.log(error)
  192. }
  193. }
  194. })
  195. } else if (isAndroid) {
  196. window.native.onClikWebView()
  197. } else {
  198. $.ajax({
  199. url: baseUrl + '/api/user/v1/promote',
  200. type: 'get',
  201. headers: {
  202. 'Authorization': id //id
  203. },
  204. contentType: "application/json",
  205. dataType: 'json',
  206. cache: false,
  207. success: function (res) {
  208. stopManyClick(() =>{
  209. //加载数据
  210. var copyBefore = JSON.stringify(res.data.url);
  211. var copyUrl = copyBefore.split('"');
  212. console.log(copyUrl[1])
  213. $('#inviteCopy').val(copyUrl[1]);
  214. var input = document.getElementById("inviteCopy");
  215. // 选中文本
  216. input.select();
  217. // 执行浏览器复制命令
  218. document.execCommand("copy");
  219. toastr.error('复制成功')
  220. })
  221. }
  222. })
  223. }
  224. }
  225. // 查询季度排行榜
  226. function getInvitationRankList() {
  227. $.ajax({
  228. url: baseUrl + '/api/user/v3/invitation/getInvitationRankList',
  229. type: 'get',
  230. headers: {
  231. 'Authorization': id //id
  232. },
  233. contentType: "application/json",
  234. dataType: 'json',
  235. cache: false,
  236. success: function (res) {
  237. var str = '';
  238. if (res.status === 0) {
  239. res.data.forEach(function(item, index) {
  240. 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
  241. if (index === 0) {
  242. str += '<div class="rank-item">';
  243. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no1.png" alt=""></span>'
  244. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  245. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  246. str += '<span class="tac cF04646">' + item.duration + '</span>'
  247. str += '</div>';
  248. } else if (index === 1) {
  249. str += '<div class="rank-item">';
  250. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no2.png" alt=""></span>'
  251. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  252. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  253. str += '<span class="tac cF04646">' + item.duration + '</span>'
  254. str += '</div>';
  255. } else if (index === 2) {
  256. str += '<div class="rank-item">';
  257. str += '<span class="tac h52"><img class="icon" src="../static/img/invite/no3.png" alt=""></span>'
  258. str += '<span class="tac cF04646">' + surfaceName + '</span>'
  259. str += '<span class="tac cF04646">' + item.invitationNum + '</span>'
  260. str += '<span class="tac cF04646">' + item.duration + '</span>'
  261. str += '</div>';
  262. } else if (index < 10) {
  263. str += '<div class="rank-item">';
  264. str += '<span class="tac c333">' + (index + 1) + '</span>'
  265. str += '<span class="tac">' + surfaceName + '</span>'
  266. str += '<span class="tac">' + item.invitationNum + '</span>'
  267. str += '<span class="tac">' + item.duration + '</span>'
  268. str += '</div>';
  269. }
  270. });
  271. }
  272. $('#rank').append(str);
  273. }
  274. })
  275. }
  276. getInvitationRankList()
  277. // 查询最新获得奖励
  278. function getInvitationRecently() {
  279. $.ajax({
  280. url: baseUrl + '/api/user/v3/invitation/getInvitationRecently',
  281. type: 'get',
  282. headers: {
  283. 'Authorization': id //id
  284. },
  285. contentType: "application/json",
  286. dataType: 'json',
  287. cache: false,
  288. success: function (res) {
  289. if (res.status === 0) {
  290. var str = '<ul class="list">'
  291. res.data.forEach(function (item) {
  292. str += '<li>恭喜' + item.username.substr(0, 3) + '*******成功获得时长' + item.duration + '小时</li>'
  293. })
  294. str += '</ul>'
  295. $('#title').append(str);
  296. }
  297. }
  298. })
  299. }
  300. getInvitationRecently()
  301. //防止提示一秒内重复显示
  302. function stopManyClick(fn) {
  303. if (flag) {
  304. fn();
  305. }
  306. flag = false;
  307. if(timer){clearTimeout(timer);}
  308. timer = setTimeout(() => {flag = true}, 1500);
  309. }
  310. </script>
  311. </body>
  312. </html>