| | |
| | | <view class="login-form-content"> |
| | | <view class="input-item flex align-center"> |
| | | <up-input prefixIcon="account" placeholder="请输入账号" border="bottom" |
| | | @blur="getUserLoginFacotryList" |
| | | maxlength="30" v-model="loginForm.userName" clearable></up-input> |
| | | </view> |
| | | <view class="input-item flex align-center"> |
| | | <up-input prefixIcon="lock" placeholder="请输入密码" border="bottom" maxlength="20" v-model="loginForm.password" clearable type="password"></up-input> |
| | | </view> |
| | | <view class="input-item flex align-center select-container"> |
| | | <up-icon name="tags" size="18"></up-icon> |
| | | <up-picker-data |
| | | v-model="loginForm.factoryId" |
| | | title="请选择公司" |
| | | :options="factoryList" |
| | | valueKey="id" |
| | | style="width: 100%;" |
| | | labelKey="name"> |
| | | </up-picker-data> |
| | | </view> |
| | | <view> |
| | | <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button> |
| | |
| | | icon: 'none' |
| | | }) |
| | | } |
| | | import { userLoginFacotryList} from '@/api/login' |
| | | import { ref, onMounted } from "vue"; |
| | | import useUserStore from '@/store/modules/user' |
| | | import { getWxCode } from '@/utils/geek'; |
| | | import { wxLogin } from '@/api/oauth'; |
| | | import { setToken } from '@/utils/auth'; |
| | | import View from "@/pages/procurementManagement/procurementLedger/view.vue"; |
| | | const userStore = useUserStore() |
| | | const useWxLogin = ref(false); // 是否使用微信登录 |
| | | const rememberPassword = ref(false); // 记住密码 |
| | | const loginForm = ref({ |
| | | userName: "", |
| | | password: "", |
| | | factoryId: "", |
| | | currentFatoryName: "", |
| | | }); |
| | | const factoryList = ref([]) // 公司列表 |
| | | |
| | | // 保存密码到本地存储 |
| | | function savePassword() { |
| | |
| | | }) |
| | | } |
| | | |
| | | function getUserLoginFacotryList() { |
| | | if(loginForm.value.userName){ |
| | | userLoginFacotryList({userName:loginForm.value.userName}).then(res => { |
| | | console.log('res',res) |
| | | // 检查res.data是否为数组 |
| | | if (res.data && Array.isArray(res.data)) { |
| | | // 重新组装数据格式:deptId变成id,deptName变成name |
| | | factoryList.value = res.data.map(item => ({ |
| | | id: item.deptId, |
| | | name: item.deptName |
| | | })) |
| | | } else { |
| | | // 如果res.data不是数组,设置为空数组 |
| | | factoryList.value = [] |
| | | } |
| | | }).catch(error => { |
| | | showToast('获取公司列表失败:', error) |
| | | factoryList.value = [] |
| | | }) |
| | | }else { |
| | | factoryList.value = [] |
| | | } |
| | | } |
| | | |
| | | async function handleLogin() { |
| | | if (loginForm.value.userName === "") { |
| | | showToast("请输入您的账号") |
| | | } else if (loginForm.value.password === "") { |
| | | showToast("请输入您的密码") |
| | | } else if (loginForm.value.factoryId === "") { |
| | | showToast("请选择公司") |
| | | } else { |
| | | showToast("登录中,请耐心等待...") |
| | | pwdLogin() |
| | |
| | | // 页面加载时检查是否有保存的密码 |
| | | onMounted(() => { |
| | | loadPassword(); |
| | | getUserLoginFacotryList() |
| | | }); |
| | | </script> |
| | | |
| | |
| | | line-height: 20px; |
| | | text-align: left; |
| | | padding-left: 15px; |
| | | } |
| | | } |
| | | .select-container { |
| | | flex: 1; |
| | | border-bottom: 1px solid #e5e5e5; |
| | | padding: 6px 9px; |
| | | |
| | | :deep(.up-select) { |
| | | border: none; |
| | | background: transparent; |
| | | |
| | | .up-select__label { |
| | | font-size: 14px; |
| | | color: #333; |
| | | } |
| | | |
| | | .up-select__value { |
| | | font-size: 14px; |
| | | color: #333; |
| | | } |
| | | } |
| | | } |
| | | |