wallet-transfer.vue 18 KB

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