You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
27 KiB
1 lines
27 KiB
import{h as e}from"./color.813a9497.js";import{o as t,c as o,w as s,a as l,j as a,n as i,l as n,f as r,i as u,I as c,r as d,t as p,u as m,e as g,v as h,b as f,F as y,d as b,g as k,k as C,S}from"./index-ae8bbb19.js";import{A as N}from"./ActiveStatus.281bae5f.js";import{_ as T}from"./_plugin-vue_export-helper.1b428a4d.js";const I={name:"NumberBox",emits:["update:modelValue","input","change","blur","plus","minus"],props:{value:{type:Number,default:1},modelValue:{type:Number,default:1},bgColor:{type:String,default:"#FFFFFF"},min:{type:Number,default:0},max:{type:Number,default:99999},step:{type:Number,default:1},stepFirst:{type:Number,default:0},stepStrictly:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:[Number,String],default:26},color:{type:String,default:"#323233"},inputWidth:{type:[Number,String],default:80},inputHeight:{type:[Number,String],default:50},index:{type:[Number,String],default:""},disabledInput:{type:Boolean,default:!1},cursorSpacing:{type:[Number,String],default:100},longPress:{type:Boolean,default:!0},pressTime:{type:[Number,String],default:250},positiveInteger:{type:Boolean,default:!0}},watch:{valueCom(e,t){this.changeFromInner||(this.inputVal=e,this.$nextTick((function(){this.changeFromInner=!1})))},inputVal(e,t){if(""==e)return;let o=0;o=this.isNumber(e)&&e>=this.min&&e<=this.max?e:t,this.positiveInteger&&(e<0||-1!==String(e).indexOf("."))&&(o=t,this.$nextTick((()=>{this.inputVal=t}))),this.handleChange(o,"change")},min(e){void 0!==e&&""!=e&&this.valueCom<e&&(this.$emit("input",e),this.$emit("update:modelValue",e))},max(e){void 0!==e&&""!=e&&this.valueCom>e&&(this.$emit("input",e),this.$emit("update:modelValue",e))}},data:()=>({inputVal:1,timer:null,changeFromInner:!1,innerChangeTimer:null,showInput:!1}),created(){this.inputVal=Number(this.valueCom)},computed:{valueCom(){return this.modelValue},getCursorSpacing(){return Number(uni.upx2px(this.cursorSpacing))}},methods:{emptyClick(){},btnTouchStart(e){this[e](),this.longPress&&(clearInterval(this.timer),this.timer=null,this.timer=setInterval((()=>{this[e]()}),this.pressTime))},clearTimer(){this.$nextTick((()=>{clearInterval(this.timer),this.timer=null}))},minus(){this.computeVal("minus")},plus(){this.computeVal("plus")},calcPlus(e,t){let o,s,l;try{s=e.toString().split(".")[1].length}catch(a){s=0}try{l=t.toString().split(".")[1].length}catch(a){l=0}return o=Math.pow(10,Math.max(s,l)),((e*o+t*o)/o).toFixed(s>=l?s:l)},calcMinus(e,t){let o,s,l;try{s=e.toString().split(".")[1].length}catch(a){s=0}try{l=t.toString().split(".")[1].length}catch(a){l=0}return o=Math.pow(10,Math.max(s,l)),((e*o-t*o)/o).toFixed(s>=l?s:l)},computeVal(e){if(uni.hideKeyboard(),this.disabled)return;let t=0;if("minus"===e?t=this.stepFirst>0&&this.inputVal==this.stepFirst?this.min:this.calcMinus(this.inputVal,this.step):"plus"===e&&(t=this.stepFirst>0&&this.inputVal<this.stepFirst?this.stepFirst:this.calcPlus(this.inputVal,this.step)),this.stepStrictly){let e=t%this.step;e>0&&(t-=e)}t>this.max?t=this.max:t<this.min&&(t=this.min),this.inputVal=t,this.handleChange(t,e)},onBlur(e){let t=0,o=e.detail.value;if(/(^\d+$)/.test(o)&&0!=o[0]||(t=this.min),t=+o,this.stepFirst>0&&this.inputVal<this.stepFirst&&this.inputVal>0&&(t=this.stepFirst),this.stepStrictly){let e=t%this.step;e>0&&(t-=e)}t>this.max?t=this.max:t<this.min&&(t=this.min),this.$nextTick((()=>{this.inputVal=t})),this.handleChange(t,"blur")},handleChange(e,t){this.disabled||(this.innerChangeTimer&&(clearTimeout(this.innerChangeTimer),this.innerChangeTimer=null),this.changeFromInner=!0,this.innerChangeTimer=setTimeout((()=>{this.changeFromInner=!1}),150),this.$emit("input",Number(e)),this.$emit("update:modelValue",Number(e)),this.$emit(t,{value:Number(e),index:this.index}))},isNumber:e=>/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(e)}};var x,_={};const v=T({components:{GoodsSkuPopup:T({name:"GoodsSkuPopup",components:{NumberBox:T(I,[["render",function(e,d,p,m,g,h){const f=u,y=c;return t(),o(f,{class:"number-box"},{default:s((()=>[l(f,{class:a(["u-icon-minus",{"u-icon-disabled":p.disabled||g.inputVal<=p.min}]),style:i({background:p.bgColor,height:p.inputHeight+"rpx",color:p.color,fontSize:p.size+"rpx",minHeight:"1.4em"}),onClick:h.emptyClick,onTouchstart:d[0]||(d[0]=n((e=>h.btnTouchStart("minus")),["prevent"])),onTouchend:n(h.clearTimer,["stop","prevent"])},{default:s((()=>[l(f,{style:i("font-size:"+(Number(p.size)+10)+"rpx"),class:"num-btn"},{default:s((()=>[r("-")])),_:1},8,["style"])])),_:1},8,["class","style","onClick","onTouchend"]),l(y,{modelValue:g.inputVal,"onUpdate:modelValue":d[1]||(d[1]=e=>g.inputVal=e),disabled:p.disabledInput||p.disabled,"cursor-spacing":h.getCursorSpacing,class:a([{"u-input-disabled":p.disabled},"u-number-input"]),type:"number",style:i({color:p.color,fontSize:p.size+"rpx",background:p.bgColor,height:p.inputHeight+"rpx",width:p.inputWidth+"rpx"}),onBlur:h.onBlur,onClick:d[2]||(d[2]=e=>g.showInput=!0)},null,8,["modelValue","disabled","cursor-spacing","class","style","onBlur"]),l(f,{class:a(["u-icon-plus",{"u-icon-disabled":p.disabled||g.inputVal>=p.max}]),style:i({background:p.bgColor,height:p.inputHeight+"rpx",color:p.color,fontSize:p.size+"rpx",minHeight:"1.4em"}),onClick:h.emptyClick,onTouchstart:d[3]||(d[3]=n((e=>h.btnTouchStart("plus")),["prevent"])),onTouchend:n(h.clearTimer,["stop","prevent"])},{default:s((()=>[l(f,{style:i("font-size:"+(Number(p.size)+10)+"rpx"),class:"num-btn"},{default:s((()=>[r("+")])),_:1},8,["style"])])),_:1},8,["class","style","onClick","onTouchend"])])),_:1})}],["__scopeId","data-v-f1fd552a"]])},emits:["update:modelValue","input","update-goods","open","close","add-cart","buy-now","cart","buy","num-change"],props:{value:{Type:Boolean,default:!1},modelValue:{Type:Boolean,default:!1},goodsId:{Type:String,default:""},action:{Type:String,default:""},noStockText:{Type:String,default:"该商品已抢完"},stockText:{Type:String,default:"库存"},goodsIdName:{Type:String,default:"_id"},skuIdName:{Type:String,default:"_id"},skuListName:{Type:String,default:"sku_list"},specListName:{Type:String,default:"spec_list"},stockName:{Type:String,default:"stock"},skuArrName:{Type:String,default:"sku_name_arr"},defaultSingleSkuName:{Type:String,default:"默认"},mode:{Type:Number,default:1},maskCloseAble:{Type:Boolean,default:!0},borderRadius:{Type:[String,Number],default:0},goodsThumbName:{Type:[String],default:"goods_thumb"},goodsThumbBackgroundColor:{Type:String,default:"#999999"},minBuyNum:{Type:[Number,String],default:1},maxBuyNum:{Type:[Number,String],default:1e5},stepBuyNum:{Type:[Number,String],default:1},stepStrictly:{Type:Boolean,default:!1},customAction:{Type:[Function],default:null},localdata:{type:Object},priceColor:{Type:String},buyNowText:{Type:String,default:"立即购买"},buyNowColor:{Type:String},buyNowBackgroundColor:{Type:String},addCartText:{Type:String,default:"加入购物车"},addCartColor:{Type:String},addCartBackgroundColor:{Type:String},disableStyle:{Type:Object,default:null},activedStyle:{Type:Object,default:null},btnStyle:{Type:Object,default:null},showClose:{Type:Boolean,default:!0},closeImage:{Type:String,default:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAYAAADFw8lbAAAEyUlEQVR42sSZeWwNURTGp4OqtBo7sSXELragdkpQsRRJ1Zr4hyJiJ9YgxNIg1qANiT+E1i5IY0kVVWtQEbuEKLFGUSH27/ANN5PXmTvzupzkl/tm8t6b7517lnvvC0lKSjJ8WmnQAUSDFqABqALKgl8gD7wE90E2SAeXwFf1SxISErQeVtKHwCgwFsSDSIf3hYFKoCkYDBaDdyAViHdueHmoF6FtwDLQ23b/E7gM7oIcejIERIDaoBFoC8qA8mA8SQNz6W1XC9GY+nCQCCYAk/c+gF0gBZwH312+IxR0BCPBUIaH2A+wHsxHCHxx+gLT5QGN6a2JfG8uvVCDws9oiDQYlxkMGfHyQvARlADTwcXk5OT6foV2kS8ATXidymlcyen1a/Jjl9IJh3hPkjELYqO8Cu0KjjNZvtETw5jFBWXPmGSTGQKSeOn5iQ0kVLL0CINfPNcPbDMKyRCbGzEMBJ+ZD8cChYFdqGTqfsWT8otPGoVsEHsMwxDFs3shNsxJ6BrQ0Po8OGUUkVHsNCVml+cntB1jUWwn2GEUsTEMrASbDK+2CCQ0kYX6nfLLisMmKqUr0S60M+jG10vAm+JSCa8+x7CKlzHwaktV6DiObzUzPJIxFO1BQ12wGtTReO9GetVgY/kjNJzZbcWmTjHfxw51AsRqvL8eOAtmsJuFu3g1l+1ZLB5eDTVZ3K0P7tL0TkWOpSg61kVkBtuuNRthGs+wtJST5aQI7cEbkkRXNYVKgX6kIdYuUhYzMQwxN8tiExCLFqHNeSF9/aem0BzGp5PYQCJ7c/Gsk1RfuSD6U1dNpcDf9ZigTmKbMRZ9iVTsHscGJluW2FMf1SSQWGnBmaB6kCJVTVVNJZE++Cx9drEllS1KMCINpURFmEbBWA63Fz9s95cGIdJgp/zXmT4pZcOvSUzuZttTbblmnc3PIjjmidDXvKgdhMh0JdbzuCjWrbNOVovjS5P7bkPJ/mBESkz2BO0166ybNeJ431S2q+01NntuIq3E0amzjiZtk9tssWyTDzO4525bACK9NAUn68TtkNhpEXpOSagRml+S6iLSSeweHv242Qhl13rRyvoDvDlKyTQny/ZQJ+1iH7vVbEx7OR5UiKVIO7VicgvHCtwrudloMIV7/0uadVYW57O4Wvvi8v4pymlKkrpwvsDeLLZAY2pkwbAB3PSQfC+4cH7l4k1ZH8zkZRq8ecO+Z5rN40JJqnXFuGfaxPCTLjcn0OZOpnArXw8HY4paIbw5CcMgXq6HN2/mt6+XGLrN15tBryIUGavMpCTrfKcDCKkAceA9S8nhAOehhSUyhXpkBxxnP4YM1InugP7cBkjBPcqVUWFYCEROxXiQz5JlXV+IfKh7mpfJac+lZ6V87QXVClBkTc7YWsWTPSDyitfzUTlJlj8TbvE6jluDOdwZ+jX57GLO3ADeuyZrDYi86vV81FD2UVGsmT+5Zl0BnkhoseOEaogL46pqO4v/IqUEyalIR4h85BgjHv6+aUWRMbb7EstX6O0cpT1Gco0ry8fWygLDMjmDnQeBt3Qe7uVfkeugDwVLcsVzGsuwLXbV+I63XNAkG5r/hvgRqgqWs6pJPKrsbvz/Q6yyun0w/h6lP+BnzrCpfPMT2L8FGAA7k1GZ/vnaqAAAAABJRU5ErkJggg=="},hideStock:{Type:Boolean,default:!1},theme:{Type:String,default:"default"},actionTips:{Type:String,default:"请求中..."},defaultSelect:{Type:Object},useCache:{Type:Boolean,default:!0},defaultGoods:{Type:Object},amountType:{Type:Number,default:1},selectedInit:{Type:Boolean,default:!1},safeAreaInsetBottom:{Type:Boolean,default:!0},buyMode:{type:Number,default:1},isJoin:{type:Boolean,default:!1},stepPeople:{type:Number,default:void 0}},data(){return{complete:!1,goodsInfo:{},isShow:!1,initKey:!0,shopItemInfo:{},selectArr:[],subIndex:[],selectShop:{},selectNum:this.minBuyNum||1,outFoStock:!1,openTime:0,themeColor:{default:{priceColor:"rgb(254, 86, 10)",buyNowColor:"#ffffff",buyNowBackgroundColor:"rgb(254, 86, 10)",addCartColor:"#ffffff",addCartBackgroundColor:"rgb(255, 148, 2)",btnStyle:{color:"#333333",borderColor:"#f4f4f4",backgroundColor:"#ffffff"},activedStyle:{color:"rgb(254, 86, 10)",borderColor:"rgb(254, 86, 10)",backgroundColor:"rgba(254,86,10,0.1)"},disableStyle:{color:"#c3c3c3",borderColor:"#f6f6f6",backgroundColor:"#f6f6f6"}},"red-black":{priceColor:"rgb(255, 68, 68)",buyNowColor:"#ffffff",buyNowBackgroundColor:"rgb(255, 68, 68)",addCartColor:"#ffffff",addCartBackgroundColor:"rgb(85, 85, 85)",activedStyle:{color:"rgb(255, 68, 68)",borderColor:"rgb(255, 68, 68)",backgroundColor:"rgba(255,68,68,0.1)"}},"black-white":{priceColor:"rgb(47, 47, 52)",buyNowColor:"#ffffff",buyNowBackgroundColor:"rgb(47, 47, 52)",addCartColor:"rgb(47, 47, 52)",addCartBackgroundColor:"rgb(235, 236, 242)",activedStyle:{color:"rgb(47, 47, 52)",borderColor:"rgba(47,47,52,0.12)",backgroundColor:"rgba(47,47,52,0.12)"}},coffee:{priceColor:"rgb(195, 167, 105)",buyNowColor:"#ffffff",buyNowBackgroundColor:"rgb(195, 167, 105)",addCartColor:"rgb(195, 167, 105)",addCartBackgroundColor:"rgb(243, 238, 225)",activedStyle:{color:"rgb(195, 167, 105)",borderColor:"rgb(195, 167, 105)",backgroundColor:"rgba(195, 167, 105,0.1)"}},green:{priceColor:"rgb(99, 190, 114)",buyNowColor:"#ffffff",buyNowBackgroundColor:"rgb(99, 190, 114)",addCartColor:"rgb(99, 190, 114)",addCartBackgroundColor:"rgb(225, 244, 227)",activedStyle:{color:"rgb(99, 190, 114)",borderColor:"rgb(99, 190, 114)",backgroundColor:"rgba(99, 190, 114,0.1)"}}},curStep:0}},created(){let e=this;x=e.vk,e.valueCom&&e.open()},mounted(){},methods:{init(e){let t=this;t.selectArr=[],t.subIndex=[],t.selectShop={},t.selectNum=t.minBuyNum||1,t.outFoStock=!1,t.shopItemInfo={};let o=t.specListName;t.goodsInfo[o].map((e=>{t.selectArr.push(""),t.subIndex.push(-1)})),t.checkItem(),t.checkInpath(-1),e||t.autoClickSku()},findGoodsInfo(e={}){let t=this,{useCache:o}=e;if(void 0===x)return t.toast("custom-action必须是function","none"),!1;let{actionTips:s}=t,l="",a=!1;"custom"!==s?l=o?"":"请求中...":a=!o,x.callFunction({url:t.action,title:l,loading:a,data:{goods_id:t.goodsId},success(e){t.updateGoodsInfo(e.goodsInfo),_[t.goodsId]=e.goodsInfo,t.$emit("update-goods",e.goodsInfo)},fail(){t.updateValue(!1)}})},updateValue(e){let t=this;e?(t.$emit("open",!0),t.$emit("input",!0),t.$emit("update:modelValue",!0)):(t.$emit("input",!1),t.$emit("close","close"),t.$emit("update:modelValue",!1))},updateGoodsInfo(e){let t=this,{skuListName:o}=t;if("{}"===JSON.stringify(t.goodsInfo)||t.goodsInfo[t.goodsIdName]!==e[t.goodsIdName]?(t.goodsInfo=e,t.initKey=!0):t.goodsInfo[o]=e[o],t.initKey){t.initKey=!1;const e=t.goodsInfo[t.skuListName],o=!t.isManyCom||1===e.length;t.init(!o)}let s=t.getListItem(t.goodsInfo[o],t.skuIdName,t.selectShop[t.skuIdName]);Object.assign(t.selectShop,s),t.defaultSelectSku(),t.complete=!0,t.initCurStep()},async open(){let e=this;e.openTime=(new Date).getTime();let t=!0;e.skuListName;let o=!1,s=_[e.goodsId];if(s&&e.useCache?(o=!0,e.updateGoodsInfo(s)):e.complete=!1,e.customAction&&"function"==typeof e.customAction){try{s=await e.customAction({useCache:o,goodsId:e.goodsId,goodsInfo:s,close:function(){setTimeout((function(){e.close()}),500)}}).catch((t=>{setTimeout((function(){e.close()}),500)}))}catch(l){let{message:t=""}=l;if(t.indexOf(".catch is not a function")>-1)return e.toast("custom-action必须返回一个Promise","none"),setTimeout((function(){e.close()}),500),!1}if(_[e.goodsId]=s,!s||"object"!=typeof s||"{}"==JSON.stringify(s))return e.toast("未获取到商品信息","none"),e.$emit("input",!1),!1;t=!1,e.updateGoodsInfo(s),e.updateValue(!0)}else if(void 0!==e.localdata&&null!==e.localdata){if(s=e.localdata,!s||"object"!=typeof s||"{}"==JSON.stringify(s))return e.toast("未获取到商品信息","none"),e.$emit("input",!1),!1;t=!1,e.updateGoodsInfo(s),e.updateValue(!0)}else t&&e.findGoodsInfo({useCache:o})},close(e){let t=this;if((new Date).getTime()-t.openTime<400)return!1;"mask"==e?!1!==t.maskCloseAble&&(t.$emit("input",!1),t.$emit("close","mask"),t.$emit("update:modelValue",!1)):(t.$emit("input",!1),t.$emit("close","close"),t.$emit("update:modelValue",!1))},moveHandle(){},skuClick(e,t,o){let s=this;e.ishow&&(s.selectArr[t]!=e.name?(s.$set(s.selectArr,t,e.name),s.$set(s.subIndex,t,o)):(s.$set(s.selectArr,t,""),s.$set(s.subIndex,t,-1)),s.checkInpath(t),s.checkSelectShop())},checkSelectShop(){let e=this;if(e.selectArr.every((e=>""!=e))){e.selectShop=e.shopItemInfo[e.getArrayToSting(e.selectArr)];let t=e.selectShop[e.stockName];void 0!==t&&e.selectNum>t&&(e.selectNum=t),e.selectNum>e.maxBuyNum&&(e.selectNum=e.maxBuyNum),e.selectNum<e.minBuyNum&&(e.selectNum=e.minBuyNum),e.selectedInit&&(e.selectNum=e.minBuyNum||1)}else e.selectShop={}},checkInpath(e){let t=this,o=t.specListName,s=t.goodsInfo[o];for(let l=0,a=s.length;l<a;l++){if(l==e)continue;let o=s[l].list.length;for(let e=0;e<o;e++){if(-1!=t.subIndex[l]&&e==t.subIndex[l])continue;let o=[...t.selectArr];t.$set(o,l,s[l].list[e].name);let a=o.filter((e=>""!==e&&void 0!==e));t.shopItemInfo.hasOwnProperty(t.getArrayToSting(a))?s[l].list[e].ishow=!0:s[l].list[e].ishow=!1}}t.$set(t.goodsInfo,o,s)},checkItem(){let e=this,{stockName:t}=e,o=e.skuListName,s=e.goodsInfo[o],l=[],a=0;s.map(((e,o)=>{e[t]>0&&(l.push(e),a+=e[t])})),a<=0&&(e.outFoStock=!0),l.reduce(((t,o)=>t.concat(o[e.skuArrName].reduce(((t,s)=>t.concat(t.map((t=>(e.shopItemInfo.hasOwnProperty(e.getArrayToSting([...t,s]))||(e.shopItemInfo[e.getArrayToSting([...t,s])]=o),[...t,s]))))),[[]]))),[[]])},getArrayToSting(e){let t="";return e.map(((e,o)=>{e=e.replace(/\./g,"。"),t+=0==o?e:","+e})),t},checkSelectComplete(e={}){let t=this,o=(new Date).getTime();if(t.clickTime&&o-t.clickTime<400)return!1;t.clickTime=o;let{selectShop:s,selectNum:l,stockText:a,stockName:i}=t;return s&&s[t.skuIdName]?l<=0?(t.toast("购买数量必须>0","none"),!1):l>s[i]?(t.toast(a+"不足","none"),!1):void("function"==typeof e.success&&e.success(s)):(t.toast("请先选择对应规格","none"),!1)},addCart(){let e=this;e.checkSelectComplete({success:function(t){t.buy_num=e.selectNum,e.$emit("add-cart",t),e.$emit("cart",t)}})},buyNow(){let e=this;e.checkSelectComplete({success:function(t){t.buy_num=e.selectNum,e.isStepsGroupon&&(t.stepPeople=e.goodsInfo.steps_config[e.curStep]),e.$emit("buy-now",t),e.$emit("buy",t)}})},toast(e,t){uni.showToast({title:e,icon:t})},getListItem(e,t,o){let s;for(let l in e)if("object"==typeof o){if(JSON.stringify(e[l][t])===JSON.stringify(o)){s=e[l];break}}else if(e[l][t]===o){s=e[l];break}return s},getListIndex(e,t,o){let s=-1;for(let l=0;l<e.length;l++)if(e[l][t]===o){s=l;break}return s},autoClickSku(){let e=this,{stockName:t}=e,o=e.goodsInfo[e.skuListName],s=e.goodsInfo[e.specListName];if(1==s.length){let l=s[0].list;for(let s=0;s<l.length;s++){let a=e.getListItem(o,e.skuArrName,[l[s].name]);if(a&&a[t]>0){e.skuClick(l[s],0,s);break}}}},themeColorFn(e){let t=this,{theme:o,themeColor:s}=t;return t[e]?t[e]:s[o][e]},defaultSelectSku(){let e=this,{defaultSelect:t}=e;t&&t.sku&&t.sku.length>0&&e.selectSku(t)},selectSku(e={}){let t=this,{sku:o,num:s}=e,l=t.goodsInfo[t.specListName];if(o&&l.length===o.length){let e=[],s=!0;for(let a=0;a<o.length;a++){let i=o[a],n=l[a].list,r=a,u=t.getListIndex(n,"name",i);if(-1==u){s=!1;break}e.push({spec:n[u],index1:r,index2:u})}s&&(t.init(!0),e.map((e=>{t.skuClick(e.spec,e.index1,e.index2)})))}s>0&&(t.selectNum=s)},priceFilter(e=0){return"string"==typeof e&&(e=parseFloat(e)),0===this.amountType?e.toFixed(2):(e/100).toFixed(2)},pushGoodsCache(e){let{goodsIdName:t}=this;_[e[t]]=e},stop(){},previewImage(){let{selectShop:e,goodsInfo:t,goodsThumbName:o}=this,s=e.image?e.image:t[o];s&&uni.previewImage({urls:[s]})},getMaxStock(){let e=0,{selectShop:t={},goodsInfo:o={},skuListName:s,stockName:l}=this;if(t[l])e=t[l];else{let t=o[s];if(t&&t.length>0){let o=[];t.map(((e,t)=>{o.push(e[l])})),e=Math.max(...o)}}return e},numChange(e){this.$emit("num-change",e.value)},handleStepItem(e){this.isJoin||(this.curStep=e)},getSkuPrice(e){const{buyMode:t,goodsInfo:o,curStep:s}=this;return 1==t&&o.active_type==N.STEPS.value?100*e.steps_price_config[s]:1==t?100*e.groupon_price:100*e.original_price},getAllSkuPrice(e){const{goodsInfo:t,curStep:o}=this,s=[];return e.forEach((e=>{t.active_type==N.STEPS.value?e.steps_price_config.forEach((e=>s.push(100*e))):s.push(100*e.price)})),s},initCurStep(){const{goodsInfo:e,stepPeople:t}=this,o=e.steps_config.indexOf(t);this.curStep=o>-1?o:0}},computed:{valueCom(){return this.modelValue},maxBuyNumCom(){let e=this.getMaxStock(),t=this.maxBuyNum||1e5;return t>e&&(t=e),t},isManyCom(){let{goodsInfo:e,defaultSingleSkuName:t,specListName:o}=this,s=!0;return e[o]&&1===e[o].length&&1===e[o][0].list.length&&e[o][0].name===t&&(s=!1),s},priceCom(){let e="",t=this,{selectShop:o={},goodsInfo:s={},skuListName:l,skuIdName:a}=t;if(o[a])e=t.priceFilter(t.getSkuPrice(o));else{let o=s[l];if(o&&o.length>0){const s=t.getAllSkuPrice(o);let l=t.priceFilter(Math.min(...s)),a=t.priceFilter(Math.max(...s));e=l===a?l+"":`${l} - ${a}`}}return e},stockCom(){let e="",{selectShop:t={},goodsInfo:o={},skuListName:s,stockName:l}=this;if(t[l])e=t[l];else{let t=o[s];if(t&&t.length>0){let o=[];t.map(((e,t)=>{o.push(e[l])}));let s=Math.min(...o),a=Math.max(...o);e=s===a?s:`${s} - ${a}`}}return e},isStepsGroupon(){const{buyMode:e,goodsInfo:{steps_config:t}}=this;return 1==e&&t&&t.length}},watch:{valueCom(e,t){e&&this.open()},defaultGoods:{immediate:!0,handler:function(e,t){let o=this,{goodsIdName:s}=o;"object"==typeof e&&e&&e[s]&&!_[e[s]]&&o.pushGoodsCache(e)}}}},[["render",function(e,c,N,T,I,x){const _=u,v=k,B=C,w=d("number-box"),V=S;return t(),o(_,{class:a(["goods-sku-popup",x.valueCom&&I.complete?"show":"none"]),catchtouchmove:"true",onTouchmove:n(x.moveHandle,["stop","prevent"]),onClick:n(x.stop,["stop"])},{default:s((()=>[l(_,{class:"mask",onClick:c[0]||(c[0]=e=>x.close("mask"))}),l(_,{class:a(["layer attr-content",{"safe-area-inset-bottom":N.safeAreaInsetBottom}]),style:i({borderRadius:N.borderRadius+"rpx "+N.borderRadius+"rpx 0 0"})},{default:s((()=>[l(_,{class:"specification-wrapper"},{default:s((()=>[l(V,{class:"specification-wrapper-content","scroll-y":"true"},{default:s((()=>[l(_,{class:"specification-header"},{default:s((()=>[l(_,{class:"specification-left"},{default:s((()=>[l(v,{class:"product-img",src:I.selectShop.image?I.selectShop.image:I.goodsInfo[N.goodsThumbName],style:i({backgroundColor:N.goodsThumbBackgroundColor}),mode:"aspectFill",onClick:x.previewImage},null,8,["src","style","onClick"])])),_:1}),l(_,{class:"specification-right"},{default:s((()=>[l(_,{class:"price-content",style:i({color:x.themeColorFn("priceColor")})},{default:s((()=>[l(B,{class:"sign"},{default:s((()=>[r("¥")])),_:1}),l(B,{class:a(["price",x.priceCom.length>16?"price2":""])},{default:s((()=>[r(p(x.priceCom),1)])),_:1},8,["class"])])),_:1},8,["style"]),N.hideStock?(t(),o(_,{key:1,class:"inventory"})):(t(),o(_,{key:0,class:"inventory"},{default:s((()=>[r(p(N.stockText)+":"+p(x.stockCom),1)])),_:1})),m(l(_,{class:"choose"},{default:s((()=>[I.selectArr.every((e=>""==e))?g("",!0):(t(),o(B,{key:0},{default:s((()=>[r("已选:"+p(I.selectArr.join(" ")),1)])),_:1}))])),_:1},512),[[h,x.isManyCom]])])),_:1})])),_:1}),l(_,{class:"specification-content"},{default:s((()=>[x.isStepsGroupon?(t(),o(_,{key:0,class:"specification-item"},{default:s((()=>[l(_,{class:"item-title"},{default:s((()=>[r("阶梯人数")])),_:1}),l(_,{class:"item-wrapper"},{default:s((()=>[(t(!0),f(y,null,b(I.goodsInfo.steps_config,((e,l)=>(t(),o(_,{class:a(["item-content",[I.curStep==l?"actived":"",N.isJoin?"noactived":""]]),key:l,style:i([I.curStep==l?x.themeColorFn("activedStyle"):""]),onClick:e=>x.handleStepItem(l)},{default:s((()=>[r(p(e)+"人团 ",1)])),_:2},1032,["class","style","onClick"])))),128))])),_:1})])),_:1})):g("",!0),(t(!0),f(y,null,b(I.goodsInfo[N.specListName],((e,n)=>m((t(),o(_,{class:"specification-item",key:n},{default:s((()=>[l(_,{class:"item-title"},{default:s((()=>[r(p(e.name),1)])),_:2},1024),l(_,{class:"item-wrapper"},{default:s((()=>[(t(!0),f(y,null,b(e.list,((e,l)=>(t(),o(_,{class:a(["item-content",[e.ishow?"":"noactived",I.subIndex[n]==l?"actived":""]]),key:l,style:i([e.ishow?"":x.themeColorFn("disableStyle"),e.ishow?x.themeColorFn("btnStyle"):"",I.subIndex[n]==l?x.themeColorFn("activedStyle"):""]),onClick:t=>x.skuClick(e,n,l)},{default:s((()=>[r(p(e.name),1)])),_:2},1032,["class","style","onClick"])))),128))])),_:2},1024)])),_:2},1024)),[[h,x.isManyCom]]))),128)),l(_,{class:"number-box-view"},{default:s((()=>[l(_,{style:{flex:"1",display:"flex","align-items":"center"}},{default:s((()=>[r("数量")])),_:1}),l(_,{style:{flex:"4",display:"flex","align-items":"center","justify-content":"flex-end"}},{default:s((()=>[N.maxBuyNum>0?(t(),o(B,{key:0,style:{"margin-right":"18rpx","font-size":"26rpx",color:"#e74800"}},{default:s((()=>[r("限购"+p(N.maxBuyNum)+"件",1)])),_:1})):g("",!0),l(w,{modelValue:I.selectNum,"onUpdate:modelValue":c[1]||(c[1]=e=>I.selectNum=e),min:N.minBuyNum||1,max:x.maxBuyNumCom,step:N.stepBuyNum||1,"step-strictly":N.stepStrictly,"positive-integer":!0},null,8,["modelValue","min","max","step","step-strictly"])])),_:1})])),_:1})])),_:1})])),_:1}),0!=N.showClose?(t(),o(_,{key:0,class:"close",onClick:c[2]||(c[2]=e=>x.close("close"))},{default:s((()=>[l(v,{class:"close-item",src:N.closeImage},null,8,["src"])])),_:1})):g("",!0)])),_:1}),I.outFoStock||4==N.mode?(t(),o(_,{key:0,class:"btn-wrapper"},{default:s((()=>[l(_,{class:"sure",style:{color:"#ffffff","background-color":"#cccccc"}},{default:s((()=>[r(p(N.noStockText),1)])),_:1})])),_:1})):1==N.mode?(t(),o(_,{key:1,class:"btn-wrapper"},{default:s((()=>[l(_,{class:"sure add-cart",style:i([{"border-radius":"38rpx 0rpx 0rpx 38rpx"},{color:x.themeColorFn("addCartColor"),backgroundColor:x.themeColorFn("addCartBackgroundColor")}]),onClick:x.addCart},{default:s((()=>[r(p(N.addCartText),1)])),_:1},8,["style","onClick"]),l(_,{class:"sure",style:i([{"border-radius":"0rpx 38rpx 38rpx 0rpx"},{color:x.themeColorFn("buyNowColor"),backgroundColor:x.themeColorFn("buyNowBackgroundColor")}]),onClick:x.buyNow},{default:s((()=>[r(p(N.buyNowText),1)])),_:1},8,["style","onClick"])])),_:1})):2==N.mode?(t(),o(_,{key:2,class:"btn-wrapper"},{default:s((()=>[l(_,{class:"sure add-cart",style:i({color:x.themeColorFn("addCartColor"),backgroundColor:x.themeColorFn("addCartBackgroundColor")}),onClick:x.addCart},{default:s((()=>[r(p(N.addCartText),1)])),_:1},8,["style","onClick"])])),_:1})):3==N.mode?(t(),o(_,{key:3,class:"btn-wrapper"},{default:s((()=>[l(_,{class:"sure",style:i({color:x.themeColorFn("buyNowColor"),backgroundColor:x.themeColorFn("buyNowBackgroundColor")}),onClick:x.buyNow},{default:s((()=>[r(p(N.buyNowText),1)])),_:1},8,["style","onClick"])])),_:1})):g("",!0)])),_:1},8,["class","style"])])),_:1},8,["class","onTouchmove","onClick"])}],["__scopeId","data-v-9d8fe828"]])},emits:["update:modelValue"],props:{modelValue:{Type:Boolean,default:!1},skuMode:{type:Number,default:1},goods:{type:Object,default:{}},buyMode:{type:Number,default:1},taskId:{type:Number,default:void 0},stepPeople:{type:Number,default:void 0}},computed:{activedBtnBackgroundColor(){return e(this.appTheme.mainBg,.1)}},watch:{buyMode(e){this.init()}},data:()=>({goodsInfo:{},maxBuyNum:null}),created(){this.init()},methods:{init(){const e=this,{goods:t}=e;e.goodsInfo={_id:t.goods_id,name:t.goods_name,goods_thumb:t.goods_image,sku_list:e.getSkuList(),spec_list:e.getSpecList(),active_type:t.active_type,steps_config:t.steps_config},e.maxBuyNum=e.getMaxBuyNum()},onChangeValue(e){this.$emit("update:modelValue",e)},getSkuList(){const e=this,{goods:{goods_name:t,goods_image:o,skuList:s}}=e,l=[];return s.forEach((s=>{l.push({_id:s.id,goods_sku_id:s.goods_sku_id,goods_id:s.goods_id,goods_name:t,image:s.image_url?s.image_url:o,price:s.groupon_price,stock:s.stock_num,spec_value_ids:s.spec_value_ids,sku_name_arr:e.getSkuNameArr(s.spec_value_ids),groupon_price:s.groupon_price,original_price:s.original_price,steps_price_config:s.steps_price_config})})),l},getSkuNameArr(e){const t=this,o=[];return e&&e.forEach(((e,s)=>{const l=t.getSpecValueName(e,s);o.push(l)})),o.length?o:["默认"]},getSpecValueName(e,t){const{goods:{specList:o}}=this;return o[t].valueList.find((t=>t.spec_value_id==e)).spec_value},getSpecList(){const{goods:{specList:e,steps_config:t}}=this,o=[];return e.forEach((e=>{const t=[];e.valueList.forEach((e=>{t.push({name:e.spec_value})})),o.push({name:e.spec_name,list:t})})),o.length?o:[{name:"默认",list:[{name:"默认"}]}]},getMaxBuyNum(){const{goods:e,buyMode:t}=this;return 1==t&&e.is_restrict?e.restrict_single:null},openSkuPopup(){},closeSkuPopup(){},buyNow(e){const t=this;t.$navTo("pages/checkout/index",t.getOrderParam(e)),t.onChangeValue(!1)},getOrderParam(e){const{goods:t,buyMode:o,taskId:s}=this,l={goodsSkuId:e.goods_sku_id,goodsNum:e.buy_num};return 1==o?(l.mode="groupon",l.grouponGoodsId=t.groupon_goods_id,l.taskId=s,l.stepPeople=e.stepPeople):(l.mode="buyNow",l.goodsId=t.goods_id),l}}},[["render",function(e,s,l,a,i,n){const r=d("goods-sku-popup");return t(),o(r,{modelValue:l.modelValue,onInput:n.onChangeValue,"border-radius":"20",localdata:i.goodsInfo,mode:l.skuMode,maskCloseAble:!0,priceColor:e.appTheme.mainBg,buyNowBackgroundColor:e.appTheme.mainBg,addCartColor:e.appTheme.viceText,addCartBackgroundColor:e.appTheme.viceBg,activedStyle:{color:e.appTheme.mainBg,borderColor:e.appTheme.mainBg,backgroundColor:n.activedBtnBackgroundColor},onOpen:n.openSkuPopup,onClose:n.closeSkuPopup,onBuyNow:n.buyNow,buyNowText:"立即购买",maxBuyNum:i.maxBuyNum,buyMode:l.buyMode,isJoin:!!l.taskId,stepPeople:l.stepPeople},null,8,["modelValue","onInput","localdata","mode","priceColor","buyNowBackgroundColor","addCartColor","addCartBackgroundColor","activedStyle","onOpen","onClose","onBuyNow","maxBuyNum","buyMode","isJoin","stepPeople"])}]]);export{v as S};
|
|
|