springFestivalActivity.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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/springFestivalActivity.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="code-container">
  16. <div class="award-tip">购买星曜月卡获得1次抽奖资格 星曜年卡获得10次抽奖资格</div>
  17. <div class="rule-wrap">
  18. <div class="rule">活动规则</div>
  19. <div class="award">奖励一览</div>
  20. </div>
  21. <div class="gift-box">
  22. <img class="gift-img" src="../static/img/springFestivalActivity/gift.png" />
  23. </div>
  24. </div>
  25. <div class="next-container">
  26. <div class="lottery-tip">抽奖10次轮盘必中年卡</div>
  27. <div class="lottery-wrap">
  28. <div class="once">抽奖1次</div>
  29. <div class="five-times">抽奖5次</div>
  30. </div>
  31. <div class="rest-times">
  32. <div class="rest-times-text">剩余次数 <span class="rest-times-number">0</span>次</div>
  33. <div class="get-times">获取次数 >></div>
  34. </div>
  35. <div class="no-join-activity">使用激活码,星币支付及PC端不参与活动</div>
  36. <div class="share-wrap">分享至朋友圈、QQ获得“幸运BUFF”</div>
  37. <div class="get-award">已获取奖励</div>
  38. <div class="activity-time">活动时间 :2021年1月25日-2月15日</div>
  39. <div class="activity-tip">仅购买星曜月卡,星曜年卡才可参与此活动哦</div>
  40. </div>
  41. <div class="award-record-mask">
  42. <div class="dialog">
  43. <div class="tab-wrap">
  44. <div class="award-change-btn active" data-index="0">领取</div>
  45. <div class="award-change-btn" data-index="1">已使用</div>
  46. </div>
  47. <div class="record-wrap">
  48. <div class="title-row">
  49. <div class="title-award">奖品</div>
  50. <div class="title-Title">时间</div>
  51. <div class="title-operat">操作</div>
  52. </div>
  53. <div class="line"></div>
  54. <div class="data-list"></div>
  55. </div>
  56. <div class="sure-btn">确定</div>
  57. <img class="close" src="../static/img/springFestivalActivity/close.png" />
  58. </div>
  59. </div>
  60. <div class="rule-mask">
  61. <div class="rule-dialog">
  62. <img class="rule-text" src="../static/img/springFestivalActivity/ruleText.png" />
  63. <div class="rule-list">
  64. <div class="rule-point">1、活动期间,购买获得的抽取资格不限次数, 活动期间可用,活动结束后未使用的做过期处理。</div>
  65. <div class="rule-point">2、参与活动的套餐是星曜月卡与年卡套餐,其他套餐不参与活动。</div>
  66. <div class="rule-point">3、星币、激活码购买的订单不参与本次活动。</div>
  67. <div class="rule-point">4、抽取的奖励只能新增云机,请去云手机首页查看。</div>
  68. <div class="rule-point">5、活动结束后3天保留奖励分配入口,但不能再参与活动。</div>
  69. <div class="rule-point">6、双子星官方对活动具有最终解释权。</div>
  70. </div>
  71. <img class="rule-close" src="../static/img/springFestivalActivity/close.png" />
  72. </div>
  73. </div>
  74. <div class="award-mask">
  75. <div class="award-dialog">
  76. <div class="award-result-row">
  77. <img class="icon" src="../static/img/springFestivalActivity/left-icon.png" />
  78. <span class="award-result">参与抽奖有几率获得以下奖励</span>
  79. <img class="icon" src="../static/img/springFestivalActivity/right-icon.png" />
  80. </div>
  81. <div class="card-wrap"></div>
  82. <img class="award-close" src="../static/img/springFestivalActivity/close.png" />
  83. </div>
  84. </div>
  85. <div class="award-result-mask">
  86. <div class="award-result-dialog">
  87. <div class="have-times-wrap">
  88. <div class="result-tip-row">
  89. <div class="award-result-tip">善良的人,好运气最终是会眷顾你</div>
  90. <div class="join-result-tip">参与抽奖有几率获得以下奖励</div>
  91. </div>
  92. <div class="card-wrap award-result-wrap"></div>
  93. <div class="btn-row">
  94. <div class="left-btn">再抽<span class="report-times"></span>次</div>
  95. <div class="look-btn">查看</div>
  96. </div>
  97. <div class="times-text">还剩次数:<span class="times-text-number"></span>次</div>
  98. </div>
  99. <div class="no-times-wrap">
  100. <div class="no-times-tip">
  101. <div>意不意外,惊不惊喜!</div>
  102. <div>当前抽奖次数不足哦</div>
  103. </div>
  104. <div class="no-times-btn">购买星曜云手机获取次数</div>
  105. </div>
  106. <img class="award-result-close" src="../static/img/springFestivalActivity/close.png" />
  107. </div>
  108. </div>
  109. <div class="distribution-mask">
  110. <div class="distribution-dialog">
  111. <div class="distribution-wrap">
  112. <div class="limit-tip">
  113. <div>云手机数量已达上限</div>
  114. <div>请分配云机时长</div>
  115. </div>
  116. <div class="distribution-btn">分配奖励</div>
  117. </div>
  118. </div>
  119. </div>
  120. <script>
  121. toastr.options.positionClass = 'toast-center-center';
  122. toastr.options.timeOut = '1500';
  123. </script>
  124. <script type="text/javascript">
  125. // var baseUrl = 'https://test.androidscloud.com'
  126. let timer,flag = true;
  127. var url = window.location.href;
  128. url = url.split('/')
  129. var loc = window.location.search,
  130. n1 = loc.length,//地址的总长度
  131. n2 = loc.indexOf("="),//取得=号的位置
  132. id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
  133. u = navigator.userAgent,
  134. ua = navigator.userAgent.toLowerCase(),
  135. isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  136. isMiniprogram = false,
  137. isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  138. let activityState = 0,
  139. surplus = 0,
  140. receive = 0,
  141. notReceive = 0;
  142. if(id !== ''){
  143. operate(3);
  144. }
  145. if (ua.match(/MicroMessenger/i) == "micromessenger") {
  146. //ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
  147. wx.miniProgram.getEnv((res) => {
  148. if (res.miniprogram) {
  149. isMiniprogram = true;
  150. } else {
  151. isMiniprogram = false;
  152. }
  153. })
  154. } else {
  155. isMiniprogram = false;
  156. }
  157. init();
  158. setInterval(() => {
  159. init();
  160. },30000);
  161. //初始化数据
  162. function init(times) {
  163. $.ajax({
  164. url: baseUrl + '/api/user/v1/activity/getSpringFestivalConfig',
  165. type: 'get',
  166. headers: {
  167. 'Authorization': id //id
  168. },
  169. contentType: "application/json",
  170. dataType: 'json',
  171. cache: false,
  172. success: function (res) {
  173. if(res.status === 0){
  174. $('.card-wrap').eq(0).text('');
  175. let time = `${res.data.startTime.substr(0,4)}年${res.data.startTime.substring(5,7)}月${res.data.startTime.substring(8,10)}日-${res.data.endTime.substring(5,7)}月${res.data.endTime.substring(8,10)}日`;
  176. $('.activity-time').eq(0).text(time);
  177. let str = '',
  178. cardData = [{name: '天',imgName: 'day'},{name: '周',imgName: 'week'},{name: '月',imgName: 'mouth'},
  179. {name: '季',imgName: 'season'},{name: '年',imgName: 'year'}],
  180. jackpot = res.data.jackpot;
  181. cardData = cardData.filter((item) => jackpot.includes(item.name));
  182. for (var i = 0; i < cardData.length; i++) {
  183. str += `<div class="card-item">
  184. <img class="card" src="../static/img/springFestivalActivity/${cardData[i].imgName}.png" />
  185. <div class="card-text">星曜${cardData[i].name}卡</div>
  186. </div>`
  187. }
  188. activityState = res.data.activityState;
  189. surplus = res.data.surplus;
  190. notReceive = res.data.notReceive;
  191. $('.rest-times-number').eq(0).text(surplus);
  192. $('.times-text-number').eq(0).text(surplus);
  193. if(res.data.addition === 1){
  194. $('.gift-box')[0].className = 'gift-box have-buff'
  195. } else {
  196. $('.gift-box')[0].className = 'gift-box'
  197. }
  198. if(notReceive > 0){
  199. $('.tab-wrap').eq(0).css('display', 'flex');
  200. $('.record-wrap').eq(0).css('marginTop', '0.2rem');
  201. $('.record-wrap').eq(0).css('height', '5.38rem');
  202. $('.data-list').eq(0).css('height', '4.38rem');
  203. }else{
  204. $('.tab-wrap').eq(0).css('display', 'none');
  205. $('.record-wrap').eq(0).css('marginTop', '1.6rem');
  206. $('.record-wrap').eq(0).css('height', '5.86rem');
  207. }
  208. $('.card-wrap').eq(0).append(str)
  209. }else{
  210. stopManyClick(() =>{
  211. toastr.error(res.msg)
  212. })
  213. }
  214. },
  215. })
  216. }
  217. //点击获奖记录
  218. $('.get-award')[0].addEventListener('click',() => {
  219. $('.dialog').animate({top: '2.24rem'},"fast");
  220. $('.award-record-mask').show();
  221. document.documentElement.style.overflow='hidden';
  222. getAward();
  223. },false);
  224. //点击获奖记录关闭按钮
  225. $('.close')[0].addEventListener('click',handleClose,false);
  226. function handleClose() {
  227. $('.dialog').animate({top: '-10.96rem'},"fast");
  228. $('.award-record-mask').hide();
  229. document.documentElement.style.overflow='auto';
  230. }
  231. //点击确定
  232. $('.sure-btn')[0].addEventListener('click',handleClose,false);
  233. //点击规则
  234. $('.rule')[0].addEventListener('click',() => {
  235. $('.rule-dialog').animate({top: '2.24rem'},"fast");
  236. $('.rule-mask').show();
  237. document.documentElement.style.overflow='hidden';
  238. },false);
  239. //点击规则关闭按钮
  240. $('.rule-close')[0].addEventListener('click',() => {
  241. $('.rule-dialog').animate({top: '-10.96rem'},"fast");
  242. $('.rule-mask').hide();
  243. document.documentElement.style.overflow='auto';
  244. },false);
  245. //点击奖励一览
  246. $('.award')[0].addEventListener('click',() => {
  247. $('.award-dialog').animate({top: '2.24rem'},"fast");
  248. $('.award-mask').show();
  249. document.documentElement.style.overflow='hidden';
  250. },false);
  251. //点击奖励一览关闭按钮
  252. $('.award-close')[0].addEventListener('click',() => {
  253. $('.award-dialog').animate({top: '-10.96rem'},"fast");
  254. $('.award-mask').hide();
  255. document.documentElement.style.overflow='auto';
  256. },false);
  257. //点击领取按钮
  258. $('.tab-wrap')[0].addEventListener('click',(e) => {
  259. receive = e.target.dataset.index;
  260. if(receive == 1){
  261. $('.award-change-btn')[0].className = 'award-change-btn'
  262. }else{
  263. $('.award-change-btn')[1].className = 'award-change-btn'
  264. }
  265. getAward();
  266. $('.award-change-btn')[receive].className = 'award-change-btn active'
  267. },false);
  268. //点击抽奖
  269. $('.once')[0].addEventListener('click',() => {
  270. handleAward(1)
  271. },false);
  272. $('.five-times')[0].addEventListener('click',() => {
  273. handleAward(5)
  274. },false);
  275. //点击再抽
  276. $('.left-btn')[0].addEventListener('click',() => {
  277. let val = $('.report-times').eq(0).text();
  278. handleAward(val,'report')
  279. },false);
  280. function handleAward(times,type) {
  281. if(surplus === 0){
  282. $('.have-times-wrap').eq(0).css('display', 'none');
  283. $('.no-times-wrap').eq(0).css('display', 'block');
  284. $('.award-result-dialog').animate({top: '1.86rem'},"fast");
  285. $('.award-result-mask').show();
  286. document.documentElement.style.overflow='hidden';
  287. return
  288. }
  289. $.ajax({
  290. url: baseUrl + '/api/user/v1/activity/obtainRewards',
  291. type: 'post',
  292. headers: {
  293. 'Authorization': id //id
  294. },
  295. data:JSON.stringify({
  296. frequency: times
  297. }),
  298. contentType: "application/json",
  299. dataType: 'json',
  300. cache: false,
  301. success: function (res) {
  302. if(res.status === 0){
  303. $('.have-times-wrap').eq(0).css('display', 'block');
  304. $('.no-times-wrap').eq(0).css('display', 'none');
  305. if(type !== 'report'){
  306. $('.award-result-dialog').animate({top: '1.86rem'},"fast");
  307. $('.award-result-mask').show();
  308. document.documentElement.style.overflow='hidden';
  309. }
  310. $('.award-result-wrap').eq(0).text('');
  311. let str = '',
  312. cardObj = {
  313. '天': 'day',
  314. '周': 'week',
  315. '月': 'mouth',
  316. '季': 'season',
  317. '年': 'year'
  318. },
  319. list = res.data.list;
  320. if(list.length === 1){
  321. $('.report-times').eq(0).text(1);
  322. $('.look-btn').eq(0).text('查看');
  323. $('.award-result-wrap')[0].className = 'card-wrap award-result-wrap one-result';
  324. str = `<div class="card-item">
  325. <img class="one-card" src="../static/img/springFestivalActivity/${cardObj[list[0].duration]}.png" />
  326. <div class="card-text">星曜${list[0].duration}卡</div>
  327. </div> `
  328. }else{
  329. $('.report-times').eq(0).text(5);
  330. $('.look-btn').eq(0).text('确定');
  331. $('.award-result-wrap')[0].className = 'card-wrap award-result-wrap'
  332. for (var i = 0; i < list.length; i++) {
  333. str += `<div class="card-item">
  334. <img class="card" src="../static/img/springFestivalActivity/${cardObj[list[i].duration]}.png" />
  335. <div class="card-text">星曜${list[i].duration}卡</div>
  336. </div>`
  337. }
  338. }
  339. $('.award-result-wrap').eq(0).append(str);
  340. init();
  341. }else{
  342. stopManyClick(() =>{
  343. toastr.error(res.msg)
  344. })
  345. }
  346. },
  347. })
  348. }
  349. //点击抽奖关闭按钮
  350. $('.award-result-close')[0].addEventListener('click',() => {
  351. $('.award-result-dialog').animate({top: '-10.96rem'},"fast");
  352. $('.award-result-mask').hide();
  353. document.documentElement.style.overflow='auto';
  354. },false);
  355. //点击分享按钮
  356. $('.share-wrap')[0].addEventListener('click',() => {
  357. if (isMiniprogram) { // 小程序
  358. wx.miniProgram.navigateTo({
  359. url: '/pages/home/home'
  360. })
  361. } else { // 不是小程序
  362. $.ajax({
  363. url: baseUrl + '/api/public/v4/actFissionAward/getActDetail',
  364. type: 'get',
  365. headers: {
  366. 'Authorization': id //id
  367. },
  368. contentType: "application/json",
  369. dataType: 'json',
  370. cache: false,
  371. success: (res) => {
  372. if (res.status === 0) {
  373. init();
  374. var shareInfo = res.data;
  375. if (isAndroid) {
  376. window.native.share(shareInfo.title, shareInfo.content, shareInfo.gotoUrl, shareInfo.shareImg)
  377. } else if (isIOS) {
  378. window.webkit.messageHandlers.share.postMessage({
  379. title: shareInfo.title,
  380. content: shareInfo.content,
  381. gotoUrl: shareInfo.gotoUrl,
  382. shareImg: shareInfo.shareImg
  383. });
  384. }
  385. } else {
  386. stopManyClick(() =>{
  387. toastr.error(res.msg)
  388. })
  389. }
  390. },
  391. })
  392. }
  393. $.ajax({
  394. url: baseUrl + '/api/user/v1/activity/addBuff',
  395. type: 'get',
  396. headers: {
  397. 'Authorization': id //id
  398. },
  399. contentType: "application/json",
  400. dataType: 'json',
  401. cache: false,
  402. success: function (res) {
  403. console.log(res)
  404. },
  405. })
  406. },false);
  407. //点击购买星耀获取云机按钮
  408. $('.no-times-btn')[0].addEventListener('click',() => {
  409. if (isMiniprogram) { // 小程序
  410. wx.miniProgram.navigateTo({
  411. url: '/packageA/order/buy/index?type=activity'
  412. })
  413. } else if (isAndroid) { // 安卓
  414. window.native.startPurchase(1, 365);
  415. } else if (isiOS) {
  416. window.webkit.messageHandlers.startPurchase.postMessage({ type: 1, day: 365 });
  417. }
  418. },false);
  419. //点击获取次数
  420. $('.get-times')[0].addEventListener('click',() => {
  421. if (isMiniprogram) { // 小程序
  422. if(notReceive > 0){
  423. wx.miniProgram.navigateTo({
  424. url: '/packageA/order/renew/index?type=activity'
  425. })
  426. } else {
  427. wx.miniProgram.navigateTo({
  428. url: '/packageA/order/buy/index?type=activity'
  429. })
  430. }
  431. } else if (isAndroid) { // 安卓
  432. if(notReceive > 0){
  433. window.native.startRenew();
  434. } else {
  435. window.native.startPurchase(1, 365);
  436. }
  437. } else if (isiOS) {
  438. if(notReceive > 0){
  439. window.webkit.messageHandlers.startRenew.postMessage();
  440. } else {
  441. window.webkit.messageHandlers.startPurchase.postMessage();
  442. }
  443. }
  444. },false);
  445. // 点击查看
  446. $('.look-btn')[0].addEventListener('click',() => {
  447. if(notReceive > 0){
  448. $('.distribution-dialog').animate({top: '5.24rem'},"fast");
  449. $('.distribution-mask').show();
  450. document.documentElement.style.overflow='hidden';
  451. return
  452. }
  453. if (isMiniprogram) { // 小程序
  454. wx.miniProgram.navigateTo({
  455. url: '/pages/home/home'
  456. })
  457. } else if (isAndroid) { // 安卓
  458. window.native.startMain();
  459. } else if (isiOS) {
  460. window.webkit.messageHandlers.startMain.postMessage();
  461. }
  462. },false);
  463. //点击分配奖励按钮
  464. $('.distribution-btn')[0].addEventListener('click',() => {
  465. $('.award-result-dialog').animate({top: '-10.96rem'},"fast");
  466. $('.award-result-mask').hide();
  467. $('.distribution-dialog').animate({top: '-10.96rem'},"fast");
  468. $('.distribution-mask').hide();
  469. $('.dialog').animate({top: '2.24rem'},"fast");
  470. $('.award-record-mask').show();
  471. document.documentElement.style.overflow='hidden';
  472. getAward()
  473. },false);
  474. //点击使用按钮
  475. $('.data-list')[0].addEventListener('click',(e) => {
  476. if (e.target.className === 'record-operate operate-btn') {
  477. let awardId = parseInt(e.target.dataset.awardid);
  478. let awardName = e.target.dataset.awardname;
  479. if (isMiniprogram) { // 小程序
  480. wx.miniProgram.navigateTo({
  481. url: '/packageA/order/buy/index?type=activity'
  482. })
  483. } else if (isAndroid) { // 安卓
  484. window.native.activatePhone(2, awardId, awardName);
  485. } else if (isiOS) {
  486. window.webkit.messageHandlers.activatePhone.postMessage({ type: 2, awardId: awardId, awardName: awardName });
  487. }
  488. }
  489. },false);
  490. //获取抽奖记录
  491. function getAward(){
  492. $.ajax({
  493. url: baseUrl + '/api/user/v1/activity/platformGetRewardsH5',
  494. type: 'post',
  495. headers: {
  496. 'Authorization': id //id
  497. },
  498. data:JSON.stringify({
  499. pageNum: 1,
  500. pageSize: 10,
  501. receive: receive
  502. }),
  503. contentType: "application/json",
  504. dataType: 'json',
  505. cache: false,
  506. success: function (res) {
  507. if(res.status === 0){
  508. $('.data-list').eq(0).text('');
  509. let str = '',
  510. records = res.data.records;
  511. if(records.length === 0){
  512. str = '<div class="no-award">没有抽奖记录,我都替你着急</div>'
  513. }
  514. for (var i = 0; i < records.length; i++) {
  515. str += `<div class="data-row">
  516. <div class="award-card">星曜${records[i].effectiveTimeStr}卡</div>
  517. <div class="record-time">${records[i].createTime.substring(5,7)}月${records[i].createTime.substring(8,10)}日${records[i].createTime.substr(11)}</div>
  518. <div class="${records[i].receive === 1?'record-operate':'record-operate operate-btn'}"
  519. data-awardId="${records[i].id}" data-awardName="星曜${records[i].effectiveTimeStr}卡">
  520. ${records[i].receive === 1?'已使用':'使用'}</div>
  521. </div>`
  522. }
  523. $('.data-list').eq(0).append(str)
  524. }else{
  525. stopManyClick(() =>{
  526. toastr.error(res.msg)
  527. })
  528. }
  529. },
  530. })
  531. }
  532. //埋点
  533. function operate(accessType){
  534. $.ajax({
  535. url: baseUrl + '/api/public/v1/game/user/operate',
  536. type: 'post',
  537. headers: {
  538. 'Authorization': id //id
  539. },
  540. data:JSON.stringify({
  541. accessType: accessType,
  542. entrance: 3,
  543. url: window.location.href
  544. }),
  545. contentType:"application/json",
  546. dataType: 'json',
  547. cache: false,
  548. success: function (res) {
  549. console.log(res)
  550. },
  551. })
  552. }
  553. //防止提示一秒内重复显示
  554. function stopManyClick(fn) {
  555. if (flag) {
  556. fn();
  557. }
  558. flag = false;
  559. if(timer){clearTimeout(timer);}
  560. timer = setTimeout(() => {flag = true}, 1500);
  561. }
  562. </script>
  563. </body>
  564. </html>