index.js 6.5 KB

1
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["plugins/check_in/index/index"],{"0aa1":function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n("2f62");function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var c=function(){Promise.all([n.e("common/vendor"),n.e("components/basic-component/app-layout/app-layout")]).then(function(){return resolve(n("3dd6"))}.bind(null,n)).catch(n.oe)},s=function(){Promise.all([n.e("common/vendor"),n.e("components/basic-component/app-form-id/app-form-id")]).then(function(){return resolve(n("e583"))}.bind(null,n)).catch(n.oe)},u={data:function(){return{month:1,year:1990,everyday:[],config:[],user:{},result:{},now:1,noday:["","","","","","","",""],week:1,date:[],getRed:!1,customize:null,page_loading:!0,template_message:!1,success:!1}},components:{"app-layout":c,"app-form-id":s},computed:o({},(0,a.mapState)({theme:function(e){return e.mallConfig.theme},userInfo:function(e){return e.user.info},mallImg:function(e){return e.mallConfig.__wxapp_img.mall},checkImg:function(e){return e.mallConfig.plugin.check_in}})),methods:{toRules:function(){e.navigateTo({url:"/plugins/check_in/rules/rules"})},toIndex:function(){e.redirectTo({url:"/pages/index/index"})},getSetting:function(){var t=this;t.$request({url:t.$api.check_in.customize}).then((function(n){0==n.code?(t.customize=n.data.list,t.getList()):(t.$hideLoading(),e.showToast({title:n.msg,icon:"none",duration:1e3}))})).catch((function(e){t.$hideLoading()}))},getList:function(){var t=this;t.$request({url:t.$api.check_in.index}).then((function(n){t.$hideLoading(),0==n.code?(t.config=n.data.config,t.user=n.data.check_in_user,t.template_message=n.data.template_message,t.getEveryday()):e.showToast({title:n.msg,icon:"none",duration:1e3})})).catch((function(e){t.$hideLoading()}))},getEveryday:function(){var e=this,t=e.month,n=e.year,a=32,i=[];t<8&&t%2==0&&2!=t?a=31:t>7&&t%2==1?a=31:2==t&&(a=n%4==0&&n%100!=0?30:29);for(var o=1;o<a;o++)i.push({date:o});for(var r=e.noday,c=e.week,s=0;s<c;s++)i.unshift(r[s]);if(i.length%7!=0)for(var u=7-i.length%7,d=0;d<u;d++)i.push(r[d]);e.everyday=i,e.getDay(t)},getDay:function(t){var n=this;n.$request({url:n.$api.check_in.sign_in_day,data:{month:t}}).then((function(t){if(n.$hideLoading(),0==t.code){for(var a=t.data.check_in_day,i=0;i<n.everyday.length;i++)a.indexOf(n.everyday[i].date)>-1&&(n.everyday[i].check=!0);n.$forceUpdate()}else e.showToast({title:t.msg,icon:"none",duration:1e3})})).catch((function(e){n.$hideLoading()}))},lose:function(){var e=this.month-1,t=this.year,n=this.now;e<1&&(e=12,t--);var a=t+"-"+e+"-01",i=new Date(Date.parse(a.replace(/-/g,"/")));this.week=i.getDay();var o=new Date,r=o.getFullYear(),c=o.getMonth()+1;n=t==r?e>c?0:e<c?32:o.getDate():t>r?0:32,this.year=t,this.month=e,this.now=n,this.getEveryday()},add:function(){var e=this.month+1,t=this.year,n=this.now;e>12&&(e=1,t++);var a=t+"-"+e+"-01",i=new Date(Date.parse(a.replace(/-/g,"/")));this.week=i.getDay();var o=new Date,r=o.getFullYear(),c=o.getMonth()+1;n=t==r?e>c?0:e<c?32:o.getDate():t>r?0:32,this.year=t,this.month=e,this.now=n,this.getEveryday()},subscribe:function(){var e=this;this.$subscribe(this.template_message).then((function(t){e.getAward(1)})).catch((function(t){e.getAward(1)}))},getAward:function(t,n){var a=this;e.showLoading({title:"领取中..."}),a.$request({url:a.$api.check_in.sign_in,data:{status:t,day:n||1}}).then((function(t){if(0==t.code){var n=t.data.queueId,i=t.data.token;a.checkInResult(n,i)}else e.hideLoading(),e.showToast({title:t.msg,icon:"none",duration:1e3})})).catch((function(i){e.hideLoading(),a.$event.on(a.$const.EVENT_USER_LOGIN).then((function(){a.$store.dispatch("user/info"),a.getAward(t,n)}))}))},checkInResult:function(t,n){var a=this;a.$request({url:a.$api.check_in.sign_in_result,data:{queueId:t,token:n}}).then((function(i){e.hideLoading(),0==i.code?1==i.data.retry?a.checkInResult(t,n):(a.result=i.data,"integral"==a.result.type?a.success=!0:"balance"==a.result.type&&(a.getRed=!0)):e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(t){e.hideLoading()}))},changeSwitch:function(){0==this.user.is_remind&&this.$subscribe(this.template_message)},toSwitch:function(t){var n=this,a=this,i=0;t.detail.value&&(i=1),a.$request({url:a.$api.check_in.user,data:{is_remind:i}}).then((function(t){a.$hideLoading(),0==t.code?n.user.is_remind=i:e.showToast({title:t.msg,icon:"none",duration:1e3})})).catch((function(e){a.$hideLoading()}))},close:function(){this.success=!1,this.getRed=!1,this.getList()}},onShareAppMessage:function(){return this.$shareAppMessage({title:"签到",path:"/plugins/check_in/index/index"})},onLoad:function(){var e=this,t=new Date;e.year=t.getFullYear(),e.month=t.getMonth()+1,e.now=t.getDate();var n=e.year+"-"+e.month+"-01",a=new Date(Date.parse(n.replace(/-/g,"/")));e.week=a.getDay(),e.$showLoading({type:"global",text:"加载中..."}),e.getSetting()}};t.default=u}).call(this,n("543d")["default"])},5536:function(e,t,n){"use strict";(function(e){n("8748");a(n("66fd"));var t=a(n("f401"));function a(e){return e&&e.__esModule?e:{default:e}}e(t.default)}).call(this,n("543d")["createPage"])},"9b9a":function(e,t,n){},a72b:function(e,t,n){"use strict";n.r(t);var a=n("0aa1"),i=n.n(a);for(var o in a)"default"!==o&&function(e){n.d(t,e,(function(){return a[e]}))}(o);t["default"]=i.a},abaf:function(e,t,n){"use strict";var a,i=function(){var e=this,t=e.$createElement;e._self._c},o=[];n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return o})),n.d(t,"a",(function(){return a}))},ea58:function(e,t,n){"use strict";var a=n("9b9a"),i=n.n(a);i.a},f401:function(e,t,n){"use strict";n.r(t);var a=n("abaf"),i=n("a72b");for(var o in i)"default"!==o&&function(e){n.d(t,e,(function(){return i[e]}))}(o);n("ea58");var r,c=n("f0c5"),s=Object(c["a"])(i["default"],a["b"],a["c"],!1,null,"72b479f9",null,!1,a["a"],r);t["default"]=s.exports}},[["5536","common/runtime","common/vendor"]]]);