transfer.vue 20 KB

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