1 |
- "use strict";const t=require("../common/vendor.js"),l=require("../api/order.js"),u=require("../common/assets.js"),y=()=>"../components/evan-switch/evan-switch.js",v=()=>"../components/px-popup-bottom/px-popup-bottom.js",I={components:{EvanSwitch:y,popupBottom:v},data(){return{priceSum:null,cartsSelect:[],address:null,addressId:null,totalNum:null,orderKey:null,price:null,liveId:null,orderList:[],userInfo:null,userAddrLiat:[],temps:[],couponUserId:null,couponText:"请选择",couponsList:[],couponVisible:!1,priceAll:{payPrice:0,totalPostage:0,usedIntegral:0,totalPrice:0},carts:[],checked:!1,type:null,cartIds:null,confirmParam:[]}},onLoad(e){console.log("确认订单",e),this.orderKey=e.orderKey,this.type=e.type,this.type=="goods"&&(this.liveId=e.liveId,this.productId=e.productId,this.totalNum=Number(e.totalNum),this.price=Number(e.price),this.priceSum=this.price*this.totalNum),this.type=="cart"&&this.getChecked()},mounted(){this.getUserAddr(),t.index.$on("updateAddress",e=>{this.address=e,this.addressId=e.addressId})},beforeDestroy(){t.index.$off("updateAddress")},methods:{getChecked(){l.checked().then(e=>{e.code==200?(this.cartsSelect=e.rows,this.priceSum=e.rows.reduce((s,d)=>s+d.price*d.cartNum,0),console.log("获取购物车选中商品>>>>",this.priceSum)):t.index.showToast({title:e.msg,icon:"none"})},e=>{})},getUserAddr(){this.userInfo=JSON.parse(t.index.getStorageSync("userInfo")),l.userAddr(this.userInfo.userId).then(e=>{e.code==200?(console.log("用户收货地址>>>>",e.data),this.address=e.data.find(s=>s.isDefault==1)):t.index.showToast({title:e.msg,icon:"none"})},e=>{})},createCartLiveOrder(){let e={orderKey:this.orderKey,userName:this.address.realName,userPhone:this.address.phone,userAddress:this.address.province+this.address.city+this.address.district+this.address.detail};return l.cartOrder(e).then(s=>{if(s.code==200)return console.log("创建购物车订单res",s),this.OrderList=s.order,s.order;throw t.index.showToast({title:s.msg,icon:"none"}),new Error(s.msg)})},createLiveOrder(){let e={liveId:this.liveId,orderKey:this.orderKey,userName:this.address.realName,userPhone:this.address.phone,userAddress:this.address.province+this.address.city+this.address.district+this.address.detail,cartId:"5",productId:this.productId,totalNum:this.totalNum};return l.createliveOrder(e).then(s=>{if(s.code==200)return this.orderList=s.order,s.order;throw t.index.showToast({title:s.msg,icon:"none"}),new Error(s.msg)})},getWeixinOrderTemps:function(){getWeixinOrderTemps().then(e=>{e.code==200&&(this.temps=e.temp)},e=>{})},couponSelect(e){this.couponText="-¥"+e.couponPrice.toFixed(2),this.couponUserId=e.id,this.couponVisible=!1,this.computed()},openCoupon(){let e=this;var s={couponType:2,useMinPrice:this.price.payPrice};getMyEnableCouponList(s).then(d=>{this.couponVisible=!0,e.couponsList=d.data})},integralChange(e){this.form.useIntegral=e?1:0,this.computed()},openAddress(){t.index.navigateTo({url:"/pages_user/address"})},async submitOrder(){try{if(this.orderKey==null){t.index.showToast({icon:"none",title:"订单KEY不存在"});return}if(this.address==null){t.index.showToast({icon:"none",title:"收货地址不能为空"});return}let e;this.type=="cart"?e=await this.createCartLiveOrder():this.type=="goods"&&(e=await this.createLiveOrder()),console.log("orderList>>",e);const s=encodeURIComponent(JSON.stringify(e));t.index.navigateTo({url:`/pages_shop/paymentOrder?orderList=${s}`})}catch(e){console.error("订单创建失败:",e),t.index.showToast({title:"提交失败",icon:"none"})}},async creatCartOrder(){try{if(this.orderKey==null){t.index.showToast({icon:"none",title:"订单KEY不存在"});return}if(this.address==null){t.index.showToast({icon:"none",title:"收货地址不能为空"});return}const e=await this.cartOrder(),s=encodeURIComponent(JSON.stringify(e));t.index.navigateTo({url:`/pages_shop/paymentOrder?orderList=${s}`})}catch(e){console.error("订单创建失败:",e),t.index.showToast({title:"提交失败",icon:"none"})}}}};Array||t.resolveComponent("popupBottom")();function _(e,s,d,N,r,c){var a,p,h;return t.e({a:r.address==null},r.address==null?{b:u._imports_0$9,c:t.o(o=>c.openAddress())}:{},{d:r.address!=null},r.address!=null?t.e({e:t.t(r.address.realName),f:r.address.phone!=null},r.address.phone!=null?{g:t.t(e.$parsePhone(r.address.phone))}:{},{h:t.t(r.address.province),i:t.t(r.address.city),j:t.t(r.address.district),k:t.t(r.address.detail),l:u._imports_0$9,m:t.o(o=>c.openAddress())}):{},{n:t.f(r.carts,(o,n,g)=>t.e({a:o.storeName&&o.storeName!="null"},o.storeName&&o.storeName!="null"?{b:t.t(o.storeName)}:{},{c:t.f(o.list,(i,f,L)=>{var m;return{a:i.productAttrImage?i.productAttrImage:i.productImage,b:t.t(e.utils.getDictLabelName("storeProductType",i.productType)),c:t.t(i.productName),d:t.t(i.productAttrName),e:t.t((m=i.price)==null?void 0:m.toFixed(2)),f:t.t(i.cartNum),g:f}})},r.price&&r.price.length>0?{d:t.t(r.price[n].payPostage==null||r.price[n].payPostage==0?"免运费":r.price[n].payPostage.toFixed(2))}:{},{e:o.markinfo,f:t.o(i=>o.markinfo=i.detail.value,n),g:n})),o:r.price&&r.price.length>0,p:t.t((a=r.priceSum)==null?void 0:a.toFixed(2)),q:t.t((p=r.priceSum)==null?void 0:p.toFixed(2)),r:t.t((h=r.priceSum)==null?void 0:h.toFixed(2)),s:t.o((...o)=>c.submitOrder&&c.submitOrder(...o)),t:r.couponsList.length>0},r.couponsList.length>0?{v:t.f(r.couponsList,(o,n,g)=>t.e({a:o.status==0},o.status==0?{b:u._imports_2$5}:{},{c:o.status!=0},o.status!=0?{d:u._imports_3$2}:{},{e:t.t(o.couponPrice),f:t.t(o.useMinPrice),g:t.t(o.couponTitle),h:t.t(o.limitTime),i:t.o(i=>c.couponSelect(o),n),j:n}))}:{},{w:r.couponsList.length==0},r.couponsList.length==0?{x:u._imports_2$2}:{},{y:t.sr("popup","5fa01107-0"),z:t.p({visible:r.couponVisible,title:" ",bgColor:"#f5f5f5",radius:"30",maxHeight:"60%"})})}const x=t._export_sfc(I,[["render",_],["__scopeId","data-v-5fa01107"]]);wx.createPage(x);
|