12345678910 |
- (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["plugins/wholesale/components/app-attr/app-attr"],{"1fb7":function(t,r,e){"use strict";var i;e.d(r,"b",(function(){return o})),e.d(r,"c",(function(){return n})),e.d(r,"a",(function(){return i}));var o=function(){var t=this,r=t.$createElement;t._self._c},n=[]},"8ced":function(t,r,e){},ac17:function(t,r,e){"use strict";e.r(r);var i=e("1fb7"),o=e("f1ba");for(var n in o)"default"!==n&&function(t){e.d(r,t,(function(){return o[t]}))}(n);e("b595");var s,a=e("f0c5"),u=Object(a["a"])(o["default"],i["b"],i["c"],!1,null,"80b422b4",null,!1,i["a"],s);r["default"]=u.exports},b595:function(t,r,e){"use strict";var i=e("8ced"),o=e.n(i);o.a},ceed:function(t,r,e){"use strict";(function(t){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var i=e("2f62");function o(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),e.push.apply(e,i)}return e}function n(t){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?o(Object(e),!0).forEach((function(r){s(t,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):o(Object(e)).forEach((function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}))}return t}function s(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}function a(t,r){var e;if("undefined"===typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(e=u(t))||r&&t&&"number"===typeof t.length){e&&(t=e);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 n,s=!0,a=!1;return{s:function(){e=t[Symbol.iterator]()},n:function(){var t=e.next();return s=t.done,t},e:function(t){a=!0,n=t},f:function(){try{s||null==e.return||e.return()}finally{if(a)throw n}}}}function u(t,r){if(t){if("string"===typeof t)return l(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?l(t,r):void 0}}function l(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,i=new Array(r);e<r;e++)i[e]=t[e];return i}var c=function(){e.e("components/page-component/goods/app-price").then(function(){return resolve(e("bb33"))}.bind(null,e)).catch(e.oe)},h=function(){e.e("components/page-component/app-member-mark/app-member-mark").then(function(){return resolve(e("207b"))}.bind(null,e)).catch(e.oe)},d=function(){e.e("components/page-component/goods/app-sell-tip").then(function(){return resolve(e("f3ad"))}.bind(null,e)).catch(e.oe)},f={name:"app-attr",components:{appPrice:c,appMemberMark:h,appSellTip:d},props:{goods:Object,attrGroupList:Array,attrCart:{type:Array,default:function(){return[]}},cartShow:{type:[Boolean,Number],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:Object},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},attentionSign:{type:String}},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(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,r=a(this.goods.attr_groups);try{for(r.s();!(t=r.n()).done;){var e=t.value,i={attr_group_name:"",attr_group_id:"",attr_id:"",attr_name:""};i.attr_group_name=e.attr_group_name,i.attr_group_id=e.attr_group_id,i.attr_id=e.attr_list[0].attr_id,i.attr_name=e.attr_list[0].attr_name,this.activeAttr.push(i)}}catch(h){r.e(h)}finally{r.f()}var o,n=a(this.goods.attr);try{for(n.s();!(o=n.n()).done;){for(var s=o.value,u=!0,l=0;l<s.attr_list.length-1;l++){var c={attr_group_name:s.attr_list[l].attr_group_name,attr_group_id:s.attr_list[l].attr_group_id,attr_id:s.attr_list[l].attr_id,attr_name:s.attr_list[l].attr_name};JSON.stringify(c)!=JSON.stringify(this.activeAttr[l])&&(u=!1)}u&&this.goodsAttr.push(s)}}catch(h){n.e(h)}finally{n.f()}}},methods:{alert:function(){this.attrGroupList&&0===this.attrGroupList.length||(this.display="block")},scrollGet:function(t,r){this.goods.attr_groups[r].scrollLeft=t.detail.scrollLeft,this.$forceUpdate()},toBottom:function(t){var r=this;this.$nextTick().then((function(){r.goods.attr_groups[t].scrollLeft=99999,r.$forceUpdate()}))},chooseAttr:function(t,r){var e,i=this,o=a(i.goods.attr_groups[t].attr_list);try{for(o.s();!(e=o.n()).done;){var n=e.value;n.active=!1,n.attr_id==r.attr_id&&n.attr_name==r.attr_name&&(n.active=!0)}}catch(f){o.e(f)}finally{o.f()}0==t&&(i.pic_url=r.pic_url),i.activeAttr[t].attr_id=r.attr_id,i.activeAttr[t].attr_name=r.attr_name,i.goodsAttr=[];var s,u=a(i.goods.attr);try{for(u.s();!(s=u.n()).done;){for(var l=s.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(f){u.e(f)}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(r){console.log(this.goodsAttr[r].number,this.goodsAttr[r].stock),+this.goodsAttr[r].number>+this.goodsAttr[r].stock&&(this.goodsAttr[r].number=+this.goodsAttr[r].stock,t.showToast({title:"数量不得大于库存",icon:"none"})),1==this.goods.attr_groups.length&&(this.pic_url=this.goodsAttr[r].pic_url),this.count(r)},count:function(t){var r=this;this.$emit("attrtap",{goods:r.goods,goodsAttr:r.goodsAttr}),setTimeout((function(){r.selectAttr=r.goodsAttr[t]}))},close:function(){this.display="none",this.$emit("close",!1)},preventD:function(){},storeAttrClick:function(r,e){var i=JSON.parse(JSON.stringify(this.newAttrGroupList)),o=this.goods.attr,n=[],s=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(e))if(parseInt(l.attr_id)===parseInt(r)){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),n.push(i[a].attr_group_id+"-"+l.attr_id))}function c(t,r){return r.some((function(r){return t==r}))}var h=[],d=null,f=1;for(var p in o){var g=[],m=0;for(var _ in o[p].attr_list){var b=o[p].attr_list[_].attr_group_id+"-"+o[p].attr_list[_].attr_id;c(b,n)||(m+=1,g.push(b))}if(0==o[p].stock&&m<=1&&(h=h.concat(g)),0==m){if(d||(d={}),d=o[p],s.forEach((function(t){t.attr_id==d.id&&(f=t.num)})),d.stock<=0)return void t.showToast({title:"库存不足",icon:"none"});d.stock<=f&&(f=d.stock)}}for(var y in 0==n.length&&(d=null),i)for(var v in i[y].attr_list){var A=i[y].attr_list[v],w=i[y].attr_group_id+"-"+A.attr_id;c(w,h)&&!c(w,n)?A.attr_num_0=!0:A.attr_num_0=!1}this.newAttrGroupList=i,this.selectAttr=d,this.number=f,this.$emit("attrtap",this.selectAttr)},numberBlur:function(r){return r=parseInt(r.value),r>this.attrNum&&(t.showToast({title:"库存不足",icon:"none"}),r=this.attrNum),this.$emit("attrtap",this.selectAttr),this.number=r},numberSub:function(){var t=this.number;if(t<=1)return!0;t--,this.number=t,this.$emit("attrtap",this.selectAttr)},numberAdd:function(){var r=this.number;if(r++,r>this.attrNum)return t.showToast({title:"库存不足",icon:"none"}),void(this.number=this.attrNum);this.number=r,this.$emit("attrtap",this.selectAttr)},cart:function(){var r=this;if(!this.submit())return!1;this.selectAttr;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 e,i=[],o=a(this.goods.attr);try{for(o.s();!(e=o.n()).done;){var n=e.value;n.number>0&&i.push(n)}}catch(s){o.e(s)}finally{o.f()}this.$request({url:this.$api.wholesale.cart,data:{attr:JSON.stringify(i)},method:"post"}).then((function(e){if(r.display="none",0===e.code){var i,o=a(r.goods.attr);try{for(o.s();!(i=o.n()).done;){var n=i.value;n.number="0"}}catch(s){o.e(s)}finally{o.f()}var u,l=a(r.goodsAttr);try{for(l.s();!(u=l.n()).done;){var c=u.value;c.number="0"}}catch(s){l.e(s)}finally{l.f()}r.count(),t.hideLoading(),t.showToast({title:"添加成功",duration:1e3})}})).catch((function(t){r.display="none"}))},buy:function(){if(this.$user.isLogin())if(this.goods.sell_time>0)this.rightTip();else{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(this.totalNumber<this.goods.wholesaleGoods.rise_num)return this.$tips.showToast({title:"至少采购"+this.goods.wholesaleGoods.rise_num+this.goods.unit,icon:"none"}),!1;var r,e={},i=[{mch_id:0,goods_list:[]}],o=0,n=a(this.goods.attr);try{for(n.s();!(r=n.n()).done;){var s=r.value;if(s.number>0){e={id:s.goods_id,attr:[],num:s.number,cat_id:0,goods_attr_id:s.id};var u,l=a(s.attr_list);try{for(l.s();!(u=l.n()).done;){var c=u.value,h={attr_id:c.attr_id,attr_group_id:c.attr_group_id};e.attr.push(h)}}catch(f){l.e(f)}finally{l.f()}i[0].goods_list.push(e),o+=s.number}}}catch(f){n.e(f)}finally{n.f()}if("undefined"!==typeof this.goods.limit_buy&&1==this.goods.limit_buy.status&&this.goods.limit_buy.rest_number<o)return this.$tips.showToast({title:this.goods.limit_buy.text,icon:"none"}),!1;var d="/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify(i));this.submitUrl&&this.previewUrl&&(d+="&preview_url=".concat(encodeURIComponent(this.previewUrl),"&submit_url=").concat(encodeURIComponent(this.submitUrl),"&plugin=").concat(this.plugin)),t.navigateTo({url:d})}}else this.$user.getInfo()},submit:function(){var r=this.selectAttr;return"wholesale"===this.goods.sign||(r?r.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(r){t.previewImage({current:0,urls:[r]})},rightTip:function(){this.$goodsRemind(this.goods.template_message_list,this.goods.id)}},computed:n(n(n({},(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(){if(this.goods&&1===this.goods.level_show)return"member"},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,0==this.selectAttr.number?"undefined":0==this.wholesaleType?(t=(t*(this.discount/10)).toFixed(2),t):(t=(t-this.discount).toFixed(2),t)):"undefined"},newData:function(){var t=this.number,r=this.display,e=this.selectAttr;return{number:t,display:r,selectAttr:e}}},(0,i.mapGetters)("iPhoneX",{boolEmpty:"getBoolEmpty"})),(0,i.mapGetters)({userInfo:"user/info"}))};r.default=f}).call(this,e("543d")["default"])},f1ba:function(t,r,e){"use strict";e.r(r);var i=e("ceed"),o=e.n(i);for(var n in i)"default"!==n&&function(t){e.d(r,t,(function(){return i[t]}))}(n);r["default"]=o.a}}]);
- ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
- 'plugins/wholesale/components/app-attr/app-attr-create-component',
- {
- 'plugins/wholesale/components/app-attr/app-attr-create-component':(function(module, exports, __webpack_require__){
- __webpack_require__('543d')['createComponent'](__webpack_require__("ac17"))
- })
- },
- [['plugins/wholesale/components/app-attr/app-attr-create-component']]
- ]);
|