pages-user-wallet-consumptionTransfers.BwLbNLXc.js 7.0 KB

1
  1. import{c as e,v as a,t as r,r as l,a2 as s,o as t,I as o,a as n,b as i,d as u,w as c,u as m,s as d,e as p,f as _,x as f,y as g,F as y,z as v,g as b,j as h,Y as w,a5 as U,at as x,ao as M,l as P,au as k,k as T,i as j,O as $,bU as q,bi as N,P as E,Q as I}from"./index-CRW3onsz.js";import{a as V,_ as C,b as F}from"./phone-international-input.vKvR7wTz.js";import{a as B,_ as O}from"./s-layout.DKC65HXL.js";import{p as D}from"./useGoods.Dxoq0xk-.js";import"./phone-international-input.vue_vue_type_style_index_0_scoped_0f0268ff_lang.Dctrwx6t.js";import{_ as Q}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./uni-icons.CkO1HN9g.js";import"./s-menu-tools.CNNsOrh3.js";import"./s-search-block.vue_vue_type_style_index_0_scoped_f692e81a_lang.CiL8L9B_.js";import"./s-layout.vue_vue_type_style_index_0_scoped_c1143e8c_lang.HuwOimZj.js";import"./s-search-block.9OtJrST_.js";const z=Q({__name:"consumptionTransfers",setup(Q){const z=e((()=>d.$store("user").userInfo)),G=e((()=>d.$store("user").userWallet)),L=a({verifyUsername:!0,verifyMobile:!0,usernameErrorMsg:"",mobileErrorMsg:"",model:{recipientUserName:void 0,recipientUserId:void 0,recipientUserPhone:void 0,consumptionPoints:void 0,integralType:1},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,a,l,s){return a<=0&&s(r("wallet.transfer_amount_less_than_zero")),!0}}]}}}),R=e((()=>1==L.model.integralType?D(G.value.integralDO.redCurrentQuota):2==L.model.integralType?D(G.value.integralDO.yellowCurrentQuota):3==L.model.integralType?D(G.value.integralDO.greenCurrentQuota):0));let S=l("");async function W(e){const a=e.detail.value;if(a==S.value)return;if(""==a)return L.verifyUsername=!0,!1;if(a===z.value.username)return L.usernameErrorMsg=r("wallet.recipient_cannot_be_self"),!1;S.value=a;const{data:l}=await w.verifyUsername(a);L.usernameErrorMsg=l?r("wallet.user_does_not_exist"):"",L.verifyUsername=l}async function J(e){const a=e.detail.value;if(""==a||!L.model.recipientUserName)return L.verifyMobile=!0,!1;const{data:l}=await w.verifyPhone(L.model.recipientUserName,a);l&&l.mobile===a?(L.mobileErrorMsg="",L.model.recipientUserId=l.id,L.verifyMobile=!1):(L.mobileErrorMsg=r("wallet.username_phone_mismatch"),L.verifyMobile=!0)}async function Y(e){const a=parseInt(e),r=e.toString(),[l,s]=r.split(".");s&&(parseFloat(`${l}.${s.slice(0,2)}`),U((()=>{L.model.consumptionPoints=l}))),a>parseInt(R.value)?U((()=>{L.model.consumptionPoints=parseInt(R.value)})):U((()=>{L.model.consumptionPoints=a}))}const A=l(null),H=async()=>{if(L.model.recipientUserName===z.value.username)return void x({title:r("wallet.cannot_transfer_to_self"),icon:"none",duration:2e3});if(L.verifyUsername)return;if(L.verifyMobile)return;await m(A).validate().catch((e=>{console.log("error: ",e)}))&&M((async e=>{L.model.payPassword=e;const{data:a,code:l}=await q.createConsumptionLog(L.model);0===l&&(d.$helper.toast(r("wallet.transfer_successful")),N("consumptionTransfersComplete"),d.$router.redirect("/pages/user/wallet/score"))}))},K=e((()=>d.$store("user").isLogin));return s((()=>K.value),(e=>{e&&window.location.reload()}),{deep:!0}),t((async e=>{K.value||o()})),(e,a)=>{const l=E,s=P,t=I,o=k,w=n(i("uni-forms-item"),V),U=T,x=j,M=n(i("uni-easyinput"),C),q=n(i("uni-forms"),F),N=$,D=n(i("su-fixed"),B),Q=n(i("s-layout"),O);return p(),u(Q,{class:"set-wrap",title:m(r)("wallet.积分转让"),bgStyle:{color:"#FFF"}},{default:c((()=>[_(q,{model:L.model,rules:L.rules,validateTrigger:"bind",labelPosition:"left",border:"",class:"form-box",labelWidth:"200",ref_key:"FormRef",ref:A},{default:c((()=>[_(x,{class:"bg-white ss-p-x-30"},{default:c((()=>[_(w,{name:"integralType",label:m(r)("wallet.转让积分类型"),required:!0},{default:c((()=>[_(o,{onChange:a[0]||(a[0]=e=>L.model.integralType=Number(e.detail.value))},{default:c((()=>[(p(!0),f(y,null,g([{value:1,text:m(r)("wallet.红积分")},{value:2,text:m(r)("wallet.黄积分")},{value:3,text:m(r)("wallet.绿积分")}],(e=>(p(),u(t,{key:e.value,class:"ss-m-r-20"},{default:c((()=>[_(l,{value:e.value,color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},checked:L.model.integralType===e.value},null,8,["value","checked"]),_(s,{class:"ss-m-l-10"},{default:c((()=>[b(h(e.text),1)])),_:2},1024)])),_:2},1024)))),128))])),_:1})])),_:1},8,["label"]),L.model.integralType?(p(),f(y,{key:0},[_(w,{name:"recipientUserName",label:m(r)("wallet.recipient"),required:!0,"error-message":L.usernameErrorMsg},{default:c((()=>[_(M,{modelValue:L.model.recipientUserName,"onUpdate:modelValue":a[1]||(a[1]=e=>L.model.recipientUserName=e),type:"recipientUserName",placeholder:m(r)("wallet.enter_recipient_username"),inputBorder:!1,clearable:!1,onBlur:W},{right:c((()=>[L.verifyUsername?(p(),u(x,{key:0,class:"icon"},{default:c((()=>[_(U,{style:"",src:m(d).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(p(),u(x,{key:1,class:"icon"},{default:c((()=>[_(U,{src:m(d).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue","placeholder"])])),_:1},8,["label","error-message"]),_(w,{name:"recipientUserPhone",label:m(r)("wallet.recipient_phone"),required:!0,"error-message":L.mobileErrorMsg},{default:c((()=>[_(M,{modelValue:L.model.recipientUserPhone,"onUpdate:modelValue":a[2]||(a[2]=e=>L.model.recipientUserPhone=e),type:"number",placeholder:m(r)("wallet.enter_recipient_phone"),inputBorder:!1,clearable:!1,onBlur:J},{right:c((()=>[L.verifyMobile?(p(),u(x,{key:0,class:"icon"},{default:c((()=>[_(U,{style:"",src:m(d).$url.static("/static/images/shibai.png")},null,8,["src"])])),_:1})):(p(),u(x,{key:1,class:"icon"},{default:c((()=>[_(U,{src:m(d).$url.static("/static/images/chenggong.png")},null,8,["src"])])),_:1}))])),_:1},8,["modelValue","placeholder"])])),_:1},8,["label","error-message"]),_(w,{name:"consumptionPoints",label:m(r)("wallet.transfer_amount"),required:!0},{default:c((()=>[_(M,{modelValue:L.model.consumptionPoints,"onUpdate:modelValue":a[3]||(a[3]=e=>L.model.consumptionPoints=e),type:"number",placeholder:m(r)("wallet.enter_transfer_amount"),inputBorder:!1,clearable:!1,onInput:Y},null,8,["modelValue","placeholder"])])),_:1},8,["label"])],64)):v("",!0)])),_:1})])),_:1},8,["model","rules"]),_(x,{class:"ss-flex ss-row-center ss-col-center ss-m-t-30"},{default:c((()=>[L.model.integralType?(p(),f(y,{key:0},[b(h(m(r)("wallet.current_transferable_amount")),1),_(s,{class:"text-red"},{default:c((()=>[b(h(R.value),1)])),_:1})],64)):v("",!0)])),_:1}),L.model.integralType?(p(),u(D,{key:0,bottom:"",placeholder:"",bg:"none"},{default:c((()=>[_(x,{class:"footer-box ss-p-20 ss-flex"},{default:c((()=>[_(N,{class:"ss-rest-button btn",onClick:H},{default:c((()=>[b(h(m(r)("common.confirm")),1)])),_:1})])),_:1})])),_:1})):v("",!0)])),_:1},8,["title"])}}},[["__scopeId","data-v-ffea2de7"]]);export{z as default};