paypassword.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="main bg-white margin-top padding-tb-sm">
  3. <view class="flex justify-between align-center margin-top-sm padding-lr-sm">
  4. <view class="flex-sub margin-right-sm">
  5. <u-input v-model="password" :type="type" placeholder="请设置支付密码(6位数字)" :border="border" />
  6. </view>
  7. </view>
  8. <view class="flex justify-between align-center margin-top-sm padding-lr-sm">
  9. <view class="flex-sub margin-right-sm">
  10. <u-input v-model="code" :type="type" placeholder="请输入验证码" :border="border" />
  11. </view>
  12. <u-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-verification-code>
  13. <u-button @click="getCode">{{tips}}</u-button>
  14. </view>
  15. <view class="cu-bar bg-white tabbar" style="position: fixed;bottom: 0;width: 100%;">
  16. <view class="submit" style="background-color: #0B73B9;color: white;" @click="">
  17. 立即保存
  18. </view>
  19. </view>
  20. <view class="cu-tabbar-height"></view>
  21. <view class="cu-tabbar-height"></view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. onLoad(options) {
  27. },
  28. mounted() {
  29. },
  30. data() {
  31. return {
  32. code:'',
  33. type: 'number',
  34. border: true,
  35. tips: '',
  36. seconds: 60,
  37. password:''
  38. }
  39. },
  40. methods: {
  41. codeChange(text) {
  42. this.tips = text;
  43. },
  44. getCode() {
  45. if (this.$refs.uCode.canGetCode) {
  46. // 模拟向后端请求验证码
  47. uni.showLoading({
  48. title: '正在获取验证码'
  49. })
  50. setTimeout(() => {
  51. uni.hideLoading();
  52. // 这里此提示会被this.start()方法中的提示覆盖
  53. uni.showToast({
  54. title: "验证码已发送",
  55. icon: "none"
  56. })
  57. // 通知验证码组件内部开始倒计时
  58. this.$refs.uCode.start();
  59. }, 2000);
  60. } else {
  61. uni.showToast({
  62. title: "结束后再发送",
  63. icon: "none"
  64. })
  65. }
  66. },
  67. end() {
  68. uni.showToast({
  69. title: "倒计时结束",
  70. icon: "none"
  71. })
  72. },
  73. start() {
  74. uni.showToast({
  75. title: "倒计时开始",
  76. icon: "none"
  77. })
  78. },
  79. }
  80. };
  81. </script>
  82. <style scoped lang="scss">
  83. .main {}
  84. </style>