paypassword.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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" maxlength="6" 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="number" maxlength="6" 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="editpwd">
  17. 立即保存
  18. </view>
  19. </view>
  20. <view class="cu-tabbar-height"></view>
  21. <view class="cu-tabbar-height"></view>
  22. <u-no-network></u-no-network>
  23. </view>
  24. </template>
  25. <script>
  26. import store from '@/store'
  27. export default {
  28. onLoad(options) {
  29. this.info = store.getters['getusers']
  30. },
  31. mounted() {
  32. },
  33. data() {
  34. return {
  35. code: '',
  36. type: 'password',
  37. border: true,
  38. tips: '',
  39. seconds: 60,
  40. password: '',
  41. info: ""
  42. }
  43. },
  44. methods: {
  45. codeChange(text) {
  46. this.tips = text;
  47. },
  48. getCode() {
  49. if (this.password.length != 6) {
  50. uni.showToast({
  51. title: "密码最低六位数",
  52. icon: "none"
  53. })
  54. return false
  55. }
  56. if (!this.$util.isNum(this.password)) {
  57. uni.showToast({
  58. title: "密码只能为数字",
  59. icon: "none"
  60. })
  61. return false
  62. }
  63. if (this.$refs.uCode.canGetCode) {
  64. // 模拟向后端请求验证码
  65. uni.showLoading({
  66. title: '正在获取验证码'
  67. })
  68. setTimeout(() => {
  69. uni.hideLoading();
  70. // 这里此提示会被this.start()方法中的提示覆盖
  71. uni.showToast({
  72. title: "验证码已发送",
  73. icon: "none"
  74. })
  75. // 通知验证码组件内部开始倒计时
  76. this.$refs.uCode.start();
  77. }, 2000);
  78. } else {
  79. uni.showToast({
  80. title: "结束后再发送",
  81. icon: "none"
  82. })
  83. }
  84. },
  85. end() {
  86. //倒计时结束
  87. },
  88. start: async function() {
  89. let res = await this.$request.post("/api/v1/common/sendVerifyCode", {
  90. phone: this.info.phone,
  91. type: 3
  92. })
  93. },
  94. editpwd: async function() {
  95. let res = await this.$request.post("/api/v1/user/updatePayPassword", {
  96. verify_code: this.code,
  97. pay_password: this.password
  98. })
  99. if (res.status == 0) {
  100. uni.showToast({
  101. title: "设置成功",
  102. icon: "none",
  103. duration: 1500
  104. })
  105. setTimeout(() => {
  106. uni.navigateBack({
  107. delta: 1
  108. })
  109. }, 1500)
  110. } else {
  111. uni.showToast({
  112. title: res.message,
  113. icon: "none",
  114. duration: 1500
  115. })
  116. }
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. page {
  123. background-color: #fff;
  124. }
  125. .main {}
  126. </style>