From f4e7cab2d004a81685fb3c96d6d21f1acfd3ec43 Mon Sep 17 00:00:00 2001
From: lvmeng <848755140@qq.com>
Date: Tue, 21 Oct 2025 09:34:30 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2=E6=98=BE?=
=?UTF-8?q?=E7=A4=BA=E8=AE=BE=E5=A4=87=E4=BA=8C=E7=BB=B4=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 22 +++--
.../java/com/sw/inbound/di/NetworkModule.kt | 7 +-
.../network/interceptor/RequestInterceptor.kt | 2 +
.../com/sw/inbound/ui/page/LoginScreen.kt | 85 ++++++++++++-------
app/src/main/res/values/themes.xml | 2 +-
5 files changed, 75 insertions(+), 43 deletions(-)
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8bd7739..f25864b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -41,14 +41,6 @@
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
- android:screenOrientation="landscape"/>
-
-
-
@@ -57,6 +49,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/sw/inbound/di/NetworkModule.kt b/app/src/main/java/com/sw/inbound/di/NetworkModule.kt
index 271a202..d20d0da 100644
--- a/app/src/main/java/com/sw/inbound/di/NetworkModule.kt
+++ b/app/src/main/java/com/sw/inbound/di/NetworkModule.kt
@@ -18,13 +18,13 @@ import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
- private const val DEVICE_BASE_URL = "http://device.shuziweidao.com:8889/"
+// private const val DEVICE_BASE_URL = "http://device.shuziweidao.com:8889/"
// private const val BASE_URL = "https://127.0.0.1"
private const val BASE_URL = "https://yyjk.shuziweidao.com/gateway/"
// private const val BASE_URL = "http://192.168.1.237:9002/"
- // private const val BASE_URL = "https://vip.shuziweidao.com/gateway/"
+// private const val BASE_URL = "https://vip.shuziweidao.com/gateway/"
private const val TIME_OUT = 30L // 超时时间(秒)
@Provides
@@ -52,7 +52,8 @@ object NetworkModule {
@Singleton
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
return Retrofit.Builder()
- .baseUrl(DEVICE_BASE_URL)
+// .baseUrl(DEVICE_BASE_URL)
+ .baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build()
diff --git a/app/src/main/java/com/sw/inbound/network/interceptor/RequestInterceptor.kt b/app/src/main/java/com/sw/inbound/network/interceptor/RequestInterceptor.kt
index 641ed7e..87896a3 100644
--- a/app/src/main/java/com/sw/inbound/network/interceptor/RequestInterceptor.kt
+++ b/app/src/main/java/com/sw/inbound/network/interceptor/RequestInterceptor.kt
@@ -1,5 +1,6 @@
package com.sw.inbound.network.interceptor
+import com.sw.inbound.GlobalData
import com.sw.inbound.GlobalKey
import com.sw.inbound.utils.ContextUtils
import com.sw.inbound.utils.SPUtil
@@ -15,6 +16,7 @@ class RequestInterceptor : Interceptor {
val requestBuilder = originalRequest.newBuilder()
.header("Content-Type", "application/json")
.header("Accept", "application/json")
+ .header("deviceId", GlobalData.deviceId)
// .header("Authorization", "Bearer ${getToken()}")
// .header("x-access-token", getToken())
diff --git a/app/src/main/java/com/sw/inbound/ui/page/LoginScreen.kt b/app/src/main/java/com/sw/inbound/ui/page/LoginScreen.kt
index b4d3691..714e5ff 100644
--- a/app/src/main/java/com/sw/inbound/ui/page/LoginScreen.kt
+++ b/app/src/main/java/com/sw/inbound/ui/page/LoginScreen.kt
@@ -1,12 +1,16 @@
package com.sw.inbound.ui.page
+import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
+import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
@@ -22,6 +26,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
@@ -42,6 +47,7 @@ import com.sw.inbound.ext.withSize
import com.sw.inbound.ui.Screen
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.weight.CustomButton
+import com.sw.inbound.utils.QRCodeUtil
import com.sw.inbound.utils.SPUtil
import com.sw.inbound.utils.ToastUtils
import com.sw.inbound.viewmodel.UserViewModel
@@ -81,41 +87,57 @@ fun LoginScreen(
// }
}
- Column(
- modifier = Modifier.fillMaxSize(),
- verticalArrangement = Arrangement.Center,
- horizontalAlignment = Alignment.CenterHorizontally
- ) {
- Text(text = "出入库管理", style = AppTypography.black141428TextStyle.withSize(60.sp).bold())
- Spacer(modifier = Modifier.height(91.dp))
+ val qrCodeBmp by lazy {
+ QRCodeUtil.generateQRCode(
+ content = GlobalData.deviceId,
+ size = 150
+ )
+ }
- UserInputView(value = username, placeholderValue = "请输入用户名", onValueChange = {
- username = it
- })
+ Box(contentAlignment = Alignment.BottomStart) {
+ Column(
+ modifier = Modifier.fillMaxSize(),
+ verticalArrangement = Arrangement.Center,
+ horizontalAlignment = Alignment.CenterHorizontally
+ ) {
+ Text(text = "出入库管理", style = AppTypography.black141428TextStyle.withSize(60.sp).bold())
+ Spacer(modifier = Modifier.height(91.dp))
- Spacer(modifier = Modifier.height(30.dp))
+ UserInputView(value = username, placeholderValue = "请输入用户名", onValueChange = {
+ username = it
+ })
- UserInputView(value = password, placeholderValue = "请输入密码", onValueChange = {
- password = it
- }, isPassword = true)
+ Spacer(modifier = Modifier.height(30.dp))
- Spacer(modifier = Modifier.height(90.dp))
- CustomButton(
- modifier = modifier
- .width(885.dp)
- .height(120.dp),
- text = "登录",
- onClick = {
- if (username.isEmpty() || password.isEmpty()) {
- ToastUtils.showToast("用户名或密码不能为空")
- return@CustomButton
- }
- viewModel.login(username, password)
-// viewModel.test()
- },
- borderColor = colorResource(R.color.blue),
- textColor = colorResource(R.color.white),
- fontSize = 36.sp
+ UserInputView(value = password, placeholderValue = "请输入密码", onValueChange = {
+ password = it
+ }, isPassword = true)
+
+ Spacer(modifier = Modifier.height(90.dp))
+ CustomButton(
+ modifier = modifier
+ .width(885.dp)
+ .height(120.dp),
+ text = "登录",
+ onClick = {
+ if (username.isEmpty() || password.isEmpty()) {
+ ToastUtils.showToast("用户名或密码不能为空")
+ return@CustomButton
+ }
+ viewModel.login(username, password)
+ // viewModel.test()
+ },
+ borderColor = colorResource(R.color.blue),
+ textColor = colorResource(R.color.white),
+ fontSize = 36.sp
+ )
+ }
+ Image(
+ bitmap = qrCodeBmp!!.asImageBitmap(),
+ contentDescription = "",
+ modifier = Modifier
+ .padding(start = 10.dp, bottom = 10.dp)
+ .size(80.dp, 80.dp)
)
}
}
@@ -172,4 +194,5 @@ private fun UserInputView(
},
singleLine = true // 确保单行输入(避免换行导致高度变化)
)
+
}
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index d2530eb..39c9ab9 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -2,6 +2,6 @@
\ No newline at end of file