transfer.vue 19 KB

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