changePassword.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <!-- 修改密码 -->
  3. <div class="changePassword flex-col">
  4. <s-header :name="$t('changePassword.changePassword')" :noback="false"></s-header>
  5. <div class="changePasswordFormBox">
  6. <van-form @submit="changePasswordSubmit">
  7. <van-field v-model="password" name="password" type="password" :label="$t('changePassword.passwordLabel')"
  8. :placeholder="$t('changePassword.passwordPlaceholder')"
  9. :rules="[{ required: true, message: $t('changePassword.passwordRequired') }]" />
  10. <van-field v-model="passwordCheck" name="passwordCheck" type="password"
  11. :label="$t('changePassword.passwordCheckLabel')" :placeholder="$t('changePassword.passwordCheckPlaceholder')"
  12. :rules="[{ required: true, message: $t('changePassword.passwordCheckRequired') }]" />
  13. <van-button round type="primary" class="register" native-type="submit">{{ $t('changePassword.registerButton') }}
  14. </van-button>
  15. </van-form>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import md5 from 'js-md5';
  21. import { ref } from 'vue';
  22. import { Toast } from 'vant';
  23. import sHeader from "@/components/SimpleHeader";
  24. // import { useRouter, useRoute } from "vue-router";
  25. import { useRouter} from "vue-router";
  26. import { updatePassword } from '@/service/changePassword';
  27. import { useI18n } from 'vue-i18n';
  28. import { getLoginUser } from "@/common/js/utils";
  29. export default {
  30. setup() {
  31. // 引入语言
  32. const { t } = useI18n();
  33. const router = useRouter();
  34. // const route = useRoute();
  35. const user = getLoginUser();
  36. const password = ref('');
  37. const passwordCheck = ref('');
  38. // 验证-表单
  39. const changePasswordSubmit = async () => {
  40. if (password.value !== passwordCheck.value) {
  41. Toast.fail(t('changePassword.inconsistentPasswords'));
  42. return false;
  43. }
  44. const { data } = await updatePassword({
  45. // username: route.query.name,
  46. username: user.username,
  47. password: md5(password.value)
  48. });
  49. if (data.code === '00000') {
  50. Toast(t('changePassword.pwdEditSucess'));
  51. router.push({ path: '/login' });
  52. } else {
  53. Toast.fail(data.message);
  54. }
  55. };
  56. return {
  57. password,
  58. passwordCheck,
  59. changePasswordSubmit
  60. };
  61. },
  62. components: { sHeader },
  63. };
  64. </script>
  65. <style lang="less" scoped>
  66. @import "../common/style/mixin";
  67. .changePassword {
  68. .changePasswordFormBox {
  69. width: 313px;
  70. margin: 0 auto;
  71. text-align: center;
  72. .van-form {
  73. .van-cell {
  74. width: 313px;
  75. height: 38px;
  76. background-color: rgba(255, 255, 255, 1);
  77. padding: 0;
  78. color: rgba(168, 168, 197, 1);
  79. font-size: 13px;
  80. margin: 0 auto;
  81. margin-top: 20px;
  82. overflow: visible;
  83. &::after {
  84. display: none;
  85. }
  86. .van-field__control {
  87. height: 38px;
  88. line-height: 38px;
  89. padding: 6px;
  90. border-radius: 2px;
  91. border: 0.5px solid rgba(185, 186, 208, 1);
  92. &:-internal-autofill-previewed,
  93. &:-internal-autofill-selected {
  94. -webkit-text-fill-color: #323233 !important;
  95. transition: background-color 5000s ease-in-out 0s !important;
  96. }
  97. }
  98. .van-field__control::-webkit-input-placeholder {
  99. color: rgba(168, 168, 197, 1);
  100. }
  101. .van-cell__value {
  102. width: 100%;
  103. flex: 0 auto;
  104. }
  105. .van-field__label {
  106. height: 38px;
  107. line-height: 38px;
  108. width: 5em;
  109. }
  110. .radioBox {
  111. display: flex;
  112. .van-radio-group--horizontal {
  113. width: 100%;
  114. justify-content: space-around;
  115. }
  116. .van-radio {
  117. overflow: visible;
  118. }
  119. .van-radio__icon {
  120. font-size: 13px;
  121. .van-icon {
  122. width: 12px;
  123. height: 12px;
  124. border-color: #4d6add;
  125. }
  126. }
  127. .van-radio__label {
  128. line-height: 13px;
  129. }
  130. .van-radio__icon--checked .van-icon-success {
  131. border-color: #4d6add;
  132. background: #4d6add;
  133. }
  134. .van-radio__icon--checked .van-icon-success::before {
  135. content: '';
  136. background: #fff;
  137. width: 40%;
  138. height: 40%;
  139. position: absolute;
  140. top: 30%;
  141. left: 30%;
  142. border-radius: 100%;
  143. }
  144. .van-radio__icon--checked+.van-radio__label {
  145. color: #4d6add;
  146. }
  147. }
  148. }
  149. }
  150. .info2 {
  151. height: 13px;
  152. overflow-wrap: break-word;
  153. color: rgba(64, 77, 116, 1);
  154. font-size: 13px;
  155. text-align: left;
  156. white-space: nowrap;
  157. line-height: 13px;
  158. display: block;
  159. margin: 34px 0 0 0;
  160. }
  161. .word2 {
  162. height: 13px;
  163. overflow-wrap: break-word;
  164. color: rgba(64, 77, 116, 1);
  165. font-size: 13px;
  166. text-align: left;
  167. white-space: nowrap;
  168. line-height: 13px;
  169. display: block;
  170. margin: 14px 0 0 0;
  171. }
  172. .register {
  173. background-color: rgba(77, 106, 221, 1);
  174. border-radius: 17px;
  175. height: 34px;
  176. width: 220px;
  177. margin-top: 60px;
  178. font-size: 15px;
  179. font-family: PingFangSC-Medium;
  180. }
  181. }
  182. }
  183. </style>