Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_street
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
0
Merge Requests
0
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
android
android_street
Commits
deaf0bd6
Commit
deaf0bd6
authored
Jul 16, 2021
by
张释方
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交手机号绑定代码
parent
c70818f0
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
155 additions
and
37 deletions
+155
-37
MainApi.kt
app/src/main/java/com/mints/street/api/MainApi.kt
+11
-0
BindMobileBean.kt
app/src/main/java/com/mints/street/bean/BindMobileBean.kt
+16
-0
LoginActivity.kt
app/src/main/java/com/mints/street/login/LoginActivity.kt
+1
-1
LoginViewModel.kt
app/src/main/java/com/mints/street/login/LoginViewModel.kt
+10
-4
BindMobileActivity.kt
.../main/java/com/mints/street/main/my/BindMobileActivity.kt
+19
-2
BindMobileViewModel.kt
...main/java/com/mints/street/main/my/BindMobileViewModel.kt
+36
-6
MoresettingsActivity.kt
...ain/java/com/mints/street/main/my/MoresettingsActivity.kt
+19
-4
MyFragment.kt
app/src/main/java/com/mints/street/main/my/MyFragment.kt
+22
-15
UserManager.kt
app/src/main/java/com/mints/street/manager/UserManager.kt
+1
-0
ApiModel.kt
app/src/main/java/com/mints/street/model/ApiModel.kt
+15
-0
HttpSubscribeImpl.kt
...n/java/com/mints/street/netwrok/base/HttpSubscribeImpl.kt
+2
-2
GsonConverterFactory.java
...com/mints/street/netwrok/common/GsonConverterFactory.java
+1
-1
activity_bindmobile.xml
app/src/main/res/layout/activity_bindmobile.xml
+2
-0
view_data_page1.xml
app/src/main/res/layout/view_data_page1.xml
+0
-2
No files found.
app/src/main/java/com/mints/street/api/MainApi.kt
View file @
deaf0bd6
...
...
@@ -57,4 +57,15 @@ interface MainApi {
@POST
(
"api/baseMsg"
)
fun
baseMsg
():
Observable
<
Response
<
BaseResponse
<
MyInfo
>>>
/**
* 绑定手机号接口
*/
@POST
(
"api/bindingMobile"
)
fun
bindingMobile
(
@Body
vo
:
@JvmSuppressWildcards
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
BindMobileBean
>>>
/**
* 获取绑定手机号验证码接口
*/
@POST
(
"api/sendMobileBindingCode"
)
fun
sendMobileBindingCode
(
@Body
vo
:
@JvmSuppressWildcards
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
Any
>>>
}
\ No newline at end of file
app/src/main/java/com/mints/street/bean/BindMobileBean.kt
0 → 100644
View file @
deaf0bd6
package
com.mints.street.bean
data class
BindMobileBean
(
val
consumer
:
Consumer
,
val
token
:
Any
)
data class
Consumer
(
val
createTime
:
Int
,
val
expireTime
:
Int
,
val
idcode
:
String
,
val
isForever
:
Boolean
,
val
mobile
:
String
,
val
nickname
:
String
,
val
pk_id
:
Long
)
\ No newline at end of file
app/src/main/java/com/mints/street/login/LoginActivity.kt
View file @
deaf0bd6
...
...
@@ -100,7 +100,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
override
fun
initViewObservable
()
{
super
.
initViewObservable
()
viewModel
.
data
.
observe
(
this
,
Observer
<
String
>
{
ToastUtils
.
showLong
(
"
初始化
成功"
)
ToastUtils
.
showLong
(
"
登录
成功"
)
startActivityThenKill
(
MainActivity
::
class
.
java
)
})
...
...
app/src/main/java/com/mints/street/login/LoginViewModel.kt
View file @
deaf0bd6
...
...
@@ -27,7 +27,7 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
}
/**
* 手机验证码
*
获取
手机验证码
*
* @param mobile
*/
...
...
@@ -49,6 +49,9 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
})
}
/**
* 调用登录接口
*/
fun
login
(
mobile
:
String
,
smsCode
:
String
)
{
// showDialog()
val
vo
=
HashMap
<
String
,
Any
>()
...
...
@@ -60,15 +63,18 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
object
:
HttpSubscribeImpl
<
BaseResponse
<
UserBean
>>(
this
@LoginViewModel
,
true
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
UserBean
>)
{
// dismissDialog()
//提交设备信息
this
@LoginViewModel
.
saveTerminalInfo
()
//保存用户信息到Usermanager
UserManager
.
INSTANCE
.
saveUserInfo
(
response
.
result
)
data
.
value
=
response
.
message
KLog
.
e
(
"login"
,
response
.
result
.
toString
())
ToastUtils
.
showShort
(
"登录信息="
+
response
.
result
.
consumer
?.
idcode
)
//
ToastUtils.showShort("登录信息="+response.result.consumer?.idcode)
data
.
value
=
response
.
message
}
override
fun
onError
(
e
:
Throwable
)
{
...
...
app/src/main/java/com/mints/street/main/my/BindMobileActivity.kt
View file @
deaf0bd6
...
...
@@ -4,10 +4,13 @@ import android.Manifest
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.View
import
androidx.lifecycle.Observer
import
com.fry.base.base.BaseActivity
import
com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.bean.BindMobileBean
import
com.mints.street.databinding.ActivityBindmobileBinding
import
com.mints.street.main.MainActivity
import
com.mints.street.utils.BackInputUtil
import
com.tbruyelle.rxpermissions2.RxPermissions
import
kotlinx.android.synthetic.main.activity_bindmobile.*
...
...
@@ -60,7 +63,7 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie
mobile
=
mobile
.
replace
(
" "
.
toRegex
(),
""
)
// loginPresenter.sendMobileBindingCode(mobile)
viewModel
.
sendMobileC
ode
(
mobile
)
viewModel
.
bindingMobilec
ode
(
mobile
)
}
R
.
id
.
tvLoginNext
->
{
var
mobile
=
etLoginMobile
.
text
.
toString
().
trim
()
...
...
@@ -80,7 +83,7 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie
.
subscribe
{
granted
:
Boolean
->
if
(
granted
)
{
mobile
=
mobile
.
replace
(
" "
.
toRegex
(),
""
)
// loginPresenter.bindingMobile(mobile,
code)
viewModel
.
bindingMobile
(
mobile
,
code
)
}
else
{
// showMissingPermissionDialog("设备")
}
...
...
@@ -89,6 +92,20 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie
}
}
override
fun
initViewObservable
()
{
super
.
initViewObservable
()
viewModel
.
bindmobiledata
.
observe
(
this
,
Observer
<
BindMobileBean
>
{
ToastUtils
.
showLong
(
"请求绑定手机号接口成功"
)
startActivityThenKill
(
MainActivity
::
class
.
java
)
})
viewModel
.
data
.
observe
(
this
,
Observer
{
})
}
/**
* 发送手机验证码,按钮动态改变状态
*/
var
num
=
0
var
run
:
Runnable
?
=
null
fun
sendCodeThread
()
{
...
...
app/src/main/java/com/mints/street/main/my/BindMobileViewModel.kt
View file @
deaf0bd6
...
...
@@ -3,6 +3,7 @@ package com.mints.street.main.my
import
android.app.Application
import
androidx.lifecycle.MutableLiveData
import
com.mints.street.bean.BaseResponse
import
com.mints.street.bean.BindMobileBean
import
com.mints.street.model.ApiModel
import
com.mints.street.netwrok.base.HttpSubscribeImpl
import
me.goldze.mvvmhabit.base.BaseViewModel
...
...
@@ -11,19 +12,21 @@ import java.util.HashMap
class
BindMobileViewModel
(
application
:
Application
):
BaseViewModel
(
application
)
{
val
data
:
MutableLiveData
<
String
>
=
MutableLiveData
()
val
bindmobiledata
:
MutableLiveData
<
BindMobileBean
>
=
MutableLiveData
()
val
data
:
MutableLiveData
<
String
>
=
MutableLiveData
()
/**
*
手机
验证码
*
绑定手机号
验证码
*
* @param mobile
*/
fun
sendMobileC
ode
(
mobile
:
String
)
{
fun
bindingMobilec
ode
(
mobile
:
String
)
{
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"mobile"
]
=
mobile
vo
[
"type"
]
=
1
ApiModel
.
sendMobileC
ode
(
lifecycleProvider
,
vo
).
safeSubscribe
(
ApiModel
.
bindingMobilec
ode
(
lifecycleProvider
,
vo
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
Any
>>(
this
@BindMobileViewModel
,
true
)
{
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
Any
>)
{
...
...
@@ -31,8 +34,35 @@ class BindMobileViewModel (application: Application): BaseViewModel(application)
}
override
fun
onError
(
e
:
Throwable
)
{
data
.
value
=
"失败"
KLog
.
e
(
"sendMobileCode"
,
"发送验证码错误"
)
KLog
.
e
(
"sendMobileCode"
,
"
绑定手机号
发送验证码错误"
)
}
})
}
/**
* 绑定手机号
*/
fun
bindingMobile
(
mobile
:
String
,
smsCode
:
String
){
val
vo
=
HashMap
<
String
,
Any
>()
vo
[
"mobile"
]=
mobile
vo
[
"smsCode"
]=
smsCode
ApiModel
.
bindingMobile
(
lifecycleProvider
,
vo
).
safeSubscribe
(
object
:
HttpSubscribeImpl
<
BaseResponse
<
BindMobileBean
>>(
this
@BindMobileViewModel
,
true
){
override
fun
onBusinessSuccess
(
response
:
BaseResponse
<
BindMobileBean
>)
{
bindmobiledata
.
value
=
response
.
result
KLog
.
e
(
"bindingMobile"
,
response
.
result
.
toString
())
}
override
fun
onBusinessFail
(
response
:
BaseResponse
<
BindMobileBean
>?)
{
super
.
onBusinessFail
(
response
)
}
override
fun
onError
(
e
:
Throwable
)
{
KLog
.
e
(
"bindingMobile"
,
"绑定手机号接口失败"
)
}
}
)
}
}
app/src/main/java/com/mints/street/main/my/MoresettingsActivity.kt
View file @
deaf0bd6
...
...
@@ -10,11 +10,17 @@ import com.fry.base.base.BaseActivity
import
com.mints.street.BR
import
com.mints.street.R
import
com.mints.street.databinding.ActivityMoresettingsBinding
import
com.mints.street.main.MainActivity
import
com.mints.street.manager.UserManager
import
kotlinx.android.synthetic.main.activity_moresettings.*
import
kotlinx.android.synthetic.main.include_header.*
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.ToastUtils
class
MoresettingsActivity
:
BaseActivity
<
ActivityMoresettingsBinding
,
MoresettingsViewModel
>(),
View
.
OnClickListener
{
private
val
userManager
by
lazy
{
UserManager
.
INSTANCE
}
override
fun
initVariableId
()
=
BR
.
viewModel
override
fun
initContentView
(
savedInstanceState
:
Bundle
?)
=
R
.
layout
.
activity_moresettings
override
fun
initData
()
{
...
...
@@ -29,6 +35,7 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
iv_left_icon
.
setOnClickListener
(
this
)
item_userAgree
.
setOnClickListener
(
this
)
item_privacyAgree
.
setOnClickListener
(
this
)
btn_switch
.
setOnClickListener
(
this
)
}
...
...
@@ -39,7 +46,7 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
iv_left_icon
.
setImageResource
(
R
.
mipmap
.
ic_arrow_back
)
iv_left_icon
.
visibility
=
View
.
VISIBLE
item_phone
.
findViewById
<
TextView
>(
R
.
id
.
tv_title
).
text
=
"手机号"
item_phone
.
findViewById
<
TextView
>(
R
.
id
.
tv_title
).
text
=
"
绑定
手机号"
val
phone
=
ContextCompat
.
getDrawable
(
this
,
R
.
mipmap
.
icon_settings_tel
)
phone
?.
setBounds
(
0
,
0
,
56
,
56
)
item_phone
.
findViewById
<
TextView
>(
R
.
id
.
tv_title
).
setCompoundDrawables
(
phone
,
null
,
null
,
null
)
...
...
@@ -76,10 +83,19 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
// return
// }
// if (userManager.mobile.isEmpty()) {
startActivity
(
BindMobileActivity
::
class
.
java
)
// if (userManager.getMobile().isEmpty()) {
startActivity
(
BindMobileActivity
::
class
.
java
)
// }else{
// ToastUtils.showLong("当前手机号已绑定")
// }
}
R
.
id
.
btn_switch
->
{
//推出登录
if
(!
userManager
.
getMobile
().
isEmpty
()){
UserManager
.
INSTANCE
.
userLogout
()
startActivityThenKill
(
MainActivity
::
class
.
java
)
}
KLog
.
e
(
"setOnClick"
,
"btn_switch has been clicked."
)
}
R
.
id
.
item_userAgree
->
{
}
...
...
@@ -91,6 +107,5 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
}
}
app/src/main/java/com/mints/street/main/my/MyFragment.kt
View file @
deaf0bd6
...
...
@@ -29,6 +29,7 @@ import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import
kotlinx.android.synthetic.main.activity_moresettings.*
import
kotlinx.android.synthetic.main.fragment_my.*
import
me.goldze.mvvmhabit.utils.KLog
import
me.goldze.mvvmhabit.utils.ToastUtils
/**
...
...
@@ -55,6 +56,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
override
fun
initVariableId
()
=
BR
.
viewModel
override
fun
initData
()
{
super
.
initData
()
srl_my
.
setOnRefreshListener
(
this
)
initView
()
initListener
()
}
...
...
@@ -63,7 +65,11 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
super
.
onResume
()
if
(
userManager
.
userIsLogin
())
{
//查询用户登录信息
viewModel
.
getmyInfo
()
}
else
{
//重新显示界面信息
setUserLoginStatus
()
}
}
...
...
@@ -89,7 +95,11 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
//设置立即领取点击事件
binding
.
btTry
.
setOnClickListener
{
// startActivity(PermissionsActivity::class.java)
startActivity
(
OpenvipActivity
::
class
.
java
)
if
(
userManager
.
userIsLogin
())
{
startActivity
(
OpenvipActivity
::
class
.
java
)
}
else
{
ToastUtils
.
showLong
(
"请先登录!"
)
}
}
aboutus
.
setOnClickListener
(
this
)
...
...
@@ -124,9 +134,9 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
}
R
.
id
.
iv_weixin
->
{
if
(
cb_checked
!!
.
isChecked
)
{
Toast
.
makeText
(
context
,
"未完成微信登录对接"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Toast
Utils
.
showShort
(
"未完成微信登录对接"
)
}
else
{
Toast
.
makeText
(
context
,
"请先同意用户协议与隐私政策"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Toast
Utils
.
showShort
(
"请先同意用户协议与隐私政策"
)
}
}
R
.
id
.
ly_phone
->
{
...
...
@@ -134,7 +144,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
startActivity
(
LoginActivity
::
class
.
java
)
mBottomSheetDialog
!!
.
dismiss
()
}
else
{
Toast
.
makeText
(
context
,
"请先同意用户协议与隐私政策"
,
Toast
.
LENGTH_SHORT
).
show
(
)
Toast
Utils
.
showShort
(
"请先同意用户协议与隐私政策"
)
}
}
...
...
@@ -157,21 +167,18 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
}
private
fun
setUserLoginStatus
()
{
// if (userManager.userIsLogin()) {
// if (userManager.getMobile().isNotEmpty()) {
item_title_id
.
text
=
userManager
.
getMobile
()
// } else {
// item_title_id.text = "未登录"
// }
// }
if
(
userManager
.
getMobile
().
isNotEmpty
())
{
item_title_id
.
text
=
userManager
.
getMobile
()
}
else
{
item_title_id
.
text
=
"未登录"
}
}
override
fun
onRefresh
(
refreshLayout
:
RefreshLayout
)
{
KLog
.
e
(
"onRefresh"
,
"The current page has been refreshed."
)
//重新显示界面信息
setUserLoginStatus
()
}
// if (it.consumer!!.mobile.isNotEmpty()) {
// item_title_id.text = it.consumer.mobile
// }
}
...
...
app/src/main/java/com/mints/street/manager/UserManager.kt
View file @
deaf0bd6
...
...
@@ -170,6 +170,7 @@ class UserManager {
fun
userLogout
()
{
MMKV
.
mmkvWithID
(
USER_ID
).
remove
(
USER_ID
)
MMKV
.
mmkvWithID
(
MOBILE
).
remove
(
MOBILE
)
MMKV
.
mmkvWithID
(
CODE_ID
).
remove
(
CODE_ID
)
MMKV
.
mmkvWithID
(
TOKEN_ID
).
remove
(
TOKEN_ID
)
MMKV
.
mmkvWithID
(
WX_OPENID
).
remove
(
WX_OPENID
)
...
...
app/src/main/java/com/mints/street/model/ApiModel.kt
View file @
deaf0bd6
...
...
@@ -6,6 +6,7 @@ import com.mints.street.netwrok.common.HttpManager
import
com.trello.rxlifecycle2.LifecycleProvider
import
io.reactivex.Observable
import
retrofit2.Response
import
retrofit2.http.Body
/**
* Created by 冯瑞雨 on 2021/7/2.
...
...
@@ -60,4 +61,18 @@ object ApiModel {
return
HttpManager
.
getInstance
()
.
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
baseMsg
())
}
/**
* 绑定手机号登录
*/
fun
bindingMobile
(
lifecycleProvider
:
LifecycleProvider
<
Any
>?,
map
:
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
BindMobileBean
>>>{
return
HttpManager
.
getInstance
().
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
bindingMobile
(
map
))
}
/**
* 获取绑定手机号验证码
*/
fun
bindingMobilecode
(
lifecycleProvider
:
LifecycleProvider
<
Any
>?,
map
:
Map
<
String
,
Any
>):
Observable
<
Response
<
BaseResponse
<
Any
>>>{
return
HttpManager
.
getInstance
().
execute
(
lifecycleProvider
,
MainApi
.
newInstance
().
sendMobileBindingCode
(
map
))
}
}
\ No newline at end of file
app/src/main/java/com/mints/street/netwrok/base/HttpSubscribeImpl.kt
View file @
deaf0bd6
...
...
@@ -63,13 +63,13 @@ abstract class HttpSubscribeImpl<T : BaseResponse<*>>(viewModel: BaseViewModel?,
return
}
if
(
needToast
)
{
ToastUtils
.
show
Short
(
response
.
getMessage
())
ToastUtils
.
show
Long
(
response
.
getMessage
())
}
}
open
fun
onFailed
(
throwable
:
ResponseThrowable
?)
{
if
(
needToast
)
{
ToastUtils
.
show
Short
(
throwable
?.
responseMessage
)
ToastUtils
.
show
Long
(
throwable
?.
responseMessage
)
}
if
(
throwable
?.
code
==
ExceptionHandle
.
ERROR
.
HTTP_ERROR
||
throwable
?.
code
==
ExceptionHandle
.
ERROR
.
NETWORD_ERROR
||
throwable
?.
code
==
ExceptionHandle
.
ERROR
.
TIMEOUT_ERROR
)
{
viewModel
?.
viewSwitch
(
ViewStatus
.
NONETWORK
)
...
...
app/src/main/java/com/mints/street/netwrok/common/GsonConverterFactory.java
View file @
deaf0bd6
...
...
@@ -92,7 +92,7 @@ public class GsonConverterFactory extends Converter.Factory {
int
code
=
br
.
getstatus
();
if
(
code
==
401
)
{
try
{
//
UserManager.Companion.getINSTANCE().userLogout();
UserManager
.
Companion
.
getINSTANCE
().
userLogout
();
// Activity forwardActivity = ForegroundOrBackground.getApp_activity();
// if (forwardActivity != null) {
...
...
app/src/main/res/layout/activity_bindmobile.xml
View file @
deaf0bd6
...
...
@@ -45,6 +45,7 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/black"
android:text=
"手机号:"
/>
<com.mints.street.widget.ClearEditText
...
...
@@ -79,6 +80,7 @@
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"@color/black"
android:text=
"验证码:"
/>
<RelativeLayout
...
...
app/src/main/res/layout/view_data_page1.xml
View file @
deaf0bd6
...
...
@@ -2,9 +2,7 @@
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:gravity=
"center_horizontal"
android:background=
"@mipmap/icon_card"
android:orientation=
"vertical"
>
</LinearLayout>
\ No newline at end of file
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