index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="register absolute">
  3. <view class="shading">
  4. <view class="pictrue acea-row row-center-wrapper">
  5. <image src="../../static/images/logo2.png" />
  6. </view>
  7. </view>
  8. <view class="whiteBg">
  9. <view class="title">找回密码</view>
  10. <view class="list">
  11. <view class="item">
  12. <view class="acea-row row-middle">
  13. <image src="/static/images/phone_1.png" />
  14. <input type="text" placeholder="输入手机号码" placeholder-class="placeholder" v-model="mobile" class="input"/>
  15. </view>
  16. </view>
  17. <view class="item">
  18. <view class="align-left acea-row row-middle">
  19. <image src="/static/images/code_2.png" />
  20. <input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" placeholder-class="placeholder"/>
  21. <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
  22. {{ text }}
  23. </button>
  24. </view>
  25. </view>
  26. <view class="item">
  27. <view class="acea-row row-middle">
  28. <image src="/static/images/code_1.png" />
  29. <input type="password" placeholder="填写您的登录密码" v-model="password" placeholder-class="placeholder" class="input"/>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="logon" @click="registerReset">确认</view>
  34. <navigator url="/pages/users/login/index" class="tip">
  35. <text class="font-color">立即登录</text>
  36. </navigator>
  37. </view>
  38. <view class="bottom" />
  39. </view>
  40. </template>
  41. <script>
  42. import sendVerifyCode from "@/mixins/SendVerifyCode";
  43. import * as AuthUtil from '@/api/member/auth.js';
  44. import * as UserApi from '@/api/member/user.js';
  45. export default {
  46. data() {
  47. return {
  48. mobile: "",
  49. password: "",
  50. captcha: ""
  51. };
  52. },
  53. mixins: [sendVerifyCode],
  54. methods: {
  55. registerReset() {
  56. if (!this.mobile) {
  57. return this.$util.Tips({
  58. title: '请填写手机号码'
  59. });
  60. }
  61. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) {
  62. return this.$util.Tips({
  63. title: '请输入正确的手机号码'
  64. });
  65. }
  66. if (!this.captcha) {
  67. return this.$util.Tips({
  68. title: '请填写验证码'
  69. });
  70. }
  71. if (!/^[\w\d]+$/i.test(this.captcha)) {
  72. return this.$util.Tips({
  73. title: '请输入正确的验证码'
  74. });
  75. }
  76. if (!this.password) {
  77. return this.$util.Tips({
  78. title: '请填写密码'
  79. });
  80. }
  81. if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/i.test(this.password)) {
  82. return this.$util.Tips({
  83. title: '您输入的密码过于简单'
  84. });
  85. }
  86. UserApi.resetUserPassword({
  87. mobile: this.mobile,
  88. code: this.captcha,
  89. password: this.password
  90. }).then(res => {
  91. return this.$util.Tips({
  92. title: '密码找回成功',
  93. icon: 'success'
  94. }, {
  95. tab: 5,
  96. url: '/pages/users/login/index'
  97. });
  98. }).catch(res => {
  99. this.$util.Tips({
  100. title: res
  101. });
  102. });
  103. },
  104. async code() {
  105. if (!this.mobile) {
  106. return this.$util.Tips({
  107. title: '请填写手机号码'
  108. });
  109. }
  110. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.mobile)) {
  111. return this.$util.Tips({
  112. title: '请输入正确的手机号码'
  113. });
  114. }
  115. AuthUtil.sendSmsCode(this.mobile, 4).then(res => {
  116. this.$util.Tips({
  117. title: res
  118. });
  119. this.sendCode();
  120. }).catch(res => {
  121. this.$util.Tips({
  122. title: res
  123. });
  124. });
  125. }
  126. }
  127. };
  128. </script>
  129. <style>
  130. </style>