"use strict";const e=require("../../common/vendor.js"),t=require("../store/index.js"),o=require("../helper/index.js"),s=require("../helper/test.js"),n=require("../api/member/auth.js"),a=require("../index.js"),i=require("../api/member/signin.js");let r=30,c=null;async function l(){console.log("onSign");const{code:o,data:s}=await i.SignInApi.createSignInRecord();var n;0===o&&(n=s,t.$store("modal").$patch((e=>{e.signUp=!0,e.signUpInfo=n}))),c&&clearInterval(c),e.index.setStorageSync("isRun",!1),e.index.setStorageSync("isSign",!0)}function u(){const t=(new Date).toISOString().slice(0,10);t!==e.index.getStorageSync("lastCheckDate")&&(e.index.setStorageSync("isSign",!1),e.index.setStorageSync("lastCheckDate",t))}function d(){c&&clearInterval(c),r=30,e.index.setStorageSync("isRun",!1)}function g(){t.$store("modal").$patch((e=>{e.auth=""}))}exports.autoSign=function(){u();const t=e.computed((()=>a.sheep.$store("user").isLogin));t.value&&(e.index.setStorageSync("isRun",!0),e.index.getStorageSync("isRun")&&!e.index.getStorageSync("isSign")&&(c=setInterval((()=>{r--,console.log("time",r),!e.index.getStorageSync("isSign")&&t.value||(console.log("已经签到了或者已经登出了 不可以在签到"),d()),r<=0&&!e.index.getStorageSync("isSign")&&(clearInterval(c),l())}),1e3)))},exports.cancelAutoSign=d,exports.closeAuthModal=g,exports.closeMenuTools=function(){t.$store("modal").$patch((e=>{e.menu=!1}))},exports.closeShareModal=function(){t.$store("modal").$patch((e=>{e.share=!1}))},exports.colseSignUpModal=function(){t.$store("modal").$patch((e=>{e.signUp=!1}))},exports.colseWalletModal=function(){t.$store("modal").$patch((e=>{e.getWallet=!1}))},exports.getSmsCode=function(a,i){const r=t.$store("modal"),c=r.lastTimer[a];if(void 0===c)return void o.$helper.toast("短信发送事件错误");if(!(e.dayjs().unix()-c>=60))return void o.$helper.toast("请稍后再试");if(i&&!s.test.mobile(i))return void o.$helper.toast("手机号码格式不正确");let l=-1;switch(a){case"resetPassword":l=4;break;case"changePassword":l=3;break;case"changeMobile":l=2;break;case"smsLogin":l=1}n.AuthUtil.sendSmsCode(i,l).then((t=>{0===t.code&&r.$patch((t=>{t.lastTimer[a]=e.dayjs().unix()}))}))},exports.getSmsTimer=function(s,n=""){const a=t.$store("modal").lastTimer[s];if(void 0===a)return void o.$helper.toast("短信发送事件错误");const i=e.ref(e.dayjs().unix()-a-60),r=i.value>=0;return r?"获取验证码":r?void 0:(setTimeout((()=>{i.value++}),1e3),-i.value.toString()+" 秒")},exports.resetSignStatusIfNeeded=u,exports.saveAdvHistory=function(e){t.$store("modal").$patch((t=>{t.advHistory.includes(e.imgUrl)||t.advHistory.push(e.imgUrl)}))},exports.showAuthModal=function(e="accountLogin",o="accountLogin"){const s=t.$store("modal");""!==s.auth?(g(),setTimeout((()=>{s.$patch((t=>{t.auth=e,t.isActive=o}))}),100)):s.$patch((t=>{t.auth=e,t.isActive=o}))},exports.showMenuTools=function(){t.$store("modal").$patch((e=>{e.menu=!0}))},exports.showShareModal=function(e=0){t.$store("modal").$patch((t=>{t.share=!0,t.shareInfo.spuId=e}))},exports.showWalletModal=function(e){t.$store("modal").$patch((t=>{t.getWallet=!0,t.getWalletInfo=e}))};
