require("../sub-vendors.js"),(wx.webpackJsonp=wx.webpackJsonp||[]).push([[7267],{1530:function(n,e,t){var i=t(4160),o=t(5652),r=t(2555),a=t(4107),s=t(4576),c=t(4269),u=t(2573),l=t.n(u),p=t(758),f=t(3816),v=t(8838),d=t(9761),g=t(9887),m=t(6070),A=function(){var n=(0,p.useState)({imageUrl:"",positiveTitle:"开启提醒",negativeTitle:"暂不开启提醒",args:[],mtopApiName:"",mtopApiConfig:"",mtopApiArgs:"",positiveBtnTextColor:"",negativeBtnTextColor:""}),e=(0,s.A)(n,2),t=e[0],i=e[1],A=(0,u.useRouter)(),h=(0,p.useRef)(!1);(0,u.useLoad)((function(){var n=(null==A?void 0:A.params)||{},e=n.args,o=void 0===e?"":e,r=n.bgUrl,s=void 0===r?"":r,c=n.mtopApiName,u=void 0===c?"":c,l=n.mtopApiConfig,p=void 0===l?"":l,f=n.mtopApiArgs,v=void 0===f?"":f,d=n.positiveBtnTextColor,g=void 0===d?"":d,m=n.negativeBtnTextColor,h=void 0===m?"":m,T=[];try{T=JSON.parse(decodeURIComponent(o)).map((function(n){var e=n;return"string"!=typeof e.entityIds&&e.entityIds.length>0&&(e.entityIds=e.entityIds[0]),e})),i((0,a.A)((0,a.A)({},t),{},{imageUrl:decodeURIComponent(s),mtopApiName:u,mtopApiConfig:p?JSON.parse(decodeURIComponent(p)):{},mtopApiArgs:v?JSON.parse(decodeURIComponent(v)):{},positiveBtnTextColor:g,negativeBtnTextColor:h,args:T}))}catch(n){}}));var T=function(){var n=(0,r.A)((0,o.A)().m((function n(){var e,i,a;return(0,o.A)().w((function(n){for(;;)switch(n.n){case 0:if(e=t.args,0!==(i=void 0===e?[]:e).length){n.n=1;break}return l().showToast({title:"暂时无法订阅，请退出后再试~",icon:"none"}),n.a(2);case 1:if(a=i.map((function(n){return n.entityIds})),!h.current){n.n=2;break}return n.a(2);case 2:h.current=!0,l().requestSubscribeMessage({tmplIds:a,success:function(){var n=(0,r.A)((0,o.A)().m((function n(e){var t,i;return(0,o.A)().w((function(n){for(;;)switch(n.n){case 0:if(h.current=!1,!((t=(a||[]).filter((function(n){return"accept"===e[n]})))&&t.length>0)){n.n=7;break}return n.n=1,f.A.isLogin();case 1:if(n.v){n.n=5;break}return n.n=2,f.A.login();case 2:if(i=n.v,!i.success){n.n=3;break}w(t),n.n=4;break;case 3:return l().showToast({title:"登录失败，请登录后重试",icon:"none"}),n.a(2);case 4:n.n=6;break;case 5:w(t);case 6:n.n=8;break;case 7:l().showToast({title:"请点击右上角「设置-通知管理」，打开相关通知权限",icon:"none",duration:3e3});case 8:return n.a(2)}}),n)})));return function(e){return n.apply(this,arguments)}}(),fail:function(n){h.current=!1,20004===(n||{}).errCode&&l().showToast({title:"请打开右上角设置-允许接收订阅消息后重试",icon:"none",duration:3e3})},entityIds:[]});case 3:return n.a(2)}}),n)})));return function(){return n.apply(this,arguments)}}(),w=function(n){l().showLoading({title:"消息订阅中~"});var e=t.mtopApiName,i=void 0===e?"":e,o=t.mtopApiConfig,r=void 0===o?{}:o,a=t.mtopApiArgs,s=void 0===a?{}:a;if(i||Object.keys(r).length)return b(s);x({templateIds:n.join(",")}).then((function(){l().hideLoading(),l().showToast({title:"订阅成功~",icon:"none"}),setTimeout((function(){l().navigateBack()}),1500)})).catch((function(n){var e=n.message,t=void 0===e?"订阅失败，请稍后再试":e;l().hideLoading(),l().showToast({title:t,icon:"none"})}))},b=function(){var n=(0,r.A)((0,o.A)().m((function n(e){var i,r,c,u,p,f,v,m;return(0,o.A)().w((function(n){for(;;)switch(n.n){case 0:return i=t.mtopApiName,r=void 0===i?"":i,c=t.mtopApiConfig,u=void 0===c?{}:c,p=d.A[r]||u,f=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new g.p((0,a.A)((0,a.A)({},p),n)).create()},n.n=1,f(e);case 1:v=n.v,m=(0,s.A)(v,1),m[0]?(l().hideLoading(),l().showToast({title:"订阅失败，请稍后再试",icon:"none"})):(l().hideLoading(),l().showToast({title:"订阅成功~",icon:"none"}),setTimeout((function(){l().navigateBack()}),2e3));case 2:return n.a(2)}}),n)})));return function(e){return n.apply(this,arguments)}}(),x=function(){var n=(0,r.A)((0,o.A)().m((function n(e){var t,i,r,c;return(0,o.A)().w((function(n){for(;;)switch(n.n){case 0:return n.n=1,v.A.subscribeMessage({data:(0,a.A)({platform:42},e)});case 1:if(t=n.v,i=(0,s.A)(t,2),r=i[0],c=i[1],!r){n.n=2;break}throw new Error(r);case 2:return n.a(2,c);case 3:return n.a(2)}}),n)})));return function(e){return n.apply(this,arguments)}}();return(0,m.jsx)(c.Ss,{className:"notification-container",children:(0,m.jsxs)(c.Ss,{className:"notification-view-content",children:[(0,m.jsx)(c._V,{src:t.imageUrl||"",mode:"aspectFill",className:"img-content"}),(0,m.jsxs)(c.Ss,{className:"btn-container",children:[(0,m.jsx)(c.Ss,{className:"positive-btn",onTap:T,style:{color:(null==t?void 0:t.positiveBtnTextColor)||"#80461D"},children:null==t?void 0:t.positiveTitle}),(0,m.jsx)(c.Ss,{className:"negative-btn",onTap:function(){l().navigateBack()},style:{color:(null==t?void 0:t.negativeBtnTextColor)||"#fff"},children:null==t?void 0:t.negativeTitle})]})]})})};Page((0,i.eU)(A,"subPackages/notification/index",{root:{cn:[]}},{enablePullDownRefresh:!1,navigationBarTitleText:"活动提醒",navigationBarTextStyle:"black",backgroundTextStyle:"light",navigationBarBackgroundColor:"#ffffff"}||{}))}},function(n){n.O(0,[6907,8096,2076],(function(){return e=1530,n(n.s=e);var e})),n.O()}]);