require('../common/vendor.js');(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/activity/giftCard/info"],{"08a4":function(t,n,i){"use strict";i.d(n,"b",(function(){return a})),i.d(n,"c",(function(){return c})),i.d(n,"a",(function(){return r}));var r={uniPopup:function(){return i.e("uni_modules/uni-popup/components/uni-popup/uni-popup").then(i.bind(null,"b29f"))}},a=function(){var t=this.$createElement;this._self._c},c=[]},"0cf4":function(t,n,i){"use strict";i.r(n);var r=i("08a4"),a=i("6e50");for(var c in a)["default"].indexOf(c)<0&&function(t){i.d(n,t,(function(){return a[t]}))}(c);i("8358");var e=i("828b"),u=Object(e["a"])(a["default"],r["b"],r["c"],!1,null,null,null,!1,r["a"],void 0);n["default"]=u.exports},"2d7d":function(t,n,i){},"6e50":function(t,n,i){"use strict";i.r(n);var r=i("6f4f"),a=i.n(r);for(var c in r)["default"].indexOf(c)<0&&function(t){i.d(n,t,(function(){return r[t]}))}(c);n["default"]=a.a},"6f4f":function(t,n,i){"use strict";(function(t){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var r=i("b0fe"),a=i("4d38"),c={name:"",data:function(){return{cardForm:{card_number:"",card_pwd:""},cardInfo:{id:"",name:"",fixed_time:[],type:1,batch_id:"",total_num:1,instructions:"",cover_image:"",valid_type:1,status:1,balance:0,exchange_type:1,gift_num:1,description:"",product:[]},disabled:!1,imgHost:a.HTTP_REQUEST_URL,cartList:[],showCart:!1}},computed:{totalLimitNum:function(){return(this.cardInfo.product||[]).reduce((function(t,n){return t+Number(n.cart_num||0)}),0)}},onLoad:function(t){this.cardForm.card_number=t.card_number,this.cardForm.card_pwd=t.card_pwd,t.card_number&&t.card_pwd&&this.getInfo()},methods:{getInfo:function(){var n=this;(0,r.giftCardGetInfoApi)(this.cardForm).then((function(i){n.cardInfo=i.data,n.cardInfo.description=i.data.description.replace(/<img/gi,'<img style="max-width: 100%;display:block;"'),n.cardInfo.product&&n.cardInfo.product.length&&n.cardInfo.product.map((function(t){n.$set(t,"cart_num",0)})),t.setNavigationBarTitle({title:1==n.cardInfo.type?"兑换礼金":"兑换礼品"})})).catch((function(t){return n.$util.Tips({title:t})}))},exchangeGift:function(){var n=this;if(2==this.cardInfo.exchange_type){if(this.totalLimitNum!=this.cardInfo.gift_num)return this.$util.Tips({title:"请检查兑换数量"});var i=this.cardInfo.product.filter((function(t){return t.cart_num>0})).map((function(t){return{product_id:t.product_id,limit_num:t.cart_num||0,unique:t.unique}}));this.$set(this.cardForm,"product",i)}this.disabled=!0,(0,r.giftCardReceiveApi)(this.cardForm).then((function(i){if(n.disabled=!1,1==n.cardInfo.type)n.$refs.popup.open();else{var r=i.data.map((function(t){return t.cartId})).join(",");t.navigateTo({url:"/pages/goods/order_confirm/index?cartId="+r+"&new=1"})}})).catch((function(t){return n.disabled=!1,n.$util.Tips({title:t})}))},toMoney:function(){this.$refs.popup.close(),t.redirectTo({url:"/pages/users/user_bill/index?type=2"})},closeGift:function(){this.$refs.popup.close()},canAddCart:function(){return 2==this.cardInfo.exchange_type&&this.totalLimitNum<Number(this.cardInfo.gift_num||0)},syncCartList:function(){this.cartList=(this.cardInfo.product||[]).filter((function(t){return Number(t.cart_num||0)>0}))},increaseLimitNum:function(t){if(!(this.totalLimitNum>=this.cardInfo.gift_num)&&this.canAddCart()){var n=this.cardInfo.product[t];this.$set(n,"cart_num",Number(n.cart_num||0)+1),this.syncCartList()}},decreaseLimitNum:function(t){if(!(this.cardInfo.product[t].cart_num<=0)){var n=this.cardInfo.product[t];!n||Number(n.cart_num||0)<=0||(this.$set(n,"cart_num",Number(n.cart_num||0)-1),this.syncCartList())}},addToCart:function(t){this.canAddCart()&&(this.$set(t,"cart_num",Number(t.cart_num||0)+1),this.syncCartList())},joinCart:function(t){if(this.canAddCart()){var n=this.cartList[t];n&&(this.$set(n,"cart_num",Number(n.cart_num||0)+1),this.syncCartList())}},leaveCart:function(t,n){var i=n||this.cartList[t];!i||Number(i.cart_num||0)<=0||(this.$set(i,"cart_num",Number(i.cart_num||0)-1),this.syncCartList())},subDel:function(){var t=this;(this.cardInfo.product||[]).forEach((function(n){t.$set(n,"cart_num",0)})),this.syncCartList(),this.showCart=!1},openCartDrawer:function(){if(!this.cartList.length)return this.$util.Tips({title:"请先添加兑换商品"});this.showCart=!0},closeDrawer:function(){this.showCart=!1},goDetail:function(n){t.navigateTo({url:"/pages/goods_details/index?id=".concat(n,"&fromType=1")})}}};n.default=c}).call(this,i("df3c")["default"])},"70df":function(t,n,i){"use strict";(function(t,n){var r=i("47a9");i("f076");r(i("3240"));var a=r(i("0cf4"));t.__webpack_require_UNI_MP_PLUGIN__=i,n(a.default)}).call(this,i("3223")["default"],i("df3c")["createPage"])},8358:function(t,n,i){"use strict";var r=i("2d7d"),a=i.n(r);a.a}},[["70df","common/runtime","common/vendor"]]]);