",{src:t});return e[0].naturalWidth?Promise.resolve(e):(e.css({opacity:.01,position:"fixed",bottom:0,left:0,height:"1px",width:"1px","z-index":1e4,"pointer-events":"none"}),$(document.body).append(e),new Promise(function(t){e.on("load",function(){e.detach(),t(e)})}))}function c(t){t=t.replace(/https?:\/\/[\w.-]+/,location.protocol+"//"+location.host);var e=$('');$("body").append(e);var i=g(t).getSize();e.attr("height",i.h),e.attr("width",i.w);var o=e[0].getContext("2d");return Promise.all([r(t)]).then(function(t){o.drawImage(t[0][0],0,0)}).then(function(){return e.remove(),e[0].toDataURL("image/jpeg",.4)}).catch(function(t){alert(""+t.message)})}function h(){var t=location.origin+location.pathname;return m.id&&(t=y(t,"id",m.id)),t.replace("&shareSu=1",""),t}function p(t,e){var i=location.origin+location.pathname;return m.id&&(i=y(i,"id",m.id)),i=y(i,"date",t),i=y(i,"index",e),i=y(i,"shareSu",1)}function d(t){return new Promise(function(e,i){t.success=function(t){e(t)},t.error=function(t){i(t)},n(t)})}var u=i("mi-home-lib"),l=u.showFloatingLayer2,f=u.ua,m=u.args,g=u.SpecificCdnImg,v=u.checkAppApi,b=u.appApi,w=u.toast,y=u.addParam,k=u.Rag,_=u.jumpTo,x=u.countEvent,T=u.appShare3,C=u.getLogin,I=u.jumptoLogin,S=u.initWechatAPI,P={startCheck:function(t){return d({url:"//"+location.host+"/api/market/attendance/clocking-in?activityId="+t,type:"GET",param:{}})},sign:function(t){var e=t.actId;return d({url:"//"+location.host+"/api/market/attendance/clocking-in",type:"POST",param:{activityId:e},paramsType:"json",returnAll:!0})},coupon:function(t){var e=t.actId,i=t.signTo;return d({url:"//"+location.host+"/api/market/attendance/clocking-in",type:"PUT",param:{activityId:e,attendTo:i},paramsType:"json",returnAll:!0})}};o.exports=function(i){function o(){var t=this;e(this,o);for(var i=arguments.length,n=Array(i),s=0;s\n \n ');a.on("click",function(){return t.bindClick({index:i,itemDate:"",status:"goLight"})}),t.$box.append(a)})}},{key:"reDraw",value:function(){var t=this;P.startCheck(this.props.actId).then(function(e){var i=e.currentDate,o=e.attended,n=void 0;t.moons.forEach(function(e,a){var s=t.$box.find(".item-box:nth-child("+(a+1)+")"),r=new Date((e.date+" 12:00:00").replace(/-/g,"/")).getTime()/1e3,c=t.dateEq(r,i);0===c&&(n=s.position().left),t.dateInList(r,o)?(t.signList[a]=!0,s.find(".moon").attr("src",e.pic1),a===t.moons.length-1&&o.length===t.moons.length?s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"hasLightWithCoupon"})}):a===t.moons.length-1?s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"waitAllLight"})}):s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"hasLightWithShare"})})):c<0?(s.find(".moon").attr("src",e.pic3),s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"waitLight"})})):0===c?a===t.moons.length-1&&o.length===t.moons.length-1?s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"goLightWithCoupon"})}):a===t.moons.length-1?s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"waitAllLight"})}):s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"goLightWithShare"})}):s.unbind("click").on("click",function(){return t.bindClick({index:a,itemDate:r,status:"UnableGoLight"})})}),t.$box.scrollLeft(n-window.innerWidth/8*3)}).catch(function(){})}},{key:"dateInList",value:function(t,e){return this.a=1,t=new Date(1e3*t),e.some(function(e){return e=new Date(1e3*e),e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()})}},{key:"dateEq",value:function(t,e){var i=function(t){return t.length<2?"0"+t:t};this.a=1,t=new Date(1e3*t),e=new Date(1e3*e),t={y:t.getFullYear(),m:i(""+t.getMonth()),d:i(""+t.getDate())},e={y:e.getFullYear(),m:i(""+e.getMonth()),d:i(""+e.getDate())};var o=Number(""+t.y+t.m+t.d),n=Number(""+e.y+e.m+e.d);return o-n}},{key:"bindClick",value:function(t){var e=this,i=t.status,o=t.itemDate,n=t.index;return x("moon",n+1),f.app||f.wxminiprogram?void("goLight"===i?C().then(function(t){t||I()}):"goLightWithShare"===i?this.signList[n]?this.showShare(o,n):(this.sign(n),setTimeout(function(){return e.showShare(o,n)},this.timeout+100)):"goLightWithCoupon"===i?this.signList[n]?this.showCoupon():(this.sign(n),setTimeout(function(){return e.showCoupon()},this.timeout+100)):"waitAllLight"===i?Object.keys(this.signList).length>=this.moons.length-1?(this.sign(n),setTimeout(function(){return e.showCoupon()},this.timeout+100)):w("请先补签未签到日期,才可以在今天签到哦~"):"hasLightWithCoupon"===i?this.showCoupon():"hasLightWithShare"===i?this.showShare(o,n):"waitLight"===i?(this.signList[n]||w("分享海报,即刻获得补签机会"),this.showShare(o,n)):"UnableGoLight"===i&&w("还没到时间,再耐心等等吧~")):void w("请去小米有品App/有品Lite小程序参与签到活动")}},{key:"coupon",value:function(t){return P.coupon({actId:this.props.actId,signTo:t}).then(function(t){t.message&&w(t.message)})}},{key:"sign",value:function(t){var e=this;P.sign({actId:this.props.actId}).then(function(i){i.message&&w(i.message),e.signList[t]=!0}),this.lightChange(t)}},{key:"lightChange",value:function(t){var e=this,i=this.$box.find(".item-box:nth-child("+(Number(t)+1)+")"),o=i.find(".moon");return!!this.signList[t]||(o.fadeToggle(100),setTimeout(function(){o.attr("src",e.moons[t].pic1).fadeIn(e.timeout)},120),void(this.signList[t]=!0))}},{key:"showCoupon",value:function(){var t=this,e=this.$$(".floating");e.find(".jump-btn").replaceWith(e.find(".jump-btn").clone());var i=l({$dom:e,closeOnTapWrap:!0,closeOnTapShadow:!0}),o=i.exit;e.find(".jump-btn").on("click",function(){x("to_use",t.$dom),_(t.props.couponLink||"https://m.xiaomiyoupin.com/shop/coupon"),o()})}},{key:"showShare",value:function(t,e){if(this.state={itemDate:t,index:e},f.app)this.posterIndex=Math.floor(Math.random()*this.props.shareResources.length),this.showSharePoster();else if(f.wxminiprogram){this.showShareTip();try{this.shareMiniprogram({title:this.props.title,image:this.props.shareResources[this.posterIndex].miniprogramPoster,url:h(),callbackUrl:p(t,e)})}catch(t){w(t.message)}}}},{key:"showShareTip",value:function(){var t=this.$$(".share-tip");l({$dom:t,closeOnTapWrap:!0,closeOnTapShadow:!0})}},{key:"showSharePoster",value:function(){var t=this,e=this.$$(".share-poster");e.find("img").attr("src",this.props.shareResources[this.posterIndex].f),e.find(".share-btn").replaceWith(e.find(".share-btn").clone());var i=l({$dom:e,closeOnTapWrap:!0,closeOnTapShadow:!0}),o=i.exit;e.find(".share-btn").on("click",function(){x("share_poster",t.posterIndex+1),t.onShare(),o()})}},{key:"onShare",value:function(){if(v("shareToPyqWithImage",1))try{c(this.props.shareResources[this.posterIndex].bg).then(function(t){v("shareToPyqWithImage",1)?(b("shareToPyqWithImage",t,1),setTimeout(function(){w("图片生成中,请稍等~")},200)):w("需升级最新版本app才能分享哦~")})}catch(t){w(t.message)}else w("需升级最新版本app才能分享哦~")}},{key:"shareMiniprogram",value:function(t){var e=t.title,i=t.image,o=t.url,n=t.callbackUrl;this.a=1;var a={shareTitle:encodeURIComponent(e),shareUrl:o,shareImg:encodeURIComponent(i)};n&&(a.shareCallBack=n),f.wxminiprogram&&wx.miniProgram.postMessage({data:a})}},{key:"onMessage",value:function(){var t=this;eventEmitter.on("share-result",function(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];"success"===e.status&&"direct-pyq"===e.channel&&t.state&&t.state.itemDate&&t.coupon(t.state.itemDate).then(function(){t.state&&t.state.hasOwnProperty("index")&&t.lightChange(t.state.index)})})}},{key:"checkMiniProgramShareResult",value:function(){var t=this;m.shareSu&&m.hasOwnProperty("date")&&m.hasOwnProperty("index")&&this.coupon(m.date).then(function(){setTimeout(function(){t.lightChange(m.index)},100)})}},{key:"parseUrl",value:function(){this.a=1;var t=location.href.split("?")[1].split("&"),e={};return t.forEach(function(t){e[t.split("=")[0]]=t.split("=")[1]}),e}},{key:"initShare",value:function(){var t=this;this.a=1;var e=h();if(f.app){var i="/pages/web/web?openUrl="+encodeURIComponent(e);e=y(e,"miniProgramPath",encodeURIComponent(i)),e=y(e,"notDirect","true"),T({title:this.props.allPageTitle,pyqTitle:this.props.allPageTitle,content:this.props.allPageContent,url:e,image:this.props.shareResources[this.posterIndex].miniprogramPoster},{mode:"icon"})}else f.wxminiprogram&&S().then(function(){t.shareMiniprogram({title:t.props.allPageTitle,image:t.props.shareResources[t.posterIndex].miniprogramPoster,url:e})})}}]),o}(k)}(o,i),i.exports&&(r["/cloud/module/sign_in/sign_in.action.js"]=i.exports)}(),d=p["/cloud/container/pure_container/pure_container.action.js"],d&&$('[data-id="editor-rag-0"]').length&&d("editor-rag-0",{mode:"没用",hideInEditor:!1}),$('[data-id="editor-rag-4"]').length&&new r["/cloud/module/scroll_footer/scroll_footer.action.js"]({colorHighlightBg:"#ffffff",colorHighlightText:"#cf4a43",colorBg:"#cf4a43",colorText:"#ffffff",arr:[{id:"a",text:"领券专区"},{id:"b",text:"签到送礼专区"},{id:"c",text:"按摩爆品区"},{id:"d",text:"更多好物"},{id:"c",text:"健康养生主会场"}],mode:"header"},"editor-rag-4"),$('[data-id="editor-rag-5"]').length&&new r["/cloud/module/one_to_three_coupon/one_to_three_coupon.action.js"]({themeColorBg:"rgb(236,129,97)",themeFontColor:"rgb(255,240,223)",actIds:"612",ids:"7123",images:{color:"rgb(236,129,97)rgb(255,240,223)2",data:["https://shop.io.mi-img.com/app/shop/img?id=shop_d706b1e129953fdaec49958e8a063bc4.png&w=850&h=206","https://shop.io.mi-img.com/app/shop/img?id=shop_5b060e76cf3dcec247bf30ff4c208db0.png&w=850&h=206","https://shop.io.mi-img.com/app/shop/img?id=shop_ccd98d2615fce688cdf18fe25c9ac76c.png&w=850&h=206"]}},"editor-rag-5"),$('[data-id="editor-rag-6"]').length&&new r["/cloud/module/one_to_three_coupon/one_to_three_coupon.action.js"]({themeColorBg:"rgb(236,129,97)",themeFontColor:"rgb(255,240,223)",actIds:"612",ids:"7273 7272",images:{color:"rgb(236,129,97)rgb(255,240,223)1",data:["https://shop.io.mi-img.com/app/shop/img?id=shop_a5b474c049be7a472bd5aed821324eec.png&w=500&h=198","https://shop.io.mi-img.com/app/shop/img?id=shop_3bb3dbce538651b74470b5b892a553a7.png&w=500&h=198","https://shop.io.mi-img.com/app/shop/img?id=shop_4c5d91bb555ea7b5d5b6ddcb96607d1d.png&w=500&h=198"]}},"editor-rag-6"),$('[data-id="editor-rag-7"]').length&&new r["/cloud/module/sign_in/sign_in.action.js"]({moons:[{date:"2019-3-28",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_cf6afd027c719b1db24523007e732bbe.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_b938ee0b1cdd7cceb85ac70d4c560bfd.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"},{date:"2019-3-29",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_baef195b4fb29c9acca96bdd8c422781.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_a2da7c6bd9a536f3850cacdc39e4f7a6.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"},{date:"2019-4-3",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_558877bfcd1172ee78d244b7644b922d.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_1244dd733c869c1094708b8e33de66ae.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"},{date:"2019-4-4",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_808936cbb7766fef31e2be9e498fdab5.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_54ffd16bb7893f841630ecb5d1b5963d.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"},{date:"2019-4-5",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_ae5f1a3c4cb0907ff38f8be0821b4e5e.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_44ab6f59fa05cb3b168dbef888f1c058.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"},{date:"2019-4-6",pic1:"https://shop.io.mi-img.com/app/shop/img?id=shop_c381c5ec5266259551c8d443db0b49a7.png&w=231&h=193",pic2:"https://shop.io.mi-img.com/app/shop/img?id=shop_d486ff79868a9b1dbbadfafe1fbe0803.png&w=231&h=193",pic3:"https://shop.io.mi-img.com/app/shop/img?id=shop_2f41518e5566443fbc727088ea149d15.png&w=231&h=193"}],shareResources:[{f:"https://shop.io.mi-img.com/app/shop/img?id=shop_8dbe24d09fc5fdb0d859a3291746fed2.jpeg&w=800&h=1080",bg:"https://shop.io.mi-img.com/app/shop/img?id=shop_0e25f2c85efea815e7876d576ce2f8ce.jpeg&w=1080&h=1920",miniprogramPoster:"https://shop.io.mi-img.com/app/shop/img?id=shop_ac74c234bfd0ce826b9afa0e230331e5.jpeg&w=500&h=400"}],actId:"893008699b3d403aae0fd4f7f9a88de5",bgImg:"https://shop.io.mi-img.com/app/shop/img?id=shop_4c12f912f02b92ad1b7c662b781a794b.jpeg&w=1080&h=544",allPageTitle:"乐范&有品2周年庆",allPageContent:"乐范&有品2周年庆",title:"乐范&有品2周年庆",couponLink:"https://m.youpin.mi.com/app/shop/content?id=v95e3f03901c5d6e7",bigCouponImg:"https://shop.io.mi-img.com/app/shop/img?id=shop_a7fd5717a4d1fcb53b257dff57e2240d.jpeg&w=800&h=1080"
},"editor-rag-7")})