Commit e9635526 authored by fengruiyu's avatar fengruiyu

Merge branch 'branche_zsf' of http://39.97.65.143:81/android/android_street into fry_dev

parents 9fa3b5fe e4f090c2
......@@ -23,7 +23,7 @@ interface MainApi {
* @return
*/
@POST("api/sendMobileCode")
fun sendMobileCode(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
fun sendMobileCode(@Body vo: Map<String, String>): Observable<Response<BaseResponse<Any>>>
/**
* 登录
......@@ -55,7 +55,7 @@ interface MainApi {
* 获取用户登录信息
*/
@POST("api/baseMsg")
fun baseMsg():Observable<Response<BaseResponse<MyInfo>>>
fun baseMsg():Observable<Response<BaseResponse<UserBean>>>
/**
* 绑定手机号接口
......
......@@ -12,7 +12,8 @@ import java.io.Serializable;
*/
public class BaseResponse<T> implements Serializable {
private int status;
private String message;
private String message="";
// @JsonAdapter(value = JsonAdapterGsonDeserializer.class)
@SerializedName("data")
......@@ -27,6 +28,11 @@ public class BaseResponse<T> implements Serializable {
this.result = result;
}
public BaseResponse(int status) {
this.status = status;
}
public int getstatus() {
return status;
}
......
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
}
}
......@@ -47,6 +47,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
return@setOnClickListener
}
sendCodeThread()
mobile = mobile.replace(" ".toRegex(), "")
viewModel.sendMobileCode(mobile)
......@@ -117,4 +118,31 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
R.id.iv_left_icon -> finish()
}
}
/**
* 发送手机验证码,按钮动态改变状态
*/
var num = 0
var run: Runnable? = null
fun sendCodeThread() {
num = 60
tv_send_sms?.let {
it.isEnabled = false
it.text = "($num)重新获取"
run = object : Runnable {
override fun run() {
num--
if (num == 0) {
it.text = "重新获取"
it.isEnabled = true
} else {
it.text = "($num)重新获取"
it.postDelayed(this, 1000)
}
}
}
it.postDelayed(run, 1000)
}
}
}
\ No newline at end of file
......@@ -32,15 +32,15 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
* @param mobile
*/
fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>()
val vo = HashMap<String, String>()
vo["mobile"] = mobile
vo["type"] = 1
// vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe(
ApiModel.sendMobileCode(lifecycleProvider,vo).subscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
// KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
......
......@@ -51,7 +51,7 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
}
//加载本地GIF动图
ImageLoader.ImageBuilder.with(this)
.setDrawable(R.mipmap.ic_eye_tokephone)
.setDrawable(R.mipmap.ic_earth_map)
.setTargetView(binding.ivTakephoto).start()
binding.mainBottom.interceptLongClick(
......
......@@ -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
......
......@@ -16,6 +16,7 @@ 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.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils
import org.w3c.dom.Text
......@@ -53,6 +54,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
item_phone.findViewById<TextView>(R.id.tv_right).setTextColor(Color.BLACK)
item_phone.findViewById<TextView>(R.id.tv_right).text = "去绑定"
item_phone.setOnClickListener(this)
RxUtils.onMultiClick(item_phone){
if (userManager.userIsLogin()) {
startActivity(BindMobileActivity::class.java)
return@onMultiClick
} else {
ToastUtils.showLong("请先使用微信登录")
}
}
}
}
private fun initView() {
......@@ -68,7 +77,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)
......@@ -96,14 +105,14 @@ class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, Moresetti
R.id.iv_left_icon -> {
finish()
}
R.id.item_phone -> {
if (userManager.userIsLogin()) {
startActivity(BindMobileActivity::class.java)
return
} else {
ToastUtils.showLong("请先使用微信登录")
}
}
// R.id.item_phone -> {
// if (userManager.userIsLogin()) {
// startActivity(BindMobileActivity::class.java)
// return
// } else {
// ToastUtils.showLong("请先使用微信登录")
// }
// }
R.id.btn_switch -> {//退出登录
UserManager.INSTANCE.userLogout()
......@@ -111,10 +120,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,8 @@ 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.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.*
......@@ -43,7 +45,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 +55,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 +68,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 +76,53 @@ 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 {
RxUtils.onMultiClick(binding.llMyLogin){
// 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)
// ly_phone?.setOnClickListener(this)
RxUtils.onMultiClick(ly_phone){
if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java)
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
}
}
//设置立即领取点击事件
binding.btTry.setOnClickListener {
......@@ -110,8 +134,13 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
}
}
aboutus.setOnClickListener(this)
moresettings.setOnClickListener(this)
RxUtils.onMultiClick(aboutus){
startActivity(AboutusActivity::class.java)
}
RxUtils.onMultiClick(moresettings){
startActivity(MoresettingsActivity::class.java)
}
}
private fun initView() {
......@@ -133,18 +162,11 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
override fun onClick(v: View?) {
when (v?.id) {
R.id.aboutus -> {
startActivity(AboutusActivity::class.java)
// startActivity(PermissionsActivity::class.java)
}
R.id.moresettings -> {
startActivity(MoresettingsActivity::class.java)
}
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
}
......@@ -164,21 +186,28 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
R.id.ly_phone -> {
if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java)
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
// R.id.ly_phone -> {
// if (cb_checked!!.isChecked) {
// startActivity(LoginActivity::class.java)
// mBottomSheetDialog!!.dismiss()
// } else {
// 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 +224,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 +234,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())
}
......
......@@ -16,7 +16,7 @@ object ApiModel {
/**
* 发送验证码
*/
fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, String>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider, MainApi.newInstance().sendMobileCode(map))
}
......@@ -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="#03A9F4"
/>
<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"
......
......@@ -104,8 +104,8 @@
<TextView
android:id="@+id/tv_send_sms"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_width="120dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:gravity="center"
......
......@@ -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"
......@@ -216,8 +219,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:gravity="bottom|center_horizontal"
android:orientation="horizontal">
......@@ -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>
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/menu_home"
android:checked="true"
......@@ -9,7 +10,7 @@
<item
android:id="@+id/menu_square"
android:icon="@drawable/menu_square"
android:title="@string/bottom_name_square" />
tools:ignore="MenuTitle" />
<item
......
......@@ -6,7 +6,7 @@ package me.goldze.mvvmhabit.http;
public class ResponseThrowable extends Exception {
public int code;
public String message;
public String message = "";
public ResponseThrowable(Throwable throwable, int code) {
super(throwable);
......
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