1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
- <title>免费活动</title>
- <link rel="icon" href="../static/img/favicon2.ico" type="img/x-ico">
- <link rel="stylesheet" href="../static/js/vender/toastr/toastr.min.css">
- <link rel="stylesheet" href="../static/css/awardActivity.css">
- <script src="../static/js/vender/jquery-3.4.1.min.js"></script>
- <script src="../static/js/vender/toastr/toastr.min.js"></script>
- <script src="../static/js/vender/config.js"></script>
- </head>
- <body>
- <div class="container">
- <div class="all-bg-wrap">
- <img class="all-bg-img" src="../static/img/awardActivity/all-bg.png" />
- </div>
- <div class="rule-wrap">活动规则</div>
- <div class="time-position"></div>
- <div class="time-wrap"></div>
- <div class="top-container">
- <img class="top-bg-one" src="../static/img/awardActivity/top-bg-one.png" />
- <img class="top-bg-two" src="../static/img/awardActivity/top-bg-two.png" />
- <div class="get-award-container">
- <div class="award-lists"></div>
- </div>
- <div class="all-award-wrap"></div>
- </div>
- <div class="rest-wrap">
- <div class="award-btn-wrap">
- <img class="start-award" src="../static/img/awardActivity/bug-phone.png" />
- </div>
- <div class="get-time-wrap">
- <div class="rest-time">剩余抽奖次数 <span class="times"></span>次</div>
- <div class="get-time-btn">获取次数</div>
- </div>
- <div class="tab-wrap">
- <img class="tab-bg1" src="../static/img/awardActivity/tab-bg1.png" />
- <img class="tab-bg2" src="../static/img/awardActivity/tab-bg2.png" />
- <img class="tab-bg3" src="../static/img/awardActivity/tab-bg3.png" />
- <img class="tab-bg4" src="../static/img/awardActivity/tab-bg4.png" />
- <div class="award-container">
- <div class="award-title-wrap">
- <div class="award-title active-title">奖励一览</div>
- <div class="award-title">分配奖励(<span class="all-times"></span>)</div>
- </div>
- <div class="award-list">
- <div class="award-list-title-wrap">
- <div class="award-list-title">时间</div>
- <div class="award-list-title">奖品</div>
- </div>
- <div class="award-list-wrap"></div>
- </div>
- <div class="distribution-wrap">
- <div class="distribution-list-wrap">
- <div class="distribution-list">
- <div class="distribution-total-wrap">
- <div class="award-total-data">奖励总时长<span class="red"></span>天</div>
- <div class="award-total-data">已分配时长<span class="red"></span>天</div>
- <div class="award-total-data">未分配时长<span class="red"></span>天</div>
- </div>
- <div class="distribution-container"></div>
- <div class="distribution-award-btn">分配奖励</div>
- </div>
- <div class="award-record-list">
- <div class="record-list-title">分配时长记录</div>
- <div class="award-record-list-title-wrap">
- <div class="award-record-list-title">云机名称</div>
- <div class="award-record-list-title">时间</div>
- <div class="award-record-list-title">时长</div>
- </div>
- <div class="award-record-list-wrap"></div>
- </div>
- </div>
- </div>
- <div class="no-award-data">
- <img class="no-award-img" src="../static/img/awardActivity/no-award.png" />
- <div class="no-award-text">没有抽奖记录,我都替你着急~</div>
- </div>
- <div class="no-distribution-data">
- <img class="no-distribution-img" src="../static/img/awardActivity/no-data.png" />
- <div class="no-distribution-text">先购买云手机,才能分配喔~</div>
- </div>
- </div>
- </div>
- </div>
- <div class="rule-mask">
- <div class="rule-result-dialog">
- <div class="rule-content">
- <div class="rule-title-wrap">
- <div class="rule-title-icon"></div>
- <div class="rule-title">活动规则</div>
- <div class="rule-title-icon"></div>
- </div>
- <div class="rule-point-wrap" style="white-space: pre-line;">
- <!-- <div class="rule-point">1、活动期间,购买获得的抽取资格不限次数, 活动期间可用,活动结束后未使用的做过期处理。</div>
- <div class="rule-point">2、参与活动的套餐是星曜月卡与年卡套餐,其他套餐不参与活动。</div>
- <div class="rule-point">3、星币、激活码购买的订单不参与本次活动。</div>
- <div class="rule-point">4、抽取的奖励只能新增云机,请去云手机首页查看。</div>
- <div class="rule-point">5、活动结束后3天保留奖励分配入口,但不能再参与活动。</div>
- <div class="rule-point">6、双子星官方对活动具有最终解释权。</div> -->
- </div>
- </div>
- <img class="rule-close" src="../static/img/anniversaryCelebrate/close.png" />
- </div>
- </div>
- <div class="result-mask">
- <div class="result-dialog">
- <div class="result-content">
- <div class="rule-title-wrap result-title-wrap">
- <div class="rule-title-icon"></div>
- <div class="rule-title result-title">换个姿势,再抽一次</div>
- <div class="rule-title-icon"></div>
- </div>
- <div class="main-contain"></div>
- </div>
- <img class="card-close" src="../static/img/anniversaryCelebrate/close.png" />
- </div>
- </div>
- <div class="sure-distribution-wrap">
- <div class="sure-distribution-box">
- <div class="sure-distribution-title">确定分配奖励时长</div>
- <div class="sure-distribution-btn-list">
- <div class="sure-distribution-btn sure-distribution-cannel">取消</div>
- <div class="sure-distribution-btn sure-distribution-sure">确定</div>
- </div>
- </div>
- </div>
- </div>
-
- <script type="text/html" id="card">
- <img class="card-img" src="{{icon}}" />
- <div class="card-title">{{goodsName}}</div>
- <div class="card-tips">{{tips}}</div>
- <div class="card-btn">{{cardBtn}}</div>
- <div class="card-rest-times">剩余次数{{lotteryCount}}次</div>
- </script>
- <script type="text/html" id="award1">
- <div class="curr-award-item curr-award-item-one">
- <div class="curr-award-img curr-award-img-one">
- <img class="award-img curr-award-img-one" src="{{icon}}" />
- </div>
- <div class="curr-award-name">{{goodsName}}</div>
- <div class="curr-award-id">{{id}}</div>
- </div>
- </script>
- <script type="text/html" id="award2">
- <div class="curr-award-item">
- <img class="award-img" src="{{icon}}" />
- <div class="curr-award-name">{{goodsName}}</div>
- <div class="curr-award-id">{{id}}</div>
- </div>
- </script>
- <script type="text/html" id="awardRecord">
- <div class="award-list-item">
- <div class="award-list-content">{{createTime}}</div>
- <div class="award-list-content">{{goodsName}}</div>
- </div>
- </script>
- <script type="text/html" id="distribution">
- <div class="distribution-item">
- <div class="distribution-main-content">
- <img class="phone-logo" src="{{icon}}" />
- <div class="distribution-info">
- <div class="distribution-name">{{diskName}}</div>
- <div class="distribution-time">{{timeLeft}}</div>
- </div>
- </div>
- <div class="change-num-wrap">
- <div class="cut" data-id={{userCardId}} data-index={{index}}>-</div>
- <input class="num-ipt" type="number" onkeyup="this.value=this.value.replace(/-/g,'')" value="0" data-id={{userCardId}} data-index={{index}} />
- <div class="add" data-id={{userCardId}} data-index={{index}}>+</div>
- </div>
- </div>
- </script>
- <script type="text/html" id="record">
- <div class="award-record-list-item">
- <div class="award-record-list-content award-record-list-name">{{diskName}}</div>
- <div class="award-record-list-content award-record-list-time">{{createTime}}</div>
- <div class="award-record-list-content award-record-list-day">{{validTime}}</div>
- </div>
- </script>
- <script>
- toastr.options.positionClass = 'toast-center-center';
- toastr.options.timeOut = '1500';
- </script>
- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
- <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>
- <script type="text/javascript">
- // var baseUrl = 'http://gntest.phone.androidscloud.com:1280'
- const fileCenterApi = 'https://file.phone.androidscloud.com:8121';
- let uploadKey = ''
- if (window.location.origin.includes('client.phone.androidscloud.com')) {
- uploadKey = 'edv834e74a9c43eaac02'
- } else if (window.location.origin.includes('prese.phone.androidscloud')) {
- uploadKey = '347905r86eb745a1sc38'
- } else {
- uploadKey = '13d0arghebcc4cm49cf04'
- }
- let timer,flag = true;
- var url = window.location.href;
- url = url.split('/')
- var loc = window.location.search,
- n1 = loc.length,//地址的总长度
- n2 = loc.indexOf("="),//取得=号的位置
- id = loc.substr(n2 + 1, n1 - n2),//从=号后面的内容
- u = navigator.userAgent,
- ua = navigator.userAgent.toLowerCase(),
- awardData = [],
- distributionList = [],
- topVal = -0.5,
- unAllotTime = 0,
- recordFlag = true,
- pageNum = 1,
- pages = 0,
- recordFlag1 = true,
- pageNum1 = 0,
- recordFlag2 = true,
- pageNum2 = 1,
- pages2 = 0,
- cardList = [],
- lotteryCount = 0,
- lotteryResult = {},
- lotteryFlag = true,
- activityState = 0,
- awardNumber = 0,
- currTotalTime = 0,
- phoneRemainQuantity = 0,
- userCardId = 0,
- awardTimer = null,
- tab = 1,
- buyVipType = 'SVIP',
- flagNum = 1;
- isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
- isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
- (function(doc) {
- var init = function () {
- getPhoneNumber();
- bindEvent();
- goodsList();
- rewardList();
- allotTimeRecord();
- allotTimeCardList();
- }
- function bindEvent () {
- //点击开始抽奖
- $('.start-award')[0].addEventListener('click', startLottery, false);
- //点击继续抽奖
- $('.main-contain')[0].addEventListener('click', nextLottery, false);
- //点击抽奖结果关闭弹窗
- $('.card-close')[0].addEventListener('click', cardClose, false);
- //点击获取次数
- $('.get-time-btn')[0].addEventListener('click',getTimeHandle,false);
- //tab切换
- $('.award-title')[0].addEventListener('click', tabHandle1, false);
- $('.award-title')[1].addEventListener('click', tabHandle2, false);
- //点击分配时长按钮
- $('.distribution-award-btn')[0].addEventListener('click', distributionTime, false);
- //点击规则
- $('.rule-wrap')[0].addEventListener('click', ruleHandle, false);
- //关闭规则
- $('.rule-close')[0].addEventListener('click', ruleClose, false);
- }
- function tabHandle1 (e) {
- tab = 1;
- operate('mfhd_2022_h5_tab奖励一览');
- $('.tab-bg1').eq(0).css('display', 'block');
- $('.tab-bg2').eq(0).css('display', 'none');
- $('.tab-bg3').eq(0).css('display', 'none');
- $('.tab-bg4').eq(0).css('display', 'none');
- $('.tab-wrap').eq(0).css('height', '5.75rem');
- $('.award-title')[0].className = 'award-title active-title';
- $('.award-title')[1].className = 'award-title';
- $('.award-list').eq(0).css('display', 'block');
- $('.no-distribution-data').eq(0).css('display', 'none');
- $('.distribution-list-wrap').eq(0).css('display', 'none');
- if(pages === 0) {
- $('.no-award-data').eq(0).css('display', 'block');
- $('.award-list').eq(0).css('display', 'none');
- } else {
- $('.award-list').eq(0).css('display', 'block');
- $('.no-award-data').eq(0).css('display', 'none');
- }
- }
- function tabHandle2 (e) {
- tab = 2;
- if(activityState == 0){
- stopManyClick(() =>{
- toastr.error('活动未开始!');
- })
- return
- }
- operate('mfhd_2022_h5_tab分配奖励');
- $('.tab-bg1').eq(0).css('display', 'none');
- $('.award-title')[0].className = 'award-title';
- $('.award-title')[1].className = 'award-title active-title';
- $('.distribution-list-wrap').eq(0).css('display', 'block');
- $('.award-list').eq(0).css('display', 'none');
- $('.no-award-data').eq(0).css('display', 'none');
- if(cardList.length === 0) {
- $('.tab-bg2').eq(0).css('display', 'none');
- $('.tab-bg3').eq(0).css('display', 'none');
- $('.tab-bg4').eq(0).css('display', 'block');
- $('.tab-wrap').eq(0).css('height', '5.76rem');
- $('.distribution-list-wrap').eq(0).css('display', 'none');
- $('.no-distribution-data').eq(0).css('display', 'block');
- } else if(pages2 == 0) {
- $('.tab-bg4').eq(0).css('display', 'none');
- $('.tab-bg2').eq(0).css('display', 'none');
- $('.tab-bg3').eq(0).css('display', 'block');
- $('.tab-wrap').eq(0).css('height', '9.05rem');
- } else {
- $('.tab-bg4').eq(0).css('display', 'none');
- $('.tab-bg3').eq(0).css('display', 'none');
- $('.tab-bg2').eq(0).css('display', 'block');
- $('.award-record-list').eq(0).css('display', 'block');
- $('.tab-wrap').eq(0).css('height', '14.75rem');
- }
- }
- // 继续抽奖
- function nextLottery(e) {
- if(e.target.className === 'card-btn'){
- cardClose();
- stopManyClick(() =>{
- startLottery('next');
- })
- }
- }
- function animation(num, time, result) {
- if(num >= 0) {
- $('.curr-award-item').eq(num).css('background', '#ffffff');
- }
- num++;
- $('.curr-award-item').eq(num).css('background', '#FAE892');
- if(time < 160) {
- time += 30;
- } else if(num === flagNum - 5) {
- time += 50;
- } else if(num === flagNum - 4) {
- time += 100;
- } else if(num === flagNum - 3) {
- time += 200;
- } else if(num === flagNum - 2) {
- time += 300;
- } else if(num === flagNum - 1) {
- time += 300;
- } else if(num === flagNum) {
- time += 100;
- } else {
- time += 30;
- }
- let flag = $('.curr-award-id').eq(num).text();
- if(flag == lotteryResult.id){
- flagNum = num < 6 ? num + awardNumber : num;
- }
- timer = setTimeout(() => {
- if(num === awardNumber) {
- num = -1;
- animation(num, time);
- } else if(flag == lotteryResult.id && time > 500) {
- lotteryResultHandle();
- clearTimeout(timer);
- } else {
- animation(num, time)
- }
- }, time)
-
- }
- // 开始抽奖
- function startLottery(type){
- if(activityState == 0){
- stopManyClick(() =>{
- toastr.error('活动未开始!');
- })
- return
- }
- if(activityState == 2){
- stopManyClick(() =>{
- toastr.error('活动已结束!');
- })
- return
- }
- if(lotteryCount <= 0) {
- operate('mfhd_2022_h5_购买云机');
- getTimeHandle('buy');
- return
- } else if(type === 'next') {
- operate('mfhd_2022_h5_继续抽奖');
- } else {
- operate('mfhd_2022_h5_开始抽奖');
- }
- if(!lotteryFlag) {
- return
- }
- lotteryFlag = false;
- if(!GetRequest().token){
- return
- }
- let num = flagNum > awardNumber ? flagNum - awardNumber : flagNum;
- $('.curr-award-item').eq(num).css('background', '#ffffff');
- $.ajax({
- url: baseUrl + '/api/activity/gratis/startLottery',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- data: {
- clientType: GetRequest().clientType
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- let time = 20;
- let num = -1;
- lotteryResult = res.data;
- animation(num, time, 3);
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- lotteryFlag = true
- }
- }
- })
- }
- //抽奖结果展示
- function lotteryResultHandle() {
- $('.main-contain').eq(0).empty();
- $('.result-dialog').animate({top: '3.86rem'},"fast");
- $('.result-mask').show();
- document.documentElement.style.overflow='hidden';
- lotteryFlag = true;
- let result = '';
- lotteryCount--;
- lotteryResult.lotteryCount = lotteryCount;
- lotteryResult.tips = lotteryResult.goodsType != 5 ?'奖励已发送您的账户内,请注意查收' : '中奖不是最终的追求,重要的是开心咯';
- lotteryResult.cardBtn = lotteryResult.lotteryCount != 0 ?'继续抽奖' : '获取次数';
- let text = lotteryResult.lotteryCount != 0 ?'换个姿势,再抽一次' : '次数用完,点击获取';
- $('.result-title').eq(0).text(text)
- if(lotteryCount === 0) {
- $('.start-award')[0].src = '../static/img/awardActivity/bug-phone.png';
- }
- lotteryResult.icon = `https://file.phone.androidscloud.com:8121/document/newFile/download/0/${uploadKey}?fileKey=${lotteryResult.icon}`
- result = $('#card').text().replace(/{{(.*?)}}/g, function(node, key) {
- return lotteryResult[key];
- })
- goodsList();
- pageNum = 1;
- rewardList();
- allotTimeCardList();
- $('.main-contain').eq(0).append(result)
- if(awardNumber === 9) {
- $('.card-img')[0].className = 'card-img card-img1';
- } else {
- $('.card-img')[0].className = 'card-img card-img2';
- }
- $('.times').eq(0).text(lotteryResult.lotteryCount)
- }
- // 抽奖记录
- function rewardList(type){
- if(!GetRequest().token){
- return
- }
- $.ajax({
- url: baseUrl + '/api/activity/gratis/rewardList',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- data: {
- page: pageNum,
- pageSize: 5
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- recordFlag = true;
- let list = res.data.list
- pages = res.data.pages;
- if(type != 'down'){
- $('.award-list-wrap').eq(0).empty();
- }
- if(pages === 0) {
- $('.no-award-data').eq(0).css('display', 'block');
- $('.award-list').eq(0).css('display', 'none');
- } else {
- $('.award-list').eq(0).css('display', 'block');
- $('.no-award-data').eq(0).css('display', 'none');
- }
- let result = ''
- list.map((item, index) => {
- item.createTime = `${item.createTime.substring(5, 7)}月${item.createTime.substring(8, 10)}日${item.createTime.substring(11)}`
- result += $('#awardRecord').text().replace(/{{(.*?)}}/g, function(node, key) {
- return item[key];
- })
- })
- $('.award-list-wrap').eq(0).append(result)
- if(tab === 2) {
- $('.award-list').eq(0).css('display', 'none');
- $('.no-award-data').eq(0).css('display', 'none');
- }
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
- }
- })
- }
- //抽奖记录下拉加载
- $('.award-list-wrap')[0].addEventListener('scroll',function () {
- let scrollTop = $('.award-list-wrap')[0].scrollTop;
- let clientHeight = $('.award-list-wrap')[0].clientHeight;
- let scrollHeight = $('.award-list-wrap')[0].scrollHeight;
- if(scrollTop + clientHeight + 100 > scrollHeight){
- if(recordFlag && pageNum < pages && pages > 1){
- recordFlag = false;
- pageNum++;
- rewardList('down');
- }
- }
- });
- // 活动基础数据
- function goodsList(){
- if(!GetRequest().token){
- return
- }
- $.ajax({
- url: baseUrl + '/api/activity/gratis/goodsList',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- let startTime = res.data.startTime
- let endTime = res.data.endTime
- $('.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)}日`);
- awardData = res.data.marquee
- let goodsInfos = res.data.goodsInfos
- lotteryCount = res.data.lotteryCount
- activityState = res.data.activityState
- awardNumber = goodsInfos.length
- let actRule = res.data.actRule
- let result = ''
- let resultDom = goodsInfos.length === 9 ? $('#award1') : $('#award2');
- if(goodsInfos.length === 9) {
- $(".top-bg-one").css({"display": "block"})
- $(".all-award-wrap").css({"marginLeft": "0.1rem"})
- $(".top-bg-two").css({"display": "none"})
- } else {
- $(".top-bg-one").css({"display": "none"})
- $(".all-award-wrap").css({"marginLeft": "0.14rem"})
- $(".top-bg-two").css({"display": "block"})
- }
- goodsInfos.map((item, index) => {
- item.index = index
- item.icon = `https://file.phone.androidscloud.com:8121/document/newFile/download/0/${uploadKey}?fileKey=${item.icon}`
- result += resultDom.text().replace(/{{(.*?)}}/g, function(node, key) {
- return item[key];
- })
- })
- if(lotteryCount > 0) {
- $('.start-award')[0].src = '../static/img/awardActivity/start-award.png';
- }
- clearInterval(awardTimer);
- headerAward();
- $('.rule-point-wrap').eq(0).html(actRule)
- $('.times').eq(0).text(lotteryCount)
- let content = $('.all-award-wrap').eq(0).text();
- if(!content){
- $('.all-award-wrap').eq(0).append(result)
- }
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
- }
- })
- }
- //轮播
- function headerAward(){
- if(awardData.length === 0) {
- return
- }
- awardTimer = setInterval(() =>{
- awardHandle();
- },3000);
- }
- function awardHandle(){
- let index = (topVal/0.5) + 1,awardString;
- let awardLen = Array.from($('.award-text')).length;
- if(awardLen < awardData.length){
- let node = document.createElement('div');
- node.className = "award-text";
- $('.award-lists')[0].appendChild(node);
- }
- if(topVal < awardData.length/2 - 0.5){
- topVal+=0.5;
- }else{
- topVal = 0;
- $('.award-lists').eq(0).css('top','0.5rem');
- }
- let numberType = Math.floor(getRandom()/4);
- if(awardData && awardData[index] && topVal < awardData.length/2){
- awardString = `恭喜${awardData[index].phone}用户获得${awardData[index].goodsName}奖品`;
- }
- // else{
- // awardString = `恭喜1${[3,5,7,8,3,5,7,8,3,5][getRandom()]}${getRandom()}****${getRandom()}${getRandom()}${getRandom()}${getRandom()}用户获得${['优惠券','激活码','云机时长','星币','云机套餐','谢谢惠顾'][numberType]}`
- // }
- $('.award-text').eq(index).text(awardString);
- $('.award-lists').eq(0).animate({top: -(topVal) + 'rem'},"fast");
- }
- // 获取一个随机数
- function getRandom(){
- return Math.floor(Math.random()*10);
- }
- // 分配云手机列表
- function allotTimeCardList(type){
- pageNum1 = 0;
- recordFlag1 = false;
- $('.distribution-container').eq(0).empty();
- if(!GetRequest().token){
- return
- }
- $.ajax({
- url: baseUrl + '/api/activity/gratis/allotTimeCardList',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- cardList = res.data.cardList
- unAllotTime = res.data.unAllotTime
- if(cardList && cardList.length > 0) {
- cardList.map(item => {
- if(item.buyVipType === 'SVIP') {
- userCardId = item.userCardId
- }
- })
- if(userCardId === 0) {
- buyVipType = cardList[0] && cardList[0].buyVipType || 'SVIP'
- userCardId = cardList[0] && cardList[0].userCardId || 0
- }
- }
- pageCardList()
- $('.all-times').eq(0).text(unAllotTime)
- $('.red').eq(0).text(res.data.totalTime)
- $('.red').eq(1).text(res.data.allotTime)
- $('.red').eq(2).text(unAllotTime)
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
- }
- })
- }
- // 分页渲染数据
- function pageCardList() {
- let result = '';
- recordFlag1 = true;
- let list = cardList.slice(pageNum1 * 5, (pageNum1 * 5) + 5);
- let mealTypeObj = {
- VIP: 'card1.png',
- SVIP: 'card2.jpg',
- STAR: 'card3.png',
- STARPRO: 'card4.png'
- }
- list.map((item, index) => {
- item.index = pageNum1 * 5 + index
- item.icon = `../static/img/awardActivity/${mealTypeObj[item.buyVipType]}`
- result += $('#distribution').text().replace(/{{(.*?)}}/g, function(node, key) {
- return item[key];
- })
- })
- $('.distribution-container').eq(0).append(result);
- for (var i = 0; i < list.length; i++) {
- $('.num-ipt')[pageNum1 * 5 + i].oninput = function (e) {
- const id = e.target.dataset.id;
- let oldDuration = 0;
- let preTotalTime = 0;
- let index = e.target.dataset.index;
- let value = $('.num-ipt').eq(index).val();
- if(value.length >= 5){
- value = value.substr(0, 5);
- }
- var position = String(value).indexOf(".");//获取小数点的位置
- if(position != -1){
- value = value.substr(0, position);
- }
- distributionList.map(item => { // 上一次的总数据
- preTotalTime += parseInt(item.allotTime);
- })
- //这一次操作
- if(value == 0){
- if(!distributionList.find((item) => item.userCardId == id)){
- distributionList.push({
- userCardId: id,
- allotTime: +value
- });
- }else{
- distributionList = distributionList.filter(item => item.userCardId != id);
- }
- distributionList = distributionList.filter(item => item.allotTime != 0);
- }else{
- if(!distributionList.find((item) => item.userCardId == id)){
- distributionList.push({
- userCardId: id,
- allotTime: Math.abs(value)
- });
- }else{
- distributionList.map(item => {
- if (item.userCardId == id) {
- oldDuration = item.allotTime;
- item.allotTime = +value;
- }
- })
- }
- }
- currTotalTime = 0;
- distributionList.map(item => { // 这一次的总数据
- currTotalTime += parseInt(item.allotTime);
- })
- if(currTotalTime > unAllotTime){ // 当前已分配大于总分配时长
- let val = unAllotTime - preTotalTime + oldDuration;
- distributionList.map(item => {
- if (item.userCardId == id) {
- item.allotTime = val;
- }
- })
- $('.num-ipt').eq(index).val(val);
- if(!lotteryFlag) {
- return
- } else {
- stopManyClick(() => {
- toastr.error('分配时长不能大于未分配总时长');
- })
- return
- }
- }
- if(value.length > 5) value = value.slice(0, 5);
- $('.num-ipt').eq(index).val(value);
- }
- }
- }
- //抽奖记录下拉加载
- $('.distribution-container')[0].addEventListener('scroll',function () {
- let scrollTop = $('.distribution-container')[0].scrollTop;
- let clientHeight = $('.distribution-container')[0].clientHeight;
- let scrollHeight = $('.distribution-container')[0].scrollHeight;
- if(scrollTop + clientHeight + 100 > scrollHeight){
- if(recordFlag1 && pageNum1 < (cardList.length/5) && (cardList.length/5) > 1){
- recordFlag1 = false;
- pageNum1++;
- pageCardList();
- }
- }
- });
- // 分配时长记录
- function allotTimeRecord(type){
- if(!GetRequest().token){
- return
- }
- $.ajax({
- url: baseUrl + '/api/activity/gratis/allotTimeRecord',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- data: {
- page: pageNum2,
- pageSize: 5
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- let list = res.data.list
- let result = ''
- pages2 = res.data.pages
- recordFlag2 = true;
- if(type != 'down'){
- $('.award-record-list-wrap').eq(0).empty();
- }
- list.map(item => {
- item.createTime = `${item.createTime.substring(0, 4)}年${item.createTime.substring(5, 7)}月${item.createTime.substring(8, 10)}日${item.createTime.substring(11)}`
- result += $('#record').text().replace(/{{(.*?)}}/g, function(node, key) {
- return item[key];
- })
- })
- $('.award-record-list-wrap').eq(0).append(result)
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
-
- }
- })
- }
- //分配时长记录下拉加载
- $('.award-record-list-wrap')[0].addEventListener('scroll',function () {
- let scrollTop = $('.award-record-list-wrap')[0].scrollTop;
- let clientHeight = $('.award-record-list-wrap')[0].clientHeight;
- let scrollHeight = $('.award-record-list-wrap')[0].scrollHeight;
- if(scrollTop + clientHeight + 100 > scrollHeight){
- if(recordFlag2 && pageNum2 < pages2 && pages2 > 1){
- recordFlag2 = false;
- pageNum2++;
- allotTimeRecord('down');
- }
- }
- });
- function getTimeHandle(type) {
- if(activityState == 0){
- stopManyClick(() =>{
- toastr.error('活动未开始!');
- })
- return
- }
- if(activityState == 2){
- stopManyClick(() =>{
- toastr.error('活动已结束!');
- })
- return
- }
- if(!lotteryFlag) {
- return
- }
- if(type != 'bug') {
- operate('mfhd_2022_h5_获取次数按钮');
- }
- stopManyClick(() =>{
- if (window.__wxjs_environment === 'miniprogram') { // 小程序
- if(phoneRemainQuantity > 0){
- wx.miniProgram.navigateTo({
- url: '/packageA/order/buy/index?type=activity'
- })
- } else {
- if(buyVipType != 'SVIP') {
- toastr.error('请前往APP进行续费喔!');
- return
- }
- wx.miniProgram.navigateTo({
- url: `/packageA/order/renew/index?record=${userCardId}`
- })
- }
- } else if (isAndroid && window.native) { // 安卓
- if(phoneRemainQuantity > 0){
- window.native.startPurchase('SVIP', 365);
- } else {
- window.native.startRenew(buyVipType);
- }
- } else if (isiOS) {
- try {
- if(phoneRemainQuantity > 0){
- window.webkit.messageHandlers.startPurchase.postMessage({ type: 1, day: 365 });
- } else {
- window.webkit.messageHandlers.startRenew.postMessage({buyVipType: buyVipType, type: 1, day: 365 });
- }
- } catch(error) {
- if(phoneRemainQuantity > 0){
- uni.webView.navigateTo({
- url: '/pages/order/order'
- })
- } else {
- uni.webView.navigateTo({
- url: `/pages/order/renew?userCardId=${userCardId}&buyVipType=${buyVipType}`
- })
- }
- }
-
- }
- })
- }
- //点击加减号
- $('.distribution-container')[0].addEventListener('click',(e) => {
- if(!lotteryFlag) {
- return
- }
- console.log(e.target.className)
- if(e.target.className === 'add'){
- operate('mfhd_2022_h5_加号');
- const id = e.target.dataset.id;
- let index = e.target.dataset.index;
- let number = $('.num-ipt').eq(index).val();
- currTotalTime = 0;
- // 这一次操作
- if(number == 0){
- if(!distributionList.find((item) => item.userCardId == id)){
- distributionList.push({
- userCardId: id,
- allotTime: +number + 1
- });
- }else{
- distributionList.map(item => {
- if(item.userCardId == id){
- item.allotTime++;
- }
- })
- }
- }else{
- distributionList.map(item => {
- if(item.userCardId == id){
- item.allotTime++;
- }
- })
- }
- distributionList.map(item => { // 这一次的总数据
- currTotalTime += parseInt(item.allotTime);
- })
- if(currTotalTime <= unAllotTime){
- number++;
- $('.num-ipt').eq(index).val(number);
- }else{
- distributionList.map(item => {
- if(item.userCardId == id){
- item.allotTime = +number;
- }
- })
- stopManyClick(() => {
- toastr.error('分配时长不能大于未分配总时长');
- })
- }
- }
- if(e.target.className === 'cut'){
- operate('mfhd_2022_h5_减号');
- const id = e.target.dataset.id;
- let index = e.target.dataset.index;
- let number = $('.num-ipt').eq(index).val();
- if(number > 0){
- distributionList.map(item => {
- if(item.userCardId == id){
- item.allotTime--;
- }
- })
- number--;
- if(number == 0){
- distributionList = distributionList.filter(item => item.userCardId != id);
- }
- currTotalTime--;
- $('.num-ipt').eq(index).val(number);
- }else{
- stopManyClick(() => {
- toastr.error('分配的时长不能小于0');
- })
- }
- }
- });
- async function distributionTime(e) {
- if(!lotteryFlag) {
- return
- }
- let res = await isShow();
- if(res == 0) {
- stopManyClick(() =>{
- toastr.error('活动已结束!');
- })
- return
- }
- operate('mfhd_2022_h5_分配奖励');
- distributionList = distributionList.filter(item => item.allotTime != 0);
- if (distributionList.length === 0) {
- stopManyClick(() => {
- toastr.error('未选中任何云手机');
- })
- } else {
- $('.sure-distribution-wrap').eq(0).css('display', 'block');
- }
- }
- // 活动结束是否超过三天
- function isShow(){
- return new Promise((resolve, reject) => {
- $.ajax({
- url: baseUrl + '/api/activity/gratis/isShow',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- contentType:"application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- resolve(res.data)
- },
- })
- })
- }
- //点击分配时长取消按钮
- $('.sure-distribution-cannel')[0].addEventListener('click', (e) => {
- operate('mfhd_2022_h5_分配奖励_取消');
- $('.sure-distribution-wrap').eq(0).css('display', 'none');
- });
- //点击分配时长确定按钮
- $('.sure-distribution-sure')[0].addEventListener('click', (e) => {
- stopManyClick(() => {
- $.ajax({
- url: baseUrl + '/api/activity/gratis/allotTime',
- type: 'post',
- data: JSON.stringify(distributionList),
- headers: {
- 'Authorization': GetRequest().token //id
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- operate('mfhd_2022_h5_分配奖励_确定');
- $('.sure-distribution-wrap').eq(0).css('display', 'none');
- $('.slider-list').eq(0).text('');
- $('.page-number').eq(0).text('');
- init();
- pageNum2 = 1;
- pages2 = 0;
- allotTimeRecord();
- distributionPageNum = 1;
- $('.time-row-data').eq(0).text('');
- distributionList.map((val) => {
- cardList.map((item, indexs) => {
- if(val.userCardId == item.userCardId){
- $('.num-ipt').eq(indexs).val(0);
- }
- })
- })
- distributionList = [];
- cardList = [];
- $('.tab-bg4').eq(0).css('display', 'none');
- $('.tab-bg3').eq(0).css('display', 'none');
- $('.tab-bg2').eq(0).css('display', 'block');
- $('.award-record-list').eq(0).css('display', 'block');
- $('.tab-wrap').eq(0).css('height', '14.75rem');
- toastr.error('分配成功,请前往云机列表查看');
- } else {
- console.log(res.msg)
- $('.sure-distribution-wrap').eq(0).css('display', 'none');
- toastr.error(res.msg);
- }
- },
- })
- })
- });
- function ruleHandle (e) {
- operate('mfhd_2022_h5_规则');
- $('.rule-result-dialog').animate({top: '3.86rem'},"fast");
- $('.rule-mask').show();
- document.documentElement.style.overflow='hidden';
- }
- function ruleClose (e) {
- operate('mfhd_2022_h5_关闭规则');
- $('.rule-result-dialog').animate({top: '-10.96rem'},"fast");
- $('.rule-mask').hide();
- document.documentElement.style.overflow='auto';
- }
- function cardClose (e) {
- operate('mfhd_2022_h5_关闭抽奖结果');
- $('.result-dialog').animate({top: '-10.96rem'},"fast");
- $('.result-mask').hide();
- document.documentElement.style.overflow='auto';
- }
- //获取云机数量
- function getPhoneNumber(){
- $.ajax({
- url: baseUrl + '/api/pay/v2/meal/info?phoneType=SVIP',
- type: 'get',
- headers: {
- 'Authorization': GetRequest().token //id
- },
- contentType: "application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {
- if(res.status === 0){
- phoneRemainQuantity = res.data.list[0].phoneRemainQuantity;
- }else{
- stopManyClick(() =>{
- toastr.error(res.msg)
- })
- }
-
- },
- })
- }
- init();
- })(document);
- //埋点
- function operate(pointName){
- $.ajax({
- url: baseUrl + '/api/public/v1/systemBuriedPoint/stat',
- type: 'post',
- data:JSON.stringify({
- pointName: pointName
- }),
- contentType:"application/json",
- dataType: 'json',
- cache: false,
- success: function (res) {},
- })
- }
- //防止提示一秒内重复显示
- function stopManyClick(fn) {
- if (flag) {
- fn();
- }
- flag = false;
- if(timer){clearTimeout(timer);}
- timer = setTimeout(() => {flag = true}, 1500);
- }
- </script>
- </body>
- </html>
|