登录页面显示设备二维码
This commit is contained in:
@@ -41,14 +41,6 @@
|
|||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
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:screenOrientation="landscape"
|
||||||
android:theme="@style/Theme.Inbound">
|
android:theme="@style/Theme.Inbound">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
@@ -57,6 +49,20 @@
|
|||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</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>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -18,13 +18,13 @@ import javax.inject.Singleton
|
|||||||
@Module
|
@Module
|
||||||
@InstallIn(SingletonComponent::class)
|
@InstallIn(SingletonComponent::class)
|
||||||
object NetworkModule {
|
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://127.0.0.1"
|
||||||
private const val BASE_URL = "https://yyjk.shuziweidao.com/gateway/"
|
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 = "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 // 超时时间(秒)
|
private const val TIME_OUT = 30L // 超时时间(秒)
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -52,7 +52,8 @@ object NetworkModule {
|
|||||||
@Singleton
|
@Singleton
|
||||||
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
|
fun provideRetrofit(okHttpClient: OkHttpClient): Retrofit {
|
||||||
return Retrofit.Builder()
|
return Retrofit.Builder()
|
||||||
.baseUrl(DEVICE_BASE_URL)
|
// .baseUrl(DEVICE_BASE_URL)
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
.client(okHttpClient)
|
.client(okHttpClient)
|
||||||
.addConverterFactory(GsonConverterFactory.create())
|
.addConverterFactory(GsonConverterFactory.create())
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.sw.inbound.network.interceptor
|
package com.sw.inbound.network.interceptor
|
||||||
|
|
||||||
|
import com.sw.inbound.GlobalData
|
||||||
import com.sw.inbound.GlobalKey
|
import com.sw.inbound.GlobalKey
|
||||||
import com.sw.inbound.utils.ContextUtils
|
import com.sw.inbound.utils.ContextUtils
|
||||||
import com.sw.inbound.utils.SPUtil
|
import com.sw.inbound.utils.SPUtil
|
||||||
@@ -15,6 +16,7 @@ class RequestInterceptor : Interceptor {
|
|||||||
val requestBuilder = originalRequest.newBuilder()
|
val requestBuilder = originalRequest.newBuilder()
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
.header("Accept", "application/json")
|
.header("Accept", "application/json")
|
||||||
|
.header("deviceId", GlobalData.deviceId)
|
||||||
// .header("Authorization", "Bearer ${getToken()}")
|
// .header("Authorization", "Bearer ${getToken()}")
|
||||||
// .header("x-access-token", getToken())
|
// .header("x-access-token", getToken())
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.sw.inbound.ui.page
|
package com.sw.inbound.ui.page
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
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.layout.width
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
@@ -22,6 +26,7 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.res.colorResource
|
import androidx.compose.ui.res.colorResource
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
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.Screen
|
||||||
import com.sw.inbound.ui.theme.AppTypography
|
import com.sw.inbound.ui.theme.AppTypography
|
||||||
import com.sw.inbound.ui.weight.CustomButton
|
import com.sw.inbound.ui.weight.CustomButton
|
||||||
|
import com.sw.inbound.utils.QRCodeUtil
|
||||||
import com.sw.inbound.utils.SPUtil
|
import com.sw.inbound.utils.SPUtil
|
||||||
import com.sw.inbound.utils.ToastUtils
|
import com.sw.inbound.utils.ToastUtils
|
||||||
import com.sw.inbound.viewmodel.UserViewModel
|
import com.sw.inbound.viewmodel.UserViewModel
|
||||||
@@ -81,41 +87,57 @@ fun LoginScreen(
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
val qrCodeBmp by lazy {
|
||||||
modifier = Modifier.fillMaxSize(),
|
QRCodeUtil.generateQRCode(
|
||||||
verticalArrangement = Arrangement.Center,
|
content = GlobalData.deviceId,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
size = 150
|
||||||
) {
|
)
|
||||||
Text(text = "出入库管理", style = AppTypography.black141428TextStyle.withSize(60.sp).bold())
|
}
|
||||||
Spacer(modifier = Modifier.height(91.dp))
|
|
||||||
|
|
||||||
UserInputView(value = username, placeholderValue = "请输入用户名", onValueChange = {
|
Box(contentAlignment = Alignment.BottomStart) {
|
||||||
username = it
|
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 = {
|
Spacer(modifier = Modifier.height(30.dp))
|
||||||
password = it
|
|
||||||
}, isPassword = true)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(90.dp))
|
UserInputView(value = password, placeholderValue = "请输入密码", onValueChange = {
|
||||||
CustomButton(
|
password = it
|
||||||
modifier = modifier
|
}, isPassword = true)
|
||||||
.width(885.dp)
|
|
||||||
.height(120.dp),
|
Spacer(modifier = Modifier.height(90.dp))
|
||||||
text = "登录",
|
CustomButton(
|
||||||
onClick = {
|
modifier = modifier
|
||||||
if (username.isEmpty() || password.isEmpty()) {
|
.width(885.dp)
|
||||||
ToastUtils.showToast("用户名或密码不能为空")
|
.height(120.dp),
|
||||||
return@CustomButton
|
text = "登录",
|
||||||
}
|
onClick = {
|
||||||
viewModel.login(username, password)
|
if (username.isEmpty() || password.isEmpty()) {
|
||||||
// viewModel.test()
|
ToastUtils.showToast("用户名或密码不能为空")
|
||||||
},
|
return@CustomButton
|
||||||
borderColor = colorResource(R.color.blue),
|
}
|
||||||
textColor = colorResource(R.color.white),
|
viewModel.login(username, password)
|
||||||
fontSize = 36.sp
|
// 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 // 确保单行输入(避免换行导致高度变化)
|
singleLine = true // 确保单行输入(避免换行导致高度变化)
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="Theme.Inbound" parent="android:Theme.Material.Light.NoActionBar" >
|
<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>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user