登录页面显示设备二维码

This commit is contained in:
2025-10-21 09:34:30 +08:00
parent 5a5385ea31
commit f4e7cab2d0
5 changed files with 75 additions and 43 deletions
+14 -8
View File
@@ -41,14 +41,6 @@
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape"/>
<!-- android:theme="@style/Theme.Inbound"-->
<activity
android:name=".InitActivity"
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/Theme.Inbound">
<intent-filter>
@@ -57,6 +49,20 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- <activity-->
<!-- android:name=".InitActivity"-->
<!-- android:configChanges="orientation|screenSize"-->
<!-- android:exported="true"-->
<!-- android:label="@string/app_name"-->
<!-- android:screenOrientation="landscape"-->
<!-- android:theme="@style/Theme.Inbound">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- </activity>-->
</application>
</manifest>
@@ -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()
@@ -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())
@@ -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 // 确保单行输入(避免换行导致高度变化)
)
}
+1 -1
View File
@@ -2,6 +2,6 @@
<resources>
<style name="Theme.Inbound" parent="android:Theme.Material.Light.NoActionBar" >
<item name="android:windowBackground">@drawable/bg_splash</item>
<!-- <item name="android:windowBackground">@drawable/bg_splash</item>-->
</style>
</resources>