index.vue 4.1 KB

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