withdraw.vue 3.1 KB

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