wallet-transfer.vue 17 KB

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