12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118 |
- <!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">{{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,
- 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;
- console.log('flagNum', flagNum)
- }
- 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
- userCardId = cardList[0] && cardList[0].userCardId
- pageCardList()
- $('.all-times').eq(0).text(res.data.totalTime)
- $('.red').eq(0).text(res.data.totalTime)
- $('.red').eq(1).text(res.data.allotTime)
- $('.red').eq(2).text(res.data.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
- })
- }
- } 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?record=' + userCardId
- })
- }
- }
-
- }
- })
- }
- //点击加减号
- $('.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>
|