filesbox/web/dist/design/designstatic/front/routine/js/bargain.js
2024-07-26 14:10:54 +08:00

2 lines
8.0 KiB
JavaScript

var datime,deid,leftTime,urls=location.search,channels=getchannel();if(urls.indexOf("?")!=-1)var ster=urls.substr(1),sty=ster.split("&"),cide=sty[0].split("cid="),bdid=sty[1].split("did="),uid=sty[2].split("uid=");$.ajax({headers:{token:getCookie("token")},type:"GET",url:"/api/operate/bargainDetail?projectid=43",data:{bargainActivityId:bdid[1],userId:uid[1]},dataType:"json",async:!1,success:function(s){deid=s.data.bargainFoundId}});function datlts(){$.ajax({headers:{token:getCookie("token")},type:"GET",url:"/api/operate/bargainFollowed?projectid=43",data:{bargainFoundId:deid},dataType:"json",async:!0,success:function(s){var a=s.data;datime=s.timeStamp,console.log(a);var n=new Date(datime),t=n.getTime(),i=new Date(a.gmtEnd),c=i.getTime();leftTime=c-t;var p=a.dealMoney,u=a.oldPrice,d=window.location.href,f=u-p,m=a.oldPrice-a.price,v=m-f,b=f/m*100,y=a.courseName,w=a.cover,x=new Array;x[0]={goodsId:cide[1],price:p,goodsUrl:d,goodsType:1,goodsName:y,cover:w,operateType:4};var e="";e+='<div class="topcover">',e+=" <img src="+((window.cdnPath||"")+w)+" />",e+=' <p class="ataser">\u8DDD\u79BB\u780D\u4EF7\u7ED3\u675F\u8FD8\u6709',e+=' <span id="_d">00</span>\u5929',e+=' <span id="_h">00</span>:',e+=' <span id="_m">00</span>:',e+=' <span id="_s">00</span>',e+=" </p>",e+=' <p class="bottke">'+y+"</p>",e+="</div>",e+='<div class="stmian">',e+=' <div class="hexes">',e+=' <span class="mt10">\u539F\u4EF7</span>',e+=" <span>\uFFE5"+(a.oldPrice/100).toFixed(2)+"</span>",e+=" </div>",e+=' <div class="hexes">',e+=' <span class="mt10">\u53EF\u780D\u81F3</span>',e+=" <span>\uFFE5"+(a.price/100).toFixed(2)+"</span>",e+=" </div>",e+=' <div class="hexes">',e+=' <span class="mt10">\u5F53\u524D\u4EF7</span>',e+=" <span>\uFFE5"+(p/100).toFixed(2)+"</span>",e+=" </div>",e+=' <div class="ytdsr"><span style="width:'+b+'%"></span></div>',v!=0&&(e+=' <p class="xasrt">\u5DF2\u780D<span class="redes">'+(f/100).toFixed(2)+'</span>\u5143\uFF0C\u8FD8\u5DEE<span class="redes">'+(v/100).toFixed(2)+"</span>\u5143</p>"),e+="</div>",e+='<div class="divbtn">',a.type==0?v==0?(e+=' <span style="margin:0 0 15px 43%;float:left;">\u780D\u4EF7\u5DF2\u5B8C\u6210</span>',e+=' <a class="mycutbtn hasrer" style="color:#fff;border:none;" href="javascript:void(0);">\u6211\u4E5F\u8981\u780D\u4EF7></a>',e+="</div>"):(e+=' <div class="retset">',e+=' <img src="'+((window.cdnPath||"")+a.headPortrait)+'" />',e+=' <span class="kasnry">\u4EB2\uFF0C\u5FEB\u5E2E\u6211\u780D\u4E00\u5200\u5427\uFF01</span>',e+="</div>",e+=' <a class="sharebtn" href="javascript:void(0);">\u5E2E\u4ED6\u780D\u4E00\u5200</a>',e+=' <a class="mycutbtn" href="javascript:void(0);">\u6211\u4E5F\u8981\u780D\u4EF7></a>',e+="</div>"):a.type==1?(e+=' <div class="retset">',e+=' <p class="atxte">\u4F60\u5DF2\u7ECF\u5E2E\u4ED6\u780D\u4E86<span class="redes">'+(a.bargainFollows[0].price/100).toFixed(2)+"</span>\u5143\uFF0C\u4E0D\u5982\u81EA\u5DF1\u4E5F\u6765\u4E00\u5355\u5427\uFF01</p>",e+="</div>",e+=' <a class="sharebtn" href="javascript:void(0);">\u6211\u4E5F\u8981\u780D\u4EF7></a>',e+="</div>"):a.type==2&&(v==0?(e+='<span style="margin:0 0 15px 43%;float:left;">\u5DF2\u780D\u81F3\u6700\u4F4E</span>',e+=' <a class="openkebtn hasrer" href="javascript:void(0);">\u7ACB\u5373\u5F00\u901A</a>',e+="</div>"):(e+=' <a class="sharebtn" href="javascript:void(0);">\u5206\u4EAB\u7ED9\u597D\u53CB\uFF0C\u9080\u8BF7\u780D\u4E00\u5200</a>',e+=' <a class="openkebtn" href="javascript:void(0);">\u4E0D\u780D\u4E86\uFF0C\u6309\u5F53\u524D\u4EF7\u5F00\u901A ></a>',e+="</div>")),e+='<div class="botlist">',e+=" <h2>\u780D\u4EF7\u699C</h2>",e+=' <ul class="uclist">';for(var g=0,T=a.bargainFollows.length;g<T;g++){var l=a.bargainFollows[g],I=formatDate(l.gmtCreate);e+=' <li class="lishow">',e+=" <img src="+((window.cdnPath||"")+l.headPortrait)+" />",e+=' <div class="jusrte">',l.realName==""?e+=' <p class="pnamt">'+l.loginName+"</p>":e+=' <p class="pnamt">'+l.realName+"</p>",e+=' <p class="pnamt">'+I+"</p>",e+=" </div>",e+=' <span class="woret">'+(l.price/100).toFixed(2)+"\u5143</span>",e+=' <span class="wistde">\u5E2E\u5FD9\u780D\u4E86</span>',e+=" </li>"}e+=" </ul>",e+="</div>";var h=a.type;$(".wapbdat").html(e),$(".sharebtn").on("click",function(){user.isLogin(function(r){r.success?h==0?$.ajax({headers:{token:getCookie("token")},type:"POST",url:"/api/operate/saveBargainFollow?projectid=43",data:JSON.stringify({bargainFoundId:deid}),contentType:"application/json",dataType:"json",async:!0,success:function(o){var k=o.data;layer.open({type:1,content:'<div style="width:266px;height:200px;"><img src="/design/designstatic/front/images/laytop.png" /><p style="text-align:center;height:30px;font-weight:bold;font-size:15px;line-height:30px;">\u4F60\u5DF2\u780D\u4E86<span style="font-size:24px;color:#C16157;">'+(k/100).toFixed(2)+"\u5143</span></p></div>",btnAlign:"c",btn:"\u8D76\u7D27\u67E5\u770B",skin:"layui-layer-demo",yes:function(j){datlts(),layer.close(j)}})}}):h==1?window.location.href="/pages/routine/info.html?cid="+cide[1]+"":h==2&&$(".zhasr").show():parseInt(r.code)==401?user.loginLayer(function(o){o.success&&datlts()}):layer.alert("\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01")})}),$(".zhasr").on("click",function(){$(this).hide()}),$(".openkebtn").on("click",function(){channels=getchannel(),user.isLogin(function(r){r.success?r.data.userTypeExact=="STUDENT"?$.ajax({headers:{token:getCookie("token")},type:"POST",url:"/api/order/shoppingCart?projectid=22",contentType:"application/json",dataType:"json",data:JSON.stringify({goodsList:x,pvid:channels.pvid,uvcid:channels.uvcid,shareUserId:channels.shareUserId,clientType:channels.channel}),async:!0,success:function(o){window.location.href="/myroom/#/shopping"}}):layer.alert("\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u62A5\u540D\uFF01"):parseInt(r.code)==401?user.loginLayer(function(o){o.success&&datlts()}):layer.alert("\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01")})}),$(".mycutbtn").on("click",function(){user.isLogin(function(r){r.success?r.data.userTypeExact=="STUDENT"?window.location.href="/pages/routine/info.html?cid="+cide[1]+"":layer.alert("\u53EA\u6709\u5B66\u751F\u8D26\u53F7\u624D\u80FD\u62A5\u540D\uFF01"):parseInt(r.code)==401?user.loginLayer(function(o){o.success&&datlts()}):layer.alert("\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458\uFF01")})})}})}setTimeout(function(){datlts()},0);function getchannel(){var s,a=localStorage.appAdapt===!0||localStorage.appAdapt==="true";if(a){var n=sessionStorage.getItem("ip")||"",t=sessionStorage.getItem("channel")||"",i=sessionStorage.getItem("gmtStart")||0,c=sessionStorage.getItem("sourceId")||0,p=sessionStorage.getItem("sourceJson")||"",u=sessionStorage.getItem("sourceType")||"";s={ip:n,channel:t,gmtStart:i,sourceId:c,sourceJson:p,sourceType:u}}else{s=sessionStorage.getItem("cluechannel")?JSON.parse(sessionStorage.getItem("cluechannel")):{};var n=sessionStorage.getItem("sourceip");s.ip=n||""}var d=getPar("channel")||"";return d&&(s.channel=d),s.uvcid=localStorage.uvcid||"",s.pvid=sessionStorage.getItem("pvid")||"",s}var fillNumber=function(s){var a=Math.floor(s);return a>9?a:"0"+a},timeChange=function(){var s,a,n,t;leftTime>=0?(s=Math.floor(leftTime/1e3/60/60/24),a=Math.floor(leftTime/1e3/60/60%24),n=Math.floor(leftTime/1e3/60%60),t=Math.floor(leftTime/1e3%60)):(window.location.href="/pages/routine/info.html?"+ster+"",clearInterval(time)),s=s<10?"0"+s:s,a=a<10?"0"+a:a,n=n<10?"0"+n:n,t=t<10?"0"+t:t,document.getElementById("_d").innerHTML=s,document.getElementById("_h").innerHTML=a,document.getElementById("_m").innerHTML=n,document.getElementById("_s").innerHTML=t,leftTime=leftTime-1e3};setTimeout(timeChange,300);var time=setInterval(timeChange,1e3);function formatDate(s){s=new Date(s);var a=s.getFullYear(),n=s.getMonth()+1,t=s.getDate(),i=s.getHours(),c=s.getMinutes();return n=n<10?"0"+n:n,t=t<10?"0"+t:t,a+"/"+n+"/"+t+" "+i+":"+c}function getCookie(s){for(var a=document.cookie,n=a.split("; "),t=0;t<n.length;t++){var i=n[t].split("=");if(i[0]==s)return i[1]}return""}function getPar(s){var a=document.location.href,n=a.indexOf(s+"=");if(n==-1)return!1;var t=a.slice(s.length+n+1),i=t.indexOf("&");return i!=-1&&(t=t.slice(0,i)),t}