pages-checkout-index.464a4a1e.js 16 KB

1
  1. import{y as e,o as t,c as o,w as s,a as l,n as a,k as i,i as r,e as n,f as d,t as u,l as c,$ as f,b as p,F as m,d as h,I as _,j as y,g}from"./index-3b24b149.js";import{_ as x}from"./u-loading.073cbc93.js";import{r as C}from"./uni-app.es.9206f90a.js";import{_ as w}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as k}from"./u-modal.955b8501.js";import{_ as v}from"./u-popup.c8f8fe8c.js";import{_ as b}from"./u-icon.72a24694.js";import{C as T}from"./CouponType.57eb5abb.js";import{O as S,D as P}from"./OrderType.2c504bdd.js";const I=w({name:"u-switch",emits:["update:modelValue","input","change"],props:{value:{type:Boolean,default:!1},modelValue:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},size:{type:[Number,String],default:50},activeColor:{type:String,default:"#2979ff"},inactiveColor:{type:String,default:"#ffffff"},vibrateShort:{type:Boolean,default:!1},activeValue:{type:[Number,String,Boolean],default:!0},inactiveValue:{type:[Number,String,Boolean],default:!1}},data:()=>({}),computed:{valueCom(){return this.modelValue},switchStyle(){let e={};return e.fontSize=this.size+"rpx",e.backgroundColor=this.valueCom?this.activeColor:this.inactiveColor,e},loadingColor(){return this.valueCom?this.activeColor:null}},methods:{onClick(){this.disabled||this.loading||(this.vibrateShort&&uni.vibrateShort(),this.$emit("input",!this.valueCom),this.$emit("update:modelValue",!this.valueCom),this.$nextTick((()=>{this.$emit("change",this.valueCom?this.activeValue:this.inactiveValue)})))}}},[["render",function(n,d,u,c,f,p){const m=C(e("u-loading"),x),h=r;return t(),o(h,{class:i(["u-switch",[1==p.valueCom?"u-switch--on":"",u.disabled?"u-switch--disabled":""]]),onClick:p.onClick,style:a([p.switchStyle])},{default:s((()=>[l(h,{class:"u-switch__node node-class",style:a({width:n.$u.addUnit(u.size),height:n.$u.addUnit(u.size)})},{default:s((()=>[l(m,{show:u.loading,class:"u-switch__loading",size:.6*u.size,color:p.loadingColor},null,8,["show","size","color"])])),_:1},8,["style"])])),_:1},8,["class","onClick","style"])}],["__scopeId","data-v-7debaf62"]]);const D=w({name:"u-toast",props:{zIndex:{type:[Number,String],default:""}},data:()=>({isShow:!1,timer:null,config:{params:{},title:"",type:"",duration:2e3,isTab:!1,url:"",icon:!0,position:"center",callback:null,back:!1},tmpConfig:{}}),computed:{iconName(){if(["error","warning","success","info"].indexOf(this.tmpConfig.type)>=0&&this.tmpConfig.icon){return this.$u.type2icon(this.tmpConfig.type)}},uZIndex(){return this.isShow?this.zIndex?this.zIndex:this.$u.zIndex.toast:"999999"}},methods:{show(e){this.tmpConfig=this.$u.deepMerge(this.config,e),this.timer&&(clearTimeout(this.timer),this.timer=null),this.isShow=!0,this.timer=setTimeout((()=>{this.isShow=!1,clearTimeout(this.timer),this.timer=null,"function"==typeof this.tmpConfig.callback&&this.tmpConfig.callback(),this.timeEnd()}),this.tmpConfig.duration)},hide(){this.isShow=!1,this.timer&&(clearTimeout(this.timer),this.timer=null)},timeEnd(){if(this.tmpConfig.url){if("/"!=this.tmpConfig.url[0]&&(this.tmpConfig.url="/"+this.tmpConfig.url),Object.keys(this.tmpConfig.params).length){let e="";/.*\/.*\?.*=.*/.test(this.tmpConfig.url)?(e=this.$u.queryParams(this.tmpConfig.params,!1),this.tmpConfig.url=this.tmpConfig.url+"&"+e):(e=this.$u.queryParams(this.tmpConfig.params),this.tmpConfig.url+=e)}this.tmpConfig.isTab?uni.switchTab({url:this.tmpConfig.url}):uni.navigateTo({url:this.tmpConfig.url})}else this.tmpConfig.back&&this.$u.route({type:"back"})}}},[["render",function(f,p,m,h,_,y){const g=C(e("u-icon"),b),x=r,w=c;return t(),o(x,{class:i(["u-toast",[_.isShow?"u-show":"","u-type-"+_.tmpConfig.type,"u-position-"+_.tmpConfig.position]]),style:a({zIndex:y.uZIndex})},{default:s((()=>[l(x,{class:"u-icon-wrap"},{default:s((()=>[_.tmpConfig.icon?(t(),o(g,{key:0,class:"u-icon",name:y.iconName,size:30,color:_.tmpConfig.type},null,8,["name","color"])):n("",!0)])),_:1}),l(w,{class:"u-text"},{default:s((()=>[d(u(_.tmpConfig.title),1)])),_:1})])),_:1},8,["class","style"])}],["__scopeId","data-v-aa0b93e8"]]),E="checkout/order",V="checkout/submit",$=Object.freeze(Object.defineProperty({__proto__:null,order:(e,t)=>f.get(E,{mode:e,...t}),submit:(e,t)=>f.post(V,{mode:e,...t},{isPrompt:!1})},Symbol.toStringTag,{value:"Module"})),O=["red","blue","violet","yellow"],U=e=>({buyNow:$,cart:$}[e]),z=(e,t)=>{const o={};return"buyNow"===e&&(o.goodsId=t.goodsId,o.goodsNum=t.goodsNum,o.goodsSkuId=t.goodsSkuId),"cart"===e&&(o.cartIds=t.cartIds),o};const N=w({data:()=>({OrderTypeEnum:S,DeliveryTypeEnum:P,CouponTypeEnum:T,options:{},isShowTab:!1,DeliveryTypeEnum:P,curDelivery:null,CouponColors:O,selectCouponId:0,isUsePoints:!1,remark:"",disabled:!1,showPoints:!1,showPopup:!1,order:{goodsList:[],couponList:[],existAddress:!1,address:null,existAddress:!1,isIntraRegion:!0,hasError:!1,errorMsg:""},personal:{},setting:{}}),onLoad(e){this.options=e},onUnload(){},onShow(){this.getOrderData()},methods:{getOrderData(){const e=this,{options:{mode:t}}=e,o=e.getRequestParam();U(t).order(t,o).then((t=>e.initData(t.data))).catch((e=>e))},initData({order:e,setting:t,personal:o}){const s=this;s.order=e,s.personal=o,s.setting=t,e.hasError&&s.showToast(e.errorMsg,3e3),s.curDelivery=e.delivery,s.isShowTab=t.deliveryType.length>1},getRequestParam(){const e=this,{options:t}=e,o=z(t.mode,t);return{...{delivery:e.curDelivery||0,couponId:e.selectCouponId||0,isUsePoints:e.isUsePoints?1:0},...o}},handleSwichDelivery(e){this.curDelivery=e,this.getOrderData()},handleShowPoints(){this.showPoints=!0},handleShowPopup(){this.showPopup=!0},handleSelectCoupon(e){const t=this,{couponList:o}=t.order,s=o[e];s.is_apply?(t.selectCouponId=s.user_coupon_id,t.getOrderData(),t.showPopup=!1):t.showToast(s.not_apply_info)},handleNotUseCoupon(){const e=this;e.selectCouponId=0,e.getOrderData(),e.showPopup=!1},onSelectAddress(){this.$navTo("pages/address/index",{from:"checkout"})},onTargetGoods(e){this.$navTo("pages/goods/detail",{goodsId:e})},onSubmitOrder(){const e=this;return!e.disabled&&(!!e.onVerifyFrom()&&(e.disabled=!0,void U(e.options.mode).submit(e.options.mode,e.getFormData()).then((e=>{const t=e.data.orderId;setTimeout((()=>{this.$navTo("pages/checkout/cashier/index",{orderId:t},"redirectTo")}),100)})).catch((t=>e.showToast(t.errMsg,3e3))).finally((()=>setTimeout((()=>e.disabled=!1),800)))))},navToMyOrder(){setTimeout((()=>{this.$navTo("pages/order/index",{},"redirectTo")}),1e3)},getFormData(){const e=this,{options:t}=e;return{...{delivery:e.curDelivery,couponId:e.selectCouponId||0,isUsePoints:e.isUsePoints?1:0,remark:e.remark||""},...z(t.mode,t)}},onVerifyFrom(){const e=this;return!e.hasError||(e.showToast(e.errorMsg,3e3),!1)},showToast(e,t=2e3){this.$refs.uToast.show({title:e,duration:t})}}},[["render",function(f,x,w,b,T,S){const P=c,E=r,V=g,$=C(e("u-switch"),I),O=_,U=y,z=C(e("u-modal"),k),N=C(e("u-popup"),v),j=C(e("u-toast"),D);return t(),o(E,{class:"container p-bottom",style:a(f.appThemeStyle)},{default:s((()=>[T.order.goodsList.length?(t(),o(E,{key:0},{default:s((()=>[T.order.orderType==T.OrderTypeEnum.PHYSICAL.value?(t(),p(m,{key:0},[T.isShowTab?(t(),o(E,{key:0,class:"swiper-tab dis-flex flex-y-center flex-x-around"},{default:s((()=>[l(E,{class:i(["swiper-tab-item",{on:T.curDelivery==T.DeliveryTypeEnum.EXPRESS.value}]),onClick:x[0]||(x[0]=e=>S.handleSwichDelivery(T.DeliveryTypeEnum.EXPRESS.value))},{default:s((()=>[l(P,null,{default:s((()=>[d("快递配送")])),_:1})])),_:1},8,["class"])])),_:1})):n("",!0),T.curDelivery==T.DeliveryTypeEnum.EXPRESS.value?(t(),o(E,{key:1,onClick:S.onSelectAddress,class:"flow-delivery"},{default:s((()=>[l(E,{class:"flow-delivery__detail dis-flex flex-y-center"},{default:s((()=>[l(E,{class:"detail-location dis-flex"},{default:s((()=>[l(P,{class:"iconfont icon-dingwei"})])),_:1}),l(E,{class:"detail-content flex-box"},{default:s((()=>[T.order.address?(t(),p(m,{key:0},[l(E,{class:"detail-content__title dis-flex"},{default:s((()=>[l(P,{class:"f-30"},{default:s((()=>[d(u(T.order.address.name),1)])),_:1}),l(P,{class:"detail-content__title-phone f-28"},{default:s((()=>[d(u(T.order.address.phone),1)])),_:1})])),_:1}),l(E,{class:"address detail-content__describe"},{default:s((()=>[(t(!0),p(m,null,h(T.order.address.region,((e,l)=>(t(),o(P,{class:"region",key:l},{default:s((()=>[d(u(e),1)])),_:2},1024)))),128)),l(P,{class:"detail"},{default:s((()=>[d(u(T.order.address.detail),1)])),_:1})])),_:1})],64)):(t(),o(E,{key:1,class:"detail-content__describe dis-flex"},{default:s((()=>[l(P,{class:"col-6"},{default:s((()=>[d("请选择配送地址")])),_:1})])),_:1}))])),_:1}),l(E,{class:"detail-arrow dis-flex"},{default:s((()=>[l(P,{class:"iconfont icon-arrow-right"})])),_:1})])),_:1})])),_:1},8,["onClick"])):n("",!0)],64)):n("",!0),(t(!0),p(m,null,h(T.order.goodsList,((e,a)=>(t(),o(E,{class:"checkout_list",key:a},{default:s((()=>[l(E,{class:"flow-shopList dis-flex","data-index":"index",onClick:t=>S.onTargetGoods(e.goods_id)},{default:s((()=>[l(E,{class:"flow-list-left"},{default:s((()=>[l(V,{mode:"scaleToFill",src:e.goods_image},null,8,["src"])])),_:2},1024),l(E,{class:"flow-list-right flex-box"},{default:s((()=>[l(P,{class:"goods-name twoline-hide"},{default:s((()=>[d(u(e.goods_name),1)])),_:2},1024),l(E,{class:"goods-props clearfix"},{default:s((()=>[(t(!0),p(m,null,h(e.skuInfo.goods_props,((e,a)=>(t(),o(E,{class:"goods-props-item",key:a},{default:s((()=>[l(P,{class:"group-name"},{default:s((()=>[d(u(e.group.name)+": ",1)])),_:2},1024),l(P,null,{default:s((()=>[d(u(e.value.name)+";",1)])),_:2},1024)])),_:2},1024)))),128))])),_:2},1024),l(E,{class:"flow-list-cont dis-flex flex-x-between flex-y-center"},{default:s((()=>[l(P,{class:"small"},{default:s((()=>[d("×"+u(e.total_num),1)])),_:2},1024),l(P,{class:i(["flow-cont",[e.is_user_grade?"price-delete":""]])},{default:s((()=>[d("¥"+u(e.goods_price),1)])),_:2},1032,["class"])])),_:2},1024),e.is_user_grade?(t(),o(E,{key:0,class:"grade-price"},{default:s((()=>[l(P,null,{default:s((()=>[d("会员折扣价:¥"+u(e.grade_goods_price),1)])),_:2},1024)])),_:2},1024)):n("",!0)])),_:2},1024)])),_:2},1032,["onClick"])])),_:2},1024)))),128)),l(E,{class:"flow-num-box b-f"},{default:s((()=>[l(P,null,{default:s((()=>[d("共"+u(T.order.orderTotalNum)+"件商品",1)])),_:1})])),_:1}),l(E,{class:"flow-all-money b-f m-top20"},{default:s((()=>[l(E,{class:"flow-all-list dis-flex"},{default:s((()=>[l(P,{class:"flex-five"},{default:s((()=>[d("订单总金额:")])),_:1}),l(E,{class:"flex-five t-r"},{default:s((()=>[l(P,{class:"col-m"},{default:s((()=>[d("¥"+u(T.order.orderTotalPrice),1)])),_:1})])),_:1})])),_:1}),f.$checkModule("market-coupon")?(t(),o(E,{key:0,class:"flow-all-list dis-flex"},{default:s((()=>[l(P,{class:"flex-five"},{default:s((()=>[d("优惠券:")])),_:1}),l(E,{class:"flex-five t-r"},{default:s((()=>[T.order.couponList.length>0?(t(),o(E,{key:0,onClick:x[1]||(x[1]=e=>S.handleShowPopup())},{default:s((()=>[T.order.couponId>0?(t(),o(P,{key:0,class:"col-m"},{default:s((()=>[d("-¥"+u(T.order.couponMoney),1)])),_:1})):(t(),o(P,{key:1,class:"col-m"},{default:s((()=>[d("有"+u(T.order.couponList.length)+"张优惠券",1)])),_:1})),l(P,{class:"right-arrow iconfont icon-arrow-right"})])),_:1})):(t(),o(P,{key:1,class:""},{default:s((()=>[d("无优惠券可用")])),_:1}))])),_:1})])),_:1})):n("",!0),f.$checkModule("market-points")&&T.order.isAllowPoints?(t(),o(E,{key:1,class:"points flow-all-list dis-flex flex-y-center"},{default:s((()=>[l(E,{class:"block-left flex-five",onClick:x[2]||(x[2]=e=>S.handleShowPoints())},{default:s((()=>[l(P,{class:"title"},{default:s((()=>[d("可用"+u(T.setting.points_name)+"抵扣:",1)])),_:1}),l(P,{class:"iconfont icon-help"})])),_:1}),l(E,{class:"flex-five dis-flex flex-x-end flex-y-center"},{default:s((()=>[l(P,{class:"points-money col-m"},{default:s((()=>[d("-¥"+u(T.order.pointsMoney),1)])),_:1}),l($,{modelValue:T.isUsePoints,"onUpdate:modelValue":x[3]||(x[3]=e=>T.isUsePoints=e),size:"48","active-color":"#07c160",onChange:x[4]||(x[4]=e=>S.getOrderData())},null,8,["modelValue"])])),_:1})])),_:1})):n("",!0),T.curDelivery==T.DeliveryTypeEnum.EXPRESS.value?(t(),o(E,{key:2,class:"dis-flex flow-all-list"},{default:s((()=>[l(P,{class:"flex-five"},{default:s((()=>[d("配送费用:")])),_:1}),l(E,{class:"flex-five t-r"},{default:s((()=>[T.order.address?(t(),o(E,{key:0},{default:s((()=>[T.order.isIntraRegion?(t(),o(P,{key:0,class:"col-m"},{default:s((()=>[d("+¥"+u(T.order.expressPrice),1)])),_:1})):(t(),o(P,{key:1},{default:s((()=>[d("不在配送范围")])),_:1}))])),_:1})):(t(),o(E,{key:1},{default:s((()=>[l(P,{class:"col-7"},{default:s((()=>[d("请先选择配送地址")])),_:1})])),_:1}))])),_:1})])),_:1})):n("",!0)])),_:1}),l(E,{class:"flow-all-money b-f m-top20"},{default:s((()=>[l(E,{class:"ipt-wrapper flow-all-list"},{default:s((()=>[l(O,{class:"input",modelValue:T.remark,"onUpdate:modelValue":x[5]||(x[5]=e=>T.remark=e),placeholder:"选填:买家留言(50字以内)"},null,8,["modelValue"])])),_:1})])),_:1}),l(E,{class:"flow-fixed-footer b-f m-top10"},{default:s((()=>[l(E,{class:"dis-flex chackout-box"},{default:s((()=>[l(E,{class:"chackout-left pl-12"},{default:s((()=>[d("实付款: "),l(P,{class:"col-m"},{default:s((()=>[d("¥"+u(T.order.orderPayPrice),1)])),_:1})])),_:1}),l(E,{class:"chackout-right",onClick:x[6]||(x[6]=e=>S.onSubmitOrder())},{default:s((()=>[l(E,{class:i(["flow-btn f-32",{disabled:T.disabled}])},{default:s((()=>[d("提交订单")])),_:1},8,["class"])])),_:1})])),_:1})])),_:1}),l(z,{modelValue:T.showPoints,"onUpdate:modelValue":x[7]||(x[7]=e=>T.showPoints=e),title:`${T.setting.points_name}说明`},{default:s((()=>[l(U,{class:"points-content","scroll-y":!0},{default:s((()=>[l(P,null,{default:s((()=>[d(u(T.setting.points_describe),1)])),_:1})])),_:1})])),_:1},8,["modelValue","title"]),l(N,{modelValue:T.showPopup,"onUpdate:modelValue":x[9]||(x[9]=e=>T.showPopup=e),mode:"bottom"},{default:s((()=>[l(E,{class:"popup__coupon"},{default:s((()=>[l(E,{class:"coupon__title f-30"},{default:s((()=>[d("选择优惠券")])),_:1}),l(E,{class:"coupon-list"},{default:s((()=>[l(U,{"scroll-y":!0,style:{height:"565rpx"}},{default:s((()=>[(t(!0),p(m,null,h(T.order.couponList,((e,a)=>(t(),o(E,{class:"coupon-item",key:a},{default:s((()=>[l(E,{class:i(["item-wrapper",[e.is_apply?"color-"+T.CouponColors[a%T.CouponColors.length]:"color-gray"]]),onClick:e=>S.handleSelectCoupon(a)},{default:s((()=>[l(E,{class:"coupon-type"},{default:s((()=>[d(u(T.CouponTypeEnum[e.coupon_type].name),1)])),_:2},1024),l(E,{class:"tip dis-flex flex-dir-column flex-x-center"},{default:s((()=>[e.coupon_type==T.CouponTypeEnum.FULL_DISCOUNT.value?(t(),o(E,{key:0},{default:s((()=>[l(P,{class:"f-30"},{default:s((()=>[d("¥")])),_:1}),l(P,{class:"money"},{default:s((()=>[d(u(e.reduce_price),1)])),_:2},1024)])),_:2},1024)):n("",!0),e.coupon_type==T.CouponTypeEnum.DISCOUNT.value?(t(),o(P,{key:1,class:"money"},{default:s((()=>[d(u(e.discount)+"折",1)])),_:2},1024)):n("",!0),l(P,{class:"pay-line"},{default:s((()=>[d("满"+u(e.min_price)+"元可用",1)])),_:2},1024)])),_:2},1024),l(E,{class:"split-line"}),l(E,{class:"content dis-flex flex-dir-column flex-x-between"},{default:s((()=>[l(E,{class:"title"},{default:s((()=>[d(u(e.name),1)])),_:2},1024),l(E,{class:"bottom dis-flex flex-y-center"},{default:s((()=>[l(E,{class:"time flex-box"},{default:s((()=>[e.start_time===e.end_time?(t(),p(m,{key:0},[d(u(e.start_time)+" 当天有效",1)],64)):(t(),p(m,{key:1},[d(u(e.start_time)+"~"+u(e.end_time),1)],64))])),_:2},1024)])),_:2},1024)])),_:2},1024)])),_:2},1032,["class","onClick"])])),_:2},1024)))),128))])),_:1})])),_:1}),l(E,{class:"coupon__do_not dis-flex flex-y-center flex-x-center"},{default:s((()=>[l(E,{class:"control dis-flex flex-y-center flex-x-center",onClick:x[8]||(x[8]=e=>S.handleNotUseCoupon())},{default:s((()=>[l(P,{class:"f-26"},{default:s((()=>[d("不使用优惠券")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1},8,["modelValue"])])),_:1})):n("",!0),l(j,{ref:"uToast"},null,512)])),_:1},8,["style"])}],["__scopeId","data-v-1c8c8100"]]);export{N as default};