pages-user-wallet-consumptionTransfers.123b037a.js 6.3 KB

1
  1. import{c as e,z as s,N as r,Z as o,o as a,t as l,f as t,g as i,w as n,s as u,m as d,k as m,x as c,E as p,b5 as f,u as b,v as g,b6 as v,V as U,a2 as y,ao as _,bN as h,a as M,aK as q,y as P,j as V,n as T,J as C,I as w}from"./index-a116b7fa.js";import{a as x,b as D,d as N}from"./phone-international-input.b9f6c8e6.js";import{a as O,_ as R}from"./s-layout.4ae51839.js";import{p as I}from"./useGoods.6b315a78.js";import{_ as $}from"./_plugin-vue_export-helper.1b428a4d.js";const k=$({__name:"consumptionTransfers",setup($){const k=e((()=>u.$store("user").userInfo)),E=e((()=>u.$store("user").userWallet)),j=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:"接收人不能为空"}]},recipientUserPhone:{rules:[{required:!0,errorMessage:"接收人手机号不能为空"}]},"smsCodeUseReqDTO.code":{rules:[{required:!0,errorMessage:"验证码不能为空"}]},consumptionPoints:{rules:[{required:!0,errorMessage:"转让金额不能为空"},{validateFunction:function(e,s,r,o){return s<=0&&o("转让金额不能小于等于0"),!0}}]}}}),B=e((()=>I(E.value.integralDO.consumptionPoints)));let F=r("");async function L(e){const s=e.detail.value;if(s==F.value)return;if(""==s)return j.verifyUsername=!0,!1;if(s===k.value.username)return j.usernameErrorMsg="接收人不能为自己",!1;F.value=s;const{data:r}=await U.verifyUsername(s);j.usernameErrorMsg=r?"用户不存在!":"",j.verifyUsername=r}async function S(e){const s=e.detail.value;if(""==s||!j.model.recipientUserName)return j.verifyMobile=!0,!1;const{data:r}=await U.verifyPhone(j.model.recipientUserName,s);r&&r.mobile===s?(j.mobileErrorMsg="",j.model.recipientUserId=r.id,j.verifyMobile=!1):(j.mobileErrorMsg="接收人用户名与手机号不匹配!",j.verifyMobile=!0)}async function W(e){const s=parseInt(e),r=e.toString(),[o,a]=r.split(".");a&&(parseFloat(`${o}.${a.slice(0,2)}`),y((()=>{j.model.consumptionPoints=o}))),s>parseInt(B.value)?y((()=>{j.model.consumptionPoints=parseInt(B.value)})):y((()=>{j.model.consumptionPoints=s}))}const z=r(null),G=async()=>{if(j.model.recipientUserName===k.value.username)return void _({title:"不能给自己转账",icon:"none",duration:2e3});if(j.verifyUsername)return;if(j.verifyMobile)return;if(!(await c(z).validate().catch((e=>{console.log("error: ",e)}))))return;const{data:e,code:s}=await h.createConsumptionLog(j.model);0===s&&(M({msg:"转账成功"}),q("consumptionTransfersComplete"),u.$router.redirect("/pages/user/wallet/score"))},J=e((()=>u.$store("user").isLogin));return o((()=>J.value),(e=>{e&&window.location.reload()}),{deep:!0}),a((async e=>{J.value||l(),j.model.smsCodeUseReqDTO.mobile=k.value.mobile})),(e,s)=>{const r=P,o=V,a=d(T("uni-easyinput"),x),l=d(T("uni-forms-item"),D),U=C,y=d(T("uni-forms"),N),_=w,h=d(T("su-fixed"),O),M=d(T("s-layout"),R);return t(),i(M,{class:"set-wrap",title:"消费分转让",bgStyle:{color:"#FFF"}},{default:n((()=>[m(y,{model:j.model,rules:j.rules,validateTrigger:"bind",labelPosition:"left",border:"",class:"form-box",labelWidth:"200",ref_key:"FormRef",ref:z},{default:n((()=>[m(o,{class:"bg-white ss-p-x-30"},{default:n((()=>[m(l,{name:"recipientUserName",label:"接收人",required:!0,"error-message":j.usernameErrorMsg},{default:n((()=>[m(a,{modelValue:j.model.recipientUserName,"onUpdate:modelValue":s[0]||(s[0]=e=>j.model.recipientUserName=e),type:"recipientUserName",placeholder:"请输入接收人用户名",inputBorder:!1,clearable:!1,onBlur:L},{right:n((()=>[j.verifyUsername?(t(),i(o,{key:0,class:"icon"},{default:n((()=>[m(r,{style:"",src:c(u).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(t(),i(o,{key:1,class:"icon"},{default:n((()=>[m(r,{src:c(u).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue"])])),_:1},8,["error-message"]),m(l,{name:"recipientUserPhone",label:"接收人手机号",required:!0,"error-message":j.mobileErrorMsg},{default:n((()=>[m(a,{modelValue:j.model.recipientUserPhone,"onUpdate:modelValue":s[1]||(s[1]=e=>j.model.recipientUserPhone=e),type:"number",placeholder:"请输入接收人手机号",inputBorder:!1,clearable:!1,onBlur:S},{right:n((()=>[j.verifyMobile?(t(),i(o,{key:0,class:"icon"},{default:n((()=>[m(r,{style:"",src:c(u).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(t(),i(o,{key:1,class:"icon"},{default:n((()=>[m(r,{src:c(u).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue"])])),_:1},8,["error-message"]),m(l,{name:"mobile",label:"手机号",class:"mobile loginUniFormItem ss-p-t-10"},{default:n((()=>[m(a,{modelValue:j.model.smsCodeUseReqDTO.mobile,"onUpdate:modelValue":s[3]||(s[3]=e=>j.model.smsCodeUseReqDTO.mobile=e),type:"smsCodeUseReqDTO",placeholder:"请输入验证码",inputBorder:!1,clearable:!1,disabled:!0},{right:n((()=>[m(U,{class:p(["ss-reset-button code-btn code-btn-start",{disabled:1==L||1==j.verifyMobile}]),disabled:1==L||1==j.verifyMobile,onClick:s[2]||(s[2]=e=>c(f)("consumptionTransfers",j.model.smsCodeUseReqDTO.mobile))},{default:n((()=>[b(g(c(v)("consumptionTransfers")),1)])),_:1},8,["disabled","class"])])),_:1},8,["modelValue"])])),_:1}),m(l,{name:"smsCodeUseReqDTO.code",label:"验证码",required:!0},{default:n((()=>[m(a,{modelValue:j.model.smsCodeUseReqDTO.code,"onUpdate:modelValue":s[4]||(s[4]=e=>j.model.smsCodeUseReqDTO.code=e),type:"number",placeholder:"请输入验证码",inputBorder:!1,clearable:!1},null,8,["modelValue"])])),_:1}),m(l,{name:"consumptionPoints",label:"转让金额",required:!0},{default:n((()=>[m(a,{modelValue:j.model.consumptionPoints,"onUpdate:modelValue":s[5]||(s[5]=e=>j.model.consumptionPoints=e),type:"number",placeholder:"请输入转让金额",inputBorder:!1,clearable:!1,onInput:W},null,8,["modelValue"])])),_:1})])),_:1})])),_:1},8,["model","rules"]),m(o,{class:"ss-flex ss-row-center ss-col-center ss-m-t-30"},{default:n((()=>[b(" 您当前可转让的金额:"),m(_,{class:"text-red"},{default:n((()=>[b(g(B.value),1)])),_:1})])),_:1}),m(h,{bottom:"",placeholder:"",bg:"none"},{default:n((()=>[m(o,{class:"footer-box ss-p-20 ss-flex"},{default:n((()=>[m(U,{class:"ss-rest-button btn",onClick:G},{default:n((()=>[b("确定")])),_:1})])),_:1})])),_:1})])),_:1})}}},[["__scopeId","data-v-d05809b7"]]);export{k as default};