You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

292 line
8.9 KiB

  1. <template>
  2. <el-form
  3. ref="loginForm"
  4. :rules="loginRules"
  5. :model="loginForm"
  6. class="login-form"
  7. status-icon
  8. label-width="0"
  9. >
  10. <el-form-item prop="username">
  11. <el-input
  12. v-model="loginForm.username"
  13. size="small"
  14. auto-complete="new-password"
  15. placeholder="请输入用户名"
  16. maxlength="11"
  17. @keyup.enter.native="handleLogin"
  18. >
  19. <i slot="prefix" style="color:#2671E2;" class="icon-yonghuming" />
  20. </el-input>
  21. </el-form-item>
  22. <el-form-item prop="password">
  23. <el-input
  24. :type="passwordType"
  25. v-model="loginForm.password"
  26. size="small"
  27. auto-complete="new-password"
  28. placeholder="请输入密码"
  29. @keyup.enter.native="handleLogin"
  30. >
  31. <i
  32. slot="suffix"
  33. style="color:#2671E2;"
  34. class="el-icon-view el-input__icon"
  35. @click="showPassword"
  36. />
  37. <i slot="prefix" style="color:#2671E2;" class="icon-mima"></i>
  38. </el-input>
  39. </el-form-item>
  40. <el-form-item prop="code">
  41. <Verify
  42. @success="verifySuccess"
  43. :mode="'pop'"
  44. :captchaType="'blockPuzzle'"
  45. :imgSize="{ width: '330px', height: '155px' }"
  46. ref="verify"
  47. />
  48. </el-form-item>
  49. <el-form-item>
  50. <el-button
  51. type="primary"
  52. size="small"
  53. style="font-size:16px; background:#2671E2; border-color: #2671E2;"
  54. class="login-submit"
  55. @click.native.prevent="handleLogin"
  56. >登录</el-button
  57. >
  58. </el-form-item>
  59. </el-form>
  60. </template>
  61. <script>
  62. import { randomLenNum } from "@/util/util";
  63. import { mapGetters } from "vuex";
  64. import { getCode } from "@/api/code";
  65. import Verify from "@/components/verifition/Verify";
  66. import { getStore, setStore } from "@/util/store";
  67. export default {
  68. name: "Userlogin",
  69. components: {
  70. Verify,
  71. },
  72. data() {
  73. return {
  74. socialForm: {
  75. code: "",
  76. state: "",
  77. },
  78. info:{},
  79. loginForm: {
  80. username: "admin",
  81. password: "123456",
  82. code: "",
  83. randomStr: "blockPuzzle",
  84. },
  85. checked: false,
  86. code: {
  87. src: undefined,
  88. len: 4,
  89. },
  90. loginRules: {
  91. username: [
  92. { required: true, message: "请输入用户名", trigger: "blur" },
  93. ],
  94. password: [
  95. { required: true, message: "请输入密码", trigger: "blur" },
  96. { min: 6, message: "密码长度最少为6位", trigger: "blur" },
  97. ],
  98. },
  99. passwordType: "password",
  100. };
  101. },
  102. computed: {
  103. ...mapGetters(["tagWel"]),
  104. },
  105. methods: {
  106. showPassword() {
  107. this.passwordType == ""
  108. ? (this.passwordType = "password")
  109. : (this.passwordType = "");
  110. },
  111. handleLogin() {
  112. this.$refs.loginForm.validate((valid) => {
  113. if (valid) {
  114. this.$refs.verify.show();
  115. }
  116. });
  117. },
  118. verifySuccess(params) {
  119. let that = this;
  120. this.loginForm.code = params.captchaVerification;
  121. this.$store.dispatch("LoginByUsername", this.loginForm).then(() => {
  122. // this.$router.push({ path: this.tagWel.value });
  123. this.info = getStore({ name: "userInfo" });
  124. localStorage.setItem('allClose',false)
  125. that.$api.api.getTab().then((res) => {
  126. // console.log(res)
  127. // 循环数组,给定各种标志
  128. if (res.data.length == 0) {
  129. // this.$message.warning("您已经被禁用");
  130. this.$message.warning("账号已禁止登录,请联系管理员恢复");
  131. } else if (res.data.length == 1) {
  132. let idx = res.data[0].orgType;
  133. localStorage.setItem("orgType", idx);
  134. // 给定一个判断是否可以跳转的东西
  135. localStorage.setItem("backFlag", false);
  136. // 当他只有质控后台时,不需要多余操作
  137. if (idx == 0) {
  138. // 质控管家后台
  139. localStorage.setItem("topName", "");
  140. localStorage.setItem("orgCode", "");
  141. localStorage.setItem("houseId", "");
  142. localStorage.setItem("agentId", "");
  143. that.$router.push({ path: "/wel" });
  144. }
  145. // 当他为其他时 先获取是否只有一个选项,然后在来进行判断
  146. if (idx == 1) {
  147. this.getAgentList();
  148. // 代理商
  149. // that.$router.push({ path: "/chose", query: { flag: 1 } });
  150. }
  151. if (idx == 2) {
  152. this.getCompanyList();
  153. // 公司后台
  154. // that.$router.push({ path: "/chose", query: { flag: 2 } });
  155. }
  156. if (idx == 3) {
  157. this.findByUserName();
  158. // 楼盘后台
  159. // that.$router.push({ path: "/chose", query: { flag: 3 } });
  160. }
  161. } else {
  162. that.$router.push({ path: "/check" });
  163. }
  164. });
  165. });
  166. },
  167. // 获取代理商
  168. getAgentList() {
  169. this.$api.api
  170. .zkagentPage({
  171. current: 1,
  172. pageSize: 10,
  173. })
  174. .then((res) => {
  175. // console.log(res);
  176. // this.list = res.data.records;
  177. // this.total = res.data.total;
  178. if (res.data.total == 0) {
  179. this.$message.warning("您当前并未绑定楼盘");
  180. return;
  181. } else if (res.data.total > 1) {
  182. // 公司后台
  183. this.$router.push({ path: "/chose", query: { flag: 1 } });
  184. } else {
  185. this.$router.push({ path: "/wel" });
  186. localStorage.setItem("topName", res.data.records[0].agentName);
  187. localStorage.setItem("agentId", res.data.records[0].id);
  188. localStorage.setItem("orgCode", "");
  189. localStorage.setItem("houseId", "");
  190. }
  191. });
  192. },
  193. getCompanyList() {
  194. this.$api.api
  195. .zkorg({
  196. current: 1,
  197. size: 10,
  198. name: this.companyName,
  199. orgType: localStorage.getItem("orgType"),
  200. })
  201. .then((res) => {
  202. // console.log(res);
  203. // this.list = res.data.records;
  204. // this.total = res.data.total;
  205. if (res.data.total == 0) {
  206. this.$message.warning("您当前并未绑定楼盘");
  207. return;
  208. } else if (res.data.total > 1) {
  209. // 公司后台
  210. this.$router.push({ path: "/chose", query: { flag: 2 } });
  211. } else {
  212. this.$router.push({ path: "/wel" });
  213. localStorage.setItem("topName", res.data.records[0].name);
  214. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  215. localStorage.setItem("agentId", "");
  216. localStorage.setItem("houseId", "");
  217. }
  218. });
  219. },
  220. findByUserName() {
  221. this.$api.api
  222. .findByUserName({
  223. username: this.info.username,
  224. })
  225. .then((res) => {
  226. // console.log(res);
  227. this.info.selectHouseType = res.selectHouseType;
  228. // 获取楼盘
  229. this.zkhousePage();
  230. });
  231. },
  232. zkhousePage() {
  233. let obj = {
  234. current: 1,
  235. size: 10,
  236. orgType: localStorage.getItem("orgType"),
  237. };
  238. if (this.info.selectHouseType == 1) {
  239. this.$api.api.zkhousePage(obj).then((res) => {
  240. // console.log(res)
  241. // this.list = res.data.records;
  242. // this.total = res.data.total;
  243. if (res.data.total == 0) {
  244. this.$message.warning("您当前并未绑定楼盘");
  245. return;
  246. } else if (res.data.total > 1) {
  247. // 公司后台
  248. this.$router.push({ path: "/chose", query: { flag: 3 } });
  249. } else {
  250. this.$router.push({ path: "/wel" });
  251. localStorage.setItem("topName", res.data.records[0].propertyName);
  252. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  253. localStorage.setItem("agentId", "");
  254. localStorage.setItem("houseId", res.data.records[0].id);
  255. }
  256. });
  257. }
  258. if (this.info.selectHouseType == 2) {
  259. this.$api.api
  260. .findHouseByArea({
  261. id: null,
  262. ...obj,
  263. })
  264. .then((res) => {
  265. // console.log(res)
  266. // this.list = res.data.records;
  267. // this.total = res.data.total;
  268. if (res.data.total == 0) {
  269. this.$message.warning("您当前并未绑定楼盘");
  270. return;
  271. } else if (res.data.total > 1) {
  272. // 公司后台
  273. this.$router.push({ path: "/chose", query: { flag: 3 } });
  274. } else {
  275. this.$router.push({ path: "/wel" });
  276. localStorage.setItem("topName", res.data.records[0].propertyName);
  277. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  278. localStorage.setItem("houseId", res.data.records[0].id);
  279. localStorage.setItem("agentId", "");
  280. }
  281. });
  282. }
  283. },
  284. },
  285. };
  286. </script>
  287. <style>
  288. </style>