(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/app_admin/add-goods/add-goods"],{6846:function(e,t,i){"use strict";var r=i("96ec"),o=i.n(r);o.a},7715:function(e,t,i){"use strict";var r;i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return a})),i.d(t,"a",(function(){return r}));var o=function(){var e=this,t=e.$createElement;e._self._c;e._isMounted||(e.e0=function(t){e.set_attr=!e.set_attr},e.e1=function(t){e.is_default_services=!e.is_default_services})},a=[]},"8e19":function(e,t,i){"use strict";i.r(t);var r=i("7715"),o=i("c83e");for(var a in o)"default"!==a&&function(e){i.d(t,e,(function(){return o[e]}))}(a);i("6846");var n,s=i("f0c5"),c=Object(s["a"])(o["default"],r["b"],r["c"],!1,null,"5e9968e5",null,!1,r["a"],n);t["default"]=c.exports},"96ec":function(e,t,i){},b238:function(e,t,i){"use strict";(function(e){i("2d0a");r(i("66fd"));var t=r(i("8e19"));function r(e){return e&&e.__esModule?e:{default:e}}e(t.default)}).call(this,i("543d")["createPage"])},c7f3:function(e,t,i){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=n(i("a34a")),o=i("2f62"),a=n(i("8896"));function n(e){return e&&e.__esModule?e:{default:e}}function s(e,t,i,r,o,a,n){try{var s=e[a](n),c=s.value}catch(d){return void i(d)}s.done?t(c):Promise.resolve(c).then(r,o)}function c(e){return function(){var t=this,i=arguments;return new Promise((function(r,o){var a=e.apply(t,i);function n(e){s(a,r,o,n,c,"next",e)}function c(e){s(a,r,o,n,c,"throw",e)}n(void 0)}))}}function d(e,t){var i;if("undefined"===typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(i=g(e))||t&&e&&"number"===typeof e.length){i&&(e=i);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},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 a,n=!0,s=!1;return{s:function(){i=e[Symbol.iterator]()},n:function(){var e=i.next();return n=e.done,e},e:function(e){s=!0,a=e},f:function(){try{n||null==i.return||i.return()}finally{if(s)throw a}}}}function g(e,t){if(e){if("string"===typeof e)return l(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?l(e,t):void 0}}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i0))return i.error="请上传商品图片",!1;if(r.pic_url=i.img,!r.name)return i.error="请设置商品名称",!1;if(0==i.cats.length)return i.error="请设置商品分类",!1;for(var a in i.cats)o.push(i.cats[a].value);if(!i.unit)return i.error="请设置商品单位",!1;if(r.unit=i.unit,0!=r.cost_price&&!r.cost_price)return i.error="请设置商品成本价",!1;if(r.cost_price<0)return i.error="成本价不得小于零",!1;if(0!=r.original_price&&!r.original_price)return i.error="请设置商品原价",!1;if(r.original_price<0)return i.error="商品原价不得小于零",!1;if(0!=r.price&&!r.price)return i.error="请设置商品售价",!1;if(i.set_attr){if(r.use_attr=1,r.goods_num=0,!r.attr_groups||0==r.attr_groups.length)return i.error="请设置商品规格",!1;t=!0}else{if(r.use_attr=0,r.attr=[],!r.goods_num)return i.error="商品库存不得为空",!1;if(r.goods_num<0)return i.error="商品库存不得小于零",!1;t=!0}if(r.cards=i.goods_card,r.is_default_services=1,r.services=[],i.form.limit_buy_status=i.confine?1:0,0==i.is_default_services&&(r.is_default_services=0,i.beService.length>0&&(r.services=i.beService)),r.status=e,!(i.goods_detail.length>0))return i.error="请设置图文描述",!1;for(var n in r.detail="",i.goods_detail)"img"==i.goods_detail[n].type?r.detail+='

':"line"==i.goods_detail[n].type?r.detail+='

':"text"==i.goods_detail[n].type&&(r.detail+="

"+i.goods_detail[n].text+"

");r.mchCats||(r.mchCats=[]),i.forehead_integral&&(i.forehead_integral>0?(r.forehead_integral_type=1,r.forehead_integral=i.forehead_integral):(r.forehead_integral_type=2,r.forehead_integral=i.forehead_integral.replace("%",""))),i.give_integral&&(i.give_integral>0?(r.give_integral_type=1,r.give_integral=i.give_integral):(r.give_integral_type=2,r.give_integral=i.give_integral.replace("%",""))),r.virtual_sales||(r.virtual_sales=0),r.cover_pic||(r.cover_pic=""),r.sort||(r.sort=100),r.accumulative||(r.accumulative=1),r.member_price||(r.member_price={}),r.freight_id=i.bePostage.id,r.freight=i.bePostage,r.shipping_id=i.beDelivery.id,r.shipping=i.beDelivery,r.individual_share||(r.individual_share=0),r.is_level||(r.is_level=0),r.individual_share||(r.individual_share=0),r.video_url||(r.video_url=""),t&&(i.form=r,i.form.cats=o,i.id>0&&(i.form.id=i.id),0==e?i.toSubmit():i.beSubmit=!0)},close:function(){this.error=null,this.modal=!1,this.beSubmit=!1},inputAttr:function(e){this.attr[e].attr_list[0].attr_id=(+e+2).toString()},_longtap:function(t,i,r){var o=this,a=e.createSelectorQuery(),n=a.selectAll(".move-img");n.fields({dataset:!0,rect:!0},(function(e){o.elements=e})).exec(),o.img[i].pic_url="",o.x=r.currentTarget.offsetLeft,o.y=r.currentTarget.offsetTop,o.imgHidden=!1,o.flag=!0,o.beMove=!0,o.img_src=t,o.beginIndex=i},touchend:function(e){var t=this;if(t.flag){for(var i=e.changedTouches[0].pageX,r=e.changedTouches[0].pageY,o=t.elements,a=t.img,n=t.beginIndex,s=0;sc.left&&ic.top&&rd){for(var u=a[n],f=n;f>d;f--)a[f]=a[f-1];a[d]=u}a[d].pic_url=t.img_src,t.img=a}}t.img[n].pic_url||(t.img[n].pic_url=t.img_src),t.imgHidden=!0,t.flag=!1,t.beMove=!1,t.beginIndex=null}},touchm:function(e){if(this.flag){var t=e.touches[0].pageX,i=e.touches[0].pageY;this.x=t-60,this.y=i-189}},cancelService:function(){var t=this.beService,i=this.service;t.length>0?i.forEach((function(e,i){e.isChoose=!1,t.forEach((function(t){t.id==e.id&&(e.isChoose=!0)}))})):i.forEach((function(e,t){e.isChoose=!1})),this.beService=t,this.service=i,this.set_service=!1,this.is_service=!1,setTimeout((function(t){e.pageScrollTo({scrollTop:45550,duration:0})}),0)},submitService:function(){var t=[];this.service.forEach((function(e){e.isChoose&&t.push(e)})),this.beService=t,this.set_service=!1,this.is_service=!1,setTimeout((function(t){e.pageScrollTo({scrollTop:45550,duration:0})}),0)},choose:function(e){var t=this;t.service.forEach((function(i){i.id==e.id&&(i.isChoose=!i.isChoose,t.$forceUpdate())}))},toGoodsDetail:function(){e.navigateTo({url:"/pages/app_admin/goods-detail/goods-detail"})},addImg:function(){var t=this,i=9-t.img.length;e.chooseImage({count:i,sizeType:["original","compressed"],sourceType:["album","camera"],success:function(i){var r=i.tempFilePaths,o=t.img;r.forEach((function(i,n){e.showLoading({mask:!0,title:"上传中..."});var s="";(0,a.default)({url:t.$api.upload.file,filePath:i,fileType:"image",fileName:s,mch_id:0}).then((function(i){var a=null;a=JSON.parse(i.data),0===a.code&&o.push({pic_url:a.data.url,id:a.data.id}),t.img=o,n===r.length-1&&e.hideLoading()})).catch((function(t){t&&t.errMsg&&e.showModal({title:"错误",content:t.errMsg,showCancel:!1})}))}))}})},del_img:function(e){this.img.splice(e,1)},chooseCat:function(){e.navigateTo({url:"/pages/goods-edit/goods-cat/goods-cat"})},chooseAttr:function(){e.navigateTo({url:"/pages/app_admin/goods-attr/goods-attr"}),this.$storage.setStorageSync("goods_unit",this.unit)},bindChange:function(e){this.newIndex=e.detail.value[0]},toggle:function(e){this.choose_list=[],this.dialog=!1,this.set_cat=!1,"postage"==this.dialogType&&(1==e?this.set_postage&&(this.bePostage=this.postage[this.newIndex]):this.set_postage=!1),"delivery"==this.dialogType&&(1==e?this.set_delivery&&(this.beDelivery=this.delivery[this.newIndex]):this.set_delivery=!1),this.dialogType=""},chooseService:function(){var t=this;t.first_service?t.$request({url:t.$api.app_admin.service}).then((function(i){if(t.$hideLoading(),0==i.code){t.service=i.data.list,0==i.data.list.length?t.modal=!0:t.is_service=!0;var r,o=[],a=d(i.data.list);try{for(a.s();!(r=a.n()).done;){var n=r.value;n.isChoose=!1,1==n.is_default&&(o.push(n),n.isChoose=!0)}}catch(s){a.e(s)}finally{a.f()}t.set_service=!0,t.beService=o,t.default_service=o,t.first_service=!1}else e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()})):0==t.service.length?t.modal=!0:t.is_service=!0},chooseCard:function(){var t=this;t.$request({url:t.$api.app_admin.card}).then((function(i){t.$hideLoading(),0==i.code?(t.card=i.data.list,0==i.data.list.length?(t.set_card=!0,t.modal=!0):e.navigateTo({url:"/pages/app_admin/goods-card/goods-card"})):e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()}))},chooseDelivery:function(){var t=this;t.$request({url:t.$api.app_admin.delivery_rules}).then((function(i){if(t.$hideLoading(),0==i.code)if(0==i.data.list.length)t.set_delivery=!0,t.modal=!0,t.delivery=i.data.list;else{var r=[];i.data.list.forEach((function(e,t){r.push(i.data.list[t].id)}));var o=r.indexOf(t.beDelivery.id);o>-1?(t.deliveryIndex=o,t.newIndex=o):t.beDelivery="",t.set_delivery=!0,t.dialog=!0,t.dialogType="delivery",t.delivery=i.data.list}else e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()}))},chooseExpress:function(){var t=this;t.$request({url:t.$api.app_admin.postage}).then((function(i){if(t.$hideLoading(),0==i.code)if(0==i.data.list.length)t.set_postage=!0,t.modal=!0,t.postage=i.data.list;else{var r=[];i.data.list.forEach((function(e,t){r.push(i.data.list[t].id)}));var o=r.indexOf(t.bePostage.id);o>-1?(t.postageIndex=o,t.newIndex=o):t.bePostage="",t.set_postage=!0,t.dialog=!0,t.dialogType="postage",t.postage=i.data.list}else e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()}))},getService:function(t){var i=this;this.$request({url:this.$api.app_admin.service}).then((function(r){i.$hideLoading();var o=r.code,a=r.data,n=r.msg;if(0===o){for(var s in i.service=a.list,i.service)i.service[s].isChoose=!1;if(t>0)for(var c in i.beService)for(var d in i.service)i.service[d].id==i.beService[c].id&&(i.service[d].isChoose=!0,i.first_service=!1);else i.beService=[],a.list.forEach((function(e){e.isChoose=!1,1==e.is_default&&(i.beService.push(e),e.isChoose=!0)}))}else e.showToast({title:n,icon:"none",duration:1e3})})).catch((function(){i.$hideLoading()}))},getPostage:function(t){var i=this;this.$request({url:this.$api.app_admin.postage}).then((function(r){if(i.$hideLoading(),0==r.code){if(i.postage=r.data.list,t>0)return!1;i.bePostage="",i.bePostage=r.data.list[0]}else e.showToast({title:r.msg,icon:"none",duration:1e3})})).catch((function(){i.$hideLoading()}))},getDelivery:function(t){var i=this;this.$request({url:this.$api.app_admin.delivery_rules}).then((function(r){if(i.$hideLoading(),0==r.code){if(i.delivery=r.data.list,t>0)return!1;i.beDelivery="",i.beDelivery=r.data.list[0]}else e.showToast({title:r.msg,icon:"none",duration:1e3})})).catch((function(){i.$hideLoading()}))},getCard:function(){var t=this;this.$request({url:this.$api.app_admin.card}).then((function(i){t.$hideLoading(),0==i.code?t.card=i.data.list:e.showToast({title:i.msg,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()}))},getDetail:function(t){var i=this;return c(r.default.mark((function o(){var a,n,s,c,d,g,l,u,f,h,_,p,v,m,y,b,S,$,x,w,O,T,P,C,L,I,j,D,E,q,M;return r.default.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.next=2,i.$request({url:i.$api.app_admin.goods_edit,data:{id:t}});case 2:return a=r.sent,n=a.code,s=a.data,c=a.msg,r.next=6,i.$hideLoading();case 6:if(i.getService(t),i.getPostage(t),i.getDelivery(t),0===n){for(E in i.form=s.detail,d=i.form,g=d.pic_url,l=d.cats,u=d.use_attr,f=d.services,h=d.freight,_=d.cards,p=d.confine_count,v=d.is_default_services,m=d.forehead_integral,y=d.forehead_integral_type,b=d.give_integral,S=d.give_integral_type,$=d.attr_groups,x=d.attr,w=d.detail,O=d.unit,T=d.shipping,P=d.min_number,C=d.limit_buy_status,d.limit_buy_type,L=d.limit_buy_value,i.img=g,i.cats=l,i.set_attr=1==u,i.beService=f,i.bePostage=h,i.beDelivery=T,i.goods_card=_,i.unit=O,i.min_number=P,1==C&&(i.confine=!0),p>0&&(i.limit_buy_first=!1),L>0&&(i.limit_buy_second=!1),0==v&&(i.is_default_services=!1),i.forehead_integral=+m,2==y&&(i.forehead_integral=m+"%"),i.give_integral=+b,2==S&&(i.give_integral=b+"%"),$.length>0&&x.length>0&&(i.attr=!0,i.$storage.setStorageSync("goods_attr_groups",$),i.$storage.setStorageSync("goods_attr",x)),I=w.split(/<\/p>||/g,"").replace(/<\/p>/g,""),D={type:""},I[E].indexOf("src")>-1?(D.type="img",D.id="",q=I[E].indexOf(".png")>-1?I[E].indexOf(".png")+4:I[E].length-1,I[E].indexOf(".jpg")>-1&&(q=I[E].indexOf(".jpg")+4),I[E].indexOf(".jpeg")>-1&&(q=I[E].indexOf(".jpeg")+5),I[E].indexOf(".gif")>-1&&(q=I[E].indexOf(".gif")+4),D.pic_url=I[E].slice(I[E].indexOf("http"),q)):(D.type="text",D.text=I[E]),j[E]=D;for(M in j)""===j[M].text&&j.splice(M,1);i.goods_detail=j,i.$storage.setStorageSync("goods_card",_),i.$storage.setStorageSync("goods_cat",i.cats),i.$storage.setStorageSync("goods_detail",j)}else e.showToast({title:c,icon:"none",duration:1e3});case 10:case"end":return r.stop()}}),o)})))()},chooseECard:function(){var t=this;0===this.id&&this.$request({url:this.$api.app_admin.ecard_api_url+this.ecard_api_url}).then((function(i){var r=i.code,o=i.data,a=i.msg;if(t.$hideLoading(),0===r)if(0===o.length)t.ecard_set_postage=!0,t.ecard_postage=o;else{var n=[];o.forEach((function(e,t){n.push(o[t].id)}));var s=n.indexOf(t.form.plugin_data.ecard.ecard_id);s>-1?(t.ecard_postageIndex=s,t.newIndex=s):t.form.plugin_data.ecard={ecard_id:0,name:""},t.ecard_set_postage=!0,t.ecard_dialog=!0,t.ecard_postage=o}else e.showToast({title:a,icon:"none",duration:1e3})})).catch((function(){t.$hideLoading()}))},typeChange:function(e){0===this.id&&(this.form.type=e.target.value)},getGoodsConfig:function(){var e=this;return c(r.default.mark((function t(){var i;return r.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.$request({url:e.$api.app_admin.goods_config});case 2:i=t.sent,0===i.code&&(e.is_ecard=i.data.is_ecard,e.ecard_api_url=i.data.ecard_api_url);case 4:case"end":return t.stop()}}),t)})))()},ecardToggle:function(e){this.ecard_dialog=!1,1==e?this.ecard_set_postage&&(this.form.plugin_data.ecard={ecard_id:this.ecard_postage[this.newIndex].id,name:this.ecard_postage[this.newIndex].name}):this.ecard_set_postage=!1},limitBuyFirstChange:function(e){"1"===e.target.value?(this.limit_buy_first=!0,this.form.confine_count=-1):(this.limit_buy_first=!1,this.form.confine_count="")}},onLoad:function(t){this.$commonLoad.onload(t);var i=this;e.getSystemInfo({success:function(e){i.windowHeight=e.windowHeight,(e.model.indexOf("iPhone X")>-1||e.model.indexOf("iPhone 11")>-1||e.model.indexOf("iPhone11")>-1||e.model.indexOf("iPhone12")>-1||e.model.indexOf("Unknown Device")>-1)&&(i.iphone_x=!0)}}),e.getSystemInfo({success:function(e){var t=e.windowHeight,r=e.windowWidth,o=750/r;i.height=t*o}}),i.getCard(),i.getGoodsConfig(),this.$storage.removeStorageSync("goods_card"),this.$storage.removeStorageSync("goods_cat"),this.$storage.removeStorageSync("goods_unit"),this.$storage.removeStorageSync("goods_attr_groups"),this.$storage.removeStorageSync("goods_attr"),this.$storage.removeStorageSync("temp_attr"),this.$storage.removeStorageSync("temp_attr_info"),this.$storage.removeStorageSync("goods_detail"),i.goods_card=[],i.goods_detail=[],t.id>0?(i.$showLoading({type:"global",text:"加载中..."}),i.id=t.id,setTimeout((function(){e.setNavigationBarTitle({title:"编辑商品"}),i.getDetail(t.id)}),500)):(i.getService(),i.getPostage(),i.getDelivery())},onShow:function(){this.goods_card=this.$storage.getStorageSync("goods_card")?this.$storage.getStorageSync("goods_card"):[],this.cats=this.$storage.getStorageSync("goods_cat")?this.$storage.getStorageSync("goods_cat"):[],this.goods_detail=this.$storage.getStorageSync("goods_detail")?this.$storage.getStorageSync("goods_detail"):[],this.form.attr=this.$storage.getStorageSync("goods_attr")?this.$storage.getStorageSync("goods_attr"):[],this.$storage.getStorageSync("goods_attr_groups")&&(this.form.attr_groups=this.$storage.getStorageSync("goods_attr_groups"),this.attr=!0),this.$storage.removeStorageSync("temp_attr"),this.$storage.removeStorageSync("temp_attr_info")},watch:{"form.type":{handler:function(e){"goods"===e&&(this.form.plugin_data.ecard.ecard_id=0,this.form.plugin_data.ecard.name="")},deep:!0}}};t.default=_}).call(this,i("543d")["default"])},c83e:function(e,t,i){"use strict";i.r(t);var r=i("c7f3"),o=i.n(r);for(var a in r)"default"!==a&&function(e){i.d(t,e,(function(){return r[e]}))}(a);t["default"]=o.a}},[["b238","common/runtime","common/vendor"]]]);