12345678910 |
- (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/page-component/app-attr/app-attr"],{"1a13":function(t,e,r){"use strict";r.r(e);var i=r("4f65"),o=r.n(i);for(var s in i)"default"!==s&&function(t){r.d(e,t,(function(){return i[t]}))}(s);e["default"]=o.a},"4f65":function(t,e,r){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=r("2f62");function o(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 s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?o(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){var r;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(r=u(t))||e&&t&&"number"===typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,n=!0,a=!1;return{s:function(){r=t[Symbol.iterator]()},n:function(){var t=r.next();return n=t.done,t},e:function(t){a=!0,s=t},f:function(){try{n||null==r.return||r.return()}finally{if(a)throw s}}}}function u(t,e){if(t){if("string"===typeof t)return l(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var c=function(){r.e("components/page-component/goods/app-price").then(function(){return resolve(r("8619"))}.bind(null,r)).catch(r.oe)},h=function(){r.e("components/basic-component/app-image/app-image").then(function(){return resolve(r("c77f"))}.bind(null,r)).catch(r.oe)},d=function(){r.e("components/page-component/app-member-mark/app-member-mark").then(function(){return resolve(r("5aba"))}.bind(null,r)).catch(r.oe)},p={name:"app-attr",components:{appPrice:c,"app-image":h,appMemberMark:d},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:"a"},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},sign:{type:String},totalPrice:{type:String,default:"0.00"},totalNumber:{type:Number,default:0},discount:{type:Number,default:0},wholesaleType:{type:Number,default:0}},data:function(){return{display:"none",number:1,selectAttr:null,newAttrGroupList:null,pic_url:null,activeAttr:[],goodsAttr:[]}},watch:{show:function(){"block"===this.display?(this.selectAttr=null,this.close()):"none"===this.display&&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}},mounted:function(){if("wholesale"==this.sign)if(this.pic_url=this.goods.attr_groups[0].attr_list[0].pic_url,1==this.goods.attr_groups.length)this.goodsAttr=this.goods.attr;else{var t,e=a(this.goods.attr_groups);try{for(e.s();!(t=e.n()).done;){var r=t.value,i={attr_group_name:"",attr_group_id:"",attr_id:"",attr_name:""};i.attr_group_name=r.attr_group_name,i.attr_group_id=r.attr_group_id,i.attr_id=r.attr_list[0].attr_id,i.attr_name=r.attr_list[0].attr_name,this.activeAttr.push(i)}}catch(h){e.e(h)}finally{e.f()}var o,s=a(this.goods.attr);try{for(s.s();!(o=s.n()).done;){for(var n=o.value,u=!0,l=0;l<n.attr_list.length-1;l++){var c={attr_group_name:n.attr_list[l].attr_group_name,attr_group_id:n.attr_list[l].attr_group_id,attr_id:n.attr_list[l].attr_id,attr_name:n.attr_list[l].attr_name};JSON.stringify(c)!=JSON.stringify(this.activeAttr[l])&&(u=!1)}u&&this.goodsAttr.push(n)}}catch(h){s.e(h)}finally{s.f()}}},methods:{alert:function(){if(0!==this.attrGroupList.length){if("wholesale"!=this.sign){var t=this.attrGroupList,e=this.goods.attr,r=null;if(this.number=1,1===t.length){for(var i in e)for(var o in t[0].attr_list)t[0].attr_list[o].attr_id==e[i].attr_list[0].attr_id&&(e[i].stock>0?(1===e.length&&(t[0].attr_list[o].checked=!0),t[0].attr_list[o].attr_num_0=!1,this.pic_url=t[0].attr_list[o].pic_url):(this.number=0,t[0].attr_list[o].checked=!1,t[0].attr_list[o].attr_num_0=!0));1===e.length&&(r=e[0],this.$emit("attrtap",r))}this.newAttrGroupList=t,this.goods.selectAttr?this.selectAttr=this.goods.selectAttr:this.selectAttr=r}this.display="block"}},scrollGet:function(t,e){this.goods.attr_groups[e].scrollLeft=t.detail.scrollLeft,this.$forceUpdate()},toBottom:function(t){var e=this;this.$nextTick().then((function(){e.goods.attr_groups[t].scrollLeft=99999,e.$forceUpdate()}))},chooseAttr:function(t,e){var r,i=this,o=a(i.goods.attr_groups[t].attr_list);try{for(o.s();!(r=o.n()).done;){var s=r.value;s.active=!1,s.attr_id==e.attr_id&&s.attr_name==e.attr_name&&(s.active=!0)}}catch(p){o.e(p)}finally{o.f()}0==t&&(i.pic_url=e.pic_url),i.activeAttr[t].attr_id=e.attr_id,i.activeAttr[t].attr_name=e.attr_name,i.goodsAttr=[];var n,u=a(i.goods.attr);try{for(u.s();!(n=u.n()).done;){for(var l=n.value,c=!0,h=0;h<l.attr_list.length-1;h++){var d={attr_group_name:l.attr_list[h].attr_group_name,attr_group_id:l.attr_list[h].attr_group_id,attr_id:l.attr_list[h].attr_id,attr_name:l.attr_list[h].attr_name};JSON.stringify(d)!=JSON.stringify(this.activeAttr[h])&&(c=!1)}c&&i.goodsAttr.push(l)}}catch(p){u.e(p)}finally{u.f()}i.$forceUpdate(),i.count()},wholesaleNumberSub:function(t){if(0==this.goodsAttr[t].number)return!1;this.goodsAttr[t].number--,1==this.goods.attr_groups.length&&(this.pic_url=this.goodsAttr[t].pic_url),this.count(t)},wholesaleNumberAdd:function(t){if(this.goodsAttr[t].number>this.goodsAttr[t].stock||this.goodsAttr[t].number==this.goodsAttr[t].stock)return!1;this.goodsAttr[t].number++,1==this.goods.attr_groups.length&&(this.pic_url=this.goodsAttr[t].pic_url),this.count(t)},wholesaleNumberBlur:function(t){+this.goodsAttr[t].number>+this.goodsAttr[t].stock&&(this.goodsAttr[t].number=this.goodsAttr[t].stock),1==this.goods.attr_groups.length&&(this.pic_url=this.goodsAttr[t].pic_url),this.count(t)},count:function(t){var e=this;this.$emit("attrtap",e.goods,e.goodsAttr),setTimeout((function(){e.selectAttr=e.goodsAttr[t]}))},close:function(){this.display="none",this.$emit("close",!1)},preventD:function(){},storeAttrClick:function(e,r){var i=JSON.parse(JSON.stringify(this.newAttrGroupList)),o=this.goods.attr,s=[],n=this.attrCart;for(var a in i)for(var u in i[a].attr_list){var l=i[a].attr_list[u];if(parseInt(i[a].attr_group_id)==parseInt(r))if(parseInt(l.attr_id)===parseInt(e)){if(l.checked?l.checked=!1:l.checked=!0,l.attr_num_0)return}else l.checked=!1;l.checked&&(0==a&&(this.pic_url=i[0].attr_list[u].pic_url),s.push(i[a].attr_group_id+"-"+l.attr_id))}function c(t,e){return e.some((function(e){return t==e}))}var h=[],d=null,p=1;for(var m in o){var f=[],g=0;for(var _ in o[m].attr_list){var b=o[m].attr_list[_].attr_group_id+"-"+o[m].attr_list[_].attr_id;c(b,s)||(g+=1,f.push(b))}if(0==o[m].stock&&g<=1&&(h=h.concat(f)),0==g){if(d||(d={}),d=o[m],n.forEach((function(t){t.attr_id==d.id&&(p=t.num)})),d.stock<=0)return void t.showToast({title:"库存不足",icon:"none"});d.stock<=p&&(p=d.stock)}}for(var v in 0==s.length&&(d=null),i)for(var y in i[v].attr_list){var A=i[v].attr_list[y],w=i[v].attr_group_id+"-"+A.attr_id;c(w,h)&&!c(w,s)?A.attr_num_0=!0:A.attr_num_0=!1}this.newAttrGroupList=i,this.selectAttr=d,this.number=p,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;if("pick"!==this.goods.sign&&"community"!==this.goods.sign)if("goods"===this.goods.type)if("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(){e.display="none"}));else if("flash_sale"===this.goods.sign)this.$request({url:this.$api.flash_sale.add_cart,data:{flash_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(){e.display="none"}));else if("wholesale"==this.goods.sign){if(this.totalNumber<this.goods.wholesaleGoods.rise_num)return t.showToast({title:"至少采购"+this.goods.wholesaleGoods.rise_num+this.goods.unit,image:"/static/image/plugins/tip.png",duration:1e3}),!1;var i,o=[],s=a(this.goods.attr);try{for(s.s();!(i=s.n()).done;){var n=i.value;n.number>0&&o.push(n)}}catch(u){s.e(u)}finally{s.f()}this.$request({url:this.$api.wholesale.cart,data:{attr:JSON.stringify(o)},method:"post"}).then((function(r){if(e.display="none",0===r.code){var i,o=a(e.goods.attr);try{for(o.s();!(i=o.n()).done;){var s=i.value;s.number="0"}}catch(u){o.e(u)}finally{o.f()}var n,l=a(e.goodsAttr);try{for(l.s();!(n=l.n()).done;){var c=n.value;c.number="0"}}catch(u){l.e(u)}finally{l.f()}e.count(),t.hideLoading(),t.showToast({title:"添加成功",duration:1e3})}})).catch((function(t){e.display="none"}))}else this.$request({url:this.$api.cart.add,data:{goods_id:r.goods_id,attr:r.id,num:this.number},method:"post"}).then((function(r){0===r.code?(t.showToast({title:r.msg,type:"success"}),e.display="none",e.selectAttr.number=e.number,e.$emit("selectNumber",e.selectAttr)):(t.showToast({title:r.msg,icon:"none",duration:2500}),e.display="none")})).catch((function(){e.display="none"}));else"ecard"===this.goods.type&&t.showToast({title:"虚拟商品不允许加入购物车",icon:"none"});else this.$emit("add",r,this.number)},buy:function(){var e=this;if(this.$user.isLogin()&&this.$store.state.user.info){var r=this.$store.state.user.info.identity.member_level;if(r<this.goods.member_level)return void t.showModal({title:"提示",content:"需达到"+this.goods.member_name+"会员才可购买",showCancel:!0,buttonText:"升级",success:function(i){i.confirm?t.navigateTo({url:"/pages/member/upgrade/upgrade?level="+r+"&other="+e.goods.member_level}):i.cancel&&console.log("用户点击取消")}})}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;if("wholesale"==this.goods.sign){if(this.totalNumber<this.goods.wholesaleGoods.rise_num)return t.showToast({title:"至少采购"+this.goods.wholesaleGoods.rise_num+this.goods.unit,image:"/static/image/plugins/tip.png",duration:1e3}),!1;var i,o={},s=[{mch_id:0,goods_list:[]}],n=a(this.goods.attr);try{for(n.s();!(i=n.n()).done;){var u=i.value;if(u.number>0){o={id:u.goods_id,attr:[],num:u.number,cat_id:0,goods_attr_id:u.id};var l,c=a(u.attr_list);try{for(c.s();!(l=c.n()).done;){var h=l.value,d={attr_id:h.attr_id,attr_group_id:h.attr_group_id};o.attr.push(d)}}catch(w){c.e(w)}finally{c.f()}s[0].goods_list.push(o)}}}catch(w){n.e(w)}finally{n.f()}var p="/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify(s));this.submitUrl&&this.previewUrl&&(p+="&preview_url=".concat(encodeURIComponent(this.previewUrl),"&submit_url=").concat(encodeURIComponent(this.submitUrl),"&plugin=").concat(this.plugin)),t.navigateTo({url:p})}else{var m=this.goods,f=this.number,g=this.selectAttr,_=g.id,b=[];for(var v in g.attr_list)b.push({attr_id:g.attr_list[v].attr_id,attr_group_id:g.attr_list[v].attr_group_id});var y=[{mch_id:m.mch_id?m.mch_id:0,goods_list:[{id:this.goodsId?this.goodsId:m.id,attr:b,num:f,cat_id:0,goods_attr_id:_}]}],A="/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify(y));this.submitUrl&&this.previewUrl&&(A+="&preview_url=".concat(encodeURIComponent(this.previewUrl),"&submit_url=").concat(encodeURIComponent(this.submitUrl),"&plugin=").concat(this.plugin)),t.navigateTo({url:A})}}},submit:function(){var e=this.selectAttr;return"wholesale"===this.goods.sign||(e?e.stock<=0?(t.showToast({title:"库存不足",icon:"none"}),!1):this.number<=0?(t.showToast({title:"数量不能为0",icon:"none"}),!1):!!this.goods:(t.showToast({title:"请先选规格",icon:"none"}),!1))},clickImg:function(e){t.previewImage({current:0,urls:[e]})}},computed:s(s({},(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(){var t;return this.selectAttr?(t=1===this.goods.level_show?this.selectAttr.price_member:this.selectAttr.price,"wholesale"==this.sign?0==this.selectAttr.number?"undefined":0==this.wholesaleType?(t=(t*(this.discount/10)).toFixed(2),t):(t=(t-this.discount).toFixed(2),t):t):"wholesale"==this.sign?"undefined":this.goods?this.goods.hasOwnProperty("price_min")?this.goods.price_min:this.goods.price:0},newData:function(){var t=this.number,e=this.display,r=this.selectAttr;return{number:t,display:e,selectAttr:r}},themeObject:function(){return{back:this.theme+"-m-back "+this.theme,theme:this.theme,color:this.theme+"-m-text "+this.theme,sBack:this.theme+"-s-back "+this.theme}}},(0,i.mapGetters)("iPhoneX",{boolEmpty:"getBoolEmpty"}))};e.default=p}).call(this,r("543d")["default"])},"51d1":function(t,e,r){},"8bc3":function(t,e,r){"use strict";var i;r.d(e,"b",(function(){return o})),r.d(e,"c",(function(){return s})),r.d(e,"a",(function(){return i}));var o=function(){var t=this,e=t.$createElement;t._self._c},s=[]},b3e8:function(t,e,r){"use strict";r.r(e);var i=r("8bc3"),o=r("1a13");for(var s in o)"default"!==s&&function(t){r.d(e,t,(function(){return o[t]}))}(s);r("d91e");var n,a=r("f0c5"),u=Object(a["a"])(o["default"],i["b"],i["c"],!1,null,"674095fa",null,!1,i["a"],n);e["default"]=u.exports},d91e:function(t,e,r){"use strict";var i=r("51d1"),o=r.n(i);o.a}}]);
- ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
- 'components/page-component/app-attr/app-attr-create-component',
- {
- 'components/page-component/app-attr/app-attr-create-component':(function(module, exports, __webpack_require__){
- __webpack_require__('543d')['createComponent'](__webpack_require__("b3e8"))
- })
- },
- [['components/page-component/app-attr/app-attr-create-component']]
- ]);
|