index.vue 2.2 KB

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