index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view>
  3. <view class="u-padding-40">
  4. <u-button type="success" @click="showPop(true)">
  5. <u-icon name="red-packet"></u-icon>
  6. <text class="u-padding-left-10">发送1.00元红包</text>
  7. </u-button>
  8. </view>
  9. <u-keyboard default="" ref="uKeyboard" mode="number" :mask="true" :mask-close-able="false" :dot-enabled="false"
  10. :show="show" :safe-area-inset-bottom="true" :tooltip="false" @change="onChange" @backspace="onBackspace">
  11. <view>
  12. <view class="u-text-center u-padding-20 money">
  13. <text>1.00</text>
  14. <text class="u-font-20 u-padding-left-10">元</text>
  15. <view class="u-padding-10 close" data-flag="false" @tap="showPop(false)">
  16. <u-icon name="close" color="#333333" size="28"></u-icon>
  17. </view>
  18. </view>
  19. <view class="u-flex u-row-center">
  20. <u-message-input mode="box" :maxlength="6" :dot-fill="true" v-model="password" :disabled-keyboard="true"
  21. @finish="finish"></u-message-input>
  22. </view>
  23. <view class="u-text-center u-padding-top-10 u-padding-bottom-20 tips">支付键盘</view>
  24. </view>
  25. </u-keyboard>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. show: false,
  33. password: ''
  34. }
  35. },
  36. onLoad() {
  37. },
  38. methods: {
  39. onChange(val) {
  40. if (this.password.length < 6) {
  41. this.password += val;
  42. }
  43. if (this.password.length >= 6) {
  44. this.pay();
  45. }
  46. },
  47. onBackspace(e) {
  48. if (this.password.length > 0) {
  49. this.password = this.password.substring(0, this.password.length - 1);
  50. }
  51. },
  52. pay() {
  53. uni.showLoading({
  54. title: '支付中'
  55. })
  56. setTimeout(() => {
  57. uni.hideLoading();
  58. this.show = false;
  59. uni.showToast({
  60. icon: 'success',
  61. title: '支付成功'
  62. })
  63. }, 2000);
  64. },
  65. showPop(flag = true) {
  66. this.password = '';
  67. this.show = flag;
  68. },
  69. finish() {
  70. console.log(11111)
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss">
  76. .money {
  77. font-size: 80rpx;
  78. color: $u-warning;
  79. position: relative;
  80. .close {
  81. position: absolute;
  82. top: 20rpx;
  83. right: 20rpx;
  84. line-height: 28rpx;
  85. font-size: 28rpx;
  86. }
  87. }
  88. .tips {
  89. color: $u-tips-color;
  90. }
  91. </style>