index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="register absolute">
  3. <div class="shading">
  4. <div class="pictrue acea-row row-center-wrapper">
  5. <image :src="login_logo" v-if="login_logo" />
  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" autocomplete="off" />
  15. <input type="text" style="height: 0;opacity: 0">
  16. </div>
  17. </div>
  18. <div class="item">
  19. <div class="acea-row row-middle">
  20. <image src="/static/images/code_2.png"></image>
  21. <input type="password" placeholder="填写您的新密码" v-model="password" autocomplete="off" />
  22. </div>
  23. </div>
  24. <div class="item">
  25. <div class="acea-row row-middle">
  26. <image src="/static/images/code_2.png"></image>
  27. <input type="password" placeholder="再次输入新密码" v-model="confirm_pwd" autocomplete="off" />
  28. </div>
  29. </div>
  30. <div class="item">
  31. <div class="acea-row row-middle">
  32. <image src="/static/images/code_2.png"></image>
  33. <input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" autocomplete="off" />
  34. <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
  35. {{ text }}
  36. </button>
  37. </div>
  38. </div>
  39. <div class="item" v-if="isShowCode">
  40. <div class="acea-row row-middle">
  41. <input type="text" placeholder="填写验证码" class="codeIput" v-model="codeVal" />
  42. <div class="code" @click="again"><image class="code-img" style="width: 100%;height: 100%;" :src="codeUrl" /></div>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="logon" @click="registerReset">确认</div>
  47. <div class="tip">
  48. <span class="font-color-red" @click="back">立即登录</span>
  49. </div>
  50. </div>
  51. <div class="bottom"></div>
  52. </div>
  53. </template>
  54. <script>
  55. // +----------------------------------------------------------------------
  56. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  57. // +----------------------------------------------------------------------
  58. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  59. // +----------------------------------------------------------------------
  60. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  61. // +----------------------------------------------------------------------
  62. // | Author: CRMEB Team <admin@crmeb.com>
  63. // +----------------------------------------------------------------------
  64. const app = getApp();
  65. import sendVerifyCode from "@/mixins/SendVerifyCode";
  66. import {
  67. registerVerify,
  68. registerForget,
  69. getCodeApi,
  70. getCaptcha
  71. } from "@/api/user";
  72. import {
  73. validatorDefaultCatch
  74. } from "@/utils/dialog";
  75. import attrs, {
  76. required,
  77. alpha_num,
  78. chs_phone
  79. } from "@/utils/validate";
  80. import { configMap } from '@/utils';
  81. export default {
  82. name: "RetrievePassword",
  83. mixins: [sendVerifyCode],
  84. data: function() {
  85. return {
  86. account: "",
  87. password: "",
  88. confirm_pwd: "",
  89. captcha: "",
  90. codeKey: "",
  91. codeUrl: "",
  92. codeVal: "",
  93. isShowCode: false,
  94. };
  95. },
  96. computed: configMap(['login_logo']),
  97. onReady() {
  98. },
  99. mounted: function() {
  100. },
  101. methods: {
  102. back() {
  103. uni.navigateBack();
  104. },
  105. again() {
  106. this.codeUrl =
  107. VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date());
  108. console.log(this.codeUrl);
  109. },
  110. async code() {
  111. let that = this;
  112. // that.sendCode();
  113. if (!that.account) return that.$util.Tips({
  114. title: '请填写手机号码'
  115. });
  116. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  117. title: '请输入正确的手机号码'
  118. });
  119. await registerVerify({
  120. phone: that.account,
  121. type: 'change_pwd',
  122. key: that.codeKey,
  123. code: that.codeVal,
  124. })
  125. .then(res => {
  126. that.$util.Tips({
  127. title: res.message
  128. });
  129. that.sendCode();
  130. }).catch(res => {
  131. console.log(res, 'res')
  132. that.getcaptcha();
  133. that.$util.Tips({
  134. title: res
  135. });
  136. });
  137. },
  138. getcaptcha() {
  139. let that = this
  140. getCaptcha().then(data => {
  141. that.codeUrl = data.data.captcha; //图片路径
  142. that.codeVal = data.data.code; //图片验证码
  143. that.codeKey = data.data.key //图片验证码key
  144. })
  145. that.isShowCode = true;
  146. },
  147. async registerReset() {
  148. var that = this;
  149. if (!that.account) return that.$util.Tips({
  150. title: '请填写手机号码'
  151. });
  152. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  153. title: '请输入正确的手机号码'
  154. });
  155. if (that.password == '123456') return that.$util.Tips({
  156. title: '您输入的密码过于简单'
  157. });
  158. if (that.password != that.confirm_pwd) return that.$util.Tips({
  159. title: '两次密码不一致'
  160. });
  161. if (!that.captcha) return that.$util.Tips({
  162. title: '请填写验证码'
  163. });
  164. registerForget({
  165. phone: that.account,
  166. sms_code: that.captcha,
  167. pwd: that.password,
  168. confirm_pwd: that.confirm_pwd
  169. })
  170. .then(res => {
  171. that.$util.Tips({
  172. title: res.msg
  173. }, {
  174. tab: 3
  175. })
  176. })
  177. .catch(res => {
  178. that.$util.Tips({
  179. title: res
  180. })
  181. });
  182. },
  183. }
  184. };
  185. </script>
  186. <style scoped>
  187. .code img {
  188. width: 100%;
  189. height: 100%;
  190. }
  191. </style>