app-attr.js 8.6 KB

12345678910
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/page-component/app-attr/app-attr"],{"156a":function(t,e,r){},"286c":function(t,e,r){"use strict";var i=r("156a"),n=r.n(i);n.a},"469b":function(t,e,r){"use strict";r.r(e);var i=r("49c4"),n=r.n(i);for(var o in i)"default"!==o&&function(t){r.d(e,t,(function(){return i[t]}))}(o);e["default"]=n.a},"49c4":function(t,e,r){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=r("2f62");function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function s(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var a=function(){r.e("components/page-component/app-member-mark/app-member-mark").then(function(){return resolve(r("0989"))}.bind(null,r)).catch(r.oe)},u=function(){r.e("components/page-component/goods/app-price").then(function(){return resolve(r("e82c"))}.bind(null,r)).catch(r.oe)},c=function(){r.e("components/basic-component/app-input/app-input").then(function(){return resolve(r("001f"))}.bind(null,r)).catch(r.oe)},l=function(){r.e("components/basic-component/app-image/app-image").then(function(){return resolve(r("e7ea"))}.bind(null,r)).catch(r.oe)},h=function(){r.e("components/basic-component/app-iphone-x/app-iphone-x").then(function(){return resolve(r("a339"))}.bind(null,r)).catch(r.oe)},p={name:"app-attr",components:{appMemberMark:a,appPrice:u,appInput:c,"app-image":l,"app-iphone-x":h},props:{goods:Object,attrGroupList:Array,attrCart:{type:Array,default:function(){return[]}},cartShow:{type:Boolean,default:function(){return!0}},previewUrl:String,submitUrl:String,goodsId:{type:Number,default:function(){return 0}},show:Number,buyText:{type:String,default:function(){return"立即报名"}},plugin:{default:""},theme:{type:String,default:"classic-red"},chooseNumber:{type:Boolean,default:!0},noPay:{type:Boolean,default:!1},buyClick:{type:Boolean,default:!1},addText:{type:String,default:"加入购物车"},is_show_buy:{type:Boolean,default:!0}},data:function(){return{display:"none",number:1,selectAttr:null,newAttrGroupList:null,pic_url:null}},watch:{show:function(){this.alert()},newData:{handler:function(){this.$emit("attr",this.newData)},immediate:!0},attrGroupList:{handler:function(){this.newAttrGroupList=this.attrGroupList,"block"==this.display&&this.alert()},immediate:!0},goods:{handler:function(){"block"==this.display&&this.alert()},immediate:!0}},methods:{alert:function(){if(0!==this.attrGroupList.length){var t=this.attrGroupList,e=this.goods.attr,r=null;if(this.number=1,1===t.length){for(var i in e)for(var n in t[0].attr_list)t[0].attr_list[n].attr_id==e[i].attr_list[0].attr_id&&(e[i].stock>0?(1===e.length&&(t[0].attr_list[n].checked=!0),t[0].attr_list[n].attr_num_0=!1,this.pic_url=t[0].attr_list[n].pic_url):(this.number=0,t[0].attr_list[n].checked=!1,t[0].attr_list[n].attr_num_0=!0));1===e.length&&(r=e[0],this.$emit("attrtap",r))}this.display="block",this.newAttrGroupList=t,this.selectAttr=r}},close:function(){this.display="none"},preventD:function(){},storeAttrClick:function(e,r){var i=JSON.parse(JSON.stringify(this.newAttrGroupList)),n=this.goods.attr,o=[],s=this.attrCart;for(var a in i)for(var u in i[a].attr_list){var c=i[a].attr_list[u];if(parseInt(i[a].attr_group_id)==parseInt(r))if(parseInt(c.attr_id)===parseInt(e)){if(c.checked?c.checked=!1:c.checked=!0,c.attr_num_0)return}else c.checked=!1;c.checked&&(0==a&&(this.pic_url=i[0].attr_list[u].pic_url),o.push(i[a].attr_group_id+"-"+c.attr_id))}function l(t,e){return e.some((function(e){return t==e}))}var h=[],p=null,d=1;for(var m in n){var f=[],b=0;for(var _ in n[m].attr_list){var g=n[m].attr_list[_].attr_group_id+"-"+n[m].attr_list[_].attr_id;l(g,o)||(b+=1,f.push(g))}if(0==n[m].stock&&b<=1&&(h=h.concat(f)),0==b){if(p||(p={}),p=n[m],s.forEach((function(t){t.attr_id==p.id&&(d=t.num)})),p.stock<=0)return void t.showToast({title:"库存不足",icon:"none"});p.stock<=d&&(d=p.stock)}}for(var v in 0==o.length&&(p=null),i)for(var y in i[v].attr_list){var w=i[v].attr_list[y],A=i[v].attr_group_id+"-"+w.attr_id;l(A,h)&&!l(A,o)?w.attr_num_0=!0:w.attr_num_0=!1}this.newAttrGroupList=i,this.selectAttr=p,this.number=d,this.$emit("attrtap",this.selectAttr)},numberBlur:function(e){return e=parseInt(e.value),e>this.attrNum&&(t.showToast({title:"库存不足",icon:"none"}),e=this.attrNum),this.$emit("attrtap",this.selectAttr),this.number=e},numberSub:function(){var t=this.number;if(t<=1)return!0;t--,this.number=t,this.$emit("attrtap",this.selectAttr)},numberAdd:function(){var e=this.number;if(e++,e>this.attrNum)return t.showToast({title:"库存不足",icon:"none"}),void(this.number=this.attrNum);this.number=e,this.$emit("attrtap",this.selectAttr)},cart:function(){var e=this;if(!this.submit())return!1;var r=this.selectAttr;"pick"!==this.goods.sign?"miaosha"===this.goods.sign?this.$request({url:this.$api.miaosha.add_cart,data:{miaosha_goods_id:r.goods_id,attr_id:r.id,num:this.number},method:"post"}).then((function(r){t.showToast({title:r.msg,type:"success"}),e.display="none",e.selectAttr.number=e.number,e.$emit("selectNumber",e.selectAttr)})).catch((function(t){e.display="none"})):this.$request({url:this.$api.cart.add,data:{goods_id:r.goods_id,attr:r.id,num:this.number},method:"post"}).then((function(r){t.showToast({title:r.msg,type:"success"}),e.display="none",e.selectAttr.number=e.number,e.$emit("selectNumber",e.selectAttr)})).catch((function(t){e.display="none"})):this.$emit("add",r,this.number)},buy:function(){if(!this.submit())return!1;if(this.noPay)this.$emit("pay",this.number);else{if(this.buyClick)return this.display="none",this.selectAttr.number=this.number,this.$emit("buyClick",this.selectAttr),!1;var e=this.goods;console.log("goods---",e);var r=this.number,i=this.selectAttr,n=i.id,o=[];for(var s in i.attr_list)o.push({attr_id:i.attr_list[s].attr_id,attr_group_id:i.attr_list[s].attr_group_id});var a=[{mch_id:e.mch_id?e.mch_id:0,goods_list:[{id:this.goodsId?this.goodsId:e.id,attr:o,num:r,cat_id:0,goods_attr_id:n}]}],u="/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify(a));this.submitUrl&&this.previewUrl&&(u+="&preview_url=".concat(encodeURIComponent(this.previewUrl),"&submit_url=").concat(encodeURIComponent(this.submitUrl),"&plugin=").concat(this.plugin)),t.navigateTo({url:u})}},submit:function(){var e=this.goods,r=this.number,i=this.selectAttr;return i?i.stock<=0?(t.showToast({title:"库存不足",icon:"none"}),!1):r<=0?(t.showToast({title:"数量不能为0",icon:"none"}),!1):!!e:(t.showToast({title:"请先选规格",icon:"none"}),!1)},clickImg:function(e){t.previewImage({current:0,urls:[e]})}},computed:o(o({},(0,i.mapState)({gConfig:function(t){return t.gConfig}})),{},{attrPic:function(){return this.pic_url?this.pic_url:this.goods?this.goods.cover_pic:""},priceColor:function(){return this.goods&&1===this.goods.level_show?"member":this.theme+"-color"},attrNum:function(){return this.selectAttr?this.selectAttr.stock:this.goods?this.goods.goods_num:0},attrPrice:function(){return this.selectAttr?1===this.goods.level_show?this.selectAttr.price_member:this.selectAttr.price:this.goods?this.goods.price:0},newData:function(){var t=this.number,e=this.display,r=this.selectAttr;return{number:t,display:e,selectAttr:r}}},(0,i.mapGetters)("iPhoneX",{boolEmpty:"getBoolEmpty"}))};e.default=p}).call(this,r("543d")["default"])},"58fd":function(t,e,r){"use strict";r.r(e);var i=r("74dd"),n=r("469b");for(var o in n)"default"!==o&&function(t){r.d(e,t,(function(){return n[t]}))}(o);r("286c");var s,a=r("f0c5"),u=Object(a["a"])(n["default"],i["b"],i["c"],!1,null,"680b80e6",null,!1,i["a"],s);e["default"]=u.exports},"74dd":function(t,e,r){"use strict";var i;r.d(e,"b",(function(){return n})),r.d(e,"c",(function(){return o})),r.d(e,"a",(function(){return i}));var n=function(){var t=this,e=t.$createElement;t._self._c},o=[]}}]);
  2. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  3. 'components/page-component/app-attr/app-attr-create-component',
  4. {
  5. 'components/page-component/app-attr/app-attr-create-component':(function(module, exports, __webpack_require__){
  6. __webpack_require__('543d')['createComponent'](__webpack_require__("58fd"))
  7. })
  8. },
  9. [['components/page-component/app-attr/app-attr-create-component']]
  10. ]);