index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="register absolute">
  3. <div class="shading">
  4. <div class="pictrue acea-row row-center-wrapper">
  5. <image src="/static/images/logo2.png" />
  6. </div>
  7. </div>
  8. <div class="whiteBg">
  9. <div class="title">找回密码</div>
  10. <div class="list">
  11. <div class="item">
  12. <div class="acea-row row-middle">
  13. <image src="/static/images/phone_1.png"></image>
  14. <input type="text" placeholder="输入手机号码" v-model="account" />
  15. </div>
  16. </div>
  17. <div class="item">
  18. <div class="acea-row row-middle">
  19. <image src="/static/images/code_2.png"></image>
  20. <input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
  21. <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
  22. {{ text }}
  23. </button>
  24. </div>
  25. </div>
  26. <div class="item">
  27. <div class="acea-row row-middle">
  28. <image src="/static/images/code_2.png"></image>
  29. <input type="password" placeholder="填写您的新密码" v-model="password" />
  30. </div>
  31. </div>
  32. <div class="item" v-if="isShowCode">
  33. <div class="align-left">
  34. <input type="text" placeholder="填写验证码" class="codeIput" v-model="codeVal" />
  35. <div class="code" @click="again"><img :src="codeUrl" /></div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="logon" @click="registerReset">确认</div>
  40. <div class="tip">
  41. <span class="font-color-red" @click="back">立即登录</span>
  42. </div>
  43. </div>
  44. <div class="bottom"></div>
  45. </div>
  46. </template>
  47. <script>
  48. import sendVerifyCode from "@/mixins/SendVerifyCode";
  49. import {
  50. registerVerify,
  51. registerReset,
  52. getCodeApi
  53. } from "@/api/user";
  54. // import { validatorDefaultCatch } from "@/utils/dialog";
  55. // import attrs, { required, alpha_num, chs_phone } from "@utils/validate";
  56. // import { VUE_APP_API_URL } from "@utils";
  57. export default {
  58. name: "RetrievePassword",
  59. data: function() {
  60. return {
  61. account: "",
  62. password: "",
  63. captcha: "",
  64. keyCode: "",
  65. codeUrl: "",
  66. codeVal: "",
  67. isShowCode: false
  68. };
  69. },
  70. mixins: [sendVerifyCode],
  71. mounted: function() {
  72. this.getCode();
  73. },
  74. methods: {
  75. back() {
  76. uni.navigateBack();
  77. },
  78. again() {
  79. this.codeUrl =
  80. VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date());
  81. console.log(this.codeUrl);
  82. },
  83. getCode() {
  84. getCodeApi()
  85. .then(res => {
  86. this.keyCode = res.data.key;
  87. })
  88. .catch(res => {
  89. this.$dialog.error(res.msg);
  90. });
  91. },
  92. async registerReset() {
  93. var that = this;
  94. if (!that.account) return that.$util.Tips({
  95. title: '请填写手机号码'
  96. });
  97. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  98. title: '请输入正确的手机号码'
  99. });
  100. if (!that.captcha) return that.$util.Tips({
  101. title: '请填写验证码'
  102. });
  103. registerReset({
  104. account: that.account,
  105. captcha: that.captcha,
  106. password: that.password,
  107. code: that.codeVal
  108. })
  109. .then(res => {
  110. that.$util.Tips({
  111. title: res.msg
  112. }, {
  113. tab: 3
  114. })
  115. })
  116. .catch(res => {
  117. that.$util.Tips({
  118. title: res
  119. })
  120. });
  121. },
  122. async code() {
  123. let that = this;
  124. if (!that.account) return that.$util.Tips({
  125. title: '请填写手机号码'
  126. });
  127. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  128. title: '请输入正确的手机号码'
  129. });
  130. if (that.formItem == 2) that.type = "register";
  131. await registerVerify({
  132. phone: that.account,
  133. type: that.type,
  134. key: that.keyCode,
  135. code: that.codeVal
  136. })
  137. .then(res => {
  138. that.$dialog.success(res.msg);
  139. that.sendCode();
  140. })
  141. .catch(res => {
  142. console.log(res, 'res')
  143. // if (res.data.status === 402) {
  144. // that.codeUrl = `${VUE_APP_API_URL}/sms_captcha?key=${that.keyCode}`;
  145. // that.isShowCode = true;
  146. // }
  147. that.$util.Tips({
  148. title: res
  149. });
  150. });
  151. },
  152. }
  153. };
  154. </script>
  155. <style scoped>
  156. .code img {
  157. width: 100%;
  158. height: 100%;
  159. }
  160. </style>