123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128 |
- <!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 {
- wx.miniProgram.navigateTo({
- url: `/packageA/order/renew/index?record=${userCardId}&buyVipType=${buyVipType}`
- })
- }
- } else if (isAndroid && window.native) { // 安卓
- if(phoneRemainQuantity > 0){
- window.native.startPurchase('SVIP', 365);
- } else {
- window.native.startRenew();
- }
- } else if (isiOS) {
- try {
- if(phoneRemainQuantity > 0){
- window.webkit.messageHandlers.startPurchase.postMessage({ type: 1, day: 365 });
- } else {
- window.webkit.messageHandlers.startRenew.postMessage({ 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>
|