transfer.vue 19 KB

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