index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. },
  82. getCode() {
  83. getCodeApi()
  84. .then(res => {
  85. this.keyCode = res.data.key;
  86. })
  87. .catch(res => {
  88. this.$dialog.error(res.msg);
  89. });
  90. },
  91. async registerReset() {
  92. var that = this;
  93. if (!that.account) return that.$util.Tips({
  94. title: '请填写手机号码'
  95. });
  96. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  97. title: '请输入正确的手机号码'
  98. });
  99. if (!that.captcha) return that.$util.Tips({
  100. title: '请填写验证码'
  101. });
  102. registerReset({
  103. account: that.account,
  104. captcha: that.captcha,
  105. password: that.password,
  106. code: that.codeVal
  107. })
  108. .then(res => {
  109. that.$util.Tips({
  110. title: res.message
  111. }, {
  112. tab: 3
  113. })
  114. })
  115. .catch(res => {
  116. that.$util.Tips({
  117. title: res
  118. })
  119. });
  120. },
  121. async code() {
  122. let that = this;
  123. if (!that.account) return that.$util.Tips({
  124. title: '请填写手机号码'
  125. });
  126. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  127. title: '请输入正确的手机号码'
  128. });
  129. if (that.formItem == 2) that.type = "register";
  130. await registerVerify({
  131. phone: that.account,
  132. type: that.type,
  133. key: that.keyCode,
  134. code: that.codeVal
  135. })
  136. .then(res => {
  137. that.$dialog.success(res.message);
  138. that.sendCode();
  139. })
  140. .catch(res => {
  141. // if (res.data.status === 402) {
  142. // that.codeUrl = `${VUE_APP_API_URL}/sms_captcha?key=${that.keyCode}`;
  143. // that.isShowCode = true;
  144. // }
  145. that.$util.Tips({
  146. title: res
  147. });
  148. });
  149. },
  150. }
  151. };
  152. </script>
  153. <style scoped>
  154. .code img {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. </style>