25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

317 satır
9.7 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. if(res.data.records[0].lockFlag!=0){
  186. this.$message.warning("您已经被禁用");
  187. return
  188. }
  189. this.$router.push({ path: "/wel" });
  190. localStorage.setItem("topName", res.data.records[0].agentName);
  191. localStorage.setItem("agentId", res.data.records[0].id);
  192. localStorage.setItem("orgCode", "");
  193. localStorage.setItem("houseId", "");
  194. }
  195. });
  196. },
  197. getCompanyList() {
  198. this.$api.api
  199. .zkorg({
  200. current: 1,
  201. size: 10,
  202. name: this.companyName,
  203. orgType: localStorage.getItem("orgType"),
  204. })
  205. .then((res) => {
  206. // console.log(res);
  207. // this.list = res.data.records;
  208. // this.total = res.data.total;
  209. if (res.data.total == 0) {
  210. this.$message.warning("您当前并未绑定楼盘");
  211. return;
  212. } else if (res.data.total > 1) {
  213. // 公司后台
  214. this.$router.push({ path: "/chose", query: { flag: 2 } });
  215. } else {
  216. if(res.data.records[0].lockFlag!=0){
  217. this.$message.warning("您已经被禁用");
  218. return
  219. }
  220. this.$router.push({ path: "/wel" });
  221. localStorage.setItem("topName", res.data.records[0].name);
  222. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  223. localStorage.setItem("agentId", "");
  224. localStorage.setItem("houseId", "");
  225. }
  226. });
  227. },
  228. findByUserName() {
  229. this.$api.api
  230. .findByUserName({
  231. username: this.info.username,
  232. })
  233. .then((res) => {
  234. // console.log(res);
  235. this.info.selectHouseType = res.selectHouseType;
  236. // 获取楼盘
  237. this.zkhousePage();
  238. });
  239. },
  240. zkhousePage() {
  241. let obj = {
  242. current: 1,
  243. size: 10,
  244. orgType: localStorage.getItem("orgType"),
  245. };
  246. if (this.info.selectHouseType == 1) {
  247. this.$api.api.zkhousePage(obj).then((res) => {
  248. // console.log(res)
  249. // this.list = res.data.records;
  250. // this.total = res.data.total;
  251. if (res.data.total == 0) {
  252. this.$message.warning("您当前并未绑定楼盘");
  253. return;
  254. } else if (res.data.total > 1) {
  255. // 公司后台
  256. this.$router.push({ path: "/chose", query: { flag: 3 } });
  257. } else {
  258. if(res.data.records[0].lockFlag!=0){
  259. this.$message.warning("您已经被禁用");
  260. return
  261. }
  262. this.$router.push({ path: "/wel" });
  263. localStorage.setItem("topName", res.data.records[0].propertyName);
  264. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  265. localStorage.setItem("agentId", "");
  266. localStorage.setItem("houseId", res.data.records[0].id);
  267. this.addLoginCount(res.data.records[0].id)
  268. }
  269. });
  270. }
  271. if (this.info.selectHouseType == 2) {
  272. this.$api.api
  273. .findHouseByArea({
  274. id: null,
  275. ...obj,
  276. })
  277. .then((res) => {
  278. // console.log(res)
  279. // this.list = res.data.records;
  280. // this.total = res.data.total;
  281. if (res.data.total == 0) {
  282. this.$message.warning("您当前并未绑定楼盘");
  283. return;
  284. } else if (res.data.total > 1) {
  285. // 公司后台
  286. this.$router.push({ path: "/chose", query: { flag: 3 } });
  287. } else {
  288. if(res.data.records[0].lockFlag!=0){
  289. this.$message.warning("您已经被禁用");
  290. return
  291. }
  292. this.$router.push({ path: "/wel" });
  293. localStorage.setItem("topName", res.data.records[0].propertyName);
  294. localStorage.setItem("orgCode", res.data.records[0].orgCode);
  295. localStorage.setItem("houseId", res.data.records[0].id);
  296. localStorage.setItem("agentId", "");
  297. this.addLoginCount(res.data.records[0].id)
  298. }
  299. });
  300. }
  301. },
  302. addLoginCount(houseId){
  303. this.$api.api.addLoginCount({
  304. houseId
  305. }).then(res=>{
  306. console.log(res);
  307. })
  308. },
  309. },
  310. };
  311. </script>
  312. <style>
  313. </style>