popPay.js
3.0 KB
"use strict";const e=require("../common/vendor.js"),y=require("../api/index.js");require("../utils/request.js");if(!Array){const t=e.resolveComponent("u-number-box"),a=e.resolveComponent("u-popup");(t+a)()}const f=()=>"../uni_modules/uview-plus/components/u-number-box/u-number-box.js",b=()=>"../uni_modules/uview-plus/components/u-popup/u-popup.js";Math||(f+b)();const D={__name:"popPay",props:{btnType:{type:Number,default:0},shopType:Number,payPopShow:{type:Boolean,default:!1},shopDetail:{type:Object,default:{}},moreSpec:{type:Object,default:{}}},emits:["close"],setup(t,{emit:a}){const n=t;let o=e.reactive({value:1,speList:[],indexList:[],specID:[],specIdList:[],formList:{},goods_spec_id:"",curPriceIdx:0});e.onMounted(()=>{setTimeout(()=>{if(console.log("多规格",n.moreSpec),n.moreSpec!=null){let s=n.moreSpec.spec_attr,c=n.moreSpec.spec_list;o.speList=s,o.specIdList=c,s.forEach((p,u)=>{o.indexList.push({curIndex:0}),o.specID.push(p.spec_items[0].item_id)}),o.goods_spec_id=o.specID.join("_"),r()}else o.goods_spec_id=n.shopDetail.spec[0].goods_spec_id},200)});const l=()=>{a("close")},h=s=>{console.log("数量"+s.value),o.value=s.value},d=()=>{let s=n.shopDetail.goodstatus,c={id:n.shopDetail.id,num:o.value,specId:o.goods_spec_id};console.log("当前值为: ",c),n.btnType==0?_():e.index.navigateTo({url:`/pages/shopCar/confirmOrder?params=${JSON.stringify(c)}&shopType=${s}`})},g=(s,c,p)=>{console.log(s,c,p),o.curPriceIdx=p,o.indexList[s].curIndex=p,o.speList.length==1?o.specID.splice(s,1,c.item_id):o.specID.splice(s,o.specID.length>1?1:0,c.item_id),r()},r=()=>{if(o.specID.length==o.speList.length){let s=o.specIdList.find(c=>c.spec_sku_id==o.specID.join("_"));o.formList=s.form,o.goods_spec_id=s.goods_spec_id,console.log("查找到的规格",s,o.specID.join("_"))}},_=async()=>{try{let s={goods_id:n.shopDetail.id,num:o.value,goods_spec_id:o.goods_spec_id};const c=await y.getAddCar(s);l(),e.index.showToast({title:"成功加入购物车~",icon:"none"}),console.log("getAddCar",c)}catch(s){e.index.showToast({title:s,icon:"none"}),console.log("getAddCar",s)}};return(s,c)=>e.e({a:t.shopType!==3},t.shopType!==3?{b:e.t(t.btnType==0?"加入购物车":"立即购买")}:{},{c:t.shopType===3},t.shopType===3?{}:{},{d:t.shopDetail.image,e:e.t(t.shopDetail.name),f:t.shopDetail.goodstatus!==3},t.shopDetail.goodstatus!==3?{g:e.t(t.shopDetail.spec[e.unref(o).curPriceIdx].goods_price)}:{h:e.t(t.shopDetail.spec[e.unref(o).curPriceIdx].coscore)},{i:e.f(e.unref(o).speList,(p,u,v)=>({a:e.t(p.group_name),b:e.f(p.spec_items,(i,m,T)=>({a:e.t(i.spec_value),b:i.item_id,c:e.n(m==e.unref(o).indexList[u].curIndex?"checked":""),d:e.o(x=>g(u,i,m),i.item_id)})),c:p.group_id})),j:e.o(h),k:e.o(p=>s.value=p),l:e.p({modelValue:s.value}),m:t.btnType==0},t.btnType==0?{n:e.o(d)}:{o:e.t(t.shopDetail.goodstatus==3?"立即兑换":"立即购买"),p:e.o(d)},{q:e.o(l),r:e.o(s.open),s:e.p({show:t.payPopShow,mode:"bottom",closeable:!0,round:"18"})})}},I=e._export_sfc(D,[["__file","D:/vue/大健康商城/healthMall/componets/popPay.vue"]]);wx.createComponent(I);