transfer.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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 } 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. .container{
  216. padding: 0;
  217. }
  218. .amount-box {
  219. display: flex;
  220. align-items: center;
  221. gap: px2rpx(12);
  222. .amount-input {
  223. flex: 1;
  224. }
  225. .btn {
  226. margin-bottom: px2rpx(22);
  227. }
  228. }
  229. .transfer-page {
  230. width: 100%;
  231. padding-bottom: px2rpx(20);
  232. .main-content {
  233. text-align: left;
  234. .box {
  235. padding-top: px2rpx(5);
  236. color: #303133;
  237. .b-card {
  238. border: 1px solid var(--bs-border-color);
  239. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  240. margin-bottom: px2rpx(10);
  241. border-radius: px2rpx(6);
  242. box-shadow: 0 px2rpx(1) px2rpx(6) 0 rgba(0, 0, 0, 0.05);
  243. &:hover {
  244. box-shadow: 0 px2rpx(2) px2rpx(8) 0 rgba(0, 0, 0, 0.1);
  245. }
  246. .card-top {
  247. padding: px2rpx(15) px2rpx(20);
  248. .card-row {
  249. margin-bottom: px2rpx(30);
  250. &:last-child {
  251. margin-bottom: 0;
  252. }
  253. }
  254. .amount-box {
  255. display: flex;
  256. align-items: center;
  257. gap: px2rpx(12);
  258. .amount-input {
  259. flex: 1;
  260. }
  261. .btn {
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. font-size: px2rpx(14);
  266. margin-bottom: px2rpx(22);
  267. height: px2rpx(35);
  268. background-color: #cf1322;
  269. color: #fff;
  270. border-radius: px2rpx(4);
  271. font-weight: 600;
  272. display: flex;
  273. align-items: center;
  274. justify-content: center;
  275. border: none;
  276. padding: 0 px2rpx(20);
  277. cursor: pointer;
  278. }
  279. }
  280. .card-tit {
  281. margin-bottom: px2rpx(0) !important;
  282. }
  283. .tit {
  284. font-size: px2rpx(16);
  285. font-weight: 600;
  286. margin-bottom: px2rpx(16);
  287. display: flex;
  288. align-items: center;
  289. color: var(--bs-heading-color);
  290. position: relative;
  291. padding-left: 20px;
  292. &:after {
  293. content: '';
  294. position: absolute;
  295. left: 0;
  296. top: 50%;
  297. transform: translateY(-50%);
  298. width: 0;
  299. height: 0;
  300. border-top: 6px solid transparent;
  301. border-bottom: 6px solid transparent;
  302. border-left: 8px solid currentColor;
  303. }
  304. .iconfont {
  305. margin-right: px2rpx(8);
  306. color: var(--color-primary);
  307. font-size: px2rpx(18);
  308. }
  309. }
  310. .title-wrapper {
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. }
  315. }
  316. }
  317. }
  318. .box-step2 {
  319. .form-row {
  320. display: flex;
  321. flex-wrap: wrap;
  322. margin-bottom: px2rpx(12);
  323. gap: px2rpx(12);
  324. &:last-child {
  325. margin-bottom: 0;
  326. }
  327. .form-col {
  328. flex: 1;
  329. min-width: px2rpx(140);
  330. @media screen and (max-width: 991px) {
  331. flex: 0 0 100%;
  332. width: 100%;
  333. }
  334. }
  335. .form-col-full {
  336. width: 100%;
  337. padding: 0 px2rpx(5);
  338. }
  339. }
  340. .tips {
  341. line-height: 1.8;
  342. font-size: px2rpx(12);
  343. color: var(--bs-heading-color);
  344. background-color: rgba(var(--bs-body-bg-rgb), 1) !important;
  345. padding: px2rpx(12);
  346. border-radius: px2rpx(4);
  347. border-left: px2rpx(2) solid #cf1322;
  348. .title {
  349. font-weight: 600;
  350. margin-bottom: px2rpx(6);
  351. color: var(--bs-heading-color);
  352. }
  353. }
  354. }
  355. }
  356. .picker-select {
  357. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  358. border: 1px solid #dcdfe6;
  359. border-radius: px2rpx(4);
  360. padding: px2rpx(12) px2rpx(14);
  361. font-size: px2rpx(14);
  362. color: #606266;
  363. line-height: 1.4;
  364. width: 100%;
  365. box-sizing: border-box;
  366. &:hover {
  367. border-color: #409eff;
  368. }
  369. &.picker-disabled {
  370. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  371. color: #c0c4cc;
  372. cursor: not-allowed;
  373. }
  374. }
  375. .disabled-input {
  376. // background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  377. // border: 1px solid #dcdfe6;
  378. border-radius: px2rpx(4);
  379. // padding: px2rpx(12) px2rpx(14);
  380. font-size: px2rpx(14);
  381. color: #606266;
  382. width: 100%;
  383. box-sizing: border-box;
  384. }
  385. .m-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. width: 100%;
  392. box-sizing: border-box;
  393. &:focus {
  394. border-color: #409eff;
  395. outline: none;
  396. box-shadow: 0 0 0 px2rpx(1) rgba(64, 158, 255, 0.2);
  397. }
  398. }
  399. .popup-content {
  400. padding: px2rpx(30) px2rpx(20);
  401. text-align: center;
  402. min-width: px2rpx(250);
  403. max-width: 80%;
  404. margin: 0 auto;
  405. @media screen and (max-width: 991px) {
  406. min-width: 80%;
  407. max-width: 90%;
  408. margin: 0 px2rpx(10);
  409. }
  410. position: relative;
  411. .icon {
  412. .iconfont {
  413. font-size: px2rpx(60);
  414. display: block;
  415. margin: 0 auto;
  416. }
  417. .icon-chenggong {
  418. color: #67c23a;
  419. }
  420. .icon-jingshi {
  421. color: #f56c6c;
  422. }
  423. .icon-dengdai {
  424. color: #e6a23c;
  425. }
  426. }
  427. .des1 {
  428. font-weight: 600;
  429. font-size: px2rpx(16);
  430. margin: px2rpx(20) 0 px2rpx(15);
  431. color: #303133;
  432. line-height: 1.4;
  433. padding: 0 px2rpx(10);
  434. }
  435. .dialog-footer {
  436. display: flex;
  437. justify-content: center;
  438. gap: px2rpx(10);
  439. margin-top: px2rpx(10);
  440. @media (max-width: 750rpx) {
  441. flex-direction: column;
  442. align-items: center;
  443. gap: px2rpx(6);
  444. }
  445. button {
  446. min-width: px2rpx(90);
  447. padding: 0 px2rpx(12);
  448. border-radius: px2rpx(4);
  449. font-size: px2rpx(14);
  450. transition: all 0.3s ease;
  451. cursor: pointer;
  452. &[type="primary"] {
  453. background-color: #409eff;
  454. color: var(--bs-emphasis-color);
  455. border: none;
  456. &:hover {
  457. background-color: #66b1ff;
  458. transform: translateY(px2rpx(-1));
  459. box-shadow: 0 px2rpx(2) px2rpx(6) 0 rgba(64, 158, 255, 0.3);
  460. }
  461. &:active {
  462. background-color: #3a8ee6;
  463. transform: translateY(0);
  464. }
  465. }
  466. &:not([type="primary"]) {
  467. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  468. border: 1px solid #dcdfe6;
  469. color: #606266;
  470. &:hover {
  471. border-color: #409eff;
  472. color: #409eff;
  473. transform: translateY(px2rpx(-1));
  474. }
  475. &:active {
  476. transform: translateY(0);
  477. }
  478. }
  479. }
  480. }
  481. }
  482. .wait-popup {
  483. .des1 {
  484. margin-top: px2rpx(10);
  485. }
  486. .icon {
  487. .iconfont {
  488. animation: spin 1s linear infinite;
  489. }
  490. }
  491. }
  492. }
  493. // 动画
  494. @keyframes popupFadeIn {
  495. from {
  496. opacity: 0;
  497. transform: scale(0.9);
  498. }
  499. to {
  500. opacity: 1;
  501. transform: scale(1);
  502. }
  503. }
  504. @keyframes fadeIn {
  505. from {
  506. opacity: 0;
  507. transform: translateY(px2rpx(10));
  508. }
  509. to {
  510. opacity: 1;
  511. transform: translateY(0);
  512. }
  513. }
  514. @keyframes pulse {
  515. 0% {
  516. transform: scale(1);
  517. }
  518. 50% {
  519. transform: scale(1.05);
  520. }
  521. 100% {
  522. transform: scale(1);
  523. }
  524. }
  525. @keyframes spin {
  526. from {
  527. transform: rotate(0deg);
  528. }
  529. to {
  530. transform: rotate(360deg);
  531. }
  532. }
  533. // 表单错误信息样式
  534. .uni-forms-item__error {
  535. font-size: px2rpx(12);
  536. color: #f56c6c;
  537. margin-top: px2rpx(4);
  538. }
  539. // 适配不同屏幕尺寸(媒体查询中的 750rpx 保持不变)
  540. @media (max-width: 750rpx) {
  541. .transfer-page {
  542. .main-content {
  543. padding: px2rpx(8);
  544. .box {
  545. .b-card {
  546. .card-top {
  547. padding: px2rpx(12) px2rpx(16);
  548. .tit {
  549. font-size: px2rpx(14);
  550. .iconfont {
  551. font-size: px2rpx(16);
  552. }
  553. }
  554. }
  555. }
  556. }
  557. }
  558. .s-btn {
  559. font-size: px2rpx(14);
  560. padding: px2rpx(10) px2rpx(16);
  561. }
  562. .popup-content {
  563. padding: px2rpx(20) px2rpx(16);
  564. .icon {
  565. .iconfont {
  566. font-size: px2rpx(50);
  567. }
  568. }
  569. .des1 {
  570. font-size: px2rpx(14);
  571. margin: px2rpx(15) 0 px2rpx(10);
  572. }
  573. .dialog-footer {
  574. button {
  575. min-width: px2rpx(80);
  576. font-size: px2rpx(13);
  577. }
  578. }
  579. }
  580. }
  581. }
  582. </style>