Files
AIGC/demo/deploy_baota/frontend/static/OrderCreate-33839111.js
2025-11-13 17:01:39 +08:00

2 lines
8.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{aA as G,r as k,l as z,c as S,al as n,z as V,A as b,R as e,J as o,u as U,O as q,W as H,B as r,Q as T,M as w,a4 as J,P as F,I as Q}from"./vue-vendor-164775a6.js";import{u as W}from"./orders-61e4e2f1.js";import{E as v,k as j,l as K,p as X}from"./element-plus-4a19e5e8.js";import{_ as Z}from"./index-2fb4354b.js";import"./orders-13d1cb00.js";import"./utils-edfcd65b.js";const ee={class:"order-create"},le={class:"field-description"},te={class:"field-description"},oe={class:"field-description"},ae={class:"field-description"},re={class:"field-description"},ne={class:"field-description"},se={class:"order-items"},de={class:"total-amount"},ue={class:"total-value"},ie={__name:"OrderCreate",setup(pe){const R=G(),x=W(),I=k(),A=k(!1),t=z({orderType:"SERVICE",currency:"CNY",description:"",contactEmail:"",contactPhone:"",shippingAddress:"",billingAddress:"",orderItems:[{productName:"",unitPrice:0,quantity:1,subtotal:0}]}),O={orderType:[{required:!0,message:"请选择订单类型",trigger:"change"}],currency:[{required:!0,message:"请选择货币",trigger:"change"}],contactEmail:[{required:!0,message:"请输入联系邮箱",trigger:"blur"},{type:"email",message:"请输入正确的邮箱格式",trigger:"blur"}]},B=S(()=>t.orderType==="PHYSICAL"),h=S(()=>t.orderItems.reduce((d,l)=>d+parseFloat(l.subtotal||0),0).toFixed(2)),C=d=>{const l=t.orderItems[d];l.unitPrice&&l.quantity?l.subtotal=parseFloat((l.unitPrice*l.quantity).toFixed(2)):l.subtotal=0},D=()=>{t.orderItems.push({productName:"",unitPrice:0,quantity:1,subtotal:0})},$=d=>{t.orderItems.length>1&&t.orderItems.splice(d,1)},P=async()=>{if(I.value)try{if(!await I.value.validate())return;const l=t.orderItems.filter(u=>u.productName&&u.unitPrice>0&&u.quantity>0);if(l.length===0){v.error("请至少添加一个有效虚拟商品");return}A.value=!0;const i={orderType:t.orderType,currency:t.currency,description:t.description,contactEmail:t.contactEmail,contactPhone:t.contactPhone,shippingAddress:t.shippingAddress,billingAddress:t.billingAddress,totalAmount:parseFloat(h.value),status:"PENDING",orderItems:l.map(u=>({productName:u.productName,unitPrice:parseFloat(u.unitPrice),quantity:parseInt(u.quantity),subtotal:parseFloat(u.subtotal)}))},_=await x.createNewOrder(i);_.success?(v.success("虚拟商品订单创建成功!商品将发送到您的邮箱"),R.push("/orders")):v.error(_.message||"创建订单失败")}catch(d){console.error("Create order error:",d),v.error("创建订单失败")}finally{A.value=!1}};return(d,l)=>{const i=n("el-icon"),_=n("el-button"),u=n("el-page-header"),c=n("el-option"),N=n("el-select"),f=n("InfoFilled"),p=n("el-form-item"),m=n("el-input"),y=n("el-col"),E=n("el-input-number"),L=n("el-row"),Y=n("el-form"),M=n("el-card");return V(),b("div",ee,[e(u,{onBack:l[0]||(l[0]=a=>d.$router.go(-1)),content:"创建订单"},{extra:o(()=>[e(_,{type:"primary",onClick:P,loading:A.value},{default:o(()=>[e(i,null,{default:o(()=>[e(U(j))]),_:1}),l[8]||(l[8]=q(" 创建订单 ",-1))]),_:1},8,["loading"])]),_:1}),e(M,{class:"form-card"},{default:o(()=>[e(Y,{ref_key:"formRef",ref:I,model:t,rules:O,"label-width":"100px",onSubmit:H(P,["prevent"])},{default:o(()=>[e(p,{label:"订单类型",prop:"orderType"},{default:o(()=>[e(N,{modelValue:t.orderType,"onUpdate:modelValue":l[1]||(l[1]=a=>t.orderType=a),placeholder:"请选择订单类型"},{default:o(()=>[e(c,{label:"AI服务",value:"SERVICE"}),e(c,{label:"AI订阅",value:"SUBSCRIPTION"}),e(c,{label:"数字商品",value:"DIGITAL"}),e(c,{label:"虚拟商品",value:"VIRTUAL"})]),_:1},8,["modelValue"]),r("div",le,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[9]||(l[9]=r("span",null,"选择您要购买的虚拟商品类型AI服务如AI绘画、AI写作、AI订阅按月/年付费)、数字商品(如软件、电子书)、虚拟商品(如游戏道具、虚拟货币)",-1))])]),_:1}),e(p,{label:"货币",prop:"currency"},{default:o(()=>[e(N,{modelValue:t.currency,"onUpdate:modelValue":l[2]||(l[2]=a=>t.currency=a),placeholder:"请选择货币"},{default:o(()=>[e(c,{label:"人民币 (CNY)",value:"CNY"}),e(c,{label:"美元 (USD)",value:"USD"}),e(c,{label:"欧元 (EUR)",value:"EUR"})]),_:1},8,["modelValue"]),r("div",te,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[10]||(l[10]=r("span",null,"选择支付货币类型,系统会根据您选择的货币进行计费和结算",-1))])]),_:1}),e(p,{label:"订单描述",prop:"description"},{default:o(()=>[e(m,{modelValue:t.description,"onUpdate:modelValue":l[3]||(l[3]=a=>t.description=a),type:"textarea",rows:3,placeholder:"请详细描述您的订单需求需要AI绘画服务风格为动漫风格尺寸为1024x1024像素"},null,8,["modelValue"]),r("div",oe,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[11]||(l[11]=r("span",null,"详细描述您的订单需求,包括服务要求、特殊需求等,这将帮助服务提供方更好地理解您的需求",-1))])]),_:1}),e(p,{label:"联系邮箱",prop:"contactEmail"},{default:o(()=>[e(m,{modelValue:t.contactEmail,"onUpdate:modelValue":l[4]||(l[4]=a=>t.contactEmail=a),type:"email",placeholder:"请输入联系邮箱(用于接收虚拟商品)"},null,8,["modelValue"]),r("div",ae,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[12]||(l[12]=r("span",null,"必填项!虚拟商品将通过此邮箱发送给您,请确保邮箱地址正确且可正常接收邮件",-1))])]),_:1}),e(p,{label:"联系电话",prop:"contactPhone"},{default:o(()=>[e(m,{modelValue:t.contactPhone,"onUpdate:modelValue":l[5]||(l[5]=a=>t.contactPhone=a),placeholder:"请输入联系电话(可选)"},null,8,["modelValue"]),r("div",re,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[13]||(l[13]=r("span",null,"可选填写,用于紧急情况联系或重要通知,建议填写以便服务提供方在需要时联系您",-1))])]),_:1}),B.value?(V(),b(T,{key:0},[e(p,{label:"收货地址",prop:"shippingAddress"},{default:o(()=>[e(m,{modelValue:t.shippingAddress,"onUpdate:modelValue":l[6]||(l[6]=a=>t.shippingAddress=a),type:"textarea",rows:3,placeholder:"请输入收货地址"},null,8,["modelValue"])]),_:1}),e(p,{label:"账单地址",prop:"billingAddress"},{default:o(()=>[e(m,{modelValue:t.billingAddress,"onUpdate:modelValue":l[7]||(l[7]=a=>t.billingAddress=a),type:"textarea",rows:3,placeholder:"请输入账单地址"},null,8,["modelValue"])]),_:1})],64)):w("",!0),e(p,{label:"虚拟商品"},{default:o(()=>[r("div",ne,[e(i,null,{default:o(()=>[e(f)]),_:1}),l[14]||(l[14]=r("span",null,"添加您要购买的虚拟商品,包括商品名称、单价和数量。支持添加多个商品。",-1))]),r("div",se,[(V(!0),b(T,null,J(t.orderItems,(a,g)=>(V(),b("div",{key:g,class:"order-item"},[e(L,{gutter:20},{default:o(()=>[e(y,{span:8},{default:o(()=>[e(m,{modelValue:a.productName,"onUpdate:modelValue":s=>a.productName=s,placeholder:"商品名称AI绘画服务、AI写作助手、AI翻译服务等",onInput:s=>C(g)},null,8,["modelValue","onUpdate:modelValue","onInput"])]),_:2},1024),e(y,{span:4},{default:o(()=>[e(E,{modelValue:a.unitPrice,"onUpdate:modelValue":s=>a.unitPrice=s,precision:2,min:0,placeholder:"单价",onChange:s=>C(g)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1024),e(y,{span:4},{default:o(()=>[e(E,{modelValue:a.quantity,"onUpdate:modelValue":s=>a.quantity=s,min:1,placeholder:"数量",onChange:s=>C(g)},null,8,["modelValue","onUpdate:modelValue","onChange"])]),_:2},1024),e(y,{span:4},{default:o(()=>[e(m,{modelValue:a.subtotal,"onUpdate:modelValue":s=>a.subtotal=s,readonly:"",placeholder:"小计"},null,8,["modelValue","onUpdate:modelValue"])]),_:2},1024),e(y,{span:4},{default:o(()=>[t.orderItems.length>1?(V(),Q(_,{key:0,type:"danger",icon:U(K),circle:"",onClick:s=>$(g)},null,8,["icon","onClick"])):w("",!0)]),_:2},1024)]),_:2},1024)]))),128)),e(_,{type:"primary",icon:U(X),onClick:D,class:"add-item-btn"},{default:o(()=>[...l[15]||(l[15]=[q(" 添加虚拟商品 ",-1)])]),_:1},8,["icon"])])]),_:1}),e(p,null,{default:o(()=>[r("div",de,[l[16]||(l[16]=r("span",{class:"total-label"},"订单总计:",-1)),r("span",ue,F(t.currency)+" "+F(h.value),1)])]),_:1})]),_:1},8,["model"])]),_:1})])}}},Ve=Z(ie,[["__scopeId","data-v-fa6e356e"]]);export{Ve as default};