123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- function parseQueryString(url) {
- var urlObj = {};
- var reg = /([^?=&]+)=([^?=&]+)/g;
- url.replace(reg, ($0, $1, $2) => {
- urlObj[$1] = decodeURIComponent($2);
- })
- return urlObj;
- }
- // [showMsg 提示各种错误信息,3s后消失]
- function showMsg(msg) {
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 3000);
- }
- var user_id = '';
- var appName = '钱多记账';
- var scrollTop = '';
- var scrollTop02 = '';
- var activityId = '';
- var jsons = {};
- var qs = parseQueryString(window.location.href);
- $().ready(function () {
- if(qs.activityId){
- activityId = qs.activityId
- }
- if(qs.userId && qs.userId != ' '){
- user_id = qs.userId;
- checkIsJoin();
- }else{
- showMsg('获取用户信息失败')
- }
- if(qs.appName){
- appName = qs.appName
- }
- jsons = {
- title:'【钱多记账】记账打卡赢现金!快到碗里来',
- desc:'每日记账打卡,投入1元,养成好习惯,还能赚到收益。',
- url:BASEURL + '/divide_red_envelopes/shareWechat.html?userId=' + user_id + '&appName=' + appName + "&time=" + new Date().getTime()
- };
- if(appName == '金牛记账' || appName == '金牛记账'){
- jsons = {
- title:'【金牛记账】记账打卡赢现金!快到碗里来',
- desc:'每日记账打卡,投入1元,养成好习惯,还能赚到收益。',
- url:BASEURL + '/divide_red_envelopes/shareWechat.html?userId=' + user_id + '&appName=' + appName + "&time=" + new Date().getTime()
- };
- }
- jsons = JSON.stringify(jsons);
-
- $(window).scroll(function(){
- scrollTop = $(this).scrollTop(); //scrollTop() 方法返回或设置匹配元素的滚动条的垂直位置
- })
- prohibitClosure();//点击内容 禁止关闭
- })
- function getDivideInfo (num) {
- // 获取瓜分新进活动首页信息
- $.ajax({
- type:"post",
- url:"/api/V2/getDivideInfo",
- dataType:'json',
- data:{
- user_id:user_id
- },
- success: function (res) {
- console.log(res)
- if(res && res.code == 0){
- var html = ''
- var is_divide_html = '';//是否已经报名参加活动
- var avatarHtml = ''//用户头像html
- var participate_nu_html = ''//当天瓜分现金参与人数html
- var account = res.res.account;//记账可随机瓜分金额
- var avatar = res.res.avatar//用户头像数据
- var participate_nu = res.res.participate_nu//当天瓜分现金参与人数
- var is_participate = res.res.is_participate//当前用户是否参加今日活动 0:未参与 1:参与且任务未完成 2:参与且任务完成
- var yesterday_finish = res.res.yesterday_finish//昨日挑战完成的人数
- var yesterday_failure = res.res.yesterday_failure//昨日挑战失败的人数
- var first = res.res.first//最早完成的用户信息
- var diligent = res.res.diligent//最勤奋完成的信息
- var is_participate_img = '';//当前用户是否参加今日活动 0:未参与 1:参与且任务未完成 2:参与且任务完成
- var is_participate_title = '';//当前用户是否参加今日活动 0:未参与 1:参与且任务未完成 2:参与且任务完成
- //判断是否已经报名参加活动
- if(num == 0){
- //为报名参加
- is_divide_html = `<div class="onePrice" onclick="wechatZhifu()">一元参与</div>`;
- }else if(num == 4004){
- //用户已经参加报名
- is_divide_html = `<div class="onePrice">已成功报名</div>`;
- }
- $(".banner .price").html(account)
- avatar.forEach(function (item, index){
- if(index < 8){
- avatarHtml += `<li><img src="${item}"/></li>`
- }
- })
- participate_nu = participate_nu.toString().split('');//当天瓜分现金参与人数转为数组
- participate_nu.forEach(function (item, index){
- if(index < 8){
- participate_nu_html += `<li>${item}</li>`
- }
- })
- if (is_participate == 0){
- //未参与
- is_participate_img = 'img/weicanjia.png';
- is_participate_title = '未报名参与今日记账活动';
- }else if (is_participate == 1){
- //参与且任务未完成
- is_participate_img = 'img/yicanjia.png';
- is_participate_title = '参与今日记账活动但任务未完成';
- }else if (is_participate == 2){
- //参与且任务完成
- is_participate_img = 'img/yicanjia.png';
- is_participate_title = '已经手动记账';
- }
- html += `<div class="content_01">
- <div class="number_people">
- <div class="title">当前参与人数</div>
- <div class="number">
- <ul>${participate_nu_html}</ul>
- <span>人</span>
- </div>
- <p>当前有 <em>${participate_nu}</em> 人参与明天记账打卡挑战</p>
- </div>
- <div class="operation">
- <div class="userImges">
- <ul>${avatarHtml}</ul>
- </div>
- ${is_divide_html}
- <div class="inviting_friends" onclick="invitingFriends()">邀请好友领现金</div>
- </div>
- </div>
- <!--今日个人状态-->
- <div class="content_02">
- <div class="title">今日个人状态</div>
- <div class="state_01">
- <img src="${is_participate_img}"/>
- <p>${is_participate_title}</p>
- </div>
- </div>
- <!--昨日记账挑战-->
- <div class="content_03">
- <div class="title">昨日记账挑战</div>
- <ul>
- <li class="first">
- <img src="img/success.png" />
- <span style="margin-left:-0.2rem;">${yesterday_finish}人成功</span>
- </li>
- <li class="last">
- <img src="img/shibai.png" />
- <span>${yesterday_failure}人失败</span>
- </li>
- </ul>
- </div>
- <!--参与用户状态-->
- <div class="content_04">
- <div class="title">参与用户状态</div>
- <ul>
- <li>
- <div class="left">
- <img src="${first.avatar}" />
- <div class="leftCon">
- <p>${first.name}</p>
- <span>${first.time}</span>
- </div>
- </div>
- <div class="right rightActive">
- <i class="icon" style="background:url(img/zuizao.png) no-repeat;background-size:100% 100%;"></i>
- <span>最早XXXX</span>
- </div>
- </li>
- <li>
- <div class="left">
- <img src="${diligent.avatar}" />
- <div class="leftCon">
- <p>${diligent.name}</p>
- <span>${diligent.time}</span>
- </div>
- </div>
- <div class="right">
- <i class="icon" style="background:url(img/zan.png) no-repeat;background-size:100% 100%;"></i>
- <span>连续${diligent.day_nu}天</span>
- </div>
- </li>
- </ul>
- </div>`
- $("#content").html(html);//参与瓜分用户头像展示 最多8个
- }
- }
- });
- }
- //查询用户是否参加了瓜分现金活动
- function checkIsJoin () {
- $.ajax({
- type:"post",
- url:"/api/V2/checkIsJoin",
- data:{
- user_id:user_id,
- activityId:activityId
- },
- dataType:'json',
- success:function (res) {
- if(res && res.code == 0){
- getDivideInfo(0)
- }else if(res && res.code == 4004){
- getDivideInfo(4004)
- }else{
- showMsg('获取用户信息失败')
- }
- }
- });
- }
- //去我的战绩
- function goMyRecord () {
- window.location.href="myRecord.html?userId=" + user_id + "&appName=" + appName
- }
- function prohibitClosure () {
- //点击内容 禁止关闭
- $(".invite_friends_zzc .content").click(function () {
- return false;
- })
- $(".wechat_zhifu_zzc .content").click(function () {
- return false;
- })
- }
- //唤起邀请好友弹窗
- function invitingFriends () {
- $(".invite_friends_zzc").show();
- scrollTop02 = scrollTop;
- $('body').css({'position':'fixed',"top":-scrollTop});
- }
- //关闭遮罩层弹窗
- function closeZzc () {
- $(".invite_friends_zzc").hide();
- $(".wechat_zhifu_zzc").hide();
- $("body").css({"position":"initial"});
- $(window).scrollTop(scrollTop02)
- }
- //微信支付弹层
- function wechatZhifu () {
- $(".wechat_zhifu_zzc").show();
- scrollTop02 = scrollTop;
- $('body').css({'position':'fixed',"top":-scrollTop});
- }
- //点击瓜分规则去瓜分规则页面
- function goDividingRules () {
- window.location.href = 'dividingRules.html'
- }
- //微信支付调取app的方法
- function wechatMoneyGo () {
- var jsonData = {
- activityId:activityId
- }
- jsonData = JSON.stringify(jsonData);
- console.log(jsonData)
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.requestAliPay(jsonData)
- }else{
- window.webkit.messageHandlers.requestAliPay.postMessage(jsonData)
- }
- }
- //微信分享微信调取app的方法
- function shareWeixin () {
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.shareWithWechatSession(jsons)
- }else{
- window.webkit.messageHandlers.shareWithWechatSession.postMessage(jsons)
- }
- }
- //微信分享微信朋友圈调取app的方法
- function sharePengyouquan () {
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.shareWithWechatTimeline(jsons)
- }else{
- window.webkit.messageHandlers.shareWithWechatTimeline.postMessage(jsons)
- }
- }
- //微信分享QQ调取app的方法
- function shareQQ () {
- if(navigator.userAgent.indexOf('Android') != -1){
- messageHandlers.shareWithQQ(jsons)
- }else{
- window.webkit.messageHandlers.shareWithQQ.postMessage(jsons)
- }
- }
|