|
@@ -0,0 +1,903 @@
|
|
|
+<!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">
|
|
|
+ <!-- <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">换个姿势,再抽一次</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" 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">
|
|
|
+ <div class="curr-award-img">
|
|
|
+ <!-- <img class="award-img" src="{{icon}}" /> -->
|
|
|
+ </div>
|
|
|
+ <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="../static/img/awardActivity/home_list_icon_xingyao.jpg" />
|
|
|
+ <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" value="0" />
|
|
|
+ <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">{{diskName}}</div>
|
|
|
+ <div class="award-record-list-content">{{exceptTime}}</div>
|
|
|
+ <div class="award-record-list-content">{{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://192.168.31.194'
|
|
|
+ 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 = 1,
|
|
|
+ recordFlag2 = true,
|
|
|
+ pageNum2 = 1,
|
|
|
+ pages2 = 0,
|
|
|
+ cardList = [],
|
|
|
+ lotteryCount = 0,
|
|
|
+ lotteryResult = {},
|
|
|
+ lotteryFlag = true,
|
|
|
+ activityState = 0,
|
|
|
+ awardNumber = 0,
|
|
|
+ currTotalTime = 0,
|
|
|
+ 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 () {
|
|
|
+ bindEvent();
|
|
|
+ headerAward();
|
|
|
+ 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) {
|
|
|
+ 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');
|
|
|
+ } else {
|
|
|
+ $('.no-award-data').eq(0).css('display', 'none');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function tabHandle2 (e) {
|
|
|
+ operate('mfhd_2022_h5_tab分配奖励');
|
|
|
+ $('.tab-bg1').eq(0).css('display', 'none');
|
|
|
+ $('.tab-wrap').eq(0).css('height', '14.75rem');
|
|
|
+ $('.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'){
|
|
|
+ $('.main-contain').eq(0).empty();
|
|
|
+ let num = flagNum > 12 ? flagNum - 12 : flagNum;
|
|
|
+ $('.curr-award-item').eq(num).css('background', '#ffffff');
|
|
|
+ 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(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
|
|
|
+ }
|
|
|
+ $.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() {
|
|
|
+ $('.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 ?'继续抽奖' : '获取次数';
|
|
|
+ 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();
|
|
|
+ allotTimeCardList();
|
|
|
+ $('.main-contain').eq(0).append(result)
|
|
|
+ $('.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: {
|
|
|
+ pageNum: 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();
|
|
|
+ }
|
|
|
+ let result = ''
|
|
|
+ list.map((item, index) => {
|
|
|
+ result += $('#awardRecord').text().replace(/{{(.*?)}}/g, function(node, key) {
|
|
|
+ return item[key];
|
|
|
+ })
|
|
|
+ })
|
|
|
+ $('.award-list-wrap').eq(0).append(result)
|
|
|
+ }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
|
|
|
+ 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"})
|
|
|
+ $(".top-bg-two").css({"display": "none"})
|
|
|
+ } else {
|
|
|
+ $(".top-bg-one").css({"display": "none"})
|
|
|
+ $(".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';
|
|
|
+ }
|
|
|
+ $('.rule-point-wrap').eq(0).html(actRule)
|
|
|
+ $('.times').eq(0).text(lotteryCount)
|
|
|
+ $('.all-award-wrap').eq(0).append(result)
|
|
|
+ }else{
|
|
|
+ stopManyClick(() =>{
|
|
|
+ toastr.error(res.msg)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ //轮播
|
|
|
+ function headerAward(){
|
|
|
+ setInterval(() =>{
|
|
|
+ awardHandle();
|
|
|
+ },3000);
|
|
|
+ }
|
|
|
+ function awardHandle(){
|
|
|
+ let index = (topVal/0.5) + 1,awardString;
|
|
|
+ let awardLen = Array.from($('.award-text')).length;
|
|
|
+ if(awardLen < 20){
|
|
|
+ let node = document.createElement('div');
|
|
|
+ node.className = "award-text";
|
|
|
+ $('.award-lists')[0].appendChild(node);
|
|
|
+ }
|
|
|
+ if(topVal < 9.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].goodsType]}奖品`;
|
|
|
+ }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){
|
|
|
+ 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
|
|
|
+ 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)
|
|
|
+ list.map((item, index) => {
|
|
|
+ item.index = index
|
|
|
+ result += $('#distribution').text().replace(/{{(.*?)}}/g, function(node, key) {
|
|
|
+ return item[key];
|
|
|
+ })
|
|
|
+ })
|
|
|
+ $('.distribution-container').eq(0).append(result)
|
|
|
+ }
|
|
|
+ //抽奖记录下拉加载
|
|
|
+ $('.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 && cardList.length > 1){
|
|
|
+ recordFlag1 = false;
|
|
|
+ pageNum1++;
|
|
|
+ pageCardList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 分配时长记录
|
|
|
+ function allotTimeRecord(){
|
|
|
+ if(!GetRequest().token){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ $.ajax({
|
|
|
+ url: baseUrl + '/api/activity/gratis/allotTimeRecord',
|
|
|
+ type: 'get',
|
|
|
+ headers: {
|
|
|
+ 'Authorization': GetRequest().token //id
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ pageNum: 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;
|
|
|
+ list.map(item => {
|
|
|
+ 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 == 2){
|
|
|
+ toastr.error('活动已结束!');
|
|
|
+ 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(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('分配时长不能大于未分配总时长');
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(distributionList)
|
|
|
+ }
|
|
|
+ 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');
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(distributionList)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ function distributionTime(e) {
|
|
|
+ operate('mfhd_2022_h5_分配奖励');
|
|
|
+ distributionList = distributionList.filter(item => item.duration != 0);
|
|
|
+ if (distributionList.length === 0) {
|
|
|
+ stopManyClick(() => {
|
|
|
+ toastr.error('未选中任何云手机');
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ $('.sure-distribution-wrap').eq(0).css('display', 'block');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //点击分配时长取消按钮
|
|
|
+ $('.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 = [];
|
|
|
+ stopManyClick(() => {
|
|
|
+ toastr.error('分配成功,请前往云机列表查看');
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log(res.msg)
|
|
|
+ $('.sure-distribution-wrap').eq(0).css('display', 'none');
|
|
|
+ stopManyClick(() => {
|
|
|
+ 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';
|
|
|
+ }
|
|
|
+ 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>
|