invite2.html 12 KB

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