1 |
- import{c as e,v as s,t as r,r as a,a0 as o,o as l,G as t,a as n,b as i,d as u,w as c,u as m,s as d,e as p,f as _,J as f,bc as b,g,j as v,bd as y,W as h,a3 as U,aq as w,bP as M,B as q,be as P,k as C,i as T,M as V,l as x}from"./index-DUAp9XEj.js";import{_ as O,a as D,b as R}from"./phone-international-input.D4fi9eUK.js";import{a as j,_ as I}from"./s-layout.a1_kfpIW.js";import{p as N}from"./useGoods.Cwnq-veC.js";import"./phone-international-input.vue_vue_type_style_index_0_scoped_a793e264_lang.Bv2EixP5.js";import{_ as $}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./s-menu-tools.Bn3wdRty.js";import"./s-layout.vue_vue_type_style_index_0_scoped_d5f7c468_lang.CKkHKX6k.js";import"./s-tabbar.fodLOlFD.js";const k=$({__name:"consumptionTransfers",setup($){const k=e((()=>d.$store("user").userInfo)),B=e((()=>d.$store("user").userWallet)),E=s({verifyUsername:!0,verifyMobile:!0,usernameErrorMsg:"",mobileErrorMsg:"",model:{recipientUserName:void 0,recipientUserId:void 0,recipientUserPhone:void 0,consumptionPoints:void 0,smsCodeUseReqDTO:{mobile:void 0,scene:11,code:void 0}},rules:{recipientUserName:{rules:[{required:!0,errorMessage:r("wallet.recipient_cannot_be_empty")}]},recipientUserPhone:{rules:[{required:!0,errorMessage:r("wallet.recipient_phone_cannot_be_empty")}]},"smsCodeUseReqDTO.code":{rules:[{required:!0,errorMessage:r("wallet.verification_code_cannot_be_empty")}]},consumptionPoints:{rules:[{required:!0,errorMessage:r("wallet.transfer_amount_cannot_be_empty")},{validateFunction:function(e,s,a,o){return s<=0&&o(r("wallet.transfer_amount_less_than_zero")),!0}}]}}}),F=e((()=>N(B.value.integralDO.consumptionPoints)));let W=a("");async function G(e){const s=e.detail.value;if(s==W.value)return;if(""==s)return E.verifyUsername=!0,!1;if(s===k.value.username)return E.usernameErrorMsg=r("wallet.recipient_cannot_be_self"),!1;W.value=s;const{data:a}=await h.verifyUsername(s);E.usernameErrorMsg=a?r("wallet.user_does_not_exist"):"",E.verifyUsername=a}async function L(e){const s=e.detail.value;if(""==s||!E.model.recipientUserName)return E.verifyMobile=!0,!1;const{data:a}=await h.verifyPhone(E.model.recipientUserName,s);a&&a.mobile===s?(E.mobileErrorMsg="",E.model.recipientUserId=a.id,E.verifyMobile=!1):(E.mobileErrorMsg=r("wallet.username_phone_mismatch"),E.verifyMobile=!0)}async function S(e){const s=parseInt(e),r=e.toString(),[a,o]=r.split(".");o&&(parseFloat(`${a}.${o.slice(0,2)}`),U((()=>{E.model.consumptionPoints=a}))),s>parseInt(F.value)?U((()=>{E.model.consumptionPoints=parseInt(F.value)})):U((()=>{E.model.consumptionPoints=s}))}const z=a(null),J=async()=>{if(E.model.recipientUserName===k.value.username)return void w({title:r("wallet.cannot_transfer_to_self"),icon:"none",duration:2e3});if(E.verifyUsername)return;if(E.verifyMobile)return;if(!(await m(z).validate().catch((e=>{console.log("error: ",e)}))))return;const{data:e,code:s}=await M.createConsumptionLog(E.model);0===s&&(q({msg:r("wallet.transfer_successful")}),P("consumptionTransfersComplete"),d.$router.redirect("/pages/user/wallet/score"))},A=e((()=>d.$store("user").isLogin));return o((()=>A.value),(e=>{e&&window.location.reload()}),{deep:!0}),l((async e=>{A.value||t(),E.model.smsCodeUseReqDTO.mobile=k.value.mobile})),(e,s)=>{const a=C,o=T,l=n(i("uni-easyinput"),O),t=n(i("uni-forms-item"),D),h=V,U=n(i("uni-forms"),R),w=x,M=n(i("su-fixed"),j),q=n(i("s-layout"),I);return p(),u(q,{class:"set-wrap",title:m(r)("wallet.points_transfer"),bgStyle:{color:"#FFF"}},{default:c((()=>[_(U,{model:E.model,rules:E.rules,validateTrigger:"bind",labelPosition:"left",border:"",class:"form-box",labelWidth:"200",ref_key:"FormRef",ref:z},{default:c((()=>[_(o,{class:"bg-white ss-p-x-30"},{default:c((()=>[_(t,{name:"recipientUserName",label:m(r)("wallet.recipient"),required:!0,"error-message":E.usernameErrorMsg},{default:c((()=>[_(l,{modelValue:E.model.recipientUserName,"onUpdate:modelValue":s[0]||(s[0]=e=>E.model.recipientUserName=e),type:"recipientUserName",placeholder:m(r)("wallet.enter_recipient_username"),inputBorder:!1,clearable:!1,onBlur:G},{right:c((()=>[E.verifyUsername?(p(),u(o,{key:0,class:"icon"},{default:c((()=>[_(a,{style:"",src:m(d).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(p(),u(o,{key:1,class:"icon"},{default:c((()=>[_(a,{src:m(d).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue","placeholder"])])),_:1},8,["label","error-message"]),_(t,{name:"recipientUserPhone",label:m(r)("wallet.recipient_phone"),required:!0,"error-message":E.mobileErrorMsg},{default:c((()=>[_(l,{modelValue:E.model.recipientUserPhone,"onUpdate:modelValue":s[1]||(s[1]=e=>E.model.recipientUserPhone=e),type:"number",placeholder:m(r)("wallet.enter_recipient_phone"),inputBorder:!1,clearable:!1,onBlur:L},{right:c((()=>[E.verifyMobile?(p(),u(o,{key:0,class:"icon"},{default:c((()=>[_(a,{style:"",src:m(d).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(p(),u(o,{key:1,class:"icon"},{default:c((()=>[_(a,{src:m(d).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue","placeholder"])])),_:1},8,["label","error-message"]),_(t,{name:"mobile",label:m(r)("account.phone_number"),class:"mobile loginUniFormItem ss-p-t-10"},{default:c((()=>[_(l,{modelValue:E.model.smsCodeUseReqDTO.mobile,"onUpdate:modelValue":s[3]||(s[3]=e=>E.model.smsCodeUseReqDTO.mobile=e),type:"smsCodeUseReqDTO",placeholder:m(r)("account.enter_phone_number"),inputBorder:!1,clearable:!1,disabled:!0},{right:c((()=>[_(h,{class:f(["ss-reset-button code-btn code-btn-start",{disabled:1==G||1==E.verifyMobile}]),disabled:1==G||1==E.verifyMobile,onClick:s[2]||(s[2]=e=>m(b)("consumptionTransfers",E.model.smsCodeUseReqDTO.mobile))},{default:c((()=>[g(v(m(y)("consumptionTransfers")),1)])),_:1},8,["disabled","class"])])),_:1},8,["modelValue","placeholder"])])),_:1},8,["label"]),_(t,{name:"smsCodeUseReqDTO.code",label:m(r)("account.verification_code"),required:!0},{default:c((()=>[_(l,{modelValue:E.model.smsCodeUseReqDTO.code,"onUpdate:modelValue":s[4]||(s[4]=e=>E.model.smsCodeUseReqDTO.code=e),type:"number",placeholder:m(r)("account.enter_verification_code"),inputBorder:!1,clearable:!1},null,8,["modelValue","placeholder"])])),_:1},8,["label"]),_(t,{name:"consumptionPoints",label:m(r)("wallet.transfer_amount"),required:!0},{default:c((()=>[_(l,{modelValue:E.model.consumptionPoints,"onUpdate:modelValue":s[5]||(s[5]=e=>E.model.consumptionPoints=e),type:"number",placeholder:m(r)("wallet.enter_transfer_amount"),inputBorder:!1,clearable:!1,onInput:S},null,8,["modelValue","placeholder"])])),_:1},8,["label"])])),_:1})])),_:1},8,["model","rules"]),_(o,{class:"ss-flex ss-row-center ss-col-center ss-m-t-30"},{default:c((()=>[g(v(m(r)("wallet.current_transferable_amount")),1),_(w,{class:"text-red"},{default:c((()=>[g(v(F.value),1)])),_:1})])),_:1}),_(M,{bottom:"",placeholder:"",bg:"none"},{default:c((()=>[_(o,{class:"footer-box ss-p-20 ss-flex"},{default:c((()=>[_(h,{class:"ss-rest-button btn",onClick:J},{default:c((()=>[g(v(m(r)("common.confirm")),1)])),_:1})])),_:1})])),_:1})])),_:1},8,["title"])}}},[["__scopeId","data-v-f840a590"]]);export{k as default};
|