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/logo2.png" /> -->
  6. </div>
  7. </div>
  8. <div class="whiteBg">
  9. <div class="title">{{$t(`找回密码`)}}</div>
  10. <div class="list">
  11. <div class="item">
  12. <div class="acea-row row-middle">
  13. <image src="../static/phone_1.png"></image>
  14. <input type="text" :placeholder="$t(`输入手机号码`)" v-model="account" />
  15. </div>
  16. </div>
  17. <div class="item">
  18. <div class="acea-row row-middle">
  19. <image src="../static/code_2.png"></image>
  20. <input type="text" :placeholder="$t(`填写验证码`)" 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//code_2.png"></image>
  29. <input type="password" :placeholder="$t(`填写您的新密码`)" v-model="password" />
  30. </div>
  31. </div>
  32. <div class="item" v-if="isShowCode">
  33. <div class="align-left">
  34. <input type="text" :placeholder="$t(`填写验证码`)" 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">{{$t(`确认`)}}</div>
  40. <div class="tip">
  41. <span class="font-color-red" @click="back">{{$t(`立即登录`)}}</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.$util.Tips({
  89. title: res.msg.msg || this.$t(`加载失败`)
  90. })
  91. });
  92. },
  93. async registerReset() {
  94. var that = this;
  95. if (!that.account) return that.$util.Tips({
  96. title: that.$t(`请填写手机号码`)
  97. });
  98. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  99. title: that.$t(`请输入正确的手机号码`)
  100. });
  101. if (!that.captcha) return that.$util.Tips({
  102. title: that.$t(`请填写验证码`)
  103. });
  104. registerReset({
  105. account: that.account,
  106. captcha: that.captcha,
  107. password: that.password,
  108. code: that.codeVal
  109. })
  110. .then(res => {
  111. that.$util.Tips({
  112. title: res.msg
  113. }, {
  114. tab: 3
  115. })
  116. })
  117. .catch(res => {
  118. that.$util.Tips({
  119. title: res
  120. })
  121. });
  122. },
  123. async code() {
  124. let that = this;
  125. if (!that.account) return that.$util.Tips({
  126. title: that.$t(`请填写手机号码`)
  127. });
  128. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  129. title: that.$t(`请输入正确的手机号码`)
  130. });
  131. if (that.formItem == 2) that.type = "register";
  132. await registerVerify({
  133. phone: that.account,
  134. type: that.type,
  135. key: that.keyCode,
  136. code: that.codeVal
  137. })
  138. .then(res => {
  139. this.$util.Tips({
  140. title: res.msg || that.$t(`加载失败`)
  141. })
  142. that.sendCode();
  143. })
  144. .catch(res => {
  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>