amount.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="amount">
  3. <!-- <image src="../../../static/index/convenient-services/return.png" mode="" @click="back" /> -->
  4. <view class="main">
  5. <view class="recharge-wrapper">
  6. <view class="title">充值金额</view>
  7. <view class="inp">
  8. <view class="icon">¥</view>
  9. <input v-model.number="payPrice" class="input" type="number" placeholder="请输入充值金额" />
  10. <view class="error">{{ errMsg }}</view>
  11. </view>
  12. <TuiButton @click="handleRecharge">充值</TuiButton>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { MainRequest } from '../../../utils'
  19. import { handleDoPay } from '../../../utils/payUtil'
  20. import tuiButton from '@/components/thorui/tui-button/tui-button.vue'
  21. export default {
  22. name: 'Amount',
  23. components: {
  24. TuiButton: tuiButton
  25. },
  26. props: {
  27. },
  28. data() {
  29. return {
  30. payPrice: null,
  31. errMsg: '',
  32. youkabianhao: ''
  33. }
  34. },
  35. watch: {
  36. payPrice(value) {
  37. if (value === 0) {
  38. this.errMsg = '充值金额不能等于零'
  39. } else if (value < 0) {
  40. this.errMsg = '充值金额不能小于零'
  41. } else if (
  42. (value + '').includes('.') &&
  43. (value + '').split('.')[1].length > 2
  44. ) {
  45. this.errMsg = '充值金额错误'
  46. } else {
  47. this.errMsg = ''
  48. }
  49. }
  50. },
  51. created() { },
  52. methods: {
  53. back() {
  54. uni.navigateTo({ url: '/pages_user/serve/tuanyou/recharge' })
  55. },
  56. handleRecharge() {
  57. if (this.errMsg) {
  58. return
  59. }
  60. if (!this.payPrice) {
  61. this.$showToast('请输入充值金额')
  62. return
  63. }
  64. if (this.youkabianhao == null || this.youkabianhao == '' || this.youkabianhao == undefined) {
  65. this.$showToast('参数错误')
  66. return
  67. }
  68. const reqData = {
  69. 'kahao': this.youkabianhao,
  70. 'amount': this.payPrice
  71. }
  72. MainRequest('/tuanyou/tygetorderinfo', reqData, 'post').then(({ data }) => {
  73. console.log(data)
  74. handleDoPay({ ...data, orderSn: data.orderno }, data.payType)
  75. })
  76. }
  77. },
  78. onLoad(options) {
  79. console.log(options)
  80. this.youkabianhao = options.kahao
  81. const { price } = options
  82. if (price != -1) {
  83. this.payPrice = price * 1
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="less" scoped>
  89. .amount {
  90. padding: 48upx;
  91. box-sizing: border-box;
  92. image {
  93. width: 56upx;
  94. height: 56upx;
  95. }
  96. .main {
  97. padding: 32upx;
  98. box-sizing: border-box;
  99. margin-top: 40px;
  100. .recharge-wrapper {
  101. .inp {
  102. position: relative;
  103. display: flex;
  104. justify-content: center;
  105. align-items: center;
  106. margin-top: 40upx;
  107. border-bottom: 1upx solid #ccc;
  108. padding-bottom: 10upx;
  109. margin-bottom: 400upx;
  110. .icon {
  111. font-weight: bold;
  112. font-size: 80upx;
  113. }
  114. .input {
  115. font-weight: bold;
  116. font-size: 128upx;
  117. }
  118. .uni-input-placeholder {
  119. font-size: 30px;
  120. }
  121. }
  122. .error {
  123. color: red;
  124. margin-top: 10upx;
  125. position: absolute;
  126. bottom: -60upx;
  127. left: 0;
  128. }
  129. }
  130. }
  131. }
  132. </style>