Browse Source

租户环境

hella_online_20240829
yufei0306 4 months ago
parent
commit
782bc9338c
  1. 5
      .env.development
  2. 5
      .env.hella13
  3. 5
      .env.hella14
  4. 5
      .env.hella15
  5. 5
      .env.hella16
  6. 5
      .env.hella8
  7. 5
      .env.hella9
  8. 5
      .env.test
  9. 2
      src/api/httpRequest3.js
  10. 5
      src/api/request2.js
  11. 756
      src/pages/login/index.vue
  12. 4
      src/store/modules/user.js

5
.env.development

@ -1,2 +1,5 @@
VITE_BASE_URL=http://dev.ccwin-in.com:25300/api/admin-api VITE_BASE_URL=http://dev.ccwin-in.com:25300/api/admin-api
VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25300/admin-api VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25300/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1},{"text":"成都","value":2}]'

5
.env.hella13

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.21.32.13:81/api/admin-api VITE_BASE_URL=http://172.21.32.13:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.21.32.13:81/admin-api VITE_BASE_URL_IMAGE=http://172.21.32.13:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1}]'

5
.env.hella14

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.21.32.14:81/api/admin-api VITE_BASE_URL=http://172.21.32.14:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.21.32.14:81/admin-api VITE_BASE_URL_IMAGE=http://172.21.32.14:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1}]'

5
.env.hella15

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.21.32.15:81/api/admin-api VITE_BASE_URL=http://172.21.32.15:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.21.32.15:81/admin-api VITE_BASE_URL_IMAGE=http://172.21.32.15:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1}]'

5
.env.hella16

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.21.32.16:81/api/admin-api VITE_BASE_URL=http://172.21.32.16:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.21.32.16:81/admin-api VITE_BASE_URL_IMAGE=http://172.21.32.16:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1}]'

5
.env.hella8

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.22.32.8:81/api/admin-api VITE_BASE_URL=http://172.22.32.8:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.22.32.8:81/admin-api VITE_BASE_URL_IMAGE=http://172.22.32.8:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"成都","value":2}]'

5
.env.hella9

@ -1,2 +1,5 @@
VITE_BASE_URL=http://172.22.32.9:81/api/admin-api VITE_BASE_URL=http://172.22.32.9:81/api/admin-api
VITE_BASE_URL_IMAGE=http://172.22.32.9:81/admin-api VITE_BASE_URL_IMAGE=http://172.22.32.9:81/admin-api
# 租户配置
VITE_TENANT='[{"text":"成都","value":2}]'

5
.env.test

@ -1,3 +1,6 @@
VITE_BASE_URL=http://dev.ccwin-in.com:25300/api/admin-api VITE_BASE_URL=http://dev.ccwin-in.com:25300/api/admin-api
VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25300/admin-api VITE_BASE_URL_IMAGE=http://dev.ccwin-in.com:25300/admin-api
# 租户配置
VITE_TENANT='[{"text":"长春","value":1},{"text":"成都","value":2}]'

2
src/api/httpRequest3.js

@ -3,7 +3,7 @@ import storage from '../common/utils/storage'
function service(options = {}) { function service(options = {}) {
var token = storage.getStorage(storage.constant.token) var token = storage.getStorage(storage.constant.token)
var tenantId = 1 var tenantId = storage.getStorage('tenantId')
// if(getApp()!=undefined){ // if(getApp()!=undefined){
// tenantId = getApp().globalData.tenantId // tenantId = getApp().globalData.tenantId
// } // }

5
src/api/request2.js

@ -17,7 +17,7 @@ export function getCaptchaImage(params) {
/** /**
* 登录方法 * 登录方法
*/ */
export function login(username, password, code, uuid) { export function login(username, password, code, uuid,tenantName) {
return request({ return request({
url: baseApi + '/system/auth/login', url: baseApi + '/system/auth/login',
headers: { headers: {
@ -28,7 +28,8 @@ export function login(username, password, code, uuid) {
username, username,
password, password,
code, code,
uuid uuid,
tenantName
} }
}) })
} }

756
src/pages/login/index.vue

@ -1,377 +1,391 @@
<template> <template>
<view class="content"> <view class="content">
<!-- <image mode="widthFix" class="loginimg" src="../../static/login.png"></image> --> <!-- <image mode="widthFix" class="loginimg" src="../../static/login.png"></image> -->
<image mode="widthFix" class="loginimg" src="../../static/icons_ui/login_bg.png"></image> <image mode="widthFix" class="loginimg" src="../../static/icons_ui/login_bg.png"></image>
<view class="login_title"> <view class="login_title">
<text>您好欢迎使用</text><br> <text>您好欢迎使用</text><br>
WMS仓库管理系统 WMS仓库管理系统
</view> </view>
<view class="bgf login_wrap"> <view class="bgf login_wrap">
<view class="loginbox"> <view class="loginbox">
<form> <form>
<view class="mytab"> <view class="mytab">
<!-- <view class="mytabline" :class="tapstyle == 1?'active':''" @click="tapchenge(1)">扫码登录</view> --> <!-- <view class="mytabline" :class="tapstyle == 1?'active':''" @click="tapchenge(1)">扫码登录</view> -->
<view class="mytabline" :class="tapstyle == 2?'active_in':''" @click="tapchenge(2)">密码登录</view> <view class="mytabline" :class="tapstyle == 2?'active_in':''" @click="tapchenge(2)">密码登录</view>
</view> </view>
<!-- <view class="mybox" v-if="tapstyle == 1"> <!-- <view class="mybox" v-if="tapstyle == 1">
<view class="conone"> <view class="conone">
<uni-easyinput prefixIcon="scan" class="uni-input" type="password" v-model="smloginmsg" <uni-easyinput prefixIcon="scan" class="uni-input" type="password" v-model="smloginmsg"
name="nickname" placeholder="扫码登录"></uni-easyinput> name="nickname" placeholder="扫码登录"></uni-easyinput>
</view> </view>
</view> --> </view> -->
<view class="mybox" v-if="tapstyle == 2"> <view class="mybox" v-if="tapstyle == 2">
<view class="conone"> <view class="conone">
<view class="title uni-flex"> <view class="title uni-flex">
<image class="icon_normal" src="@/static/icons_ui/icon_tenant.svg"></image> <image class="icon_normal" src="@/static/icons_ui/icon_tenant.svg"></image>
租户 租户
</view> </view>
<view> <view>
<input class="uni-input" placeholder="请输入租户名" v-model="tenantName" disabled="true" /> <!-- <input class="uni-input" placeholder="请输入租户名" v-model="tenantName" disabled="true" /> -->
</view> <uni-data-select class="uni-data-select" placeholder="请输入租户名" v-model="tenantValue" :clear="false" :localdata="tenantArray"></uni-data-select>
</view> </view>
<view class="conone"> </view>
<view class="title uni-flex"> <view class="conone">
<image class="icon_normal" src="@/static/icons_ui/icon_login_user.svg"></image> <view class="title uni-flex">
用户名 <image class="icon_normal" src="@/static/icons_ui/icon_login_user.svg"></image>
</view> 用户名
<view> </view>
<input class="uni-input" style="padding:25rpx" placeholder="请输入用户名" v-model="username" /> <view>
</view> <input class="uni-input" style="padding:25rpx" placeholder="请输入用户名"
</view> v-model="username" />
<view class="conone"> </view>
<view class="title uni-flex"> </view>
<image class="icon_normal" src="../../static/icons_ui/icon_login_password.svg"></image> <view class="conone">
密码 <view class="title uni-flex">
</view> <image class="icon_normal" src="../../static/icons_ui/icon_login_password.svg"></image>
<view class="uni-input-wrapper" > 密码
<input class="uni-input" style="padding:25rpx" placeholder="请输入密码" :password="showPassword" </view>
v-model="password" /> <view class="uni-input-wrapper">
<text class="uni-icon" :class="[!showPassword ? 'uni-eye-active' : '']" <input class="uni-input" style="padding:25rpx" placeholder="请输入密码"
@click="changePassword">&#xe568;</text> :password="showPassword" v-model="password" />
</view> <text class="uni-icon" :class="[!showPassword ? 'uni-eye-active' : '']"
<!-- <view class="uni-input-wrapper"> @click="changePassword">&#xe568;</text>
<input class="uni-input" type="password" name="password" </view>
:password="showPassword" <!-- <view class="uni-input-wrapper">
placeholder="请输入密码" v-model="password"></input> <input class="uni-input" type="password" name="password"
<text class="uni-icon" :class="[!showPassword ? 'uni-eye-active' : '']" @click="changePassword">&#xe568;</text> :password="showPassword"
</view> --> placeholder="请输入密码" v-model="password"></input>
<text class="uni-icon" :class="[!showPassword ? 'uni-eye-active' : '']" @click="changePassword">&#xe568;</text>
</view> </view> -->
</view> </view>
<view style="display: flex;flex-direction: row;">
<!-- <view class="uni-input"> </view>
<input class="" placeholder="请输入验证码" <view style="display: flex;flex-direction: row;">
v-model="code" <!-- <view class="uni-input">
style="background-color: lightgray;padding-top: 40rpx;padding-bottom: 40rpx;margin-right: 20rpx;" /> <input class="" placeholder="请输入验证码"
</view> --> v-model="code"
<view class="uni-input-wrapper"> style="background-color: lightgray;padding-top: 40rpx;padding-bottom: 40rpx;margin-right: 20rpx;" />
<input class="" style="height: 80rpx; background-color: #F7F9FF;margin-right: 20rpx;" </view> -->
placeholder="请输入验证码" type="number" v-model="code" /> <view class="uni-input-wrapper">
</view> <input class="" style="height: 80rpx; background-color: #F7F9FF;margin-right: 20rpx;"
<view class="display: flex; align-items: center; text-center"> placeholder="请输入验证码" type="number" v-model="code" />
<view class=""> </view>
<image :src="imageSrc" style="width: 260rpx;height: 80rpx;" @click="getCode"></image> <view class="display: flex; align-items: center; text-center">
</view> <view class="">
<view style="font-size: 35rpx;color: #476DF5;" @click="getCode"> 获取验证码?</view> <image :src="imageSrc" style="width: 260rpx;height: 80rpx;" @click="getCode"></image>
</view> </view>
<view style="font-size: 35rpx;color: #476DF5;" @click="getCode"> 获取验证码?</view>
</view> </view>
<view class="loginbtnbox">
<button @click="handelerlogin()" class="loginbtn">登录</button> </view>
</view> <view class="loginbtnbox">
</form> <button @click="handelerlogin()" class="loginbtn">登录</button>
</view> </view>
</view> </form>
<comMessage ref="comMessage"></comMessage> </view>
</view> </view>
</template> <comMessage ref="comMessage"></comMessage>
</view>
<script> </template>
import {
getCaptchaImage <script>
} from '@/api/request2.js'; import {
import { getCaptchaImage
mapState, } from '@/api/request2.js';
mapMutations import {
} from 'vuex' mapState,
mapMutations
export default { } from 'vuex'
components: {},
data() { export default {
return { components: {},
data() {
return {
tenantArray: JSON.parse(import.meta.env.VITE_TENANT),
smloginmsg: "", smloginmsg: "",
tenantName: "闻荫源码", tenantValue:0,
username: "", // tenantName: "",
password: "", username: "",
tapstyle: 2, password: "",
loading: false, tapstyle: 2,
showPassword: true, loading: false,
imageSrc: "", showPassword: true,
code: "", imageSrc: "",
uuid: "" code: "",
} uuid: ""
}, }
// computed: mapState(['forcedLogin', 'hasLogin']), },
mounted() { // computed: mapState(['forcedLogin', 'hasLogin']),
mounted() {
uni.clearStorageSync() this.tenantValue = this.tenantArray[0].value
uni.clearStorage(); // uni.clearStorageSync()
if (process.env.NODE_ENV === 'development') { uni.clearStorage(); //
this.username = "admin" if (process.env.NODE_ENV === 'development') {
this.password = "123456"; this.username = "admin"
} this.password = "123456";
uni.setNavigationBarColor({ }
frontColor: '#ffffff', uni.setNavigationBarColor({
backgroundColor: "#476DF5 !important" frontColor: '#ffffff',
}) backgroundColor: "#476DF5 !important"
})
// #ifdef APP-PLUS
uni.setNavigationBarColor({ // #ifdef APP-PLUS
frontColor: "#ffffff", uni.setNavigationBarColor({
backgroundColor: "#476DF5" frontColor: "#ffffff",
}) backgroundColor: "#476DF5"
// #endif })
// #endif
},
// },
onNavigationBarButtonTap(e) { //
if (e.index === 0) { onNavigationBarButtonTap(e) {
uni.navigateTo({ if (e.index === 0) {
url: "/pages/config/config" uni.navigateTo({
}) url: "/pages/config/config"
} })
}
},
onLoad() { },
getCaptchaImage().then(res => { onLoad() {
if (res) { getCaptchaImage().then(res => {
var code = res.data.img; if (res) {
let base64 = 'data:image/jpeg;base64,' + code var code = res.data.img;
// console.log("", base64) let base64 = 'data:image/jpeg;base64,' + code
this.imageSrc = base64.replace(/[\r\n]/g, "") // console.log("", base64)
this.uuid = res.data.uuid this.imageSrc = base64.replace(/[\r\n]/g, "")
} this.uuid = res.data.uuid
}).catch(error => { }
this.showErrorMessage(error); }).catch(error => {
}) this.showErrorMessage(error);
}, })
methods: { },
// ...mapMutations(['login']), methods: {
handelerlogin() { // ...mapMutations(['login']),
if (this.username === '') { handelerlogin() {
uni.showToast({ if (this.username === '') {
title: '用户名不能为空', uni.showToast({
icon: 'none', title: '用户名不能为空',
mask: true icon: 'none',
}) mask: true
} else if (this.password === '') { })
uni.showToast({ } else if (this.password === '') {
title: '密码不能为空', uni.showToast({
icon: 'none', title: '密码不能为空',
mask: true icon: 'none',
}) mask: true
} else if (this.code === '') { })
uni.showToast({ } else if (this.code === '') {
title: '验证码不能为空', uni.showToast({
icon: 'none', title: '验证码不能为空',
mask: true icon: 'none',
}) mask: true
} else { })
// console.log("", this.username, "", this.password, this.tapstyle, this.smloginmsg) } else {
let logininfo = { // console.log("", this.username, "", this.password, this.tapstyle, this.smloginmsg)
username: "", let logininfo = {
password: "", username: "",
code: "", password: "",
uuid: "" code: "",
} uuid: ""
if (this.tapstyle == 2) // }
{ if (this.tapstyle == 2) //
logininfo.username = this.username; {
logininfo.password = this.password logininfo.username = this.username;
logininfo.code = this.code; logininfo.password = this.password
logininfo.uuid = this.uuid; logininfo.code = this.code;
} else if (this.tapstyle == 1) { logininfo.uuid = this.uuid;
// let arr = Base64.decode(this.smloginmsg).split(':') logininfo.tenantName = this.tenantArray.find(item=>item.value==this.tenantValue).text;
// logininfo.username = arr[0];
// logininfo.password = arr[1] uni.setStorageSync('tenantId', this.tenantValue)
}
let params = JSON.stringify(logininfo); } else if (this.tapstyle == 1) {
console.log('params', params); // let arr = Base64.decode(this.smloginmsg).split(':')
this.newLogin(logininfo) // logininfo.username = arr[0];
// logininfo.password = arr[1]
} }
}, let params = JSON.stringify(logininfo);
console.log('params', params);
async newLogin(logininfo) { this.newLogin(logininfo)
uni.showLoading({
title: "正在登录", }
mask: true },
})
await this.$store.dispatch('Login', logininfo); async newLogin(logininfo) {
// await this.$store.dispatch('GetTenantIdInfo', this.tenantName) uni.showLoading({
uni.hideLoading() title: "正在登录",
uni.setStorageSync('hasLogin', true) mask: true
uni.switchTab({ })
url: '/pages/index/index' await this.$store.dispatch('Login', logininfo);
}); // await this.$store.dispatch('GetTenantIdInfo', this.tenantName)
uni.setStorageSync('username', this.username); uni.hideLoading()
}, uni.setStorageSync('hasLogin', true)
uni.switchTab({
url: '/pages/index/index'
tapchenge(e) { });
this.tapstyle = e uni.setStorageSync('username', this.username);
}, },
onchange(e) {
const value = e.detail.value
}, tapchenge(e) {
changePassword: function() { this.tapstyle = e
this.showPassword = !this.showPassword; },
}, onchange(e) {
showErrorMessage(message) { const value = e.detail.value
this.$refs.comMessage.showErrorMessage(message, res => { },
if (res) { changePassword: function() {
this.showPassword = !this.showPassword;
} },
}); showErrorMessage(message) {
}, this.$refs.comMessage.showErrorMessage(message, res => {
getCode() { if (res) {
getCaptchaImage().then(res => {
if (res) { }
var code = res.data.img; });
let base64 = 'data:image/jpeg;base64,' + code },
this.imageSrc = base64.replace(/[\r\n]/g, "") getCode() {
this.uuid = res.data.uuid getCaptchaImage().then(res => {
} if (res) {
}) var code = res.data.img;
} let base64 = 'data:image/jpeg;base64,' + code
} this.imageSrc = base64.replace(/[\r\n]/g, "")
this.uuid = res.data.uuid
}
})
}
}
}
</script>
<style>
page {
background-color: #fff;
}
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #FFFFFF;
}
.cs {
margin-bottom: 20upx;
}
.mytab {
display: flex;
}
.mytabline {
flex: 1;
text-align: center;
padding: 20rpx 0;
color: #666;
position: relative;
font-size: 0.875rem;
}
.active_in {
color: #101010;
font-weight: bold;
}
.active_in::after {
content: "";
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
height: 8rpx;
background-color: #007AFF;
width: 40rpx;
border-radius: 8rpx;
}
.loginbox {
box-sizing: border-box;
padding: 30rpx;
}
.loginimg {
width: 100%;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.conone {
margin: 30rpx 0;
align-items: center;
}
.conone .uni-input-wrapper {
position: relative;
}
.conone .uni-input {
background-color: #F7F9FF;
height: 90rpx;
line-height: 90rpx;
padding: 0 0 0 20rpx;
} }
</script> .conone .uni-data-select .uni-select{
<style>
page {
background-color: #fff;
}
.content {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #FFFFFF;
}
.cs {
margin-bottom: 20upx;
}
.mytab {
display: flex;
}
.mytabline {
flex: 1;
text-align: center;
padding: 20rpx 0;
color: #666;
position: relative;
font-size: 0.875rem;
}
.active_in {
color: #101010;
font-weight: bold;
}
.active_in::after {
content: "";
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
height: 8rpx;
background-color: #007AFF;
width: 40rpx;
border-radius: 8rpx;
}
.loginbox {
box-sizing: border-box;
padding: 30rpx;
}
.loginimg {
width: 100%;
}
.logo {
height: 200rpx;
width: 200rpx;
margin-left: auto;
margin-right: auto;
margin-bottom: 50rpx;
}
.conone {
margin: 30rpx 0;
align-items: center;
}
.conone .uni-input-wrapper {
position: relative;
}
.conone .uni-input {
background-color: #F7F9FF; background-color: #F7F9FF;
height: 90rpx; height: 90rpx;
line-height: 90rpx; line-height: 90rpx;
padding: 0 0 0 20rpx; border: 0px;
} padding: 0 10rpx 0 20rpx;
}
.conone .title { .conone .title {
font-size: .875rem; font-size: .875rem;
align-items: center; align-items: center;
margin-bottom: 20rpx; margin-bottom: 20rpx;
letter-spacing: 1rpx; letter-spacing: 1rpx;
} }
.conone .title image { .conone .title image {
margin-right: 6rpx; margin-right: 6rpx;
} }
.uni-easyinput .is-input-border { .uni-easyinput .is-input-border {
border-color: transparent !important; border-color: transparent !important;
} }
.loginbtnbox { .loginbtnbox {
margin-top: 40rpx; margin-top: 40rpx;
} }
.loginbtn { .loginbtn {
color: #fff; color: #fff;
font-size: 0.875rem; font-size: 0.875rem;
height: 100rpx; height: 100rpx;
line-height: 100rpx; line-height: 100rpx;
background: #5d66de; background: #5d66de;
border-radius: 8rpx; border-radius: 8rpx;
border: none; border: none;
outline: none; outline: none;
} }
.conone .uni-icon { .conone .uni-icon {
float: right; float: right;
position: absolute; position: absolute;
right: 20rpx; right: 20rpx;
color: #ccc; color: #ccc;
font-size: 1.25rem; font-size: 1.25rem;
} }
.conone .uni-eye-active { .conone .uni-eye-active {
color: #5a7cf3; color: #5a7cf3;
} }
</style> </style>

4
src/store/modules/user.js

@ -50,9 +50,9 @@ const user = {
const password = userInfo.password const password = userInfo.password
const code = userInfo.code const code = userInfo.code
const uuid = userInfo.uuid const uuid = userInfo.uuid
const tenantName = userInfo.tenantName
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login(username, password, code, uuid).then(res => { login(username, password, code, uuid,tenantName).then(res => {
if(res.data){ if(res.data){
res = res.data; res = res.data;
// 设置 token // 设置 token

Loading…
Cancel
Save