1
0

u-attr.js 6.8 KB

12345678910
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/page-component/goods/u-attr"],{"0dd7":function(t,e,i){"use strict";i.r(e);var n=i("595b"),o=i.n(n);for(var c in n)"default"!==c&&function(t){i.d(e,t,(function(){return n[t]}))}(c);e["default"]=o.a},"595b":function(t,e,i){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=function(){i.e("components/basic-component/u-popup/u-popup").then(function(){return resolve(i("62f5"))}.bind(null,i)).catch(i.oe)},o=function(){i.e("components/page-component/goods/app-price").then(function(){return resolve(i("0c14"))}.bind(null,i)).catch(i.oe)},c=function(){i.e("components/page-component/app-member-mark/app-member-mark").then(function(){return resolve(i("3f20"))}.bind(null,i)).catch(i.oe)},r={name:"u-attr",props:{value:{type:Boolean},goods:{type:Object},themeObject:{type:Object},checked:{type:Object},is_show_price:{type:Boolean,default:!0},is_show_left:{type:Boolean,default:!0},is_must_left:{type:Boolean,default:!0},is_show_right:{type:Boolean,default:!0},leftText:{type:String,default:"加入购物车"},rightText:{type:String,default:"立即购买"},leftFunc:{type:Boolean},rightFunc:{type:Boolean},sign:{type:String},again:{type:Number}},data:function(){return{newValue:!1,picUrl:null,newGroup:[],number:1}},methods:{close:function(){this.$emit("input",!1)},turnOn:function(){this.$emit("input",!0)},inArray:function(t,e){return e.some((function(e){return t===e}))},identifier:function(t,e,i){var n=this;t.forEach((function(t){t.attr_list.forEach((function(o){var c="".concat(t.attr_group_id,"-").concat(o.attr_id);n.inArray(c,e)&&!n.inArray(c,i)?o.num_0=!0:o.num_0=!1}))}))},selectCheck:function(t,e,i){var n=this;t.forEach((function(t){var o=[],c=0;t.attr_list.forEach((function(t){var e="".concat(t.attr_group_id,"-").concat(t.attr_id);n.inArray(e,i)||(c+=1,o.push(e))})),0===t.stock&&c<=1&&Array.prototype.push.apply(e,o),0===c&&n.$emit("check",t,1)}))},storeAttr:function(t,e,i){var n=this;if(!0!==i){var o=this.newGroup,c=this.copyAttr,r=[];o.forEach((function(i,o){var c=i.attr_list;c.forEach((function(c){i.attr_group_id===e&&(c.attr_id===t?!0===c.select?c.select=!1:c.select=!0:c.select=!1),!0===c.select&&(r.push("".concat(i.attr_group_id,"-").concat(c.attr_id)),0===o&&(n.picUrl=c.pic_url))}))}));var s=[];this.selectCheck(c,s,r),this.$nextTick((function(){n.number>n.stock&&(n.number=n.stock)})),this.identifier(o,s,r),r.length!==o.length&&this.$emit("check",null,1)}},firstSelect:function(){var t=this;if(this.copyGroup&&this.copyAttr){var e=this.copyGroup,i=this.copyAttr,n=e.length,o=[];i.forEach((function(i){var c=i.attr_list;c.forEach((function(c){var r=c.attr_group_id;e.forEach((function(s){if(r===s.attr_group_id){var a=s.attr_list;a.forEach((function(r){r.attr_id===c.attr_id&&i.stock>0&&n>0&&(r.select=!0,o.push("".concat(s.attr_group_id,"-").concat(r.attr_id)),n===e.length&&(t.picUrl=r.pic_url),n--)}))}}))}))}));var c=[];this.selectCheck(i,c,o),this.identifier(e,c,o),this.newGroup=e}},numberBlur:function(e){var i=parseInt(e.detail.value);i||(i=1),i>this.stock&&(i=this.stock,t.showToast({title:"库存不足",icon:"none"})),this.number=i},numberSub:function(){var t=this.number;t>1&&(t--,this.number=t)},numberAdd:function(){var e=this.number;e++,e>this.stock&&(e=this.stock,t.showToast({title:"库存不足",icon:"none"})),this.number=e},leftSubmit:function(){!0===this.leftFunc?this.$emit("leftFunc",this.number):this.cart(),this.close()},rightSubmit:function(){var e=[];if(!this.checked)return t.showToast({title:"请先选规格",icon:"none"}),!1;this.checked.attr_list.forEach((function(t){e.push({attr_id:t.attr_id,attr_group_id:t.attr_group_id})}));var i={mch_id:this.goods.mch_id?this.goods.mch_id:0,goods_list:[{id:this.goods.id,attrs:e,num:this.number,cat_id:0,goods_attr_id:this.checked.id}]};!0===this.rightFunc?this.$emit("rightFunc",i):this.shop(i),this.close()},shop:function(e){t.navigateTo({url:"/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify([e]))})},cart:function(){var e=this;if(!this.checked)return t.showToast({title:"请先选规格",icon:"none"}),!1;"ecard"!==this.goods.type&&this.$request({url:this.$api.cart.add,method:"post",data:{goods_id:this.checked.goods_id,attr:this.checked.id,num:this.number}}).then((function(i){0===i.code?(t.showToast({title:i.msg,icon:"none"}),e.$emit("cart",e.checked,e.number),e.close()):t.showToast({title:i.msg,icon:"none",duration:2500})}))},clickImg:function(e){t.previewImage({current:0,urls:[e]})}},components:{uPopup:n,appPrice:o,appMemberMark:c},computed:{imgUrl:function(){return this.picUrl?this.picUrl:this.goods?this.goods.cover_pic:""},stock:function(){return this.$validation.isEmpty(this.checked)?this.$validation.isEmpty(this.goods)?void 0:this.goods.goods_num:this.checked.stock},sellPrice:function(){return this.$validation.isEmpty(this.checked)?this.$validation.isEmpty(this.goods)?void 0:this.goods.hasOwnProperty("price_min")?this.goods.price_min:this.goods.price:1===this.goods.level_show?this.checked.price_member:this.checked.price},copyGroup:function(){if(this.goods){for(var t=this.$utils.deepClone(this.goods.attr_groups),e=0;e<t.length;e++)t[e].attr_list.forEach((function(t){t.select=!1,t.num_0=!1}));return t}},copyAttr:function(){if(this.goods)return this.$utils.deepClone(this.goods.attr)},cartClass:function(){return this.$slots.left_slot?"":"a"===this.themeObject.theme||"b"===this.themeObject.theme||"f"===this.themeObject.theme?this.themeObject.sBack+" u-btn u-btn-color ":this.themeObject.sBack+" u-btn "+this.themeObject.color}},watch:{value:{handler:function(t){this.newValue=t,!1!==t&&this.$validation.isEmpty(this.checked)&&this.$utils.throttle(this.firstSelect,800)},immediate:!0},number:{handler:function(t){this.$emit("check",this.checked,t)}},again:{handler:function(){this.firstSelect()}}}};e.default=r}).call(this,i("543d")["default"])},"72c4":function(t,e,i){},bca3:function(t,e,i){"use strict";var n=i("72c4"),o=i.n(n);o.a},ee7c:function(t,e,i){"use strict";var n;i.d(e,"b",(function(){return o})),i.d(e,"c",(function(){return c})),i.d(e,"a",(function(){return n}));var o=function(){var t=this,e=t.$createElement;t._self._c},c=[]},fae7:function(t,e,i){"use strict";i.r(e);var n=i("ee7c"),o=i("0dd7");for(var c in o)"default"!==c&&function(t){i.d(e,t,(function(){return o[t]}))}(c);i("bca3");var r,s=i("f0c5"),a=Object(s["a"])(o["default"],n["b"],n["c"],!1,null,"00bfab64",null,!1,n["a"],r);e["default"]=a.exports}}]);
  2. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  3. 'components/page-component/goods/u-attr-create-component',
  4. {
  5. 'components/page-component/goods/u-attr-create-component':(function(module, exports, __webpack_require__){
  6. __webpack_require__('543d')['createComponent'](__webpack_require__("fae7"))
  7. })
  8. },
  9. [['components/page-component/goods/u-attr-create-component']]
  10. ]);