Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

210 lignes
7.3 KiB

  1. <template>
  2. <div class="app-container calendar-list-container">
  3. <basic-container>
  4. <template>
  5. <el-row>
  6. <el-form
  7. ref="ruleForm"
  8. :model="ruleForm"
  9. :rules="rules"
  10. label-width="100px"
  11. class="demo-ruleForm"
  12. >
  13. <el-col :span="12">
  14. <div class="grid-content bg-purple">
  15. <!-- <el-form-item label="头像">
  16. <el-upload
  17. :headers="headers"
  18. :show-file-list="false"
  19. :on-success="handleAvatarSuccess"
  20. class="avatar-uploader"
  21. action="/admin/sys-file/upload"
  22. >
  23. <img v-if="ruleForm.avatar" id="avatar" :src="avatarUrl" class="avatar" />
  24. <i v-else class="el-icon-plus avatar-uploader-icon" />
  25. </el-upload>
  26. </el-form-item> -->
  27. <el-form-item label="用户名" prop="username">
  28. <el-input v-model="ruleForm.username" type="text" disabled />
  29. </el-form-item>
  30. <el-form-item label="手机号" prop="phone">
  31. <el-input v-model="ruleForm.phone" disabled placeholder="验证码登录使用" />
  32. </el-form-item>
  33. <!--
  34. <el-form-item label="社交登录" prop="social">
  35. <a href="#" class="icon-weixin1" @click="handleClick('wechat')"></a>|
  36. <a href="#" class="icon-qq" @click="handleClick('tencent')"></a> |
  37. <a href="#" class="icon-gitee-fill-round" @click="handleClick('gitee')"></a> |
  38. <a href="#" class="icon-C" @click="handleClick('osc')"></a>
  39. </el-form-item> -->
  40. <el-form-item label="原密码" prop="password">
  41. <el-input v-model="ruleForm.password" type="password" auto-complete="off" />
  42. </el-form-item>
  43. <el-form-item label="新密码" prop="newpassword1">
  44. <el-input v-model="ruleForm.newpassword1" type="password" auto-complete="off" />
  45. </el-form-item>
  46. <el-form-item label="确认密码" prop="newpassword2">
  47. <el-input v-model="ruleForm.newpassword2" type="password" auto-complete="off" />
  48. </el-form-item>
  49. <el-form-item>
  50. <el-button type="primary" @click="submitForm()">提交</el-button>
  51. <el-button @click="resetForm()">重置</el-button>
  52. </el-form-item>
  53. </div>
  54. </el-col>
  55. </el-form>
  56. </el-row>
  57. </template>
  58. </basic-container>
  59. </div>
  60. </template>
  61. <script>
  62. import { handleImg, openWindow } from "@/util/util";
  63. import { mapState } from "vuex";
  64. import store from "@/store";
  65. import { getStore, setStore } from "@/util/store";
  66. import { isValidateNoneMobile } from "@/util/validate";
  67. import { editInfo } from "@/api/admin/user";
  68. export default {
  69. data() {
  70. const validatePhone = (rule, value, callback) => {
  71. if (isValidateNoneMobile(value)[0]) {
  72. callback(new Error(isValidateNoneMobile(value)[1]));
  73. } else {
  74. callback();
  75. }
  76. };
  77. const validatePass = (rule, value, callback) => {
  78. if (this.ruleForm.password !== "") {
  79. if (value !== this.ruleForm.newpassword1) {
  80. callback(new Error("两次输入密码不一致!"));
  81. } else {
  82. callback();
  83. }
  84. } else {
  85. callback();
  86. }
  87. };
  88. return {
  89. avatarUrl: "",
  90. headers: {
  91. Authorization: "Bearer " + store.getters.access_token,
  92. },
  93. ruleForm: {
  94. username: "",
  95. password: "",
  96. newpassword1: "",
  97. newpassword2: "",
  98. avatar: "",
  99. phone: "",
  100. userId:'',
  101. },
  102. rules: {
  103. phone: [{ required: false, validator: validatePhone, trigger: "blur" }],
  104. password: [
  105. {
  106. required: true,
  107. min: 6,
  108. message: "原密码不少于6位",
  109. trigger: "blur",
  110. },
  111. ],
  112. newpassword1: [
  113. {
  114. required: false,
  115. min: 6,
  116. message: "新密码不少于6位",
  117. trigger: "blur",
  118. },
  119. ],
  120. newpassword2: [
  121. { required: false, validator: validatePass, trigger: "blur" },
  122. ],
  123. },
  124. };
  125. },
  126. created() {
  127. this.resetForm();
  128. },
  129. computed: {
  130. ...mapState({
  131. userInfo: (state) => state.user.userInfo,
  132. }),
  133. },
  134. methods: {
  135. submitForm() {
  136. this.$refs.ruleForm.validate((valid) => {
  137. if (!valid) {
  138. return false;
  139. }
  140. this.$api.api.resetPassword({
  141. userId:this.ruleForm.userId,
  142. password:this.ruleForm.newpassword1
  143. }).then((res) => {
  144. // console.log(res);
  145. this.$notify.success("修改成功");
  146. this.$store.dispatch("LogOut").then(() => {
  147. location.reload();
  148. });
  149. });
  150. // editInfo(this.ruleForm).then((response) => {
  151. // this.$notify.success("修改成功");
  152. // // 修改后注销当前token,重新登录
  153. // this.$store.dispatch("LogOut").then(() => {
  154. // location.reload();
  155. // });
  156. // });
  157. });
  158. },
  159. resetForm() {
  160. this.ruleForm.password = undefined;
  161. this.ruleForm.newpassword1 = undefined;
  162. this.ruleForm.newpassword2 = undefined;
  163. this.ruleForm.username = this.userInfo.username;
  164. this.ruleForm.phone = this.userInfo.phone;
  165. this.ruleForm.avatar = this.userInfo.avatar;
  166. this.ruleForm.userId = this.userInfo.userId;
  167. handleImg(this.userInfo.avatar, "avatar");
  168. //判断是否选择了租户ID
  169. const TENANT_ID = getStore({ name: "tenantId" });
  170. if (TENANT_ID) {
  171. this.headers["TENANT-ID"] = TENANT_ID; // 租户ID
  172. }
  173. },
  174. handleAvatarSuccess(res, file) {
  175. this.avatarUrl = URL.createObjectURL(file.raw);
  176. this.ruleForm.avatar = res.data.url;
  177. },
  178. handleClick(thirdpart) {
  179. let appid, client_id, redirect_uri, url;
  180. redirect_uri = encodeURIComponent(
  181. window.location.origin + "/#/authredirect"
  182. );
  183. if (thirdpart === "wechat") {
  184. appid = "wxd1678d3f83b1d83a";
  185. url = `https://open.weixin.qq.com/connect/qrconnect?appid=${appid}&redirect_uri=${redirect_uri}&state=WX-BIND&response_type=code&scope=snsapi_login#wechat_redirect`;
  186. } else if (thirdpart === "tencent") {
  187. client_id = "101322838";
  188. url = `https://graph.qq.com/oauth2.0/authorize?response_type=code&state=QQ-BIND&client_id=${client_id}&redirect_uri=${redirect_uri}`;
  189. } else if (thirdpart === "gitee") {
  190. client_id =
  191. "235ce26bbc59565b82c989aa3a407ce844cf59a7c5e0f9caa9bb3bf32cee5952";
  192. url = `https://gitee.com/oauth/authorize?response_type=code&state=GITEE-BIND&client_id=${client_id}&redirect_uri=${redirect_uri}`;
  193. } else if (thirdpart === "osc") {
  194. client_id = "neIIqlwGsjsfsA6uxNqD";
  195. url = `https://www.oschina.net/action/oauth2/authorize?response_type=code&client_id=${client_id}&state=OSC-BIND&redirect_uri=${redirect_uri}`;
  196. }
  197. openWindow(url, thirdpart, 540, 540);
  198. },
  199. },
  200. };
  201. </script>
  202. <style lang="scss">
  203. @import "@/styles/info.scss";
  204. </style>