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