| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <template>
- <div class="container">
- <div class="login-box">
- <div class="left">
- <div class="left-up-icon"></div>
- </div>
- <div class="right">
- <div class="title">
- <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>
- <div class="form-container">
- <el-form :model="ruleForm" :rules="rules" ref="form">
- <el-form-item prop="phone">
- <el-input placeholder="请输入手机号" v-model="ruleForm.phone">
- <template v-slot:prepend>
- <el-button icon="el-icon-mobile-phone"></el-button>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <el-input
- type="password"
- placeholder="请输入密码"
- v-model="ruleForm.password"
- >
- <template v-slot:prepend>
- <el-button icon="el-icon-lock"></el-button>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item>
- <el-button
- style="
- width: 384px;
- height: 48px;
- border-radius: 2px;
- margin-top: 40px;
- "
- type="primary"
- @click="login('ruleForm')"
- >
- 登录
- </el-button>
- </el-form-item>
- </el-form>
- </div>
- <div class="df aic jcc" style="margin-top: 55px">
- <img
- style="height: 20px"
- src="https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/%E6%B1%87%E5%BE%88%E5%A4%9Alogo-%E5%B7%A6%E5%8F%B3.png"
- alt=""
- />
- <div
- style="
- height: 20px;
- line-height: 18px;
- font-size: 10px;
- color: #999;
- margin-left: 15px;
- "
- >
- 汇很多智慧航运研发中心
- </div>
- </div>
- </div>
- </div>
- <div @click="goBeian" class="copyright">
- Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
- </div>
- </div>
- </template>
- <script setup>
- import { ref, reactive, toRefs, computed, onMounted } from "vue";
- import { ElNotification } from "element-plus";
- import store from "../../store";
- import router from "../../router";
- import md5 from "md5";
- import api from "../../apis/fetch";
- const form = ref(null);
- let ruleForm = ref({
- phone: "",
- password: "",
- });
- 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",
- },
- // 路易达孚
- 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]?.cargoOwnerId ||
- cargoOwners.value["wuchan"]?.cargoOwnerId,
- });
- 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("/");
- 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/");
- }
- 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);
- }
- if (!cargoOwners.value[currentCompanyLevelTwo.value]?.cargoOwnerId) {
- currentCompanyLevelTwo.value = "wuchan";
- }
- console.log(currentCompanyLevelTwo.value);
- }
- onMounted(() => {
- getLevel2domain();
- });
- </script>
- <style scoped>
- .container {
- width: 100%;
- height: 100%;
- background-image: url(../../assets/login-back.png);
- background-size: cover;
- }
- .login-box {
- position: relative;
- display: flex;
- top: calc(50% - 255px);
- left: calc(50% - 478px);
- width: 966px;
- height: 508px;
- border-radius: 10px;
- overflow: hidden;
- }
- .left {
- height: 100%;
- width: 450px;
- background-image: url(../../assets/login-modal.png);
- }
- .left-up-icon {
- width: 40px;
- height: 40px;
- border-radius: 50%;
- margin: 24px;
- background-image: url(../../assets/logo.png);
- background-size: contain;
- }
- .right {
- height: 100%;
- width: 516px;
- background: #fff;
- }
- .title {
- padding-top: 100px;
- width: 384px;
- height: 38px;
- display: flex;
- margin: 0 auto;
- align-items: center;
- justify-content: space-between;
- color: #333;
- }
- .title-logo {
- max-width: 50px;
- max-height: 40px;
- object-fit: contain;
- }
- .title-left {
- font-size: 20px;
- }
- .title-mid {
- font-size: 24px;
- }
- .title-right {
- font-size: 20px;
- }
- .form-container {
- margin: 0 auto;
- margin-top: 60px;
- width: 384px;
- }
- .copyright {
- position: absolute;
- width: 100vw;
- bottom: 70px;
- text-align: center;
- font-family: PingFang SC;
- font-weight: 400;
- color: #aaa;
- opacity: 0.8;
- cursor: pointer;
- }
- </style>
|