paypassword.vue 2.7 KB

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