withdraw.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="withdraw" catchtouchmove="true">
  3. <view class="withdraw_content">
  4. <view class="title">提现金额</view>
  5. <view class="content">
  6. <view>¥</view>
  7. <input type="number" class="input" v-model="withdrawAmount" @blur="_valiteMoney" />
  8. </view>
  9. <view class="bottom">
  10. <text>当前可提现余额{{ maxWithdrawAmount }}元</text>
  11. <view style="color: #5baff4" @click="_getAll">全部提现</view>
  12. </view>
  13. </view>
  14. <button class="withdraw_btn" :class="isDisabled ? 'disabled' : ''" @click="_getMoney">确定提现</button>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref, watch, onMounted } from "vue";
  19. import http from "@/utils/request";
  20. const withdrawAmount = ref(0);
  21. const maxWithdrawAmount = ref(134.14);
  22. const isDisabled = ref(true);
  23. onMounted(() => {
  24. http.request("api/custom/get_info").then((res) => {
  25. console.log(res);
  26. });
  27. });
  28. const _valiteMoney = (e) => {
  29. if (!isNaN(e.target.value)) {
  30. if (maxWithdrawAmount.value < e.target.value) {
  31. withdrawAmount.value = maxWithdrawAmount.value;
  32. } else withdrawAmount.value = e.target.value;
  33. } else {
  34. // 如果不是数字,可以设置为0或者其他默认值
  35. withdrawAmount.value = 0;
  36. }
  37. };
  38. const _getAll = () => {
  39. withdrawAmount.value = maxWithdrawAmount.value;
  40. };
  41. const _getMoney = () => {
  42. if (isDisabled.value) return;
  43. uni.showModal({
  44. title: "温馨提示",
  45. content: "您已成功提现,请注意查看信息",
  46. showCancel: false,
  47. confirmText: "确认",
  48. success: (res) => {
  49. if (res.confirm) {
  50. console.log("用户点击确认");
  51. }
  52. },
  53. });
  54. };
  55. watch(withdrawAmount, (newValue) => {
  56. isDisabled.value = isNaN(newValue) || newValue == 0;
  57. });
  58. </script>
  59. <style lang="less" scoped>
  60. .withdraw {
  61. width: 100vw;
  62. height: 100vh;
  63. padding: 46rpx 26rpx;
  64. display: flex;
  65. flex-direction: column;
  66. align-items: center;
  67. justify-content: space-between;
  68. box-sizing: border-box;
  69. background-color: #ffffff;
  70. .withdraw_content {
  71. border: 1px solid #f3f3f3;
  72. border-radius: 6px;
  73. width: 100%;
  74. padding: 20rpx;
  75. box-sizing: border-box;
  76. .title {
  77. font-weight: bold;
  78. margin-bottom: 36rpx;
  79. }
  80. .content {
  81. position: relative;
  82. border-bottom: 2rpx solid #f3f3f3;
  83. padding: 10rpx 0;
  84. box-sizing: border-box;
  85. input {
  86. width: 100%;
  87. height: 60rpx;
  88. font-size: 36rpx;
  89. border-radius: 6px;
  90. padding-left: 45rpx;
  91. }
  92. view {
  93. position: absolute;
  94. left: 5rpx;
  95. top: 50%;
  96. transform: translateY(-50%);
  97. font-size: 36rpx;
  98. }
  99. }
  100. .bottom {
  101. display: flex;
  102. justify-content: space-between;
  103. align-items: center;
  104. font-size: 28rpx;
  105. margin-top: 20rpx;
  106. }
  107. }
  108. .withdraw_btn {
  109. width: 100%;
  110. height: 70rpx;
  111. background-color: #169bd5;
  112. color: #ffffff;
  113. font-size: 36rpx;
  114. border-radius: 10rpx;
  115. line-height: 70rpx;
  116. box-shadow: 0rpx 5rpx 10rpx #169bd5;
  117. &.disabled {
  118. background-color: #97d2ec;
  119. color: #fff;
  120. box-shadow: none;
  121. }
  122. }
  123. }
  124. </style>