"use strict";var e=require("../common/vendor.js"),o=require("../api/coupon.js");require("../common/request.js");const t={name:"getCoupon",props:{},data:function(){return{couponId:null,item:null,isShare:null,code:null}},onLoad(o){this.couponId=o.couponId,this.code=o.code,this.$isEmpty(o.isShare)?e.index.hideShareMenu():(this.isShare=o.isShare,this.genCode()),console.log(o.couponId),this.companyId=e.index.getStorageSync("companyId"),this.companyUserId=e.index.getStorageSync("companyUserId"),this.getCouponById()},onShareAppMessage(o){return e.index.showShareMenu({withShareTicket:!0}),wx.updateShareMenu({isPrivateMessage:!0,withShareTicket:!0,success(e){console.log("updateShareMenu: ",e)},fail(){}}),{title:this.item.title,path:"/pages_company/couponDetails?couponId="+this.item.couponId+"&companyId="+this.companyId+"&companyUserId="+this.companyUserId+"&code="+this.code}},mounted:function(){},onShow(){},methods:{genCode:function(){let e=this;var t={couponId:this.couponId};o.genCode(t).then((function(o){e.code=o.data})).catch((function(e){}))},getCouponById:function(){let t=this;var n={couponId:this.couponId};o.getCouponById(n).then((function(e){t.item=e.data})).catch((function(o){e.index.showToast({title:o.msg,icon:"none",duration:2e3})}))},receive:function(){var t={couponId:this.item.couponId,companyId:this.companyId,companyUserId:this.companyUserId,code:this.code};o.receive(t).then((function(o){200==o.code?e.index.showToast({title:"领取成功",icon:"success",duration:2e3}):e.index.showToast({title:o.msg,duration:2e3})})).catch((function(o){e.index.showToast({title:o.msg,icon:"none",duration:2e3})}))}}};var n=e._export_sfc(t,[["render",function(o,t,n,i,c,s){return e.e({a:null!=o.item},null!=o.item?e.e({b:e.t(o.item.price.toFixed(2)),c:e.t(o.item.minPrice.toFixed(2)),d:e.t(o.item.title),e:e.t(o.item.limitTime),f:o.item.remainNumber>0},o.item.remainNumber>0?{g:e.o((e=>s.receive()))}:(o.item.remainNumber,{}),{h:0==o.item.remainNumber}):{})}],["__scopeId","data-v-bfdfb32e"]]);t.__runtimeHooks=2,wx.createPage(n);
