invite.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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">
  16. <div class="pr">
  17. <picture>
  18. <source media="(max-width: 640px)" srcset="../static/img/inviteTop.png 640w" />
  19. <source media="(min-width: 640px)" srcset="../static/img/inviteTop.png 1366w" />
  20. <img src="../static/img/inviteTop.png" class="bottom-img" alt="">
  21. </picture>
  22. <div class="recv-cont">
  23. <div class="recv-ipt" id="recv_ipt">
  24. <span id="invitationCode"></span>
  25. <span class="copy-btn-style btn-code-copy">复制</span>
  26. </div>
  27. <div onclick="appDown()" class="mt40">
  28. <div class="recv-btn" id="recv_btn"></div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="load-menu">
  33. <div class="center-reward-con">
  34. <div class="top-title">你的奖励</div>
  35. <div class="reward-second-title">好友购机,返时长奖励</div>
  36. <div id="goode"></div>
  37. </div>
  38. <div>
  39. <div class="code-title-font">活动规则</div>
  40. <div class="tb-codes">
  41. <p class="fw500 fs28">好友购机,买一送一</p>
  42. <p class="fs26 mb45">被邀好友购买任意套餐,您可获其等额时长返现(仅限首单);邀请越多返现越多,返现无上限;</p>
  43. <p class="fw500 fs26">规则</p>
  44. <p class="fs26">1. 账户内无云手机,或仅有2小时免费体验时长的用户,则无法获时长奖励;</p>
  45. <p class="fs26">2. 时长奖励直接下发至您账户内时长最多的云手机;</p>
  46. <p class="fs26">3. 如发现有刷单等行为用户,将对该账号及其所关联账号进行冻结处理;</p>
  47. <p class="fs26">4. 本活动最终解释权归双子星云手机所有。</p>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="passwordCopy" value="">
  53. <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="inviteCopy" value="">
  54. <script>
  55. toastr.options.positionClass = 'toast-center-center';
  56. toastr.options.timeOut = '3000';
  57. </script>
  58. <script type="text/javascript">
  59. var url = window.location.href;
  60. url = url.split('/')
  61. // var baseUrl = url[0] + '//' + url[2]
  62. var loc = window.location.search;
  63. var n1 = loc.length;//地址的总长度
  64. var n2 = loc.indexOf("=");//取得=号的位置
  65. var id = loc.substr(n2 + 1, n1 - n2);//从=号后面的内容
  66. var u = navigator.userAgent;
  67. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  68. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  69. if (isiOS) {
  70. var btnMsg = '立即邀请'
  71. } else if (isAndroid) {
  72. btnMsg = '立即邀请'
  73. } else {
  74. btnMsg = '复制邀请链接'
  75. }
  76. $('#recv_btn').append(btnMsg)
  77. $.ajax({
  78. url: baseUrl + '/api/user/v3/invitation/client/getInvitationInfo',
  79. type: 'get',
  80. headers: {
  81. 'Authorization': id //id
  82. },
  83. contentType: "application/json",
  84. dataType: 'json',
  85. cache: false,
  86. success: function (res) {
  87. $('#invitationCode').text(res.data.invitationCode)
  88. //加载数据
  89. $('#passwordCopy').val($('#invitationCode').text());
  90. //复制按钮
  91. $('.btn-code-copy').on('click', function () {
  92. var input = document.getElementById("passwordCopy");
  93. // 选中文本
  94. input.select();
  95. // 执行浏览器复制命令
  96. document.execCommand("copy");
  97. toastr.error('复制成功', 0)
  98. });
  99. if (res.data.friendList.length > 0) {
  100. var str = '<ul class="goodFriend-title-list"><li class="tal">被邀请好友帐号</li><li class="tac">获时长数(小时)</li><li class="tar">邀请时间</li></ul>'
  101. for (var i = 0; i < res.data.friendList.length; i++) {
  102. var phone = res.data.friendList[i].newPhone
  103. var inviteMsg = res.data.friendList[i].duration
  104. var registerTime = res.data.friendList[i].createTime
  105. var nPhone = phone.substr(0, 3) + '****' + phone.substring(7, 11)
  106. str += '<div class="goodFriend-item">'
  107. str += '<span class="tal">' + nPhone + '</span>'
  108. str += Number(inviteMsg) && inviteMsg > 0 ? '<span class="tac cF04646">' + inviteMsg + '</span>' : '<span class="tac">' + inviteMsg + '</span>'
  109. str += '<span class="tar">' + registerTime + '</span>'
  110. str += '</div>';
  111. }
  112. } else if (res.data.friendList.length === 0) {
  113. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  114. }
  115. $('#goode').append(str);
  116. },
  117. error: function () {
  118. str = '<div class="no-data">还没有邀请到好友哦~</div>'
  119. $('#goode').append(str)
  120. }
  121. })
  122. $("#recv_ipt").bind('input propertychange', function (e) {
  123. var ipt_phones = $('#recv_ipt').val();
  124. var c = $(this);
  125. if (/[^\d]/.test(c.val())) {//替换非数字字符
  126. var temp_amount = c.val().replace(/[^\d]/g, '');
  127. $(this).val(temp_amount);
  128. toastr.error('请输入正确的手机号')
  129. }
  130. if (ipt_phones.length >= 12) {
  131. toastr.error('请输入正确的手机号')
  132. var recvstr = ipt_phones.substring(0, 11)
  133. $("#recv_ipt").val(recvstr);
  134. }
  135. });
  136. function appDown() {
  137. var u = navigator.userAgent;
  138. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  139. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  140. if (isiOS) {
  141. $.ajax({
  142. url: baseUrl + '/api/user/v1/promote',
  143. type: 'get',
  144. headers: {
  145. 'Authorization': id //id
  146. },
  147. contentType: "application/json",
  148. dataType: 'json',
  149. cache: false,
  150. success: function (res) {
  151. var jsonStr = JSON.stringify(res.data)
  152. var jsonObj = JSON.parse(jsonStr)
  153. // WKWebView使用
  154. // 使用下方方法,会报错,为使界面执行逻辑通畅,因此使用try-catch
  155. try {
  156. getMessage(jsonObj);
  157. } catch (error) {
  158. console.log(error)
  159. }
  160. try {
  161. window.webkit.messageHandlers.getMessage.postMessage(jsonObj)
  162. } catch (error) {
  163. console.log(error)
  164. }
  165. }
  166. })
  167. } else if (isAndroid) {
  168. window.native.onClikWebView()
  169. } else {
  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. //加载数据
  181. var copyBefore = JSON.stringify(res.data.url);
  182. var copyUrl = copyBefore.split('"');
  183. $('#inviteCopy').val(copyUrl[1]);
  184. var input = document.getElementById("inviteCopy");
  185. // 选中文本
  186. input.select();
  187. // 执行浏览器复制命令
  188. document.execCommand("copy");
  189. toastr.error('复制成功')
  190. }
  191. })
  192. }
  193. }
  194. </script>
  195. </body>
  196. </html>