transfer.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <cwg-header :title="t('Documentary.TundManagement.item2')" />
  4. <uni-loading v-if="loading" />
  5. <view id="custom_WalletTransfer" class="transfer-page" v-else>
  6. <view class="main-content">
  7. <view class="box box-step2">
  8. <view class="b-card">
  9. <view class="card-top">
  10. <uni-forms ref="formRef" :model="form" :rules="rules" label-position="top"
  11. validate-trigger="submit">
  12. <view class="card-row card-tit">
  13. <view class="title-wrapper">
  14. <view class="tit">
  15. <text class="iconfont icon-caret-right"></text>
  16. <span>{{ t('wallet.item63') }}</span>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="card-row">
  21. <uni-forms-item name="walletbalance">
  22. <uni-easyinput v-model="walletbalanceDisplay" disabled class="disabled-input" />
  23. </uni-forms-item>
  24. </view>
  25. <view class="card-row card-tit">
  26. <view class="title-wrapper">
  27. <view class="tit">
  28. <text class="iconfont icon-caret-right"></text>
  29. <span>{{ t('Custom.Transfer.IntoAccount') }}</span>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="card-row">
  34. <uni-forms-item name="login">
  35. <cwg-combox v-model:value="form.login" :clearable="false"
  36. :options="toOptionsDisplay" :placeholder="t('placeholder.choose')" />
  37. </uni-forms-item>
  38. </view>
  39. <view class="card-row card-tit">
  40. <view class="title-wrapper">
  41. <view class="tit">
  42. <text class="iconfont icon-caret-right"></text>
  43. <span>{{ t('Label.Amount') }}</span>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="card-row amount-box">
  48. <uni-forms-item name="amount" :error-message="amountErrorMessage"
  49. class="amount-input">
  50. <uni-easyinput v-model="form.amount" :placeholder="t('placeholder.input')"
  51. @blur="validateAmount" />
  52. </uni-forms-item>
  53. <view class="btn" v-t="'State.All'" @click="setAllAmount"></view>
  54. </view>
  55. <view class="form-row">
  56. <button class="s-btn reselect" type="primary" @click="toTransfer">{{ t('Btn.Submit')
  57. }}</button>
  58. </view>
  59. </uni-forms>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 失败弹窗 -->
  65. <cwg-error-popup v-model:visible="dialogError" @confirm="closeDia" :responseMessage="RES" />
  66. <!-- 成功弹窗 -->
  67. <cwg-success-popup v-model:visible="dialogSuccess" @confirm="closeDia" />
  68. <!-- 等待弹窗 -->
  69. <cwg-wait-popup v-model:visible="dialogCheckWait" type="center" :mask-click="false" :showFooters="false" />
  70. </view>
  71. </cwg-page-wrapper>
  72. </template>
  73. <script setup lang="ts">
  74. import { ref, reactive, computed, onMounted } from 'vue'
  75. import { useI18n } from 'vue-i18n'
  76. import { customApi } from '@/service/custom'
  77. import { documentaryApi } from '@/service/documentary'
  78. import Config from '@/config/index'
  79. const { Code } = Config
  80. const { t } = useI18n()
  81. const loading = ref(false)
  82. const flag = ref(false)
  83. const RES = ref('')
  84. const walletbalance = ref('0')
  85. const toOptions = ref([])
  86. const form = reactive({
  87. currency: 'USD',
  88. login: null,
  89. amount: ''
  90. })
  91. const currencyOptions = [{ text: 'USD', value: 'USD' }]
  92. const walletbalanceDisplay = computed(() => `$ ${walletbalance.value}`)
  93. const groupTypeName = (type) => {
  94. if (type == '1') return t("AccountType.ClassicAccount")
  95. if (type == '2') return t("AccountType.SeniorAccount")
  96. if (type == '5') return t("AccountType.SpeedAccount")
  97. if (type == '6') return t("AccountType.SpeedAccount")
  98. if (type == '7') return t("AccountType.StandardAccount")
  99. if (type == '8') return t("AccountType.CentAccount")
  100. return ''
  101. }
  102. // 单位类型
  103. function groupCurrency(type) {
  104. const map = { GBP: ': £', USD: ': $', EUR: ': €', USC: ': ¢' }
  105. return map[type] || ': $'
  106. }
  107. const toOptionsDisplay = computed(() => {
  108. return toOptions.value.map(item => ({
  109. text: `${item.login} - ${groupTypeName(item.type)} - ${t('Custom.Deposit.AvailableBalance')}${groupCurrency(item.currency)}${item.balance}`,
  110. value: item.login
  111. }))
  112. })
  113. const dialogCheck = ref(false)
  114. const dialogVisible = ref(false)
  115. const dialogCheckWait = ref(false)
  116. const dialogSuccess = computed(() => dialogCheck.value && dialogVisible.value)
  117. const dialogError = computed(() => dialogCheck.value && !dialogVisible.value)
  118. const rules = {
  119. login: {
  120. rules: [{ required: true, errorMessage: t('vaildate.select.empty') }]
  121. },
  122. currency: {
  123. rules: [{ required: true, errorMessage: t('vaildate.select.empty') }]
  124. },
  125. amount: {
  126. rules: [
  127. { required: true, errorMessage: t('vaildate.amount.format') },
  128. {
  129. validateFunction: (rule, value, data, callback) => {
  130. if (!value) {
  131. callback(t('vaildate.amount.format'))
  132. } else if (!/^[0-9]+([.]{1}[0-9]{1,2})?$/.test(value)) {
  133. callback(t('vaildate.amount.format'))
  134. }
  135. return true
  136. }
  137. }
  138. ]
  139. }
  140. }
  141. const amountErrorMessage = ref('')
  142. const setAllAmount = () => {
  143. form.amount = walletbalance.value.toFixed(2)
  144. validateAmount()
  145. }
  146. function validateAmount() {
  147. const value = form.amount
  148. if (!value) {
  149. amountErrorMessage.value = t('vaildate.amount.format')
  150. return false
  151. } else if (!/^[0-9]+([.]{1}[0-9]{1,2})?$/.test(value)) {
  152. amountErrorMessage.value = t('vaildate.amount.format')
  153. }
  154. amountErrorMessage.value = ''
  155. return true
  156. }
  157. const formRef = ref(null)
  158. const closeDia = () => {
  159. if (formRef.value) {
  160. form.amount = ''
  161. form.login = null
  162. amountErrorMessage.value = ''
  163. formRef.value.clearValidate()
  164. }
  165. dialogCheck.value = false
  166. dialogVisible.value = false
  167. }
  168. const toTransfer = async () => {
  169. try {
  170. await formRef.value.validate()
  171. if (walletbalance.value == '0' || Number(walletbalance.value) < Number(form.amount)) {
  172. uni.showToast({ title: t('wallet.item64'), icon: 'none' })
  173. return
  174. }
  175. if (flag.value) return
  176. flag.value = true
  177. dialogCheckWait.value = true
  178. let res = await documentaryApi.followTransferApply({
  179. transferType: 2,
  180. ...form
  181. })
  182. if (res.code == Code.StatusOK) {
  183. dialogCheck.value = true
  184. dialogVisible.value = true
  185. flag.value = false
  186. getWalletList() // refresh balance after success
  187. uni.$emit('updatePayment')
  188. } else {
  189. RES.value = res.msg
  190. dialogCheck.value = true
  191. dialogVisible.value = false
  192. flag.value = false
  193. }
  194. dialogCheckWait.value = false
  195. } catch (e) {
  196. if (e.code == 400) {
  197. dialogCheckWait.value = false
  198. RES.value = e.msg
  199. dialogCheck.value = true
  200. dialogVisible.value = false
  201. flag.value = false
  202. }
  203. }
  204. }
  205. const getToDateList = async () => {
  206. loading.value = true
  207. try {
  208. let res = await documentaryApi.CustomDropdown({})
  209. if (res.code == Code.StatusOK) {
  210. toOptions.value = res.data || []
  211. } else {
  212. uni.showToast({ title: res.msg, icon: 'none' })
  213. }
  214. } catch (e) {
  215. console.log(e)
  216. }
  217. loading.value = false
  218. }
  219. const getWalletList = async () => {
  220. try {
  221. let res = await documentaryApi.followWalletSingle({})
  222. if (res.code == Code.StatusOK) {
  223. walletbalance.value = res.data != null ? res.data.walletAmount : '0'
  224. } else {
  225. uni.showToast({ title: res.msg, icon: 'none' })
  226. }
  227. } catch (e) {
  228. console.log(e)
  229. }
  230. }
  231. onMounted(() => {
  232. getToDateList()
  233. getWalletList()
  234. })
  235. </script>
  236. <style scoped lang="scss">
  237. @import "@/uni.scss";
  238. .transfer-page {
  239. width: 100%;
  240. padding-bottom: px2rpx(20);
  241. .main-content {
  242. text-align: left;
  243. .box {
  244. padding-top: px2rpx(5);
  245. color: #303133;
  246. .b-card {
  247. border: 1px solid var(--bs-border-color);
  248. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  249. margin-bottom: px2rpx(10);
  250. border-radius: px2rpx(6);
  251. box-shadow: 0 px2rpx(1) px2rpx(6) 0 rgba(0, 0, 0, 0.05);
  252. &:hover {
  253. box-shadow: 0 px2rpx(2) px2rpx(8) 0 rgba(0, 0, 0, 0.1);
  254. }
  255. .card-top {
  256. padding: px2rpx(15) px2rpx(20);
  257. .card-row {
  258. margin-bottom: px2rpx(30);
  259. &:last-child {
  260. margin-bottom: 0;
  261. }
  262. }
  263. .amount-box {
  264. display: flex;
  265. align-items: center;
  266. gap: px2rpx(12);
  267. .amount-input {
  268. flex: 1;
  269. }
  270. .btn {
  271. display: flex;
  272. align-items: center;
  273. justify-content: center;
  274. font-size: px2rpx(14);
  275. color: var(--color-zinc-600);
  276. margin-bottom: px2rpx(22);
  277. height: px2rpx(35);
  278. background-color: #cf1322;
  279. color: var(--bs-emphasis-color);
  280. border-radius: px2rpx(4);
  281. font-weight: 600;
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. border: none;
  286. padding: 0 px2rpx(20);
  287. cursor: pointer;
  288. }
  289. }
  290. .card-tit {
  291. margin-bottom: px2rpx(0) !important;
  292. }
  293. .tit {
  294. font-size: px2rpx(16);
  295. font-weight: 600;
  296. margin-bottom: px2rpx(16);
  297. display: flex;
  298. align-items: center;
  299. color: var(--bs-heading-color);
  300. position: relative;
  301. padding-left: 20px;
  302. &:after {
  303. content: '';
  304. position: absolute;
  305. left: 0;
  306. top: 50%;
  307. transform: translateY(-50%);
  308. width: 0;
  309. height: 0;
  310. border-top: 6px solid transparent;
  311. border-bottom: 6px solid transparent;
  312. border-left: 8px solid currentColor;
  313. }
  314. .iconfont {
  315. margin-right: px2rpx(8);
  316. color: var(--color-primary);
  317. font-size: px2rpx(18);
  318. }
  319. }
  320. .title-wrapper {
  321. display: flex;
  322. justify-content: space-between;
  323. align-items: center;
  324. }
  325. }
  326. }
  327. }
  328. .box-step2 {
  329. .form-row {
  330. display: flex;
  331. flex-wrap: wrap;
  332. margin-bottom: px2rpx(12);
  333. gap: px2rpx(12);
  334. &:last-child {
  335. margin-bottom: 0;
  336. }
  337. .form-col {
  338. flex: 1;
  339. min-width: px2rpx(140);
  340. @media screen and (max-width: 991px) {
  341. flex: 0 0 100%;
  342. width: 100%;
  343. }
  344. }
  345. .form-col-full {
  346. width: 100%;
  347. padding: 0 px2rpx(5);
  348. }
  349. }
  350. .tips {
  351. line-height: 1.8;
  352. font-size: px2rpx(12);
  353. color: var(--bs-heading-color);
  354. background-color: rgba(var(--bs-body-bg-rgb), 1) !important;
  355. padding: px2rpx(12);
  356. border-radius: px2rpx(4);
  357. border-left: px2rpx(2) solid #cf1322;
  358. .title {
  359. font-weight: 600;
  360. margin-bottom: px2rpx(6);
  361. color: var(--bs-heading-color);
  362. }
  363. }
  364. }
  365. }
  366. .picker-select {
  367. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  368. border: 1px solid #dcdfe6;
  369. border-radius: px2rpx(4);
  370. padding: px2rpx(12) px2rpx(14);
  371. font-size: px2rpx(14);
  372. color: #606266;
  373. line-height: 1.4;
  374. width: 100%;
  375. box-sizing: border-box;
  376. &:hover {
  377. border-color: #409eff;
  378. }
  379. &.picker-disabled {
  380. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  381. color: #c0c4cc;
  382. cursor: not-allowed;
  383. }
  384. }
  385. .disabled-input {
  386. // background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  387. // border: 1px solid #dcdfe6;
  388. border-radius: px2rpx(4);
  389. // padding: px2rpx(12) px2rpx(14);
  390. font-size: px2rpx(14);
  391. color: #606266;
  392. width: 100%;
  393. box-sizing: border-box;
  394. }
  395. .m-input {
  396. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  397. border: 1px solid #dcdfe6;
  398. border-radius: px2rpx(4);
  399. padding: px2rpx(12) px2rpx(14);
  400. font-size: px2rpx(14);
  401. width: 100%;
  402. box-sizing: border-box;
  403. &:focus {
  404. border-color: #409eff;
  405. outline: none;
  406. box-shadow: 0 0 0 px2rpx(1) rgba(64, 158, 255, 0.2);
  407. }
  408. }
  409. .popup-content {
  410. padding: px2rpx(30) px2rpx(20);
  411. text-align: center;
  412. min-width: px2rpx(250);
  413. max-width: 80%;
  414. margin: 0 auto;
  415. @media screen and (max-width: 991px) {
  416. min-width: 80%;
  417. max-width: 90%;
  418. margin: 0 px2rpx(10);
  419. }
  420. position: relative;
  421. .icon {
  422. .iconfont {
  423. font-size: px2rpx(60);
  424. display: block;
  425. margin: 0 auto;
  426. }
  427. .icon-chenggong {
  428. color: #67c23a;
  429. }
  430. .icon-jingshi {
  431. color: #f56c6c;
  432. }
  433. .icon-dengdai {
  434. color: #e6a23c;
  435. }
  436. }
  437. .des1 {
  438. font-weight: 600;
  439. font-size: px2rpx(16);
  440. margin: px2rpx(20) 0 px2rpx(15);
  441. color: #303133;
  442. line-height: 1.4;
  443. padding: 0 px2rpx(10);
  444. }
  445. .dialog-footer {
  446. display: flex;
  447. justify-content: center;
  448. gap: px2rpx(10);
  449. margin-top: px2rpx(10);
  450. @media (max-width: 750rpx) {
  451. flex-direction: column;
  452. align-items: center;
  453. gap: px2rpx(6);
  454. }
  455. button {
  456. min-width: px2rpx(90);
  457. padding: 0 px2rpx(12);
  458. border-radius: px2rpx(4);
  459. font-size: px2rpx(14);
  460. transition: all 0.3s ease;
  461. cursor: pointer;
  462. &[type="primary"] {
  463. background-color: #409eff;
  464. color: var(--bs-emphasis-color);
  465. border: none;
  466. &:hover {
  467. background-color: #66b1ff;
  468. transform: translateY(px2rpx(-1));
  469. box-shadow: 0 px2rpx(2) px2rpx(6) 0 rgba(64, 158, 255, 0.3);
  470. }
  471. &:active {
  472. background-color: #3a8ee6;
  473. transform: translateY(0);
  474. }
  475. }
  476. &:not([type="primary"]) {
  477. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  478. border: 1px solid #dcdfe6;
  479. color: #606266;
  480. &:hover {
  481. border-color: #409eff;
  482. color: #409eff;
  483. transform: translateY(px2rpx(-1));
  484. }
  485. &:active {
  486. transform: translateY(0);
  487. }
  488. }
  489. }
  490. }
  491. }
  492. .wait-popup {
  493. .des1 {
  494. margin-top: px2rpx(10);
  495. }
  496. .icon {
  497. .iconfont {
  498. animation: spin 1s linear infinite;
  499. }
  500. }
  501. }
  502. }
  503. // 动画
  504. @keyframes popupFadeIn {
  505. from {
  506. opacity: 0;
  507. transform: scale(0.9);
  508. }
  509. to {
  510. opacity: 1;
  511. transform: scale(1);
  512. }
  513. }
  514. @keyframes fadeIn {
  515. from {
  516. opacity: 0;
  517. transform: translateY(px2rpx(10));
  518. }
  519. to {
  520. opacity: 1;
  521. transform: translateY(0);
  522. }
  523. }
  524. @keyframes pulse {
  525. 0% {
  526. transform: scale(1);
  527. }
  528. 50% {
  529. transform: scale(1.05);
  530. }
  531. 100% {
  532. transform: scale(1);
  533. }
  534. }
  535. @keyframes spin {
  536. from {
  537. transform: rotate(0deg);
  538. }
  539. to {
  540. transform: rotate(360deg);
  541. }
  542. }
  543. // 表单错误信息样式
  544. .uni-forms-item__error {
  545. font-size: px2rpx(12);
  546. color: #f56c6c;
  547. margin-top: px2rpx(4);
  548. }
  549. // 适配不同屏幕尺寸(媒体查询中的 750rpx 保持不变)
  550. @media (max-width: 750rpx) {
  551. .transfer-page {
  552. .main-content {
  553. padding: px2rpx(8);
  554. .box {
  555. .b-card {
  556. .card-top {
  557. padding: px2rpx(12) px2rpx(16);
  558. .tit {
  559. font-size: px2rpx(14);
  560. .iconfont {
  561. font-size: px2rpx(16);
  562. }
  563. }
  564. }
  565. }
  566. }
  567. }
  568. .s-btn {
  569. font-size: px2rpx(14);
  570. padding: px2rpx(10) px2rpx(16);
  571. }
  572. .popup-content {
  573. padding: px2rpx(20) px2rpx(16);
  574. .icon {
  575. .iconfont {
  576. font-size: px2rpx(50);
  577. }
  578. }
  579. .des1 {
  580. font-size: px2rpx(14);
  581. margin: px2rpx(15) 0 px2rpx(10);
  582. }
  583. .dialog-footer {
  584. button {
  585. min-width: px2rpx(80);
  586. font-size: px2rpx(13);
  587. }
  588. }
  589. }
  590. }
  591. }
  592. </style>