(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/category/components/pikerGoods"],{"1c47":function(t,e,i){"use strict";i.r(e);var n=i("ffd6"),s=i.n(n);for(var o in n)["default"].indexOf(o)<0&&function(t){i.d(e,t,(function(){return n[t]}))}(o);e["default"]=s.a},4497:function(t,e,i){},6496:function(t,e,i){"use strict";i.d(e,"b",(function(){return s})),i.d(e,"c",(function(){return o})),i.d(e,"a",(function(){return n}));var n={uIcon:function(){return Promise.all([i.e("common/vendor"),i.e("uni_modules/uview-ui/components/u-icon/u-icon")]).then(i.bind(null,"b248"))},uEmpty:function(){return Promise.all([i.e("common/vendor"),i.e("uni_modules/uview-ui/components/u-empty/u-empty")]).then(i.bind(null,"f174"))}},s=function(){var t=this,e=t.$createElement,i=(t._self._c,t.__map(t.list,(function(e,i){var n=t.__get_orig(e),s=t.hasSelected(e.id);return{$orig:n,m0:s}}))),n=t.list.length;t.$mp.data=Object.assign({},{$root:{l0:i,g0:n}})},o=[]},ac40:function(t,e,i){"use strict";var n=i("4497"),s=i.n(n);s.a},df56:function(t,e,i){"use strict";i.r(e);var n=i("6496"),s=i("1c47");for(var o in s)["default"].indexOf(o)<0&&function(t){i.d(e,t,(function(){return s[t]}))}(o);i("ac40");var r=i("828b"),c=Object(r["a"])(s["default"],n["b"],n["c"],!1,null,null,null,!1,n["a"],void 0);e["default"]=c.exports},ffd6:function(t,e,i){"use strict";(function(t){var n=i("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var s=n(i("7ca3")),o=i("8f59");function r(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function c(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?r(Object(i),!0).forEach((function(e){(0,s.default)(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):r(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}var u={components:{goodsPicker:function(){i.e("components/goods/goodsPicker").then(function(){return resolve(i("d582"))}.bind(null,i)).catch(i.oe)}},props:{list:{type:Array,default:[]},defaultSelectedList:{type:Array,default:[]},showTabbar:{type:Boolean,default:!1}},name:"goods",data:function(){return{selectedList:this.defaultSelectedList,cartIndex:0,goods:{},selected_sku:{},cartList:[],isLoading:!1}},computed:c({},(0,o.mapGetters)(["base","is_login"])),created:function(){this.getCartList(),this.initList()},watch:{defaultSelectedList:function(t){JSON.stringify(t)!=JSON.stringify(this.selectedList)&&(this.selectedList=t)},selectedList:{handler:function(e){this.initList(),t.setStorageSync("selectedList",JSON.stringify(e))},deep:!0}},methods:{initList:function(){var t=this;this.list.forEach((function(e){if(t.selectedList.some((function(t){return t.goods_id==e.id}))){var i=t.selectedList.find((function(t){return t.goods_id==e.id})),n=i.total||0,s=i.sku_id||"";t.$set(e,"total",n),t.$set(e,"sku_id",s)}}))},getCartList:function(){var t=this;this.$util.get("user/cart/index",{},!1,!1).then((function(e){1==e.code?t.cartList=e.data.list:t.cartList=[]}))},addCart:function(t){this.selectedList.push(t),this.$emit("selectedListChange",this.selectedList),this.getCartList()},hasSelected:function(t){var e=this.selectedList.some((function(e){return e.goods_id==t}));return e},onSpec:function(t){if(!this.is_login)return this.$util.authLogin();this.goods=t,this.$refs["goodsPicker"].show()},delCart:function(t){var e=this,i=this.cartList.filter((function(e){return e.goods_id==t.id&&e.sku_id==t.sku_id})).map((function(t){return t.id}));this.$util.post("user/cart/del",{cart_ids:i}).then((function(i){1==i.code?(e.getCartList(),e.selectedList=e.selectedList.filter((function(e){return e.goods_id!=t.id})),e.$emit("selectedListChange",e.selectedList)):e.toast(i.message)}))},jisuan:function(t,e){var i=this;if(!this.isLoading){this.isLoading=!0;var n=this.cartList.find((function(e){return e.goods_id==t.id})),s=parseInt(t.total),o=s;if(1==e)if(1==s){if(1==n.total)return this.delCart(t);s=n.total-1,o=0}else s=n.total-1,o--;else{if(n.total>=n.stock)return!1;s=n.total+1,o++}var r={cart_id:"",total:s};n&&(r.cart_id=n.id),t.sku_id&&(r.sku_id=t.sku_id),this.$util.get("user/cart/edit",r).then((function(e){if(1==e.code){if(0==o)i.selectedList=i.selectedList.filter((function(e){return e.goods_id!=t.id}));else{var n=i.selectedList.findIndex((function(e){return e.goods_id==t.id})),s=i.selectedList[n];i.$set(i.selectedList,n,c(c({},s),{},{total:o}))}i.$emit("selectedListChange",i.selectedList)}else i.$util.toast(e.message)})).catch((function(t){})).finally((function(){i.getCartList(),i.isLoading=!1}))}},jump:function(t){if(!t)return!1;this.$util.jump("/pages/goods/detail?id="+t)}}};e.default=u}).call(this,i("df3c")["default"])}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
    'pages/category/components/pikerGoods-create-component',
    {
        'pages/category/components/pikerGoods-create-component':(function(module, exports, __webpack_require__){
            __webpack_require__('df3c')['createComponent'](__webpack_require__("df56"))
        })
    },
    [['pages/category/components/pikerGoods-create-component']]
]);
