awardActivity.html 34 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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/awardActivity.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="container">
  16. <div class="all-bg-wrap">
  17. <img class="all-bg-img" src="../static/img/awardActivity/all-bg.png" />
  18. </div>
  19. <div class="rule-wrap">活动规则</div>
  20. <div class="time-position"></div>
  21. <div class="time-wrap"></div>
  22. <div class="top-container">
  23. <img class="top-bg-one" src="../static/img/awardActivity/top-bg-one.png" />
  24. <img class="top-bg-two" src="../static/img/awardActivity/top-bg-two.png" />
  25. <div class="get-award-container">
  26. <div class="award-lists"></div>
  27. </div>
  28. <div class="all-award-wrap"></div>
  29. </div>
  30. <div class="rest-wrap">
  31. <div class="award-btn-wrap">
  32. <img class="start-award" src="../static/img/awardActivity/bug-phone.png" />
  33. </div>
  34. <div class="get-time-wrap">
  35. <div class="rest-time">剩余抽奖次数 <span class="times"></span>次</div>
  36. <div class="get-time-btn">获取次数</div>
  37. </div>
  38. <div class="tab-wrap">
  39. <img class="tab-bg1" src="../static/img/awardActivity/tab-bg1.png" />
  40. <img class="tab-bg2" src="../static/img/awardActivity/tab-bg2.png" />
  41. <img class="tab-bg3" src="../static/img/awardActivity/tab-bg3.png" />
  42. <img class="tab-bg4" src="../static/img/awardActivity/tab-bg4.png" />
  43. <div class="award-container">
  44. <div class="award-title-wrap">
  45. <div class="award-title active-title">奖励一览</div>
  46. <div class="award-title">分配奖励(<span class="all-times"></span>)</div>
  47. </div>
  48. <div class="award-list">
  49. <div class="award-list-title-wrap">
  50. <div class="award-list-title">时间</div>
  51. <div class="award-list-title">奖品</div>
  52. </div>
  53. <div class="award-list-wrap"></div>
  54. </div>
  55. <div class="distribution-wrap">
  56. <div class="distribution-list-wrap">
  57. <div class="distribution-list">
  58. <div class="distribution-total-wrap">
  59. <div class="award-total-data">奖励总时长<span class="red"></span>天</div>
  60. <div class="award-total-data">已分配时长<span class="red"></span>天</div>
  61. <div class="award-total-data">未分配时长<span class="red"></span>天</div>
  62. </div>
  63. <div class="distribution-container"></div>
  64. <div class="distribution-award-btn">分配奖励</div>
  65. </div>
  66. <div class="award-record-list">
  67. <div class="record-list-title">分配时长记录</div>
  68. <div class="award-record-list-title-wrap">
  69. <div class="award-record-list-title">云机名称</div>
  70. <div class="award-record-list-title">时间</div>
  71. <div class="award-record-list-title">时长</div>
  72. </div>
  73. <div class="award-record-list-wrap"></div>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="no-award-data">
  78. <img class="no-award-img" src="../static/img/awardActivity/no-award.png" />
  79. <div class="no-award-text">没有抽奖记录,我都替你着急~</div>
  80. </div>
  81. <div class="no-distribution-data">
  82. <img class="no-distribution-img" src="../static/img/awardActivity/no-data.png" />
  83. <div class="no-distribution-text">先购买云手机,才能分配喔~</div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="rule-mask">
  89. <div class="rule-result-dialog">
  90. <div class="rule-content">
  91. <div class="rule-title-wrap">
  92. <div class="rule-title-icon"></div>
  93. <div class="rule-title">活动规则</div>
  94. <div class="rule-title-icon"></div>
  95. </div>
  96. <div class="rule-point-wrap">
  97. <!-- <div class="rule-point">1、活动期间,购买获得的抽取资格不限次数, 活动期间可用,活动结束后未使用的做过期处理。</div>
  98. <div class="rule-point">2、参与活动的套餐是星曜月卡与年卡套餐,其他套餐不参与活动。</div>
  99. <div class="rule-point">3、星币、激活码购买的订单不参与本次活动。</div>
  100. <div class="rule-point">4、抽取的奖励只能新增云机,请去云手机首页查看。</div>
  101. <div class="rule-point">5、活动结束后3天保留奖励分配入口,但不能再参与活动。</div>
  102. <div class="rule-point">6、双子星官方对活动具有最终解释权。</div> -->
  103. </div>
  104. </div>
  105. <img class="rule-close" src="../static/img/anniversaryCelebrate/close.png" />
  106. </div>
  107. </div>
  108. <div class="result-mask">
  109. <div class="result-dialog">
  110. <div class="result-content">
  111. <div class="rule-title-wrap result-title-wrap">
  112. <div class="rule-title-icon"></div>
  113. <div class="rule-title result-title">换个姿势,再抽一次</div>
  114. <div class="rule-title-icon"></div>
  115. </div>
  116. <div class="main-contain"></div>
  117. </div>
  118. <img class="card-close" src="../static/img/anniversaryCelebrate/close.png" />
  119. </div>
  120. </div>
  121. <div class="sure-distribution-wrap">
  122. <div class="sure-distribution-box">
  123. <div class="sure-distribution-title">确定分配奖励时长</div>
  124. <div class="sure-distribution-btn-list">
  125. <div class="sure-distribution-btn sure-distribution-cannel">取消</div>
  126. <div class="sure-distribution-btn sure-distribution-sure">确定</div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <script type="text/html" id="card">
  132. <img class="card-img" src="{{icon}}" />
  133. <div class="card-title">{{goodsName}}</div>
  134. <div class="card-tips">{{tips}}</div>
  135. <div class="card-btn">{{cardBtn}}</div>
  136. <div class="card-rest-times">剩余次数{{lotteryCount}}次</div>
  137. </script>
  138. <script type="text/html" id="award1">
  139. <div class="curr-award-item curr-award-item-one">
  140. <div class="curr-award-img curr-award-img-one">
  141. <img class="award-img" src="{{icon}}" />
  142. </div>
  143. <div class="curr-award-name">{{goodsName}}</div>
  144. <div class="curr-award-id">{{id}}</div>
  145. </div>
  146. </script>
  147. <script type="text/html" id="award2">
  148. <div class="curr-award-item">
  149. <div class="curr-award-img">
  150. <!-- <img class="award-img" src="{{icon}}" /> -->
  151. </div>
  152. <div class="curr-award-name">{{goodsName}}</div>
  153. <div class="curr-award-id">{{id}}</div>
  154. </div>
  155. </script>
  156. <script type="text/html" id="awardRecord">
  157. <div class="award-list-item">
  158. <div class="award-list-content">{{createTime}}</div>
  159. <div class="award-list-content">{{goodsName}}</div>
  160. </div>
  161. </script>
  162. <script type="text/html" id="distribution">
  163. <div class="distribution-item">
  164. <div class="distribution-main-content">
  165. <img class="phone-logo" src="../static/img/awardActivity/home_list_icon_xingyao.jpg" />
  166. <div class="distribution-info">
  167. <div class="distribution-name">{{diskName}}</div>
  168. <div class="distribution-time">{{timeLeft}}</div>
  169. </div>
  170. </div>
  171. <div class="change-num-wrap">
  172. <div class="cut" data-id={{userCardId}} data-index={{index}}>-</div>
  173. <input class="num-ipt" type="number" onkeyup="this.value=this.value.replace(/-/g,'')" value="0" data-id={{userCardId}} data-index={{index}} />
  174. <div class="add" data-id={{userCardId}} data-index={{index}}>+</div>
  175. </div>
  176. </div>
  177. </script>
  178. <script type="text/html" id="record">
  179. <div class="award-record-list-item">
  180. <div class="award-record-list-content">{{diskName}}</div>
  181. <div class="award-record-list-content">{{exceptTime}}</div>
  182. <div class="award-record-list-content">{{validTime}}</div>
  183. </div>
  184. </script>
  185. <script>
  186. toastr.options.positionClass = 'toast-center-center';
  187. toastr.options.timeOut = '1500';
  188. </script>
  189. <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
  190. <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
  191. <script type="text/javascript">
  192. // var baseUrl = 'http://gntest.phone.androidscloud.com:1280'
  193. const fileCenterApi = 'https://file.phone.androidscloud.com:8121';
  194. let uploadKey = ''
  195. if (window.location.origin.includes('client.phone.androidscloud.com')) {
  196. uploadKey = 'edv834e74a9c43eaac02'
  197. } else if (window.location.origin.includes('prese.phone.androidscloud')) {
  198. uploadKey = '347905r86eb745a1sc38'
  199. } else {
  200. uploadKey = '13d0arghebcc4cm49cf04'
  201. }
  202. let timer,flag = true;
  203. var url = window.location.href;
  204. url = url.split('/')
  205. var loc = window.location.search,
  206. n1 = loc.length,//地址的总长度
  207. n2 = loc.indexOf("="),//取得=号的位置
  208. id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
  209. u = navigator.userAgent,
  210. ua = navigator.userAgent.toLowerCase(),
  211. awardData = [],
  212. distributionList = [],
  213. topVal = -0.5,
  214. unAllotTime = 0,
  215. recordFlag = true,
  216. pageNum = 1,
  217. pages = 0,
  218. recordFlag1 = true,
  219. pageNum1 = 1,
  220. recordFlag2 = true,
  221. pageNum2 = 1,
  222. pages2 = 0,
  223. cardList = [],
  224. lotteryCount = 0,
  225. lotteryResult = {},
  226. lotteryFlag = true,
  227. activityState = 0,
  228. awardNumber = 0,
  229. currTotalTime = 0,
  230. phoneRemainQuantity = 0,
  231. userCardId = 0,
  232. flagNum = 1;
  233. isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  234. isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
  235. (function(doc) {
  236. var init = function () {
  237. getPhoneNumber();
  238. bindEvent();
  239. goodsList();
  240. rewardList();
  241. allotTimeRecord();
  242. allotTimeCardList();
  243. }
  244. function bindEvent () {
  245. //点击开始抽奖
  246. $('.start-award')[0].addEventListener('click', startLottery, false);
  247. //点击继续抽奖
  248. $('.main-contain')[0].addEventListener('click', nextLottery, false);
  249. //点击抽奖结果关闭弹窗
  250. $('.card-close')[0].addEventListener('click', cardClose, false);
  251. //点击获取次数
  252. $('.get-time-btn')[0].addEventListener('click',getTimeHandle,false);
  253. //tab切换
  254. $('.award-title')[0].addEventListener('click', tabHandle1, false);
  255. $('.award-title')[1].addEventListener('click', tabHandle2, false);
  256. //点击分配时长按钮
  257. $('.distribution-award-btn')[0].addEventListener('click', distributionTime, false);
  258. //点击规则
  259. $('.rule-wrap')[0].addEventListener('click', ruleHandle, false);
  260. //关闭规则
  261. $('.rule-close')[0].addEventListener('click', ruleClose, false);
  262. }
  263. function tabHandle1 (e) {
  264. operate('mfhd_2022_h5_tab奖励一览');
  265. $('.tab-bg1').eq(0).css('display', 'block');
  266. $('.tab-bg2').eq(0).css('display', 'none');
  267. $('.tab-bg3').eq(0).css('display', 'none');
  268. $('.tab-bg4').eq(0).css('display', 'none');
  269. $('.tab-wrap').eq(0).css('height', '5.75rem');
  270. $('.award-title')[0].className = 'award-title active-title';
  271. $('.award-title')[1].className = 'award-title';
  272. $('.award-list').eq(0).css('display', 'block');
  273. $('.no-distribution-data').eq(0).css('display', 'none');
  274. $('.distribution-list-wrap').eq(0).css('display', 'none');
  275. if(pages === 0) {
  276. $('.no-award-data').eq(0).css('display', 'block');
  277. $('.award-list').eq(0).css('display', 'none');
  278. } else {
  279. $('.award-list').eq(0).css('display', 'block');
  280. $('.no-award-data').eq(0).css('display', 'none');
  281. }
  282. }
  283. function tabHandle2 (e) {
  284. if(activityState == 0){
  285. stopManyClick(() =>{
  286. toastr.error('活动未开始!');
  287. })
  288. return
  289. }
  290. if(activityState == 2){
  291. stopManyClick(() =>{
  292. toastr.error('活动已结束!');
  293. })
  294. return
  295. }
  296. operate('mfhd_2022_h5_tab分配奖励');
  297. $('.tab-bg1').eq(0).css('display', 'none');
  298. $('.tab-wrap').eq(0).css('height', '14.75rem');
  299. $('.award-title')[0].className = 'award-title';
  300. $('.award-title')[1].className = 'award-title active-title';
  301. $('.distribution-list-wrap').eq(0).css('display', 'block');
  302. $('.award-list').eq(0).css('display', 'none');
  303. $('.no-award-data').eq(0).css('display', 'none');
  304. if(cardList.length === 0) {
  305. $('.tab-bg2').eq(0).css('display', 'none');
  306. $('.tab-bg3').eq(0).css('display', 'none');
  307. $('.tab-bg4').eq(0).css('display', 'block');
  308. $('.tab-wrap').eq(0).css('height', '5.76rem');
  309. $('.distribution-list-wrap').eq(0).css('display', 'none');
  310. $('.no-distribution-data').eq(0).css('display', 'block');
  311. } else if(pages2 == 0) {
  312. $('.tab-bg4').eq(0).css('display', 'none');
  313. $('.tab-bg2').eq(0).css('display', 'none');
  314. $('.tab-bg3').eq(0).css('display', 'block');
  315. $('.tab-wrap').eq(0).css('height', '9.05rem');
  316. } else {
  317. $('.tab-bg4').eq(0).css('display', 'none');
  318. $('.tab-bg3').eq(0).css('display', 'none');
  319. $('.tab-bg2').eq(0).css('display', 'block');
  320. $('.award-record-list').eq(0).css('display', 'block');
  321. $('.tab-wrap').eq(0).css('height', '14.75rem');
  322. }
  323. }
  324. // 继续抽奖
  325. function nextLottery(e) {
  326. if(e.target.className === 'card-btn'){
  327. $('.main-contain').eq(0).empty();
  328. let num = flagNum > 12 ? flagNum - 12 : flagNum;
  329. $('.curr-award-item').eq(num).css('background', '#ffffff');
  330. cardClose();
  331. stopManyClick(() =>{
  332. startLottery('next');
  333. })
  334. }
  335. }
  336. function animation(num, time, result) {
  337. if(num >= 0) {
  338. $('.curr-award-item').eq(num).css('background', '#ffffff');
  339. }
  340. num++;
  341. $('.curr-award-item').eq(num).css('background', '#FAE892');
  342. if(time < 160) {
  343. time += 30;
  344. } else if(num === flagNum - 5) {
  345. time += 50;
  346. } else if(num === flagNum - 4) {
  347. time += 100;
  348. } else if(num === flagNum - 3) {
  349. time += 200;
  350. } else if(num === flagNum - 2) {
  351. time += 300;
  352. } else if(num === flagNum - 1) {
  353. time += 300;
  354. } else if(num === flagNum) {
  355. time += 100;
  356. } else {
  357. time += 30;
  358. }
  359. let flag = $('.curr-award-id').eq(num).text();
  360. if(flag == lotteryResult.id){
  361. flagNum = num < 6 ? num + awardNumber : num;
  362. }
  363. timer = setTimeout(() => {
  364. if(num === awardNumber) {
  365. num = -1;
  366. animation(num, time);
  367. } else if(flag == lotteryResult.id && time > 500) {
  368. lotteryResultHandle();
  369. clearTimeout(timer);
  370. } else {
  371. animation(num, time)
  372. }
  373. }, time)
  374. }
  375. // 开始抽奖
  376. function startLottery(type){
  377. if(activityState == 0){
  378. stopManyClick(() =>{
  379. toastr.error('活动未开始!');
  380. })
  381. return
  382. }
  383. if(activityState == 2){
  384. stopManyClick(() =>{
  385. toastr.error('活动已结束!');
  386. })
  387. return
  388. }
  389. if(lotteryCount === 0) {
  390. operate('mfhd_2022_h5_购买云机');
  391. getTimeHandle('buy');
  392. return
  393. } else if(type === 'next') {
  394. operate('mfhd_2022_h5_继续抽奖');
  395. } else {
  396. operate('mfhd_2022_h5_开始抽奖');
  397. }
  398. if(!lotteryFlag) {
  399. return
  400. }
  401. lotteryFlag = false;
  402. if(!GetRequest().token){
  403. return
  404. }
  405. $.ajax({
  406. url: baseUrl + '/api/activity/gratis/startLottery',
  407. type: 'get',
  408. headers: {
  409. 'Authorization': GetRequest().token //id
  410. },
  411. data: {
  412. clientType: GetRequest().clientType
  413. },
  414. contentType: "application/json",
  415. dataType: 'json',
  416. cache: false,
  417. success: function (res) {
  418. if(res.status === 0){
  419. let time = 20;
  420. let num = -1;
  421. lotteryResult = res.data;
  422. animation(num, time, 3);
  423. }else{
  424. stopManyClick(() =>{
  425. toastr.error(res.msg)
  426. })
  427. lotteryFlag = true
  428. }
  429. }
  430. })
  431. }
  432. //抽奖结果展示
  433. function lotteryResultHandle() {
  434. $('.result-dialog').animate({top: '3.86rem'},"fast");
  435. $('.result-mask').show();
  436. document.documentElement.style.overflow='hidden';
  437. lotteryFlag = true;
  438. let result = '';
  439. lotteryCount--;
  440. lotteryResult.lotteryCount = lotteryCount;
  441. lotteryResult.tips = lotteryResult.goodsType != 5 ?'奖励已发送您的账户内,请注意查收' : '中奖不是最终的追求,重要的是开心咯';
  442. lotteryResult.cardBtn = lotteryResult.lotteryCount != 0 ?'继续抽奖' : '获取次数';
  443. let text = lotteryResult.lotteryCount != 0 ?'换个姿势,再抽一次' : '次数用完,点击获取';
  444. $('.result-title').eq(0).text(text)
  445. if(lotteryCount === 0) {
  446. $('.start-award')[0].src = '../static/img/awardActivity/bug-phone.png';
  447. }
  448. lotteryResult.icon = `https://file.phone.androidscloud.com:8121/document/newFile/download/0/${uploadKey}?fileKey=${lotteryResult.icon}`
  449. result = $('#card').text().replace(/{{(.*?)}}/g, function(node, key) {
  450. return lotteryResult[key];
  451. })
  452. goodsList();
  453. allotTimeCardList();
  454. $('.main-contain').eq(0).append(result)
  455. $('.times').eq(0).text(lotteryResult.lotteryCount)
  456. }
  457. // 抽奖记录
  458. function rewardList(type){
  459. if(!GetRequest().token){
  460. return
  461. }
  462. $.ajax({
  463. url: baseUrl + '/api/activity/gratis/rewardList',
  464. type: 'get',
  465. headers: {
  466. 'Authorization': GetRequest().token //id
  467. },
  468. data: {
  469. pageNum: pageNum,
  470. pageSize: 5
  471. },
  472. contentType: "application/json",
  473. dataType: 'json',
  474. cache: false,
  475. success: function (res) {
  476. if(res.status === 0){
  477. recordFlag = true;
  478. let list = res.data.list
  479. pages = res.data.pages;
  480. if(type != 'down'){
  481. $('.award-list-wrap').eq(0).empty();
  482. }
  483. if(pages === 0) {
  484. $('.no-award-data').eq(0).css('display', 'block');
  485. $('.award-list').eq(0).css('display', 'none');
  486. } else {
  487. $('.award-list').eq(0).css('display', 'block');
  488. $('.no-award-data').eq(0).css('display', 'none');
  489. }
  490. let result = ''
  491. list.map((item, index) => {
  492. result += $('#awardRecord').text().replace(/{{(.*?)}}/g, function(node, key) {
  493. return item[key];
  494. })
  495. })
  496. $('.award-list-wrap').eq(0).append(result)
  497. }else{
  498. stopManyClick(() =>{
  499. toastr.error(res.msg)
  500. })
  501. }
  502. }
  503. })
  504. }
  505. //抽奖记录下拉加载
  506. $('.award-list-wrap')[0].addEventListener('scroll',function () {
  507. let scrollTop = $('.award-list-wrap')[0].scrollTop;
  508. let clientHeight = $('.award-list-wrap')[0].clientHeight;
  509. let scrollHeight = $('.award-list-wrap')[0].scrollHeight;
  510. if(scrollTop + clientHeight + 100 > scrollHeight){
  511. if(recordFlag && pageNum < pages && pages > 1){
  512. recordFlag = false;
  513. pageNum++;
  514. rewardList('down');
  515. }
  516. }
  517. });
  518. // 活动基础数据
  519. function goodsList(){
  520. if(!GetRequest().token){
  521. return
  522. }
  523. $.ajax({
  524. url: baseUrl + '/api/activity/gratis/goodsList',
  525. type: 'get',
  526. headers: {
  527. 'Authorization': GetRequest().token //id
  528. },
  529. contentType: "application/json",
  530. dataType: 'json',
  531. cache: false,
  532. success: function (res) {
  533. if(res.status === 0){
  534. let startTime = res.data.startTime
  535. let endTime = res.data.endTime
  536. $('.time-wrap').eq(0).text(`活动时间:${startTime.substring(0,4)}年${startTime.substring(5,7)}月${startTime.substring(8,10)}日-${endTime.substring(5,7)}月${endTime.substring(8,10)}日`);
  537. awardData = res.data.marquee
  538. let goodsInfos = res.data.goodsInfos
  539. lotteryCount = res.data.lotteryCount
  540. activityState = res.data.activityState
  541. awardNumber = goodsInfos.length
  542. let actRule = res.data.actRule
  543. let result = ''
  544. let resultDom = goodsInfos.length === 9 ? $('#award1') : $('#award2');
  545. if(goodsInfos.length === 9) {
  546. $(".top-bg-one").css({"display": "block"})
  547. $(".top-bg-two").css({"display": "none"})
  548. } else {
  549. $(".top-bg-one").css({"display": "none"})
  550. $(".top-bg-two").css({"display": "block"})
  551. }
  552. goodsInfos.map((item, index) => {
  553. item.index = index
  554. item.icon = `https://file.phone.androidscloud.com:8121/document/newFile/download/0/${uploadKey}?fileKey=${item.icon}`
  555. result += resultDom.text().replace(/{{(.*?)}}/g, function(node, key) {
  556. return item[key];
  557. })
  558. })
  559. if(lotteryCount !== 0) {
  560. $('.start-award')[0].src = '../static/img/awardActivity/start-award.png';
  561. }
  562. headerAward();
  563. $('.rule-point-wrap').eq(0).html(actRule)
  564. $('.times').eq(0).text(lotteryCount)
  565. $('.all-award-wrap').eq(0).append(result)
  566. }else{
  567. stopManyClick(() =>{
  568. toastr.error(res.msg)
  569. })
  570. }
  571. }
  572. })
  573. }
  574. //轮播
  575. function headerAward(){
  576. if(awardData.length === 0) {
  577. return
  578. }
  579. setInterval(() =>{
  580. awardHandle();
  581. },3000);
  582. }
  583. function awardHandle(){
  584. let index = (topVal/0.5) + 1,awardString;
  585. let awardLen = Array.from($('.award-text')).length;
  586. if(awardLen < awardData.length){
  587. let node = document.createElement('div');
  588. node.className = "award-text";
  589. $('.award-lists')[0].appendChild(node);
  590. }
  591. if(topVal < awardData.length/2 - 0.5){
  592. topVal+=0.5;
  593. }else{
  594. topVal = 0;
  595. $('.award-lists').eq(0).css('top','0.5rem');
  596. }
  597. let numberType = Math.floor(getRandom()/4);
  598. if(awardData && awardData[index] && topVal < awardData.length/2){
  599. awardString = `恭喜${awardData[index].phone}用户获得${['优惠券','激活码','云机时长','星币','云机套餐','谢谢惠顾'][awardData[index].goodsType]}奖品`;
  600. }
  601. // else{
  602. // awardString = `恭喜1${[3,5,7,8,3,5,7,8,3,5][getRandom()]}${getRandom()}****${getRandom()}${getRandom()}${getRandom()}${getRandom()}用户获得${['优惠券','激活码','云机时长','星币','云机套餐','谢谢惠顾'][numberType]}`
  603. // }
  604. $('.award-text').eq(index).text(awardString);
  605. $('.award-lists').eq(0).animate({top: -(topVal) + 'rem'},"fast");
  606. }
  607. // 获取一个随机数
  608. function getRandom(){
  609. return Math.floor(Math.random()*10);
  610. }
  611. // 分配云手机列表
  612. function allotTimeCardList(type){
  613. if(!GetRequest().token){
  614. return
  615. }
  616. $.ajax({
  617. url: baseUrl + '/api/activity/gratis/allotTimeCardList',
  618. type: 'get',
  619. headers: {
  620. 'Authorization': GetRequest().token //id
  621. },
  622. contentType: "application/json",
  623. dataType: 'json',
  624. cache: false,
  625. success: function (res) {
  626. if(res.status === 0){
  627. cardList = res.data.cardList
  628. unAllotTime = res.data.unAllotTime
  629. userCardId = cardList[0].userCardId
  630. pageCardList()
  631. $('.all-times').eq(0).text(res.data.totalTime)
  632. $('.red').eq(0).text(res.data.totalTime)
  633. $('.red').eq(1).text(res.data.allotTime)
  634. $('.red').eq(2).text(res.data.unAllotTime)
  635. }else{
  636. stopManyClick(() =>{
  637. toastr.error(res.msg)
  638. })
  639. }
  640. }
  641. })
  642. }
  643. // 分页渲染数据
  644. function pageCardList() {
  645. let result = '';
  646. recordFlag1 = true;
  647. let list = cardList.slice(pageNum1 * 5, (pageNum1 * 5) + 5)
  648. list.map((item, index) => {
  649. item.index = (pageNum1 - 1) * 5 + index
  650. result += $('#distribution').text().replace(/{{(.*?)}}/g, function(node, key) {
  651. return item[key];
  652. })
  653. })
  654. $('.distribution-container').eq(0).append(result);
  655. for (var i = 0; i < list.length; i++) {
  656. $('.num-ipt')[(pageNum1 - 1) * 5 + i].oninput = function (e) {
  657. const id = e.target.dataset.id;
  658. let oldDuration = 0;
  659. let preTotalTime = 0;
  660. let index = e.target.dataset.index;
  661. let value = $('.num-ipt').eq(index).val();
  662. if(value.length >= 5){
  663. value = value.substr(0, 5);
  664. }
  665. var position = String(value).indexOf(".");//获取小数点的位置
  666. if(position != -1){
  667. value = value.substr(0, position);
  668. }
  669. distributionList.map(item => { // 上一次的总数据
  670. preTotalTime += parseInt(item.allotTime);
  671. })
  672. //这一次操作
  673. if(value == 0){
  674. if(!distributionList.find((item) => item.userCardId == id)){
  675. distributionList.push({
  676. userCardId: id,
  677. allotTime: +value
  678. });
  679. }else{
  680. distributionList = distributionList.filter(item => item.userCardId != id);
  681. }
  682. distributionList = distributionList.filter(item => item.allotTime != 0);
  683. }else{
  684. if(!distributionList.find((item) => item.userCardId == id)){
  685. distributionList.push({
  686. userCardId: id,
  687. allotTime: Math.abs(value)
  688. });
  689. }else{
  690. distributionList.map(item => {
  691. if (item.userCardId == id) {
  692. oldDuration = item.allotTime;
  693. item.allotTime = +value;
  694. }
  695. })
  696. }
  697. }
  698. currTotalTime = 0;
  699. distributionList.map(item => { // 这一次的总数据
  700. currTotalTime += parseInt(item.allotTime);
  701. })
  702. if(currTotalTime > unAllotTime){ // 当前已分配大于总分配时长
  703. let val = unAllotTime - preTotalTime + oldDuration;
  704. distributionList.map(item => {
  705. if (item.userCardId == id) {
  706. item.allotTime = val;
  707. }
  708. })
  709. $('.num-ipt').eq(index).val(val);
  710. stopManyClick(() => {
  711. toastr.error('分配时长不能大于未分配总时长');
  712. })
  713. return
  714. }
  715. if(value.length > 5) value = value.slice(0, 5);
  716. $('.num-ipt').eq(index).val(value);
  717. }
  718. }
  719. }
  720. //抽奖记录下拉加载
  721. $('.distribution-container')[0].addEventListener('scroll',function () {
  722. let scrollTop = $('.distribution-container')[0].scrollTop;
  723. let clientHeight = $('.distribution-container')[0].clientHeight;
  724. let scrollHeight = $('.distribution-container')[0].scrollHeight;
  725. if(scrollTop + clientHeight + 100 > scrollHeight){
  726. if(recordFlag1 && pageNum1 < cardList.length && cardList.length > 1){
  727. recordFlag1 = false;
  728. pageNum1++;
  729. pageCardList();
  730. }
  731. }
  732. });
  733. // 分配时长记录
  734. function allotTimeRecord(){
  735. if(!GetRequest().token){
  736. return
  737. }
  738. $.ajax({
  739. url: baseUrl + '/api/activity/gratis/allotTimeRecord',
  740. type: 'get',
  741. headers: {
  742. 'Authorization': GetRequest().token //id
  743. },
  744. data: {
  745. pageNum: pageNum2,
  746. pageSize: 5
  747. },
  748. contentType: "application/json",
  749. dataType: 'json',
  750. cache: false,
  751. success: function (res) {
  752. if(res.status === 0){
  753. let list = res.data.list
  754. let result = ''
  755. pages2 = res.data.pages
  756. recordFlag2 = true;
  757. list.map(item => {
  758. result += $('#record').text().replace(/{{(.*?)}}/g, function(node, key) {
  759. return item[key];
  760. })
  761. })
  762. $('.award-record-list-wrap').eq(0).append(result)
  763. }else{
  764. stopManyClick(() =>{
  765. toastr.error(res.msg)
  766. })
  767. }
  768. }
  769. })
  770. }
  771. //分配时长记录下拉加载
  772. $('.award-record-list-wrap')[0].addEventListener('scroll',function () {
  773. let scrollTop = $('.award-record-list-wrap')[0].scrollTop;
  774. let clientHeight = $('.award-record-list-wrap')[0].clientHeight;
  775. let scrollHeight = $('.award-record-list-wrap')[0].scrollHeight;
  776. if(scrollTop + clientHeight + 100 > scrollHeight){
  777. if(recordFlag2 && pageNum2 < pages2 && pages2 > 1){
  778. recordFlag2 = false;
  779. pageNum2++;
  780. allotTimeRecord('down');
  781. }
  782. }
  783. });
  784. function getTimeHandle(type) {
  785. if(activityState == 0){
  786. stopManyClick(() =>{
  787. toastr.error('活动未开始!');
  788. })
  789. return
  790. }
  791. if(activityState == 2){
  792. stopManyClick(() =>{
  793. toastr.error('活动已结束!');
  794. })
  795. return
  796. }
  797. if(type != 'bug') {
  798. operate('mfhd_2022_h5_获取次数按钮');
  799. }
  800. stopManyClick(() =>{
  801. if (window.__wxjs_environment === 'miniprogram') { // 小程序
  802. if(phoneRemainQuantity > 0){
  803. wx.miniProgram.navigateTo({
  804. url: '/packageA/order/buy/index?type=activity'
  805. })
  806. } else {
  807. wx.miniProgram.navigateTo({
  808. url: '/packageA/order/renew/index?record=' + userCardId
  809. })
  810. }
  811. } else if (isAndroid && window.native) { // 安卓
  812. if(phoneRemainQuantity > 0){
  813. window.native.startPurchase('SVIP', 365);
  814. } else {
  815. window.native.startRenew();
  816. }
  817. } else if (isiOS) {
  818. try {
  819. if(phoneRemainQuantity > 0){
  820. window.webkit.messageHandlers.startPurchase.postMessage({ type: 1, day: 365 });
  821. } else {
  822. window.webkit.messageHandlers.startRenew.postMessage({ type: 1, day: 365 });
  823. }
  824. } catch(error) {
  825. if(phoneRemainQuantity > 0){
  826. uni.webView.navigateTo({
  827. url: '/pages/order/order'
  828. })
  829. } else {
  830. uni.webView.navigateTo({
  831. url: '/pages/order/renew?record=' + userCardId
  832. })
  833. }
  834. }
  835. }
  836. })
  837. }
  838. //点击加减号
  839. $('.distribution-container')[0].addEventListener('click',(e) => {
  840. if(e.target.className === 'add'){
  841. operate('mfhd_2022_h5_加号');
  842. const id = e.target.dataset.id;
  843. let index = e.target.dataset.index;
  844. let number = $('.num-ipt').eq(index).val();
  845. currTotalTime = 0;
  846. // 这一次操作
  847. if(number == 0){
  848. if(!distributionList.find((item) => item.userCardId == id)){
  849. distributionList.push({
  850. userCardId: id,
  851. allotTime: +number + 1
  852. });
  853. }else{
  854. distributionList.map(item => {
  855. if(item.userCardId == id){
  856. item.allotTime++;
  857. }
  858. })
  859. }
  860. }else{
  861. distributionList.map(item => {
  862. if(item.userCardId == id){
  863. item.allotTime++;
  864. }
  865. })
  866. }
  867. distributionList.map(item => { // 这一次的总数据
  868. currTotalTime += parseInt(item.allotTime);
  869. })
  870. if(currTotalTime <= unAllotTime){
  871. number++;
  872. $('.num-ipt').eq(index).val(number);
  873. }else{
  874. distributionList.map(item => {
  875. if(item.userCardId == id){
  876. item.allotTime = +number;
  877. }
  878. })
  879. stopManyClick(() => {
  880. toastr.error('分配时长不能大于未分配总时长');
  881. })
  882. }
  883. console.log(distributionList)
  884. }
  885. if(e.target.className === 'cut'){
  886. operate('mfhd_2022_h5_减号');
  887. const id = e.target.dataset.id;
  888. let index = e.target.dataset.index;
  889. let number = $('.num-ipt').eq(index).val();
  890. if(number > 0){
  891. distributionList.map(item => {
  892. if(item.userCardId == id){
  893. item.allotTime--;
  894. }
  895. })
  896. number--;
  897. if(number == 0){
  898. distributionList = distributionList.filter(item => item.userCardId != id);
  899. }
  900. currTotalTime--;
  901. $('.num-ipt').eq(index).val(number);
  902. }else{
  903. stopManyClick(() => {
  904. toastr.error('分配的时长不能小于0');
  905. })
  906. }
  907. console.log(distributionList)
  908. }
  909. });
  910. function distributionTime(e) {
  911. operate('mfhd_2022_h5_分配奖励');
  912. distributionList = distributionList.filter(item => item.allotTime != 0);
  913. console.log(distributionList)
  914. if (distributionList.length === 0) {
  915. stopManyClick(() => {
  916. toastr.error('未选中任何云手机');
  917. })
  918. } else {
  919. $('.sure-distribution-wrap').eq(0).css('display', 'block');
  920. }
  921. }
  922. //点击分配时长取消按钮
  923. $('.sure-distribution-cannel')[0].addEventListener('click', (e) => {
  924. operate('mfhd_2022_h5_分配奖励_取消');
  925. $('.sure-distribution-wrap').eq(0).css('display', 'none');
  926. });
  927. //点击分配时长确定按钮
  928. $('.sure-distribution-sure')[0].addEventListener('click', (e) => {
  929. stopManyClick(() => {
  930. $.ajax({
  931. url: baseUrl + '/api/activity/gratis/allotTime',
  932. type: 'post',
  933. data: JSON.stringify(distributionList),
  934. headers: {
  935. 'Authorization': GetRequest().token //id
  936. },
  937. contentType: "application/json",
  938. dataType: 'json',
  939. cache: false,
  940. success: function (res) {
  941. if(res.status === 0){
  942. operate('mfhd_2022_h5_分配奖励_确定');
  943. $('.sure-distribution-wrap').eq(0).css('display', 'none');
  944. $('.slider-list').eq(0).text('');
  945. $('.page-number').eq(0).text('');
  946. init();
  947. pageNum2 = 1;
  948. pages2 = 0;
  949. allotTimeRecord();
  950. distributionPageNum = 1;
  951. $('.time-row-data').eq(0).text('');
  952. distributionList.map((val) => {
  953. cardList.map((item, indexs) => {
  954. if(val.userCardId == item.userCardId){
  955. $('.num-ipt').eq(indexs).val(0);
  956. }
  957. })
  958. })
  959. distributionList = [];
  960. cardList = [];
  961. stopManyClick(() => {
  962. toastr.error('分配成功,请前往云机列表查看');
  963. })
  964. } else {
  965. console.log(res.msg)
  966. $('.sure-distribution-wrap').eq(0).css('display', 'none');
  967. stopManyClick(() => {
  968. toastr.error(res.msg);
  969. })
  970. }
  971. },
  972. })
  973. })
  974. });
  975. function ruleHandle (e) {
  976. operate('mfhd_2022_h5_规则');
  977. $('.rule-result-dialog').animate({top: '3.86rem'},"fast");
  978. $('.rule-mask').show();
  979. document.documentElement.style.overflow='hidden';
  980. }
  981. function ruleClose (e) {
  982. operate('mfhd_2022_h5_关闭规则');
  983. $('.rule-result-dialog').animate({top: '-10.96rem'},"fast");
  984. $('.rule-mask').hide();
  985. document.documentElement.style.overflow='auto';
  986. }
  987. function cardClose (e) {
  988. operate('mfhd_2022_h5_关闭抽奖结果');
  989. $('.result-dialog').animate({top: '-10.96rem'},"fast");
  990. $('.result-mask').hide();
  991. document.documentElement.style.overflow='auto';
  992. }
  993. //获取云机数量
  994. function getPhoneNumber(){
  995. $.ajax({
  996. url: baseUrl + '/api/pay/v2/meal/info?phoneType=SVIP',
  997. type: 'get',
  998. headers: {
  999. 'Authorization': GetRequest().token //id
  1000. },
  1001. contentType: "application/json",
  1002. dataType: 'json',
  1003. cache: false,
  1004. success: function (res) {
  1005. if(res.status === 0){
  1006. phoneRemainQuantity = res.data.list[0].phoneRemainQuantity;
  1007. }else{
  1008. stopManyClick(() =>{
  1009. toastr.error(res.msg)
  1010. })
  1011. }
  1012. },
  1013. })
  1014. }
  1015. init();
  1016. })(document);
  1017. //埋点
  1018. function operate(pointName){
  1019. $.ajax({
  1020. url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
  1021. type: 'post',
  1022. data:JSON.stringify({
  1023. pointName: pointName
  1024. }),
  1025. contentType:"application/json",
  1026. dataType: 'json',
  1027. cache: false,
  1028. success: function (res) {},
  1029. })
  1030. }
  1031. //防止提示一秒内重复显示
  1032. function stopManyClick(fn) {
  1033. if (flag) {
  1034. fn();
  1035. }
  1036. flag = false;
  1037. if(timer){clearTimeout(timer);}
  1038. timer = setTimeout(() => {flag = true}, 1500);
  1039. }
  1040. </script>
  1041. </body>
  1042. </html>