spec-popup.js 5.8 KB

12345678910
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/spec-popup/spec-popup"],{"602e":function(e,t,o){"use strict";o.r(t);var i=o("b75d"),n=o("a512");for(var s in n)["default"].indexOf(s)<0&&function(e){o.d(t,e,(function(){return n[e]}))}(s);o("d9f9");var c=o("f0c5"),u=Object(c["a"])(n["default"],i["b"],i["c"],!1,null,"ae4ed8d4",null,!1,i["a"],void 0);t["default"]=u.exports},"67e5":function(e,t,o){"use strict";(function(e){var i=o("4ea4");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(o("448a")),s={data:function(){return{shop:{},checkedGoods:{stock:0},outOfStock:[],specList:[],disable:[],goodsNum:1,showPop:!1}},props:{show:{type:Boolean},goods:{type:Object},showAdd:{type:Boolean,default:!0},showBuy:{type:Boolean,default:!0},showConfirm:{type:Boolean,default:!1},redBtnText:{type:String,default:"立即购买"},yellowBtnText:{type:String,default:"加入购物车"},showStock:{type:Boolean,default:!0},group:{type:Boolean,default:!1},isSeckill:{type:Boolean,default:!1},type:{}},computed:{specValueText:function(){var e,t,o,i=this,n=null===(e=this.checkedGoods.spec_value_ids)||void 0===e?void 0:e.split(","),s="";return n&&n.forEach((function(e,t){""==e&&(s+=i.specList[t].name+",")})),0!=(null===(t=this.checkedGoods)||void 0===t?void 0:t.stock)&&""==s?"已选择 ".concat(this.checkedGoods.spec_value_str," ").concat(this.goodsNum," 件"):0!=(null===(o=this.checkedGoods)||void 0===o?void 0:o.stock)&&s.length?"请选择 ".concat(s.slice(0,s.length-1)):"库存不足"}},watch:{goods:function(e){this.specList=e.goods_spec||[];var t=e.goods_item||[];this.shop=e.shop||{},this.outOfStock=t.filter((function(e){return 0==e.stock}));var o=t.filter((function(e){return 0!=e.stock}));0!=o.length?(o[0].spec_value_ids_arr=o[0].spec_value_ids.split(","),this.checkedGoods=o[0]):(t[0].spec_value_ids_arr=[],this.disable=t.map((function(e){return e.spec_value_ids.split(",")})),this.checkedGoods=t[0])},specList:function(e){var t=this,o=this.goods.goods_item.filter((function(e){return t.checkedGoods.spec_value_ids===e.spec_value_ids}));if(0!=o.length){var i=JSON.parse(JSON.stringify(o[0]));i.spec_value_ids_arr=i.spec_value_ids.split(","),this.checkedGoods=i,this.$emit("change",{detail:this.checkedGoods})}var n=this.checkedGoods.spec_value_ids_arr,s=this.outOfStock,c=this.getArrResult(n,s);this.disable=this.getOutOfStockArr(c,n)},show:function(e){this.showPop=e}},created:function(){console.log("spec")},methods:{isDisable:function(e){if(this.disable.includes(e))return!0;var t=this.checkedGoods,o=this.goods.goods_item.filter((function(e){return 0==t.stock&&t.spec_value_ids===e.spec_value_ids}));return o.length?t.spec_value_ids_arr.includes(e+""):void 0},onClose:function(){this.$emit("close")},onClick:function(e){var t=this.checkedGoods,o=this.goodsNum;return-1!=this.specValueText.indexOf("请选择")?this.$toast({title:this.specValueText}):0==t.stock?this.$toast({title:"当前选择库存不足"}):(t.goodsNum=o,void this.$emit(e,{detail:t}))},choseSpecItem:function(e,t){var o=this.specList[e].spec_value[t].id,i=this.checkedGoods.spec_value_ids_arr;o==i[e]?i[e]="":i[e]=o,this.checkedGoods.spec_value_ids_arr=i,this.checkedGoods.spec_value_ids=i.join(","),this.specList=(0,n.default)(this.specList)},getOutOfStockArr:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return e.forEach((function(e){e.num>=t.length-1&&o.push.apply(o,(0,n.default)(e.different))})),o},getArrIdentical:function(e,t){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;return e.forEach((function(e){t.forEach((function(t){e==t&&(i+=1,o.push(e))}))})),{num:i,different:this.getArrDifference((0,n.default)(new Set(o)).map(Number),t.map(Number)),identical:(0,n.default)(new Set(o))}},getArrResult:function(e,t){var o=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return t.forEach((function(t){var n=o.getArrIdentical(e,t.spec_value_ids.split(","));void 0!=n&&0!=n.length&&i.push(n)})),i},getArrDifference:function(e,t){return e.concat(t).filter((function(e,t,o){return o.indexOf(e)==o.lastIndexOf(e)}))},previewImage:function(t){e.previewImage({current:t,urls:[t]})}}};t.default=s}).call(this,o("543d")["default"])},a512:function(e,t,o){"use strict";o.r(t);var i=o("67e5"),n=o.n(i);for(var s in i)["default"].indexOf(s)<0&&function(e){o.d(t,e,(function(){return i[e]}))}(s);t["default"]=n.a},b75d:function(e,t,o){"use strict";o.d(t,"b",(function(){return n})),o.d(t,"c",(function(){return s})),o.d(t,"a",(function(){return i}));var i={uPopup:function(){return o.e("components/uview-ui/components/u-popup/u-popup").then(o.bind(null,"d6b4"))},uImage:function(){return o.e("components/uview-ui/components/u-image/u-image").then(o.bind(null,"2a31"))},priceFormat:function(){return o.e("components/price-format/price-format").then(o.bind(null,"87ff"))},uNumberBox:function(){return o.e("components/uview-ui/components/u-number-box/u-number-box").then(o.bind(null,"16c2"))}},n=function(){var e=this,t=e.$createElement,o=(e._self._c,e.__map(e.specList,(function(t,o){var i=e.__get_orig(t),n=e.__map(t.spec_value,(function(t,i){var n=e.__get_orig(t),s=e.checkedGoods.spec_value_ids_arr[o]!=t.id&&e.isDisable(t.id),c=e.isDisable(t.id);return{$orig:n,m0:s,m1:c}}));return{$orig:i,l0:n}}))),i=e.shop.is_pay?e.specValueText.indexOf("请选择"):null;e.$mp.data=Object.assign({},{$root:{l1:o,g0:i}})},s=[]},d9f9:function(e,t,o){"use strict";var i=o("ef1f"),n=o.n(i);n.a},ef1f:function(e,t,o){}}]);
  2. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  3. 'components/spec-popup/spec-popup-create-component',
  4. {
  5. 'components/spec-popup/spec-popup-create-component':(function(module, exports, __webpack_require__){
  6. __webpack_require__('543d')['createComponent'](__webpack_require__("602e"))
  7. })
  8. },
  9. [['components/spec-popup/spec-popup-create-component']]
  10. ]);