Commit a4949318 authored by 张释方's avatar 张释方

提交个人中心界面逻辑

parent 6ef43e37
......@@ -55,7 +55,7 @@ interface MainApi {
* 获取用户登录信息
*/
@POST("api/baseMsg")
fun baseMsg():Observable<Response<BaseResponse<MyInfo>>>
fun baseMsg():Observable<Response<BaseResponse<UserBean>>>
/**
* 绑定手机号接口
......
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
package com.mints.street.bean
import java.io.Serializable
class MyInfo {
val token: String = ""
val consumer: ConsumerBean? = null
inner class ConsumerBean : Serializable {
val openid: String = ""
val nickname: String = ""
val mobile: String = ""
val idcode: String = ""
val isForever: Boolean = false
val expireTime: Long = 0
val pk_id: Long = 0
}
}
......@@ -8,7 +8,6 @@ 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.bean.UserBean
import com.mints.street.databinding.ActivityBindmobileBinding
import com.mints.street.main.MainActivity
......
......@@ -3,7 +3,6 @@ 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.bean.UserBean
import com.mints.street.manager.UserManager
import com.mints.street.model.ApiModel
......
......@@ -68,7 +68,7 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
item_phone.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(phone, null, null, null)
item_phone.findViewById<ImageView>(R.id.iv_right).visibility = View.GONE
item_userAgree.findViewById<TextView>(R.id.tv_title).text = "用户协议"
item_userAgree.findViewById<TextView>(R.id.tv_title).text = "注册协议"
val userAgree = ContextCompat.getDrawable(this, R.mipmap.icon_settings_user)
userAgree?.setBounds(0, 0, 56, 56)
item_userAgree.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(userAgree, null, null, null)
......@@ -111,10 +111,10 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
KLog.e("setOnClick", "btn_switch has been clicked.")
}
R.id.item_userAgree -> {//用户协议
ToastUtils.showShort("点击了《注册协议》")
}
R.id.item_privacyAgree -> {//隐私协议
ToastUtils.showShort("点击了《隐私协议》")
}
}
......
......@@ -19,7 +19,7 @@ import com.fry.base.base.BaseFragment
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.bean.MyInfo
import com.mints.street.bean.UserBean
import com.mints.street.bean.WXInfo
import com.mints.street.databinding.FragmentMyBinding
import com.mints.street.login.LoginActivity
......@@ -31,6 +31,7 @@ import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.fragment_my.*
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.*
......@@ -43,7 +44,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
View.OnClickListener, OnLoginListener {
private val userManager by lazy { UserManager.INSTANCE }
private var userConfig: MyInfo? = null
private var userConfig: UserBean? = null
private val loginApi by lazy { LoginApi() }
private var wxInfo: WXInfo? = null
......@@ -53,6 +54,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
private var iv_weixin: ImageView? = null
private var ly_phone: LinearLayoutCompat? = null
private var cb_checked: CheckBox? = null
private var tv_regist: TextView? = null
private var tv_private: TextView? = null
override fun initContentView(inflater: LayoutInflater?,
......@@ -64,7 +67,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
super.initData()
srl_my.setOnRefreshListener(this)
//隐藏立即领取
bt_try.visibility=View.GONE
bt_try.visibility = View.GONE
initView()
initListener()
}
......@@ -72,33 +75,44 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
override fun onResume() {
super.onResume()
if (userManager.userIsLogin()) {
//查询用户登录信息
viewModel.getmyInfo()
}else{
//重新显示界面信息
setUserLoginStatus()
}
//
// if (userManager.userIsLogin()) {
// //查询用户登录信息
// viewModel.getmyInfo()
// } else {
// //重新显示界面信息
// setUserLoginStatus()
// }
}
private fun initListener() {
//设置登录点击事件
binding.llMyLogin.setOnClickListener {
if (!userManager.userIsLogin()) {
//创建弹窗
mBottomSheetDialog = BottomSheetDialog(context!!)
val view1: View = layoutInflater.inflate(R.layout.layout_popupwindow, null)
mBottomSheetDialog!!.setContentView(view1)
mBottomSheetDialog!!.window!!.findViewById<View>(R.id.design_bottom_sheet).setBackgroundColor(Color.TRANSPARENT)
mBottomSheetDialog!!.show()
iv_weixin = view1.findViewById(R.id.iv_weixin)
ly_phone = view1.findViewById(R.id.ly_phone)
cb_checked = view1.findViewById(R.id.cb_checked)
tv_private = view1.findViewById(R.id.tv_private)
tv_regist = view1.findViewById(R.id.tv_regist)
tv_regist?.setOnClickListener(this)
tv_private?.setOnClickListener(this)
iv_weixin?.setOnClickListener(this)
ly_phone?.setOnClickListener(this)
}
}
}
//设置立即领取点击事件
binding.btTry.setOnClickListener {
......@@ -143,8 +157,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
R.id.iv_weixin -> {
if (cb_checked!!.isChecked) {
// ToastUtils.showShort("未完成微信登录对接")
val wechat =ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid){
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
ToastUtils.showShort("请先安装微信")
return
}
......@@ -172,13 +186,20 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
R.id.tv_regist -> {
KLog.e("sssss", "点击了《注册协议》")
ToastUtils.showShort("点击了《注册协议》")
}
R.id.tv_private -> {
KLog.e("sssss", "点击了《隐私协议》")
ToastUtils.showShort("点击了《隐私协议》")
}
}
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.myInfodata.observe(this, Observer<MyInfo> {
viewModel.myInfodata.observe(this, Observer<UserBean> {
srl_my.finishRefresh(true)
if (it == null) {
userConfig = null
......@@ -195,7 +216,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
private fun setUserLoginStatus() {
if (userManager.userIsLogin()) {
// 已登录
item_title_id.text=userManager.getWxName()
item_title_id.text = userManager.getWxName()
Glide.with(requireContext()).load(userManager.getWxHeader()).into(item_title_avatar)
} else {
// 未登录
......@@ -205,13 +226,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
}
override fun onRefresh(refreshLayout: RefreshLayout) {
if (userManager.userIsLogin()) {
//查询用户登录信息
viewModel.getmyInfo()
}else{
setUserLoginStatus()
srl_my.finishRefresh(true)
}
}
override fun onDestroy() {
super.onDestroy()
......
......@@ -3,7 +3,6 @@ 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.MyInfo
import com.mints.street.bean.UserBean
import com.mints.street.common.DeviceInfo
import com.mints.street.manager.UserManager
......@@ -19,7 +18,7 @@ import java.util.HashMap
*/
class MyViewModel(application: Application) : BaseViewModel(application) {
val myInfodata: MutableLiveData<MyInfo> = MutableLiveData()
val myInfodata: MutableLiveData<UserBean> = MutableLiveData()
val deviceInfo: DeviceInfo
get() {
......@@ -31,11 +30,13 @@ class MyViewModel(application: Application) : BaseViewModel(application) {
*/
fun getmyInfo() {
ApiModel.getuserInfo(lifecycleProvider).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<MyInfo>>(
object : HttpSubscribeImpl<BaseResponse<UserBean>>(
this@MyViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<MyInfo>) {
override fun onBusinessSuccess(response: BaseResponse<UserBean>) {
myInfodata.value = response.result
//保存用户信息到Usermanager
UserManager.INSTANCE.saveUserInfo(response.result)
KLog.e("getmyInfo", response.result.toString())
}
......
......@@ -57,7 +57,7 @@ object ApiModel {
/**
* 获取用户登录信息
*/
fun getuserInfo(lifecycleProvider: LifecycleProvider<Any>?): Observable<Response<BaseResponse<MyInfo>>> {
fun getuserInfo(lifecycleProvider: LifecycleProvider<Any>?): Observable<Response<BaseResponse<UserBean>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider, MainApi.newInstance().baseMsg())
}
......
......@@ -4,7 +4,7 @@
<!-- 边框的颜色和粗细 -->
<stroke
android:width="1dp"
android:color="#4CAF50"
android:color="#C7EDCC"
/>
<solid android:color="#ffffffff" />
<corners android:radius="10dp" />
......
......@@ -30,7 +30,7 @@
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="65dp"
android:src="@mipmap/ic_avatar_ph" />
android:src="@mipmap/ic_launcher_main" />
<LinearLayout
android:layout_centerHorizontal="true"
android:id="@+id/ly_text"
......
......@@ -12,7 +12,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/include_header" />
<com.mints.street.widget.ElasticScrollView
......
......@@ -75,6 +75,7 @@
android:layout_width="wrap_content"
android:layout_height="20dp"
app:isOpened="true"
app:primaryColor="#2196F3"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
......@@ -120,6 +121,7 @@
<com.github.iielse.switchbutton.SwitchView
android:id="@+id/svStrong"
app:primaryColor="#2196F3"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
......@@ -168,6 +170,7 @@
<com.github.iielse.switchbutton.SwitchView
android:id="@+id/svReadmsg"
app:primaryColor="#2196F3"
android:layout_width="wrap_content"
android:layout_height="20dp"
app:isOpened="true"
......@@ -231,14 +234,14 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《隐私协议》"
android:text="《注册协议》"
android:textColor="@color/black"
android:textSize="12sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《用户协议》"
android:text="《隐私协议》"
android:textColor="@color/black"
android:textSize="12sp" />
</LinearLayout>
......
......@@ -8,11 +8,11 @@
<androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/ly_phone"
android:layout_alignParentRight="true"
android:paddingTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_alignParentRight="true"
android:orientation="horizontal"
android:paddingTop="20dp">
<TextView
android:layout_width="wrap_content"
......@@ -27,10 +27,10 @@
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_below="@+id/ly_phone"
android:id="@+id/ly_constrain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ly_phone"
android:layout_centerHorizontal="true"
android:padding="10dp">
......@@ -78,9 +78,10 @@
android:textColor="@color/black" />
<TextView
android:id="@+id/tv_regist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《隐私政策》"
android:text="《注册协议》"
android:textColor="@color/black" />
<TextView
......@@ -90,9 +91,10 @@
android:textColor="@color/black" />
<TextView
android:id="@+id/tv_private"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="《用户协议》"
android:text="《隐私协议》"
android:textColor="@color/black" />
</LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment