transfer.vue 20 KB

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