findPassword.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="bg-F5">
  3. <div class="topDiv">
  4. <div class="container">
  5. <span class="title">{{ $t("title") }}</span>
  6. <span class="line"></span>
  7. <span class="info">{{
  8. $t("page.views.account.findPassword.title")
  9. }}</span>
  10. </div>
  11. </div>
  12. <div class="bg">
  13. <div class="container ">
  14. <img :src="require(`@assets/loginbg_${$i18n.locale}.png`)" />
  15. <div class="loginDiv">
  16. <div class="x-title">
  17. {{ $t("page.views.account.findPassword.title") }}
  18. </div>
  19. <el-form :model="form" :rules="rules" class="form" ref="form">
  20. <el-form-item class="formItem" prop="loginAccount">
  21. <img class="icon" src="@assets/user.png" alt="" />
  22. <el-input
  23. v-model="form.loginAccount"
  24. prefix-icon="x-el-icon-user"
  25. :placeholder="
  26. `${$t(`inputPlaceholder`)}${$t(`form.loginAccount`)}`
  27. "
  28. />
  29. </el-form-item>
  30. <el-form-item class="formItem" prop="phone">
  31. <img class="icon" src="@assets/phone.png" alt="" />
  32. <el-input
  33. v-model="form.phone"
  34. prefix-icon="x-el-icon-lock"
  35. :placeholder="`${$t(`inputPlaceholder`)}${$t(`form.phone`)}`"
  36. />
  37. </el-form-item>
  38. <el-form-item class="formItem yzm" prop="validateCode">
  39. <img class="icon" src="@assets/yz.png" alt="" />
  40. <el-input
  41. v-model="form.validateCode"
  42. prefix-icon="icon-yzm"
  43. :placeholder="
  44. `${$t(`inputPlaceholder`)}${$t(`form.validateCode`)}`
  45. "
  46. />
  47. <div class="getyzm">{{ $t("form.getValidateCode") }}</div>
  48. </el-form-item>
  49. <el-form-item class="formItem" prop="loginPassword">
  50. <img class="icon" src="@assets/lock.png" alt="" />
  51. <el-input
  52. v-model="form.loginPassword"
  53. prefix-icon="x-el-icon-lock"
  54. :placeholder="
  55. `${$t(`inputPlaceholder`)}${$t(
  56. `page.views.account.findPassword.loginPassword`
  57. )}`
  58. "
  59. show-password
  60. />
  61. </el-form-item>
  62. <el-button class="loginBtn" @click="validate">{{
  63. $t("page.views.account.findPassword.submit")
  64. }}</el-button>
  65. </el-form>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script lang="ts">
  72. import { Component, Vue, Watch } from "vue-property-decorator";
  73. import user from "@/store/modules/user";
  74. import { RegAccount } from "@/utils";
  75. import { ElForm } from "element-ui/types/form";
  76. import i18n from "@/lang";
  77. @Component
  78. export default class extends Vue {
  79. private verifyImg = "";
  80. private form = {
  81. loginAccount: "",
  82. loginPassword: "",
  83. validateCode: "",
  84. phone: ""
  85. };
  86. private rules = {
  87. loginAccount: [
  88. {
  89. required: true,
  90. message: `${i18n.t(`inputPlaceholder`)}${i18n.t(`form.loginAccount`)}`,
  91. trigger: "blur"
  92. },
  93. {
  94. validator: (rule: any, value: string, callback: any) =>
  95. callback(
  96. RegAccount.test(value)
  97. ? undefined
  98. : new Error(`${i18n.t("form.RegAccount")}`)
  99. ),
  100. trigger: "blur"
  101. }
  102. ],
  103. loginPassword: [
  104. {
  105. required: true,
  106. message: `${i18n.t(`inputPlaceholder`)}${i18n.t(
  107. `page.views.account.findPassword.loginPassword`
  108. )}`,
  109. trigger: "blur"
  110. },
  111. {
  112. validator: (rule: any, value: string, callback: any) =>
  113. callback(
  114. RegAccount.test(value)
  115. ? undefined
  116. : new Error(`${i18n.t("form.RegAccount")}`)
  117. ),
  118. trigger: "blur"
  119. }
  120. ],
  121. phone: [
  122. {
  123. required: true,
  124. message: `${i18n.t(`inputPlaceholder`)}${i18n.t(`form.phone`)}`,
  125. trigger: "blur"
  126. },
  127. {
  128. validator: (rule: any, value: string, callback: any) =>
  129. callback(
  130. /^1[3|4|5|7|8][0-9]\d{8}$/.test(value)
  131. ? undefined
  132. : new Error(`${i18n.t("form.validatePhone")}`)
  133. ),
  134. trigger: "blur"
  135. }
  136. ],
  137. validateCode: [
  138. {
  139. required: true,
  140. message: `${i18n.t(`inputPlaceholder`)}${i18n.t(`form.validateCode`)}`,
  141. trigger: "blur"
  142. }
  143. ]
  144. };
  145. validate() {
  146. (this.$refs.form as ElForm).validate(x => x && this.submit());
  147. }
  148. async submit() {
  149. const [err] = await this.$post("/member/info/resetPassword", this.form);
  150. if (err) return;
  151. this.$message.success(`${this.$i18n.t("message.success.findPassword")}`);
  152. (this.$refs.form as ElForm).resetFields();
  153. this.$router.push("/login");
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .bg-F5 {
  159. .topDiv {
  160. height: 9rem;
  161. line-height: 9rem;
  162. background: #fff;
  163. .title {
  164. font-size: 2.2rem;
  165. font-weight: bold;
  166. color: #fd5522;
  167. }
  168. .line {
  169. display: inline-block;
  170. height: 3rem;
  171. width: 0.1rem;
  172. background: #e5e5e5;
  173. margin: 0 2rem;
  174. vertical-align: middle;
  175. }
  176. .info {
  177. font-size: 1.8rem;
  178. font-weight: bold;
  179. color: #666;
  180. }
  181. }
  182. .bg {
  183. background: #84ccc9;
  184. padding: 75px 0;
  185. .container {
  186. overflow: hidden;
  187. > img {
  188. margin-left: 180px;
  189. margin-top: 50px;
  190. float: left;
  191. }
  192. .loginDiv {
  193. // width: 320px;
  194. // height: 338px;
  195. overflow: hidden;
  196. margin-left: 218px;
  197. float: left;
  198. background: #fff;
  199. box-sizing: border-box;
  200. border-radius: 0.4rem;
  201. box-shadow: 2px 2px 12px #ddd;
  202. .x-title {
  203. margin-top: 20px;
  204. }
  205. .form {
  206. padding: 15px 20px;
  207. .formItem {
  208. height: 40px;
  209. line-height: 40px;
  210. box-sizing: border-box;
  211. border-radius: 4px;
  212. margin-bottom: 20px;
  213. position: relative;
  214. .icon {
  215. position: absolute;
  216. left: 10px;
  217. top: 50%;
  218. transform: translateY(-50%);
  219. z-index: 1;
  220. width: 12px;
  221. }
  222. }
  223. .loginBtn {
  224. width: 100%;
  225. background: #fd5522;
  226. color: #fff;
  227. border-color: #fd5522;
  228. }
  229. }
  230. }
  231. .getyzm {
  232. height: 40px;
  233. line-height: 40px;
  234. width: 100px;
  235. font-size: 14px;
  236. color: #fd5522;
  237. text-align: center;
  238. float: right;
  239. background: #ffded5;
  240. border-radius: 0.4rem;
  241. cursor: pointer;
  242. }
  243. .xieyi {
  244. color: #fd5522;
  245. }
  246. }
  247. }
  248. }
  249. </style>
  250. <style lang="scss">
  251. .formItem.yzm {
  252. .el-input {
  253. width: 200px;
  254. }
  255. .verifyImg {
  256. height: 40px;
  257. width: 108px;
  258. margin-left: 10px;
  259. vertical-align: middle;
  260. }
  261. }
  262. </style>