Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
HBHAndroid
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨秀秀
HBHAndroid
Commits
453183a1
Commit
453183a1
authored
Jul 26, 2024
by
小费同学阿
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础搭建
功能开发 1:bug 修复 企业端修复登录超时问题
parent
53555810
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
348 additions
and
8 deletions
+348
-8
AndroidManifest.xml
hbhbcompany/src/main/AndroidManifest.xml
+7
-5
HomeRequest.java
...java/com/xx/hbhbcompany/data/http/requst/HomeRequest.java
+68
-0
HomeActivity.java
...rc/main/java/com/xx/hbhbcompany/ui/home/HomeActivity.java
+39
-1
HomeViewModel.java
...c/main/java/com/xx/hbhbcompany/ui/home/HomeViewModel.java
+207
-0
LoginViewModel.java
...main/java/com/xx/hbhbcompany/ui/login/LoginViewModel.java
+8
-0
MineViewModel.java
...c/main/java/com/xx/hbhbcompany/ui/mine/MineViewModel.java
+19
-2
No files found.
hbhbcompany/src/main/AndroidManifest.xml
View file @
453183a1
...
@@ -36,17 +36,19 @@
...
@@ -36,17 +36,19 @@
android:name=
".ui.login.LoginActivity"
android:name=
".ui.login.LoginActivity"
android:exported=
"true"
android:exported=
"true"
android:screenOrientation=
"portrait"
>
android:screenOrientation=
"portrait"
>
</activity>
<!--注册首页页面-->
<activity
android:name=
".ui.home.HomeActivity"
android:exported=
"true"
android:screenOrientation=
"portrait"
>
<intent-filter>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<!--注册首页页面-->
<activity
android:name=
".ui.home.HomeActivity"
android:exported=
"true"
android:screenOrientation=
"portrait"
/>
<!-- 忘记密码页面-->
<!-- 忘记密码页面-->
<activity
<activity
android:name=
".ui.pwd.ForgetPwdActivity"
android:name=
".ui.pwd.ForgetPwdActivity"
...
...
hbhbcompany/src/main/java/com/xx/hbhbcompany/data/http/requst/HomeRequest.java
View file @
453183a1
...
@@ -6,8 +6,12 @@ import com.xx.hbhbcompany.data.http.respons.ActivityCenterBean;
...
@@ -6,8 +6,12 @@ import com.xx.hbhbcompany.data.http.respons.ActivityCenterBean;
import
com.xx.hbhbcompany.data.http.respons.AdvertisingBean
;
import
com.xx.hbhbcompany.data.http.respons.AdvertisingBean
;
import
com.xx.hbhbcompany.data.http.respons.ConsultationInformationBean
;
import
com.xx.hbhbcompany.data.http.respons.ConsultationInformationBean
;
import
com.xx.hbhbcompany.data.http.respons.ConsultationTitleBean
;
import
com.xx.hbhbcompany.data.http.respons.ConsultationTitleBean
;
import
com.xx.hbhbcompany.data.http.respons.DictValueBean
;
import
com.xx.hbhbcompany.data.http.respons.JobInformationBean
;
import
com.xx.hbhbcompany.data.http.respons.JobInformationBean
;
import
com.xx.hbhbcompany.data.http.respons.MessageBean
;
import
com.xx.hbhbcompany.data.http.respons.MessageBean
;
import
com.xx.hbhbcompany.data.staticdata.DictTypeEnum
;
import
com.xx.hbhbcompany.data.http.respons.UserInfoBean
;
import
com.xx.hbhbcompany.data.staticdata.StaticData
;
import
com.xx.xxviewlibrary.model.VersionBean
;
import
com.xx.xxviewlibrary.model.VersionBean
;
import
com.xx.xxviewlibrary.model.VersionBody
;
import
com.xx.xxviewlibrary.model.VersionBody
;
...
@@ -20,6 +24,70 @@ import me.goldze.mvvmhabit.http.BaseResponse;
...
@@ -20,6 +24,70 @@ import me.goldze.mvvmhabit.http.BaseResponse;
import
okhttp3.RequestBody
;
import
okhttp3.RequestBody
;
public
class
HomeRequest
extends
BaseRespons
{
public
class
HomeRequest
extends
BaseRespons
{
/**
* 登录
*/
public
Observable
<
BaseResponse
<
String
>>
login
(
String
user
,
String
pwd
)
{
return
getApiService
().
Login
(
new
ApiParams
<
LoginRequestBody
>().
setParams
(
new
LoginRequestBody
(
user
,
pwd
,
"01"
)
)
);
}
/**
* 登陆入参
* userType : 10 系统用户,01 企业用户,02商户用户,13消费者用户
*/
public
class
LoginRequestBody
{
String
phone
;
String
password
;
String
userType
;
public
LoginRequestBody
(
String
phone
,
String
password
,
String
userType
)
{
this
.
phone
=
phone
;
this
.
password
=
password
;
this
.
userType
=
userType
;
}
public
String
getPhone
()
{
return
phone
;
}
public
void
setPhone
(
String
phone
)
{
this
.
phone
=
phone
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getUserType
()
{
return
userType
;
}
public
void
setUserType
(
String
userType
)
{
this
.
userType
=
userType
;
}
}
/**
* 获取用户信息
*/
public
Observable
<
BaseResponse
<
UserInfoBean
>>
getUserInfo
()
{
return
getApiService
().
getUserInfo
();
}
/**
* 获取商品操作日志的字典列表
* @param dictType 字典类型
* @return 字典列表
*/
public
Observable
<
BaseResponse
<
List
<
DictValueBean
>>>
getDictValue
(
DictTypeEnum
dictType
)
{
return
getApiService
().
getDictValueByDictType
(
dictType
.
getValue
());
}
/**
/**
* 获取消息列表
* 获取消息列表
*/
*/
...
...
hbhbcompany/src/main/java/com/xx/hbhbcompany/ui/home/HomeActivity.java
View file @
453183a1
package
com
.
xx
.
hbhbcompany
.
ui
.
home
;
package
com
.
xx
.
hbhbcompany
.
ui
.
home
;
import
static
me
.
goldze
.
mvvmhabit
.
utils
.
Utils
.
Interceptor_TOKEN
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
import
android.util.Log
;
import
android.view.KeyEvent
;
import
android.view.KeyEvent
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -11,7 +16,9 @@ import androidx.fragment.app.Fragment;
...
@@ -11,7 +16,9 @@ import androidx.fragment.app.Fragment;
import
com.google.android.material.bottomnavigation.BottomNavigationView
;
import
com.google.android.material.bottomnavigation.BottomNavigationView
;
import
com.xx.hbhbcompany.R
;
import
com.xx.hbhbcompany.R
;
import
com.xx.hbhbcompany.data.http.requst.HomeRequest
;
import
com.xx.hbhbcompany.databinding.ActivityHomeBinding
;
import
com.xx.hbhbcompany.databinding.ActivityHomeBinding
;
import
com.xx.hbhbcompany.ui.login.LoginActivity
;
import
com.xx.hbhbcompany.ui.mine.MineFragment
;
import
com.xx.hbhbcompany.ui.mine.MineFragment
;
import
com.xx.hbhbcompany.ui.work.WorkFragment
;
import
com.xx.hbhbcompany.ui.work.WorkFragment
;
import
com.xx.xxviewlibrary.base.AppManager
;
import
com.xx.xxviewlibrary.base.AppManager
;
...
@@ -19,6 +26,7 @@ import com.xx.xxviewlibrary.comm.CommTextDialog;
...
@@ -19,6 +26,7 @@ import com.xx.xxviewlibrary.comm.CommTextDialog;
import
com.xx.xxviewlibrary.comm.RefuseDialogBean
;
import
com.xx.xxviewlibrary.comm.RefuseDialogBean
;
import
me.goldze.mvvmhabit.base.BaseActivity
;
import
me.goldze.mvvmhabit.base.BaseActivity
;
import
me.tatarka.bindingcollectionadapter2.BR
;
public
class
HomeActivity
extends
BaseActivity
<
ActivityHomeBinding
,
HomeViewModel
>{
public
class
HomeActivity
extends
BaseActivity
<
ActivityHomeBinding
,
HomeViewModel
>{
...
@@ -40,13 +48,37 @@ public class HomeActivity extends BaseActivity<ActivityHomeBinding,HomeViewModel
...
@@ -40,13 +48,37 @@ public class HomeActivity extends BaseActivity<ActivityHomeBinding,HomeViewModel
@Override
@Override
public
int
initVariableId
()
{
public
int
initVariableId
()
{
return
1
;
return
BR
.
homeViewModel
;
}
}
@Override
@Override
public
void
initData
()
{
public
void
initData
()
{
super
.
initData
();
super
.
initData
();
Log
.
v
(
"直接登录首页"
,
""
);
// 获取SharedPreferences实例
SharedPreferences
sharedPreferences
=
getSharedPreferences
(
"AppNamePreferences"
,
Context
.
MODE_PRIVATE
);
// 从SharedPreferences中获取用户名和密码
String
username
=
sharedPreferences
.
getString
(
"username"
,
null
);
String
password
=
sharedPreferences
.
getString
(
"password"
,
null
);
String
token
=
sharedPreferences
.
getString
(
"token"
,
null
);
// 检查是否成功获取到用户名和密码
if
(
username
!=
null
&&
password
!=
null
)
{
Log
.
v
(
"刚开始获取的账号:"
,
username
);
Log
.
v
(
"刚开始获取的密码:"
,
password
);
Log
.
v
(
"刚开始获取的token:"
,
token
);
Interceptor_TOKEN
=
token
;
viewModel
.
getLogin
(
username
,
password
);
}
else
{
Log
.
v
(
"账号密码为空跳转登录页"
,
""
);
startActivity
(
LoginActivity
.
class
);
finish
();
}
// 初始化底部导航栏
// 初始化底部导航栏
BottomNavigationView
bottomNavigationView
=
findViewById
(
R
.
id
.
bottom_navigation_view
);
BottomNavigationView
bottomNavigationView
=
findViewById
(
R
.
id
.
bottom_navigation_view
);
bottomNavigationView
.
setOnNavigationItemSelectedListener
(
navItemSelectedListener
);
bottomNavigationView
.
setOnNavigationItemSelectedListener
(
navItemSelectedListener
);
...
@@ -111,5 +143,11 @@ public class HomeActivity extends BaseActivity<ActivityHomeBinding,HomeViewModel
...
@@ -111,5 +143,11 @@ public class HomeActivity extends BaseActivity<ActivityHomeBinding,HomeViewModel
}
}
@Override
public
HomeViewModel
initViewModel
()
{
HomeRequest
lm
=
new
HomeRequest
();
return
new
HomeViewModel
(
getApplication
(),
lm
);
}
}
}
hbhbcompany/src/main/java/com/xx/hbhbcompany/ui/home/HomeViewModel.java
View file @
453183a1
This diff is collapsed.
Click to expand it.
hbhbcompany/src/main/java/com/xx/hbhbcompany/ui/login/LoginViewModel.java
View file @
453183a1
...
@@ -9,6 +9,7 @@ import android.app.Application;
...
@@ -9,6 +9,7 @@ import android.app.Application;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -343,6 +344,12 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
...
@@ -343,6 +344,12 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
public
void
onSuccess
(
String
resultBean
)
{
public
void
onSuccess
(
String
resultBean
)
{
//是指token
//是指token
Interceptor_TOKEN
=
resultBean
;
Interceptor_TOKEN
=
resultBean
;
SharedPreferences
sharedPreferences
=
getContext
().
getSharedPreferences
(
"AppNamePreferences"
,
Context
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
putString
(
"username"
,
userName
.
get
());
editor
.
putString
(
"password"
,
password
.
get
());
editor
.
putString
(
"token"
,
Interceptor_TOKEN
);
editor
.
apply
();
// 请求字典数据
// 请求字典数据
getDictValue
();
getDictValue
();
//临时关闭
//临时关闭
...
@@ -434,6 +441,7 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
...
@@ -434,6 +441,7 @@ public class LoginViewModel extends BaseViewModel<LoginRequest> {
ShowOverDueDialog
();
ShowOverDueDialog
();
}
else
{
}
else
{
startActivity
(
HomeActivity
.
class
);
startActivity
(
HomeActivity
.
class
);
finish
();
}
}
// startActivity(MerchantAuditListActivity.class);
// startActivity(MerchantAuditListActivity.class);
...
...
hbhbcompany/src/main/java/com/xx/hbhbcompany/ui/mine/MineViewModel.java
View file @
453183a1
...
@@ -4,6 +4,7 @@ import android.Manifest;
...
@@ -4,6 +4,7 @@ import android.Manifest;
import
android.app.Application
;
import
android.app.Application
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.Bundle
;
...
@@ -130,8 +131,24 @@ public class MineViewModel extends BaseViewModel<MineRequest> {
...
@@ -130,8 +131,24 @@ public class MineViewModel extends BaseViewModel<MineRequest> {
showCommTextDialog
(
new
RefuseDialogBean
(
"是否确定退出?"
,
"确定"
,
"取消"
),
new
CommTextDialog
.
onAcceptCallBack
()
{
showCommTextDialog
(
new
RefuseDialogBean
(
"是否确定退出?"
,
"确定"
,
"取消"
),
new
CommTextDialog
.
onAcceptCallBack
()
{
@Override
@Override
public
void
acceptBack
()
{
public
void
acceptBack
()
{
startActivity
(
LoginActivity
.
class
);
AppManager
.
getAppManager
().
finishAllActivityExThis
(
LoginActivity
.
class
);
// 获取SharedPreferences实例
SharedPreferences
sharedPreferences
=
getApplication
().
getSharedPreferences
(
"AppNamePreferences"
,
Context
.
MODE_PRIVATE
);
// 获取SharedPreferences.Editor实例
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
// 清除username和password
editor
.
remove
(
"username"
);
editor
.
remove
(
"password"
);
editor
.
remove
(
"token"
);
// 提交更改
editor
.
apply
();
startActivity
(
LoginActivity
.
class
);
// 跳转到登录页面
finish
();
// startActivity(LoginActivity.class);
// AppManager.getAppManager().finishAllActivityExThis(LoginActivity.class);
}
}
@Override
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment