invite.html 9.2 KB

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