Просмотр исходного кода

更新 备案信息;登录样式及参数逻辑

wzh 3 лет назад
Родитель
Сommit
23170e7a7c
1 измененных файлов с 199 добавлено и 118 удалено
  1. 199 118
      src/views/index/Login.vue

+ 199 - 118
src/views/index/Login.vue

@@ -6,7 +6,14 @@
       </div>
       <div class="right">
         <div class="title">
-          <div class="title-left">浙江物产</div>
+          <img
+            class="title-logo"
+            :src="cargoOwners[currentCompanyLevelTwo]?.logoUrl"
+            alt=""
+          />
+          <div class="title-left">
+            {{ cargoOwners[currentCompanyLevelTwo]?.cargoOwner }}
+          </div>
           <div class="title-mid">丨</div>
           <div class="title-right">智慧航运管理平台</div>
         </div>
@@ -68,12 +75,12 @@
     </div>
 
     <div @click="goBeian" class="copyright">
-      Copyright © 2021 河南省汇很多科技有限公司 豫ICP备 2021029101 号
+      Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
     </div>
   </div>
 </template>
-<script>
-import { ref, reactive, toRefs, computed } from "vue";
+<script setup>
+import { ref, reactive, toRefs, computed, onMounted } from "vue";
 import { ElNotification } from "element-plus";
 import store from "../../store";
 import router from "../../router";
@@ -81,112 +88,188 @@ import router from "../../router";
 import md5 from "md5";
 import api from "../../apis/fetch";
 
-export default {
-  setup() {
-    const form = ref(null);
-    const ruleForm = reactive({
-      ruleForm: {
-        phone: "",
-        password: "",
-      },
-    });
+const form = ref(null);
+let ruleForm = ref({
+  phone: "",
+  password: "",
+});
 
-    const rules = reactive({
-      rules: {
-        phone: [
-          { required: true, message: "请输入手机号", trigger: "blur" },
-          { min: 11, max: 11, message: "请正确输入手机号", trigger: "blur" },
-        ],
-        password: [
-          { required: true, message: "请输入密码", trigger: "blur" },
-          { min: 6, max: 20, message: "请正确输入手机号", trigger: "blur" },
-        ],
-      },
-    });
-    function check() {
-      // form.value.validate((valid) => {});
-    }
-    function login() {
-      form.value.validate(async (valid) => {
-        if (valid) {
-          let { phone, password } = ruleForm.ruleForm;
-          let res = await api.staffLogin({
-            phone,
-            // password: md5(password).toUpperCase(),
-            password,
-            // cargoOwnerId: 31,
-          });
-          if (res.data.status == 0) {
-            let {
-              userId,
-              userName,
-              phone,
-              contactName,
-              loginAccountId,
-              rolePermission,
-            } = res.data.result;
-            if (!rolePermission.length) {
-              ElNotification.error({
-                title: "失败",
-                duration: 2000,
-                message: "暂无权限,请联系管理员",
-                type: "error",
-              });
-              return;
-            }
-            ElNotification.success({
-              title: "成功",
-              duration: 2000,
-              message: res.data.msg,
-              type: "success",
-            });
-            localStorage.setItem("userId", userId);
-            localStorage.setItem("userName", userName);
-            localStorage.setItem("phone", phone);
-            localStorage.setItem("contactName", contactName);
-            localStorage.setItem("userType", 1);
-            localStorage.setItem("loginAccountId", loginAccountId);
-            rolePermission = rolePermission || [];
-            let arr = [...new Set([...rolePermission])];
-            localStorage.setItem("rolePermission", arr);
-            store.dispatch(
-              "GetBasePermissionData",
-              localStorage.loginAccountId
-            );
-            let res1 = await store.dispatch(
-              "GetUserPermission",
-              localStorage.loginAccountId
-            );
+const rules = ref({
+  phone: [
+    { required: true, message: "请输入手机号", trigger: "blur" },
+    { min: 11, max: 11, message: "请正确输入手机号", trigger: "blur" },
+  ],
+  password: [
+    { required: true, message: "请输入密码", trigger: "blur" },
+    { min: 6, max: 20, message: "请正确输入手机号", trigger: "blur" },
+  ],
+});
+function check() {
+  // form.value.validate((valid) => {});
+}
+let cargoOwners = ref({
+  // 嘉吉
+  cargill: {
+    cargoOwner: "嘉吉粮油",
+    cargoOwnerId: 1,
+    logoUrl:
+      "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/jjly.jpg",
+  },
 
-            router.replace({ path: store.state.menuData[0]?.items[0].path });
-            store.commit("changeLogin", true);
-          } else {
-            ElNotification.error({
-              title: "错误",
-              duration: 3000,
-              message: res.data.msg,
-            });
-          }
-        } else {
-          console.log("error submit!!");
-          return false;
-        }
+  // 路易达孚
+  lydf: {
+    cargoOwner: "路易达孚",
+    cargoOwnerId: 2,
+    logoUrl:
+      "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/lydf-web/lydf-logo.png",
+  },
+
+  // 泰兴邦基
+  bunge: {
+    cargoOwner: "泰兴邦基",
+    cargoOwnerId: 3,
+    logoUrl:
+      "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/bunge.jpg",
+  },
+
+  // 双胞胎
+  twins: {
+    cargoOwnerId: 4,
+    logoUrl: "",
+  },
+
+  // 东海粮油
+  dhly: {
+    cargoOwner: "东海粮油",
+
+    cargoOwnerId: 5,
+    logoUrl:
+      "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/%E4%B8%9C%E6%B5%B7%E7%B2%AE%E6%B2%B9/dhly.png",
+  },
+
+  // 中储粮
+  zcl: {
+    cargoOwnerId: 6,
+    logoUrl: "",
+  },
+  // 物产
+  wuchan: {
+    cargoOwner: "物产",
+    cargoOwnerId: 7,
+    logoUrl:
+      "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/wuchan3.jpg",
+  },
+
+  // 浙江粮贸
+  zjlm: {
+    cargoOwnerId: 8,
+    logoUrl: "",
+  },
+
+  // 货主公司
+  cargo: {
+    cargoOwnerId: 9,
+    logoUrl: "",
+  },
+
+  // 浙江粮海
+  zjlh: {
+    cargoOwnerId: 10,
+    logoUrl: "",
+  },
+});
+function login() {
+  form.value.validate(async (valid) => {
+    if (valid) {
+      let { phone, password } = ruleForm.value;
+      let res = await api.staffLogin({
+        phone,
+        // password: md5(password).toUpperCase(),
+        password,
+        cargoOwnerId: cargoOwners.value[currentCompanyLevelTwo.value],
       });
+      if (res.data.status == 0) {
+        let {
+          userId,
+          userName,
+          phone,
+          contactName,
+          loginAccountId,
+          rolePermission,
+        } = res.data.result;
+        if (!rolePermission.length) {
+          ElNotification.error({
+            title: "失败",
+            duration: 2000,
+            message: "暂无权限,请联系管理员",
+            type: "error",
+          });
+          return;
+        }
+        ElNotification.success({
+          title: "成功",
+          duration: 2000,
+          message: res.data.msg,
+          type: "success",
+        });
+        localStorage.setItem("userId", userId);
+        localStorage.setItem("userName", userName);
+        localStorage.setItem("phone", phone);
+        localStorage.setItem("contactName", contactName);
+        localStorage.setItem("userType", 1);
+        localStorage.setItem("loginAccountId", loginAccountId);
+        rolePermission = rolePermission || [];
+        let arr = [...new Set([...rolePermission])];
+        localStorage.setItem("rolePermission", arr);
+        store.dispatch("GetBasePermissionData", localStorage.loginAccountId);
+        let res1 = await store.dispatch(
+          "GetUserPermission",
+          localStorage.loginAccountId
+        );
+
+        router.replace({ path: store.state.menuData[0]?.items[0].path });
+        store.commit("changeLogin", true);
+      } else {
+        ElNotification.error({
+          title: "错误",
+          duration: 3000,
+          message: res.data.msg,
+        });
+      }
+    } else {
+      console.log("error submit!!");
+      return false;
     }
+  });
+}
 
-    function goBeian() {
-      window.open("https://beian.miit.gov.cn/");
+function goBeian() {
+  window.open("https://beian.miit.gov.cn/");
+}
+let currentCompanyLevelTwo = ref("");
+function getLevel2domain() {
+  let baseurl = window.location.href;
+  let index0 = baseurl.indexOf("localhost");
+  if (index0 != -1) {
+    currentCompanyLevelTwo.value = "wuchan";
+  } else {
+    let index1 = baseurl.indexOf("http://");
+    let index2 = baseurl.indexOf(".");
+    let plenth;
+    if (index1 == -1) {
+      plenth = 8;
+    } else {
+      plenth = 7;
     }
+    currentCompanyLevelTwo.value = baseurl.substring(plenth, index2);
+  }
+  // currentCompanyLevelTwo.value = "dhly";
+  console.log(currentCompanyLevelTwo.value);
+}
 
-    return {
-      form,
-      ...toRefs(ruleForm),
-      ...toRefs(rules),
-      login,
-      goBeian,
-    };
-  },
-};
+onMounted(() => {
+  getLevel2domain();
+});
 </script>
 <style scoped>
 .container {
@@ -229,34 +312,32 @@ export default {
 }
 
 .title {
+  padding-top: 100px;
   width: 384px;
   height: 38px;
   display: flex;
   margin: 0 auto;
-  margin-top: 100px;
+  align-items: center;
+  justify-content: space-between;
+  color: #333;
+}
+
+.title-logo {
+  max-width: 50px;
+  max-height: 40px;
+  object-fit: contain;
 }
 
 .title-left {
-  height: 38px;
-  background: url(https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/web-static/wuchan3.jpg);
-  background-size: contain;
-  background-repeat: no-repeat;
-  line-height: 38px;
-  padding-left: 46px;
-  font-size: 22px;
+  font-size: 20px;
 }
 
 .title-mid {
-  font-size: 25px;
-  color: #e4e4e4;
+  font-size: 24px;
 }
 
 .title-right {
-  font-size: 28px;
-  font-family: Adobe Heiti Std;
-  font-weight: normal;
-  color: #434343;
-  line-height: 38px;
+  font-size: 20px;
 }
 
 .form-container {