paypassword.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.$refs.uCode.canGetCode) {
  50. // 模拟向后端请求验证码
  51. uni.showLoading({
  52. title: '正在获取验证码'
  53. })
  54. setTimeout(() => {
  55. uni.hideLoading();
  56. // 这里此提示会被this.start()方法中的提示覆盖
  57. uni.showToast({
  58. title: "验证码已发送",
  59. icon: "none"
  60. })
  61. // 通知验证码组件内部开始倒计时
  62. this.$refs.uCode.start();
  63. }, 2000);
  64. } else {
  65. uni.showToast({
  66. title: "结束后再发送",
  67. icon: "none"
  68. })
  69. }
  70. },
  71. end() {
  72. //倒计时结束
  73. },
  74. start: async function() {
  75. let res = await this.$request.post("/api/v1/common/sendVerifyCode", {
  76. phone: this.info.phone,
  77. type: 3
  78. })
  79. },
  80. editpwd: async function() {
  81. let res = await this.$request.post("/api/v1/user/updatePayPassword", {
  82. verify_code: this.code,
  83. pay_password: this.password
  84. })
  85. if (res.status == 0) {
  86. uni.showToast({
  87. title: "设置成功",
  88. icon: "none",
  89. duration: 1500
  90. })
  91. setTimeout(() => {
  92. uni.navigateBack({
  93. delta: 1
  94. })
  95. }, 1500)
  96. }else{
  97. uni.showToast({
  98. title: res.message,
  99. icon: "none",
  100. duration: 1500
  101. })
  102. }
  103. }
  104. }
  105. };
  106. </script>
  107. <style lang="scss">
  108. page {
  109. background-color: #fff;
  110. }
  111. .main {}
  112. </style>