withdraw.vue 3.0 KB

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