index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <div class="register absolute">
  3. <div class="shading">
  4. <div class="pictrue acea-row row-center-wrapper">
  5. <image :src="logoUrl" v-if="logoUrl" />
  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="align-left">
  41. <input type="text" placeholder="填写验证码" class="codeIput" v-model="codeVal" />
  42. <div class="code" @click="again"><img :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. const app = getApp();
  56. import sendVerifyCode from "@/mixins/SendVerifyCode";
  57. import {
  58. registerVerify,
  59. registerForget,
  60. getCodeApi,
  61. getCaptcha
  62. } from "@/api/user";
  63. import {
  64. validatorDefaultCatch
  65. } from "@/utils/dialog";
  66. import attrs, {
  67. required,
  68. alpha_num,
  69. chs_phone
  70. } from "@/utils/validate";
  71. export default {
  72. name: "RetrievePassword",
  73. mixins: [sendVerifyCode],
  74. data: function() {
  75. return {
  76. account: "",
  77. password: "",
  78. confirm_pwd: "",
  79. captcha: "",
  80. codeKey: "",
  81. codeUrl: "",
  82. codeVal: "",
  83. isShowCode: false,
  84. logoUrl: "",
  85. };
  86. },
  87. onReady() {
  88. uni.$on('update', (data) => {
  89. this.logoUrl = data.login_logo
  90. })
  91. },
  92. mounted: function() {
  93. this.$nextTick(() => {
  94. this.logoUrl = app.globalData.login_logo
  95. });
  96. },
  97. methods: {
  98. back() {
  99. uni.navigateBack();
  100. },
  101. again() {
  102. this.codeUrl =
  103. VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date());
  104. console.log(this.codeUrl);
  105. },
  106. async code() {
  107. let that = this;
  108. // that.sendCode();
  109. if (!that.account) return that.$util.Tips({
  110. title: '请填写手机号码'
  111. });
  112. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  113. title: '请输入正确的手机号码'
  114. });
  115. await registerVerify({
  116. phone: that.account,
  117. type: 'change_pwd',
  118. key: that.codeKey,
  119. code: that.codeVal,
  120. })
  121. .then(res => {
  122. that.$util.Tips({
  123. title: res.message
  124. });
  125. that.sendCode();
  126. }).catch(res => {
  127. console.log(res, 'res')
  128. that.getcaptcha();
  129. that.$util.Tips({
  130. title: res
  131. });
  132. });
  133. },
  134. getcaptcha() {
  135. let that = this
  136. getCaptcha().then(data => {
  137. that.codeUrl = data.data.captcha; //图片路径
  138. that.codeVal = data.data.code; //图片验证码
  139. that.codeKey = data.data.key //图片验证码key
  140. })
  141. that.isShowCode = true;
  142. },
  143. async registerReset() {
  144. var that = this;
  145. if (!that.account) return that.$util.Tips({
  146. title: '请填写手机号码'
  147. });
  148. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  149. title: '请输入正确的手机号码'
  150. });
  151. if (that.password == '123456') return that.$util.Tips({
  152. title: '您输入的密码过于简单'
  153. });
  154. if (that.password != that.confirm_pwd) return that.$util.Tips({
  155. title: '两次密码不一致'
  156. });
  157. if (!that.captcha) return that.$util.Tips({
  158. title: '请填写验证码'
  159. });
  160. registerForget({
  161. phone: that.account,
  162. sms_code: that.captcha,
  163. pwd: that.password,
  164. confirm_pwd: that.confirm_pwd
  165. })
  166. .then(res => {
  167. that.$util.Tips({
  168. title: res.msg
  169. }, {
  170. tab: 3
  171. })
  172. })
  173. .catch(res => {
  174. that.$util.Tips({
  175. title: res
  176. })
  177. });
  178. },
  179. }
  180. };
  181. </script>
  182. <style scoped>
  183. .code img {
  184. width: 100%;
  185. height: 100%;
  186. }
  187. </style>