国内微信登录和手机验证码登录
This commit is contained in:
8
.idea/deploymentTargetSelector.xml
generated
8
.idea/deploymentTargetSelector.xml
generated
@@ -4,6 +4,14 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
<DropdownSelection timestamp="2026-07-29T04:01:42.827217400Z">
|
||||||
|
<Target type="DEFAULT_BOOT">
|
||||||
|
<handle>
|
||||||
|
<DeviceId pluginId="PhysicalDevice" identifier="serial=3A251FDJH000CE" />
|
||||||
|
</handle>
|
||||||
|
</Target>
|
||||||
|
</DropdownSelection>
|
||||||
|
<DialogSelection />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
</selectionStates>
|
</selectionStates>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#Mon Jul 20 16:50:50 CST 2026
|
#Fri Jul 31 17:44:57 CST 2026
|
||||||
|
|||||||
Binary file not shown.
@@ -28,9 +28,9 @@ android {
|
|||||||
applicationId "com.abbidot.tracker"
|
applicationId "com.abbidot.tracker"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 35
|
targetSdkVersion 35
|
||||||
versionCode 2300
|
versionCode 2400
|
||||||
// versionName "2.3.0"
|
// versionName "2.4.0"
|
||||||
versionName "2.3.0-Beta2"
|
versionName "2.4.0-Beta1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,9 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.account.cn.VerifyCodeLoginCNActivity"
|
android:name=".ui.activity.account.cn.VerifyCodeLoginCNActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.activity.account.cn.WXLoginActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activity.account.cn.LoginV2CNActivity"
|
android:name=".ui.activity.account.cn.LoginV2CNActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|||||||
@@ -128,7 +128,8 @@ class MySubscriptionAdapter(
|
|||||||
} else if (item.subscriptionStatus == ConstantInt.Close) {
|
} else if (item.subscriptionStatus == ConstantInt.Close) {
|
||||||
setText(R.string.txt_enable_auto_renew)
|
setText(R.string.txt_enable_auto_renew)
|
||||||
expiresTitle.setText(R.string.txt_expires_on1)
|
expiresTitle.setText(R.string.txt_expires_on1)
|
||||||
View.VISIBLE
|
//createUserId不一样就是绑定了其他用户有套餐的设备
|
||||||
|
if (item.createUserId == userId) visibility else View.GONE
|
||||||
} else {
|
} else {
|
||||||
expiresTitle.setText(R.string.txt_expires_on1)
|
expiresTitle.setText(R.string.txt_expires_on1)
|
||||||
View.GONE
|
View.GONE
|
||||||
|
|||||||
@@ -556,7 +556,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
|||||||
|
|
||||||
private fun Activity.overrideTransitionOpen(enter: Int, exit: Int) {
|
private fun Activity.overrideTransitionOpen(enter: Int, exit: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_OPEN, enter, exit)
|
overrideActivityTransition(OVERRIDE_TRANSITION_OPEN, enter, exit)
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
overridePendingTransition(enter, exit)
|
overridePendingTransition(enter, exit)
|
||||||
@@ -565,7 +565,7 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
|||||||
|
|
||||||
private fun Activity.overrideTransitionClose(enter: Int, exit: Int) {
|
private fun Activity.overrideTransitionClose(enter: Int, exit: Int) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||||
overrideActivityTransition(Activity.OVERRIDE_TRANSITION_CLOSE, enter, exit)
|
overrideActivityTransition(OVERRIDE_TRANSITION_CLOSE, enter, exit)
|
||||||
} else {
|
} else {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
overridePendingTransition(enter, exit)
|
overridePendingTransition(enter, exit)
|
||||||
@@ -590,15 +590,19 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
|||||||
//服务器返回错误信息
|
//服务器返回错误信息
|
||||||
val exceptionMessage = it.exceptionOrNull()?.message
|
val exceptionMessage = it.exceptionOrNull()?.message
|
||||||
//服务器返回错误code
|
//服务器返回错误code
|
||||||
val exceptionCode: String? = it.exceptionOrNull()?.toString()
|
val exceptionCode= it.exceptionOrNull()?.toString()
|
||||||
LogUtil.d("Throwable异常", "code=${exceptionCode},${exceptionMessage}")
|
LogUtil.d("Throwable异常", "code=${exceptionCode},${exceptionMessage}")
|
||||||
if (null != exceptionCode) {
|
if (null != exceptionCode) {
|
||||||
//处理注册用户已存在的情况
|
//处理验证码登录,用户未注册的情况
|
||||||
if (exceptionCode == ErrorCode.USER_HAS_EXIST.toString()) {
|
if (!isShowCodeError && exceptionCode == ErrorCode.USER_NO_EXIST.toString()) {
|
||||||
getResultCallback.onRequestError(exceptionCode)
|
getResultCallback.onRequestError(exceptionCode)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
//处理注册用户已存在的情况
|
||||||
if (exceptionCode == ErrorCode.DEVICE_HAS_BIND.toString()) {
|
else if (exceptionCode == ErrorCode.USER_HAS_EXIST.toString()) {
|
||||||
|
getResultCallback.onRequestError(exceptionCode)
|
||||||
|
return
|
||||||
|
} else if (exceptionCode == ErrorCode.DEVICE_HAS_BIND.toString()) {
|
||||||
val str =
|
val str =
|
||||||
String.format(getString(R.string.txt_device_has_bind), exceptionMessage)
|
String.format(getString(R.string.txt_device_has_bind), exceptionMessage)
|
||||||
showToast(str)
|
showToast(str)
|
||||||
@@ -808,9 +812,9 @@ abstract class BaseActivity<T : ViewBinding>(val inflater: (inflater: LayoutInfl
|
|||||||
/**
|
/**
|
||||||
* 隐藏软键盘
|
* 隐藏软键盘
|
||||||
*/
|
*/
|
||||||
fun hideInputMethod(view: View): Boolean {
|
fun hideInputMethod(rootView: View): Boolean {
|
||||||
getInputMethodManager()?.apply {
|
getInputMethodManager()?.apply {
|
||||||
return hideSoftInputFromWindow(view.windowToken, 0)
|
return hideSoftInputFromWindow(rootView.windowToken, 0)
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.abbidot.tracker.constant.GetResultCallback
|
|||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
import com.qmuiteam.qmui.alpha.QMUIAlphaButton
|
import com.qmuiteam.qmui.alpha.QMUIAlphaButton
|
||||||
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
|
import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton
|
||||||
import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*Created by .yzq on 2021/11/2/002.
|
*Created by .yzq on 2021/11/2/002.
|
||||||
@@ -35,7 +34,6 @@ abstract class BaseFragment<T : ViewBinding>(
|
|||||||
protected lateinit var mViewBinding: T
|
protected lateinit var mViewBinding: T
|
||||||
var mActivity: Activity? = null
|
var mActivity: Activity? = null
|
||||||
var mContext: Context? = null
|
var mContext: Context? = null
|
||||||
var mLoadingDialog: QMUITipDialog? = null
|
|
||||||
|
|
||||||
//防止某个时间执行多次
|
//防止某个时间执行多次
|
||||||
private var mLimitExecutionTime = 0L
|
private var mLimitExecutionTime = 0L
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ data class SubscriptionsOrderBean(
|
|||||||
var isRefundable: Int,//是否显示退款按钮 1:是 0:否
|
var isRefundable: Int,//是否显示退款按钮 1:是 0:否
|
||||||
var isAutoRenewal: Int,//是否是自动续订 1:是 0:否
|
var isAutoRenewal: Int,//是否是自动续订 1:是 0:否
|
||||||
@MultipleEntity var menuType: Int,
|
@MultipleEntity var menuType: Int,
|
||||||
var renewNum:String,
|
var renewNum: String,
|
||||||
|
var createUserId: String,//这个订单是由哪个用户创建的
|
||||||
var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否
|
var isUpdateOrder: Int = 0//是否是升级订单 1:是 0:否
|
||||||
) : Parcelable, MultiItemEntity {
|
) : Parcelable, MultiItemEntity {
|
||||||
constructor(@MultipleEntity menuType: Int) : this(
|
constructor(@MultipleEntity menuType: Int) : this(
|
||||||
@@ -106,7 +107,7 @@ data class SubscriptionsOrderBean(
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
menuType,"",
|
menuType, "", "",
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -155,7 +156,7 @@ data class SubscriptionsOrderBean(
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
MultipleEntity.TEXT,"",
|
MultipleEntity.TEXT, "", "",
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ data class UserBean(
|
|||||||
var token: String,
|
var token: String,
|
||||||
var userName: String,
|
var userName: String,
|
||||||
var wxId: String,
|
var wxId: String,
|
||||||
|
var wxCode: String,
|
||||||
//0没有绑定手机号 1绑定了
|
//0没有绑定手机号 1绑定了
|
||||||
var status: Int,
|
var status: Int,
|
||||||
var isBindDevice: Int, //是否绑定了设备 0未绑定 1绑定
|
var isBindDevice: Int, //是否绑定了设备 0未绑定 1绑定
|
||||||
@@ -23,5 +24,5 @@ data class UserBean(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
//设置空的构造方法
|
//设置空的构造方法
|
||||||
constructor() : this("", "", "", "", "", "", 0, 0, 0, 0, ConstantInt.Type1)
|
constructor() : this("", "", "", "", "", "", "", 0, 0, 0, 0, ConstantInt.Type1)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import com.abbidot.tracker.base.BaseFragment
|
|||||||
import com.abbidot.tracker.constant.GetResultCallback
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.FragmentBindPhoneCnBinding
|
import com.abbidot.tracker.databinding.FragmentBindPhoneCnBinding
|
||||||
import com.abbidot.tracker.deprecated.ui.activity.LoginRegisterCNActivity
|
import com.abbidot.tracker.deprecated.ui.activity.LoginRegisterCNActivity
|
||||||
|
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
||||||
import com.abbidot.tracker.vm.cn.LoginCNViewModel
|
import com.abbidot.tracker.vm.cn.LoginCNViewModel
|
||||||
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
||||||
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +71,7 @@ class BindPhoneCNFragment :
|
|||||||
val data = it.getOrNull()
|
val data = it.getOrNull()
|
||||||
data?.apply {
|
data?.apply {
|
||||||
val activity = activity as LoginRegisterCNActivity
|
val activity = activity as LoginRegisterCNActivity
|
||||||
mLoginCNViewModel.loginSuccess(activity, this, R.string.txt_bind_success)
|
// mLoginCNViewModel.loginSuccess(activity, this, R.string.txt_bind_success)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ class LoginCNAccountFragment :
|
|||||||
val data = it.getOrNull()
|
val data = it.getOrNull()
|
||||||
data?.apply {
|
data?.apply {
|
||||||
val activity = activity as LoginRegisterCNActivity
|
val activity = activity as LoginRegisterCNActivity
|
||||||
mLoginCNViewModel.loginSuccess(activity, this)
|
// mLoginCNViewModel.loginSuccess(activity, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -78,7 +78,7 @@ class LoginCNAccountFragment :
|
|||||||
val data = it.getOrNull()
|
val data = it.getOrNull()
|
||||||
data?.apply {
|
data?.apply {
|
||||||
val activity = activity as LoginRegisterCNActivity
|
val activity = activity as LoginRegisterCNActivity
|
||||||
mLoginCNViewModel.loginSuccess(activity, this)
|
// mLoginCNViewModel.loginSuccess(activity, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class LoginCNCodeFragment :
|
|||||||
val data = it.getOrNull()
|
val data = it.getOrNull()
|
||||||
data?.apply {
|
data?.apply {
|
||||||
val activity = activity as LoginRegisterCNActivity
|
val activity = activity as LoginRegisterCNActivity
|
||||||
mLoginCNViewModel.loginSuccess(activity, this)
|
// mLoginCNViewModel.loginSuccess(activity, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class LoginCNFirstFragment :
|
|||||||
val data = it.getOrNull()
|
val data = it.getOrNull()
|
||||||
data?.apply {
|
data?.apply {
|
||||||
val activity = activity as LoginRegisterCNActivity
|
val activity = activity as LoginRegisterCNActivity
|
||||||
mLoginCNViewModel.loginSuccess(activity, this)
|
// mLoginCNViewModel.loginSuccess(activity, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import retrofit2.http.Url
|
|||||||
interface INetworkService {
|
interface INetworkService {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val IP_SERVER = "https://aws.abbidot.com"
|
// private const val IP_SERVER = "https://aws.abbidot.com"
|
||||||
// private const val IP_SERVER = "https://192.168.0.22"
|
// private const val IP_SERVER = "https://192.168.0.22"
|
||||||
// const val BASE_URL = "http://ec2-50-18-65-40.us-west-1.compute.amazonaws.com:8090/abbidot/"
|
// const val BASE_URL = "http://ec2-50-18-65-40.us-west-1.compute.amazonaws.com:8090/abbidot/"
|
||||||
// const val BASE_URL = "http://ec2-3-101-8-36.us-west-1.compute.amazonaws.com:8090/abbidot/"
|
// const val BASE_URL = "http://ec2-3-101-8-36.us-west-1.compute.amazonaws.com:8090/abbidot/"
|
||||||
@@ -63,7 +63,7 @@ interface INetworkService {
|
|||||||
const val BASE_URL_ABROAD = "https://aws.abbidot.com/abbidot/"
|
const val BASE_URL_ABROAD = "https://aws.abbidot.com/abbidot/"
|
||||||
|
|
||||||
//设备透传
|
//设备透传
|
||||||
const val BASE_URL_BLE = "https://ab-server.abbidot.cn/"
|
const val BASE_URL_BLE = "https://ab-server.abbidot.com/"
|
||||||
|
|
||||||
//测试服务器
|
//测试服务器
|
||||||
const val BASE_URL_TEST = "https://aws.abbidot.com:8443/abbidot/"
|
const val BASE_URL_TEST = "https://aws.abbidot.com:8443/abbidot/"
|
||||||
@@ -141,7 +141,8 @@ interface INetworkService {
|
|||||||
@Field("phone") phone: String,
|
@Field("phone") phone: String,
|
||||||
@Field("password") password: String,
|
@Field("password") password: String,
|
||||||
@Field("userName") userName: String,
|
@Field("userName") userName: String,
|
||||||
@Field("countryCode") countryCode: String
|
@Field("countryCode") countryCode: String,
|
||||||
|
@Field("openidIdentifier") openidIdentifier: String
|
||||||
): BaseResponse<UserBean>
|
): BaseResponse<UserBean>
|
||||||
|
|
||||||
|
|
||||||
@@ -1435,7 +1436,7 @@ interface INetworkService {
|
|||||||
@Field("phone") phone: String, @Field("code") code: String,
|
@Field("phone") phone: String, @Field("code") code: String,
|
||||||
//验证码类型 1是注册 2是忘记密码
|
//验证码类型 1是注册 2是忘记密码
|
||||||
@Field("type") type: Int
|
@Field("type") type: Int
|
||||||
): BaseResponse<String>
|
): BaseResponse<UserBean>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号密码登录
|
* 账号密码登录
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
|||||||
* 注册/创建用户
|
* 注册/创建用户
|
||||||
*/
|
*/
|
||||||
suspend fun registerV2(
|
suspend fun registerV2(
|
||||||
email: String, phone: String, password: String, userName: String, countryCode: String
|
email: String, phone: String, password: String, userName: String, countryCode: String, wxOpenidId: String
|
||||||
) = getResult {
|
) = getResult {
|
||||||
service.registerV2(email, phone, password, userName, countryCode)
|
service.registerV2(email, phone, password, userName, countryCode, wxOpenidId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -785,9 +785,10 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
|||||||
if (SRBleUtil.instance.isBleEnable(mContext)) {
|
if (SRBleUtil.instance.isBleEnable(mContext)) {
|
||||||
if (BleManager.getInstance().isConnected(macID)) {
|
if (BleManager.getInstance().isConnected(macID)) {
|
||||||
LogUtil.e("已连接设备,不用再次自动连接设备")
|
LogUtil.e("已连接设备,不用再次自动连接设备")
|
||||||
// SRBleUtil.instance.cancelBleScan("已连接设备,取消其他连接扫描")
|
//通知其他页面取消其他连接扫描
|
||||||
// val bleTrack = SRBleUtil.instance.getConnectMacDevice(macID)
|
SRBleUtil.instance.cancelBleScan("已连接设备,取消其他连接扫描")
|
||||||
// XEventBus.post(EventName.ConnectDeviceState, bleTrack)
|
val bleTrack = SRBleUtil.instance.getConnectMacDevice(macID)
|
||||||
|
XEventBus.post(EventName.ConnectDeviceState, bleTrack)
|
||||||
} else {
|
} else {
|
||||||
mAutomaticConnectionDeviceViewModel.connectDeviceToMac(
|
mAutomaticConnectionDeviceViewModel.connectDeviceToMac(
|
||||||
this@HomeV2Activity, macID, false
|
this@HomeV2Activity, macID, false
|
||||||
|
|||||||
@@ -1,23 +1,32 @@
|
|||||||
package com.abbidot.tracker.ui.activity
|
package com.abbidot.tracker.ui.activity
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.view.Gravity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.abbidot.baselibrary.constant.EventName
|
import com.abbidot.baselibrary.constant.EventName
|
||||||
import com.abbidot.baselibrary.constant.MMKVKey
|
import com.abbidot.baselibrary.constant.MMKVKey
|
||||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||||
|
import com.abbidot.baselibrary.network.exception.ErrorCode
|
||||||
import com.abbidot.baselibrary.util.AppUtils
|
import com.abbidot.baselibrary.util.AppUtils
|
||||||
import com.abbidot.baselibrary.util.MMKVUtil
|
import com.abbidot.baselibrary.util.MMKVUtil
|
||||||
import com.abbidot.tracker.R
|
import com.abbidot.tracker.R
|
||||||
import com.abbidot.tracker.base.BaseActivity
|
import com.abbidot.tracker.base.BaseActivity
|
||||||
|
import com.abbidot.tracker.bean.UserBean
|
||||||
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.ActivitySayHelloBinding
|
import com.abbidot.tracker.databinding.ActivitySayHelloBinding
|
||||||
import com.abbidot.tracker.ui.activity.account.CreateAccountV2Activity
|
import com.abbidot.tracker.ui.activity.account.CreateAccountV2Activity
|
||||||
import com.abbidot.tracker.ui.activity.account.LoginV2Activity
|
import com.abbidot.tracker.ui.activity.account.LoginV2Activity
|
||||||
import com.abbidot.tracker.ui.activity.account.cn.LoginV2CNActivity
|
import com.abbidot.tracker.ui.activity.account.cn.LoginV2CNActivity
|
||||||
import com.abbidot.tracker.ui.activity.account.cn.RegisterCNActivity
|
import com.abbidot.tracker.ui.activity.account.cn.RegisterCNActivity
|
||||||
|
import com.abbidot.tracker.ui.activity.account.cn.WXLoginActivity
|
||||||
import com.abbidot.tracker.util.ThirdPartyUtil
|
import com.abbidot.tracker.util.ThirdPartyUtil
|
||||||
|
import com.abbidot.tracker.util.Util
|
||||||
|
|
||||||
class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloBinding::inflate) {
|
class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloBinding::inflate) {
|
||||||
|
|
||||||
|
private var mWXCode = ""
|
||||||
|
|
||||||
override fun getTopBar() = null
|
override fun getTopBar() = null
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
@@ -36,6 +45,43 @@ class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloB
|
|||||||
XEventBus.observe(this, EventName.FinishActivity) {
|
XEventBus.observe(this, EventName.FinishActivity) {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XEventBus.observe(this, EventName.PostValue) { s: String ->
|
||||||
|
mWXCode = s
|
||||||
|
}
|
||||||
|
|
||||||
|
//微信登录成功返回
|
||||||
|
XEventBus.observe(this, EventName.WXLoginResult) { it: Result<UserBean> ->
|
||||||
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
|
override fun onResult(any: Any) {
|
||||||
|
it.getOrNull()?.let { userBean ->
|
||||||
|
Util.dealLoginSuccessData(mContext, userBean)
|
||||||
|
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
||||||
|
Util.loginSuccessGo(this@SayHelloActivity, mViewBinding.root)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterceptCode() {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnSayHelloLoginWechat, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestError(exceptionCode: String?) {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnSayHelloLoginWechat, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
exceptionCode?.let { code ->
|
||||||
|
if (code == ErrorCode.USER_NO_EXIST.toString()) {
|
||||||
|
Intent(mContext, WXLoginActivity::class.java).let { i ->
|
||||||
|
i.putExtra(MMKVKey.CountryCode, mWXCode)
|
||||||
|
startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, isShowCodeError = false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onClick(v: View?) {
|
override fun onClick(v: View?) {
|
||||||
@@ -44,6 +90,8 @@ class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloB
|
|||||||
btnSayHelloLogin -> {
|
btnSayHelloLogin -> {
|
||||||
if (AppUtils.isChina()) {
|
if (AppUtils.isChina()) {
|
||||||
val intent = Intent(mContext, LoginV2CNActivity::class.java)
|
val intent = Intent(mContext, LoginV2CNActivity::class.java)
|
||||||
|
val phone = MMKVUtil.getString(MMKVKey.Phone)
|
||||||
|
intent.putExtra(MMKVKey.Phone, phone)
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
} else {
|
} else {
|
||||||
val intent = Intent(mContext, LoginV2Activity::class.java)
|
val intent = Intent(mContext, LoginV2Activity::class.java)
|
||||||
@@ -61,7 +109,12 @@ class SayHelloActivity : BaseActivity<ActivitySayHelloBinding>(ActivitySayHelloB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btnSayHelloLoginWechat -> ThirdPartyUtil.instance.startWXLogin(this@SayHelloActivity)
|
btnSayHelloLoginWechat -> {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnSayHelloLoginWechat, ConstantInt.Type0
|
||||||
|
)
|
||||||
|
ThirdPartyUtil.instance.startWXLogin(this@SayHelloActivity)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import com.abbidot.tracker.base.BaseActivity
|
|||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.constant.GetResultCallback
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.ActivityLoginV2Binding
|
import com.abbidot.tracker.databinding.ActivityLoginV2Binding
|
||||||
import com.abbidot.tracker.ui.activity.set.FirstPermissionsActivity
|
|
||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.LoginViewModel
|
import com.abbidot.tracker.vm.LoginViewModel
|
||||||
@@ -54,8 +53,8 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
|
|||||||
it.etInputContent.setText(userEmail)
|
it.etInputContent.setText(userEmail)
|
||||||
it.etInputContent.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
it.etInputContent.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||||
ViewUtil.instance.setInputViewErrorHideClick(
|
ViewUtil.instance.setInputViewErrorHideClick(
|
||||||
mContext, it.rlEtInputLayout, tvEmailErrorTipLogin, it.etInputContent
|
mContext, it.rlEtInputLayout, tvEmailErrorTipLogin, it.etInputContent, true
|
||||||
,true )
|
)
|
||||||
}
|
}
|
||||||
ilLoginV2Password.let {
|
ilLoginV2Password.let {
|
||||||
it.tvInputNameTitle.setText(R.string.login_txt_password)
|
it.tvInputNameTitle.setText(R.string.login_txt_password)
|
||||||
@@ -106,15 +105,24 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
|
|||||||
Util.dealLoginSuccessData(mContext, this)
|
Util.dealLoginSuccessData(mContext, this)
|
||||||
|
|
||||||
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
||||||
loginSuccessGo()
|
Util.loginSuccessGo(this@LoginV2Activity, mViewBinding.btnLoginV2Login)
|
||||||
//登录成功,把保存的设备存本地
|
//登录成功,把保存的设备存本地
|
||||||
// mTrackerViewModel.getDeviceList(this@LoginV2Activity, 1)
|
// mTrackerViewModel.getDeviceList(this@LoginV2Activity, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onInterceptCode() {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnLoginV2Login, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestError(exceptionCode: String?) {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnLoginV2Login, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
setButtonEnabled(
|
|
||||||
mViewBinding.btnLoginV2Login, ConstantInt.Type1
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取设备列表
|
//获取设备列表
|
||||||
@@ -126,7 +134,7 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
|
|||||||
val isBindDevice = MMKVUtil.getInt(MMKVKey.isBindDevice)
|
val isBindDevice = MMKVUtil.getInt(MMKVKey.isBindDevice)
|
||||||
val isBindPet = MMKVUtil.getInt(MMKVKey.isBindPet)
|
val isBindPet = MMKVUtil.getInt(MMKVKey.isBindPet)
|
||||||
if (isBindDevice == ConstantInt.isBind && isBindPet == ConstantInt.NoBind) {
|
if (isBindDevice == ConstantInt.isBind && isBindPet == ConstantInt.NoBind) {
|
||||||
if (list.size > 0) {
|
if (list.isNotEmpty()) {
|
||||||
MMKVUtil.putString(MMKVKey.FirstDeviceId, list[0].deviceId)
|
MMKVUtil.putString(MMKVKey.FirstDeviceId, list[0].deviceId)
|
||||||
MMKVUtil.putString(
|
MMKVUtil.putString(
|
||||||
MMKVKey.FirstDeviceOutId, list[0].deviceOutId
|
MMKVKey.FirstDeviceOutId, list[0].deviceOutId
|
||||||
@@ -144,7 +152,7 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
|
|||||||
|
|
||||||
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
||||||
|
|
||||||
loginSuccessGo()
|
Util.loginSuccessGo(this@LoginV2Activity, mViewBinding.btnLoginV2Login)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,17 +160,6 @@ class LoginV2Activity : BaseActivity<ActivityLoginV2Binding>(ActivityLoginV2Bind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loginSuccessGo() {
|
|
||||||
val hasPermissions = Util.checkNeedPermissionsEnabled(mContext)
|
|
||||||
mViewBinding.btnLoginV2Login.postDelayed({
|
|
||||||
if (hasPermissions) {
|
|
||||||
startActivityFinish(Util.checkBindDeviceAndPetGoActivity(mContext))
|
|
||||||
} else {
|
|
||||||
startActivityFinish(Intent(mContext, FirstPermissionsActivity::class.java))
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loginClick(isMd5: Boolean = true) {
|
private fun loginClick(isMd5: Boolean = true) {
|
||||||
mViewBinding.apply {
|
mViewBinding.apply {
|
||||||
var email = ilLoginV2EmailAddress.etInputContent.text.toString()
|
var email = ilLoginV2EmailAddress.etInputContent.text.toString()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class ForgotPasswordCNActivity : AddEmailValidActivity() {
|
|||||||
switchFragment(2)
|
switchFragment(2)
|
||||||
}.apply {
|
}.apply {
|
||||||
mContext = this@ForgotPasswordCNActivity
|
mContext = this@ForgotPasswordCNActivity
|
||||||
mFragmentList.add(AccountCnPhoneFragment.newInstance(mContext!!))
|
mFragmentList.add(AccountCnPhoneFragment.newInstance(mContext!!,2))
|
||||||
mFragmentList.add(this)
|
mFragmentList.add(this)
|
||||||
mFragmentList.add(ForgotPasswordV2ThereFragment.newInstance(mContext!!))
|
mFragmentList.add(ForgotPasswordV2ThereFragment.newInstance(mContext!!))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.Gravity
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import com.abbidot.baselibrary.constant.EventName
|
import com.abbidot.baselibrary.constant.EventName
|
||||||
|
import com.abbidot.baselibrary.constant.MMKVKey
|
||||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||||
import com.abbidot.baselibrary.util.AppUtils
|
import com.abbidot.baselibrary.util.AppUtils
|
||||||
import com.abbidot.baselibrary.util.Utils
|
import com.abbidot.baselibrary.util.Utils
|
||||||
@@ -17,7 +18,6 @@ import com.abbidot.tracker.base.BaseActivity
|
|||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.constant.GetResultCallback
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.ActivityLoginV2CnBinding
|
import com.abbidot.tracker.databinding.ActivityLoginV2CnBinding
|
||||||
import com.abbidot.tracker.ui.activity.set.FirstPermissionsActivity
|
|
||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.cn.LoginCNViewModel
|
import com.abbidot.tracker.vm.cn.LoginCNViewModel
|
||||||
@@ -38,9 +38,15 @@ class LoginV2CNActivity :
|
|||||||
mViewBinding.apply {
|
mViewBinding.apply {
|
||||||
root.setBackgroundResource(R.drawable.icon_login_v2_bg)
|
root.setBackgroundResource(R.drawable.icon_login_v2_bg)
|
||||||
|
|
||||||
|
var userPhone = ""
|
||||||
|
intent.extras?.apply {
|
||||||
|
userPhone = getString(MMKVKey.Phone, "")
|
||||||
|
}
|
||||||
|
|
||||||
ilLoginV2CnPhone.let {
|
ilLoginV2CnPhone.let {
|
||||||
it.tvInputNameTitle.setText(R.string.login_txt_phone)
|
it.tvInputNameTitle.setText(R.string.login_txt_phone)
|
||||||
it.etInputContent.setHint(R.string.login_txt_phone)
|
it.etInputContent.setHint(R.string.login_txt_phone)
|
||||||
|
it.etInputContent.setText(userPhone)
|
||||||
it.etInputContent.inputType = InputType.TYPE_CLASS_NUMBER
|
it.etInputContent.inputType = InputType.TYPE_CLASS_NUMBER
|
||||||
val filters = arrayOf<InputFilter>(InputFilter.LengthFilter(11))
|
val filters = arrayOf<InputFilter>(InputFilter.LengthFilter(11))
|
||||||
it.etInputContent.filters = filters
|
it.etInputContent.filters = filters
|
||||||
@@ -83,7 +89,7 @@ class LoginV2CNActivity :
|
|||||||
Util.dealLoginSuccessData(mContext, this)
|
Util.dealLoginSuccessData(mContext, this)
|
||||||
|
|
||||||
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
||||||
loginSuccessGo()
|
Util.loginSuccessGo(this@LoginV2CNActivity, mViewBinding.btnLoginV2CnLogin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,17 +104,6 @@ class LoginV2CNActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loginSuccessGo() {
|
|
||||||
val hasPermissions = Util.checkNeedPermissionsEnabled(mContext)
|
|
||||||
mViewBinding.btnLoginV2CnLogin.postDelayed({
|
|
||||||
if (hasPermissions) {
|
|
||||||
startActivityFinish(Util.checkBindDeviceAndPetGoActivity(mContext))
|
|
||||||
} else {
|
|
||||||
startActivityFinish(Intent(mContext, FirstPermissionsActivity::class.java))
|
|
||||||
}
|
|
||||||
}, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun goForgotPassword() {
|
private fun goForgotPassword() {
|
||||||
Intent(mContext, ForgotPasswordCNActivity::class.java).apply {
|
Intent(mContext, ForgotPasswordCNActivity::class.java).apply {
|
||||||
// val email = mViewBinding.ilLoginV2EmailAddress.etInputContent.text.toString()
|
// val email = mViewBinding.ilLoginV2EmailAddress.etInputContent.text.toString()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class RegisterCNActivity : AddEmailValidActivity() {
|
|||||||
mEmailValidFragment = EmailValidFragment.newInstance(this, 1) {
|
mEmailValidFragment = EmailValidFragment.newInstance(this, 1) {
|
||||||
switchFragment(2)
|
switchFragment(2)
|
||||||
}.apply {
|
}.apply {
|
||||||
mFragmentList.add(AccountCnPhoneFragment.newInstance(this@RegisterCNActivity))
|
mFragmentList.add(AccountCnPhoneFragment.newInstance(this@RegisterCNActivity, 1))
|
||||||
mFragmentList.add(this)
|
mFragmentList.add(this)
|
||||||
mFragmentList.add(CreateAccountV2ThreeFragment.newInstance(this@RegisterCNActivity))
|
mFragmentList.add(CreateAccountV2ThreeFragment.newInstance(this@RegisterCNActivity))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,23 @@
|
|||||||
package com.abbidot.tracker.ui.activity.account.cn
|
package com.abbidot.tracker.ui.activity.account.cn
|
||||||
|
|
||||||
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.ui.activity.account.AddEmailValidActivity
|
import com.abbidot.tracker.ui.activity.account.AddEmailValidActivity
|
||||||
|
import com.abbidot.tracker.ui.fragment.account.CreateAccountV2ThreeFragment
|
||||||
import com.abbidot.tracker.ui.fragment.account.EmailValidFragment
|
import com.abbidot.tracker.ui.fragment.account.EmailValidFragment
|
||||||
import com.abbidot.tracker.ui.fragment.account.cn.AccountCnPhoneFragment
|
import com.abbidot.tracker.ui.fragment.account.cn.AccountCnPhoneFragment
|
||||||
|
|
||||||
class VerifyCodeLoginCNActivity : AddEmailValidActivity() {
|
class VerifyCodeLoginCNActivity : AddEmailValidActivity() {
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
mEmailValidFragment = EmailValidFragment.newInstance(this, 1) {
|
mEmailValidFragment = EmailValidFragment.newInstance(this, ConstantInt.Type3) {
|
||||||
// switchFragment(2)
|
switchFragment(2)
|
||||||
}.apply {
|
}.apply {
|
||||||
mFragmentList.add(AccountCnPhoneFragment.newInstance(this@VerifyCodeLoginCNActivity))
|
mFragmentList.add(
|
||||||
|
AccountCnPhoneFragment.newInstance(
|
||||||
|
this@VerifyCodeLoginCNActivity, ConstantInt.Type3
|
||||||
|
)
|
||||||
|
)
|
||||||
mFragmentList.add(this)
|
mFragmentList.add(this)
|
||||||
|
mFragmentList.add(CreateAccountV2ThreeFragment.newInstance(this@VerifyCodeLoginCNActivity))
|
||||||
}
|
}
|
||||||
super.initData()
|
super.initData()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.abbidot.tracker.ui.activity.account.cn
|
||||||
|
|
||||||
|
import com.abbidot.baselibrary.constant.MMKVKey
|
||||||
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
|
import com.abbidot.tracker.ui.activity.account.AddEmailValidActivity
|
||||||
|
import com.abbidot.tracker.ui.fragment.account.CreateAccountV2ThreeFragment
|
||||||
|
import com.abbidot.tracker.ui.fragment.account.EmailValidFragment
|
||||||
|
import com.abbidot.tracker.ui.fragment.account.cn.AccountCnPhoneFragment
|
||||||
|
|
||||||
|
class WXLoginActivity : AddEmailValidActivity() {
|
||||||
|
private var mWXCode = ""
|
||||||
|
override fun initData() {
|
||||||
|
mWXCode = intent.getStringExtra(MMKVKey.CountryCode) ?: ""
|
||||||
|
mEmailValidFragment = EmailValidFragment.newInstance(this, ConstantInt.Type4) {
|
||||||
|
switchFragment(2)
|
||||||
|
}.apply {
|
||||||
|
mFragmentList.add(
|
||||||
|
AccountCnPhoneFragment.newInstance(
|
||||||
|
this@WXLoginActivity, ConstantInt.Type4
|
||||||
|
)
|
||||||
|
)
|
||||||
|
mFragmentList.add(this)
|
||||||
|
mFragmentList.add(
|
||||||
|
CreateAccountV2ThreeFragment.newInstance(
|
||||||
|
this@WXLoginActivity, mWXCode
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
super.initData()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -39,12 +39,15 @@ class CreateAccountV2ThreeFragment : BaseFragment<FragmentCreateAccountV2ThreeBi
|
|||||||
private lateinit var mCountryCommon: CountryCommon
|
private lateinit var mCountryCommon: CountryCommon
|
||||||
|
|
||||||
private var isShowPassword = false
|
private var isShowPassword = false
|
||||||
|
private var mWXCode = ""
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newInstance(context: Context) = CreateAccountV2ThreeFragment().apply {
|
fun newInstance(context: Context, wxCode: String = "") =
|
||||||
mContext = context
|
CreateAccountV2ThreeFragment().apply {
|
||||||
}
|
mContext = context
|
||||||
|
mWXCode = wxCode
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
@@ -218,7 +221,9 @@ class CreateAccountV2ThreeFragment : BaseFragment<FragmentCreateAccountV2ThreeBi
|
|||||||
// it, e, p, password, name, mCountryCommon.getCountryCode()
|
// it, e, p, password, name, mCountryCommon.getCountryCode()
|
||||||
// )
|
// )
|
||||||
setButtonEnabled(btnCreateAccountV2Signup, ConstantInt.Type0)
|
setButtonEnabled(btnCreateAccountV2Signup, ConstantInt.Type0)
|
||||||
mUserViewModel.registerV2(it, e, p, password, name, locale.country.uppercase())
|
mUserViewModel.registerV2(
|
||||||
|
it, e, p, password, name, locale.country.uppercase(), mWXCode
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import android.view.View.OnClickListener
|
|||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import com.abbidot.baselibrary.network.exception.ErrorCode
|
||||||
import com.abbidot.baselibrary.util.AppUtils
|
import com.abbidot.baselibrary.util.AppUtils
|
||||||
import com.abbidot.tracker.R
|
import com.abbidot.tracker.R
|
||||||
import com.abbidot.tracker.base.BaseActivity
|
import com.abbidot.tracker.base.BaseActivity
|
||||||
@@ -16,8 +17,10 @@ import com.abbidot.tracker.base.BaseFragment
|
|||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.constant.GetResultCallback
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.FragmentBaseEmailValidBinding
|
import com.abbidot.tracker.databinding.FragmentBaseEmailValidBinding
|
||||||
|
import com.abbidot.tracker.util.Util
|
||||||
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
import com.abbidot.tracker.vm.CountDownTimerViewModel
|
||||||
import com.abbidot.tracker.vm.UserProfileViewModel
|
import com.abbidot.tracker.vm.UserProfileViewModel
|
||||||
|
import com.abbidot.tracker.vm.cn.LoginCNViewModel
|
||||||
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
||||||
import com.daimajia.androidanimations.library.Techniques
|
import com.daimajia.androidanimations.library.Techniques
|
||||||
import com.daimajia.androidanimations.library.YoYo
|
import com.daimajia.androidanimations.library.YoYo
|
||||||
@@ -34,6 +37,7 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
|
|
||||||
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
|
private val mCountDownTimerViewModel: CountDownTimerViewModel by viewModels()
|
||||||
private val mRegisterViewModel: UserProfileViewModel by viewModels()
|
private val mRegisterViewModel: UserProfileViewModel by viewModels()
|
||||||
|
private val mLoginCNViewModel: LoginCNViewModel by viewModels()
|
||||||
private val mRegisterCNViewModel: RegisterCNViewModel by viewModels()
|
private val mRegisterCNViewModel: RegisterCNViewModel by viewModels()
|
||||||
|
|
||||||
private val mResendCodeTime = 5 * 60
|
private val mResendCodeTime = 5 * 60
|
||||||
@@ -47,13 +51,13 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newInstance(
|
fun newInstance(
|
||||||
context: Context,
|
context: Context,
|
||||||
emailCodeType: Int,
|
verifyCodeType: Int,
|
||||||
btnString: String = "",
|
btnString: String = "",
|
||||||
okClickListener: OnClickListener
|
okClickListener: OnClickListener
|
||||||
) = EmailValidFragment().apply {
|
) = EmailValidFragment().apply {
|
||||||
mContext = context
|
mContext = context
|
||||||
mBtnString = btnString
|
mBtnString = btnString
|
||||||
mVerifyCodeType = emailCodeType
|
mVerifyCodeType = verifyCodeType
|
||||||
mOnOkClickListener = okClickListener
|
mOnOkClickListener = okClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,6 +81,8 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
|
|
||||||
mViewBinding.apply {
|
mViewBinding.apply {
|
||||||
|
|
||||||
|
getHostActivity(BaseActivity::class.java)?.hideInputMethod(root)
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(mBtnString)) {
|
if (!TextUtils.isEmpty(mBtnString)) {
|
||||||
btnForgotPasswordV2TwoContinue.text = mBtnString
|
btnForgotPasswordV2TwoContinue.text = mBtnString
|
||||||
}
|
}
|
||||||
@@ -132,6 +138,36 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (AppUtils.isChina()) {
|
if (AppUtils.isChina()) {
|
||||||
|
mLoginCNViewModel.mPhoneLoginResultLiveData.observe(viewLifecycleOwner) {
|
||||||
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
|
override fun onResult(any: Any) {
|
||||||
|
it.getOrNull()?.let { userBean ->
|
||||||
|
Util.dealLoginSuccessData(mContext!!, userBean)
|
||||||
|
showToast(R.string.txt_login_successful, gravity = Gravity.CENTER)
|
||||||
|
getHostActivity(BaseActivity::class.java)?.let { activity ->
|
||||||
|
Util.loginSuccessGo(activity, mViewBinding.root)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onInterceptCode() {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onRequestError(exceptionCode: String?) {
|
||||||
|
setButtonEnabled(
|
||||||
|
mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type1
|
||||||
|
)
|
||||||
|
exceptionCode?.let { code ->
|
||||||
|
if (code == ErrorCode.USER_NO_EXIST.toString()) {
|
||||||
|
mOnOkClickListener?.onClick(view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, isShowCodeError = false)
|
||||||
|
}
|
||||||
mRegisterCNViewModel.apply {
|
mRegisterCNViewModel.apply {
|
||||||
mSendCodeResultLiveData.observe(viewLifecycleOwner) {
|
mSendCodeResultLiveData.observe(viewLifecycleOwner) {
|
||||||
dealRequestResult(it, object : GetResultCallback {
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
@@ -148,8 +184,16 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
mValidateCodeResultLiveData.observe(viewLifecycleOwner) {
|
mValidateCodeResultLiveData.observe(viewLifecycleOwner) {
|
||||||
dealRequestResult(it, object : GetResultCallback {
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
override fun onResult(any: Any) {
|
override fun onResult(any: Any) {
|
||||||
it.getOrNull()?.apply {
|
it.getOrNull()?.let { data ->
|
||||||
mOnOkClickListener?.onClick(view)
|
if (mVerifyCodeType == ConstantInt.Type4) {
|
||||||
|
Util.dealLoginSuccessData(mContext!!, data)
|
||||||
|
showToast(
|
||||||
|
R.string.txt_login_successful, gravity = Gravity.CENTER
|
||||||
|
)
|
||||||
|
getHostActivity(BaseActivity::class.java)?.let { activity ->
|
||||||
|
Util.loginSuccessGo(activity, mViewBinding.root)
|
||||||
|
}
|
||||||
|
} else mOnOkClickListener?.onClick(view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,6 +207,17 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
setButtonEnabled(
|
setButtonEnabled(
|
||||||
mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type1
|
mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type1
|
||||||
)
|
)
|
||||||
|
if (mVerifyCodeType == ConstantInt.Type4) {
|
||||||
|
exceptionCode?.let { code ->
|
||||||
|
if (code == "519") {
|
||||||
|
mOnOkClickListener?.onClick(view)
|
||||||
|
} else if (code == "520") {
|
||||||
|
showToast(
|
||||||
|
R.string.txt_phone_has_bound, gravity = Gravity.CENTER
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -246,9 +301,15 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
|
|
||||||
setButtonEnabled(mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type0)
|
setButtonEnabled(mViewBinding.btnForgotPasswordV2TwoContinue, ConstantInt.Type0)
|
||||||
if (AppUtils.isChina()) {
|
if (AppUtils.isChina()) {
|
||||||
mRegisterCNViewModel.validatePhoneCode(
|
if (mVerifyCodeType == ConstantInt.Type3) {
|
||||||
this@EmailValidFragment, mEmail, content, mVerifyCodeType
|
mLoginCNViewModel.phoneLogin(
|
||||||
)
|
this@EmailValidFragment, mEmail, content
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
mRegisterCNViewModel.validatePhoneCode(
|
||||||
|
this@EmailValidFragment, mEmail, content, mVerifyCodeType
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mRegisterViewModel.validateCode(
|
mRegisterViewModel.validateCode(
|
||||||
this@EmailValidFragment, mEmail, content, mVerifyCodeType
|
this@EmailValidFragment, mEmail, content, mVerifyCodeType
|
||||||
@@ -259,6 +320,7 @@ open class EmailValidFragment : BaseFragment<FragmentBaseEmailValidBinding>(
|
|||||||
|
|
||||||
override fun onClick(v: View?) {
|
override fun onClick(v: View?) {
|
||||||
mViewBinding.apply {
|
mViewBinding.apply {
|
||||||
|
getHostActivity(BaseActivity::class.java)?.hideInputMethod(mViewBinding.root)
|
||||||
when (v!!) {
|
when (v!!) {
|
||||||
btnForgotPasswordV2TwoContinue -> continueVerifyCode()
|
btnForgotPasswordV2TwoContinue -> continueVerifyCode()
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
package com.abbidot.tracker.ui.fragment.account.cn
|
package com.abbidot.tracker.ui.fragment.account.cn
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
import android.text.InputFilter
|
import android.text.InputFilter
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import com.abbidot.baselibrary.constant.MMKVKey
|
||||||
|
import com.abbidot.baselibrary.network.exception.ErrorCode
|
||||||
import com.abbidot.tracker.R
|
import com.abbidot.tracker.R
|
||||||
|
import com.abbidot.tracker.base.BaseDialog
|
||||||
import com.abbidot.tracker.base.BaseFragment
|
import com.abbidot.tracker.base.BaseFragment
|
||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.constant.GetResultCallback
|
import com.abbidot.tracker.constant.GetResultCallback
|
||||||
import com.abbidot.tracker.databinding.FragmentAccountCnPhoneBinding
|
import com.abbidot.tracker.databinding.FragmentAccountCnPhoneBinding
|
||||||
import com.abbidot.tracker.ui.activity.account.AddEmailValidActivity
|
import com.abbidot.tracker.ui.activity.account.AddEmailValidActivity
|
||||||
|
import com.abbidot.tracker.ui.activity.account.cn.LoginV2CNActivity
|
||||||
import com.abbidot.tracker.util.ViewUtil
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
import com.abbidot.tracker.vm.cn.RegisterCNViewModel
|
||||||
|
|
||||||
@@ -25,12 +30,14 @@ class AccountCnPhoneFragment :
|
|||||||
BaseFragment<FragmentAccountCnPhoneBinding>(FragmentAccountCnPhoneBinding::inflate) {
|
BaseFragment<FragmentAccountCnPhoneBinding>(FragmentAccountCnPhoneBinding::inflate) {
|
||||||
|
|
||||||
private val mRegisterCNViewModel: RegisterCNViewModel by viewModels()
|
private val mRegisterCNViewModel: RegisterCNViewModel by viewModels()
|
||||||
|
private var mVerifyCodeType = 0
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newInstance(context: Context) =
|
fun newInstance(context: Context, verifyCodeType: Int) =
|
||||||
AccountCnPhoneFragment().apply {
|
AccountCnPhoneFragment().apply {
|
||||||
mContext = context
|
mContext = context
|
||||||
|
mVerifyCodeType = verifyCodeType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +69,25 @@ class AccountCnPhoneFragment :
|
|||||||
|
|
||||||
override fun onRequestError(exceptionCode: String?) {
|
override fun onRequestError(exceptionCode: String?) {
|
||||||
setButtonEnabled(mViewBinding.btnAccountCnPhoneContinue, ConstantInt.Type1)
|
setButtonEnabled(mViewBinding.btnAccountCnPhoneContinue, ConstantInt.Type1)
|
||||||
|
exceptionCode?.let { code ->
|
||||||
|
if (code == ErrorCode.USER_HAS_EXIST.toString()) {
|
||||||
|
ViewUtil.instance.showDialog(
|
||||||
|
mContext!!,
|
||||||
|
R.string.txt_account_exists_log_in,
|
||||||
|
object : BaseDialog.OnDialogOkListener {
|
||||||
|
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||||
|
dialog.dismiss()
|
||||||
|
val intent = Intent(mContext, LoginV2CNActivity::class.java)
|
||||||
|
val phone =
|
||||||
|
mViewBinding.ilAccountCnPhoneEditLayout.etInputContent.text.toString()
|
||||||
|
intent.putExtra(MMKVKey.Phone, phone)
|
||||||
|
startActivityFinish(mActivity!!, intent)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
okTextResId = R.string.txt_sure
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -87,7 +113,7 @@ class AccountCnPhoneFragment :
|
|||||||
}
|
}
|
||||||
getHostActivity(AddEmailValidActivity::class.java)?.setToEmail(phone)
|
getHostActivity(AddEmailValidActivity::class.java)?.setToEmail(phone)
|
||||||
setButtonEnabled(btnAccountCnPhoneContinue, ConstantInt.Type0)
|
setButtonEnabled(btnAccountCnPhoneContinue, ConstantInt.Type0)
|
||||||
mRegisterCNViewModel.sendCode(this@AccountCnPhoneFragment, phone, 1)
|
mRegisterCNViewModel.sendCode(this@AccountCnPhoneFragment, phone, mVerifyCodeType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ class HomeTrackFragment :
|
|||||||
|
|
||||||
private fun addMenuListData(petBean: PetBean) {
|
private fun addMenuListData(petBean: PetBean) {
|
||||||
petBean.apply {
|
petBean.apply {
|
||||||
if (mTrackMenuList.size == 0) {
|
if (mTrackMenuList.isEmpty()) {
|
||||||
if (deviceType == ConstantInt.Type1) {
|
if (deviceType == ConstantInt.Type1) {
|
||||||
ViewUtil.instance.addMenuBean(
|
ViewUtil.instance.addMenuBean(
|
||||||
mTrackMenuList, getString(R.string.tracker_manage_led)
|
mTrackMenuList, getString(R.string.tracker_manage_led)
|
||||||
@@ -825,7 +825,7 @@ class HomeTrackFragment :
|
|||||||
mFencesAdapter.setData(null)
|
mFencesAdapter.setData(null)
|
||||||
mZoneAdapter.setData(null)
|
mZoneAdapter.setData(null)
|
||||||
mapDeviceBean.fences?.apply {
|
mapDeviceBean.fences?.apply {
|
||||||
if (size > 0) {
|
if (isNotEmpty()) {
|
||||||
if (size > 3) mFencesList.addAll(subList(0, 3).toList())
|
if (size > 3) mFencesList.addAll(subList(0, 3).toList())
|
||||||
else mFencesList.addAll(this.toList())
|
else mFencesList.addAll(this.toList())
|
||||||
mFencesAdapter.setData(mFencesList, true)
|
mFencesAdapter.setData(mFencesList, true)
|
||||||
@@ -835,7 +835,7 @@ class HomeTrackFragment :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mapDeviceBean.wifiZones?.apply {
|
mapDeviceBean.wifiZones?.apply {
|
||||||
if (size > 0) {
|
if (isNotEmpty()) {
|
||||||
mZoneList.addAll(this)
|
mZoneList.addAll(this)
|
||||||
mZoneAdapter.setData(mZoneList, true)
|
mZoneAdapter.setData(mZoneList, true)
|
||||||
mViewBinding.btnHomePetTrackWifiZoneManage.visibility = View.VISIBLE
|
mViewBinding.btnHomePetTrackWifiZoneManage.visibility = View.VISIBLE
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
fun setLatLngData(data: MutableList<HistoryDataBean>) {
|
fun setLatLngData(data: MutableList<HistoryDataBean>) {
|
||||||
mGoogleMap?.clear()
|
mGoogleMap?.clear()
|
||||||
|
|
||||||
if (data.size == 0) return
|
if (data.isEmpty()) return
|
||||||
mLatLngList.clear()
|
mLatLngList.clear()
|
||||||
var maxLat = data[0].latitude
|
var maxLat = data[0].latitude
|
||||||
var maxLon = data[0].longitude
|
var maxLon = data[0].longitude
|
||||||
@@ -214,7 +214,7 @@ class HistoryDataGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
* 停止滑动
|
* 停止滑动
|
||||||
*/
|
*/
|
||||||
fun slideStopChanged(progress: Int) {
|
fun slideStopChanged(progress: Int) {
|
||||||
if (mLatLngList.size > 0) {
|
if (mLatLngList.isNotEmpty()) {
|
||||||
moveCameraLocation(
|
moveCameraLocation(
|
||||||
mLatLngList[progress].latitude, mLatLngList[progress].longitude, true
|
mLatLngList[progress].latitude, mLatLngList[progress].longitude, true
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.location.LocationManager
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
|
import android.view.View
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import cn.jpush.android.api.JPushInterface
|
import cn.jpush.android.api.JPushInterface
|
||||||
@@ -37,6 +38,7 @@ import com.abbidot.tracker.ui.activity.SayHelloActivity
|
|||||||
import com.abbidot.tracker.ui.activity.device.AddNewTracker1Activity
|
import com.abbidot.tracker.ui.activity.device.AddNewTracker1Activity
|
||||||
import com.abbidot.tracker.ui.activity.pet.ShowInviteDeviceActivity
|
import com.abbidot.tracker.ui.activity.pet.ShowInviteDeviceActivity
|
||||||
import com.abbidot.tracker.ui.activity.pet.first.FirstSetPetTypeActivity
|
import com.abbidot.tracker.ui.activity.pet.first.FirstSetPetTypeActivity
|
||||||
|
import com.abbidot.tracker.ui.activity.set.FirstPermissionsActivity
|
||||||
import com.abbidot.tracker.ui.activity.subscribe.SubscriptionPlanActivity
|
import com.abbidot.tracker.ui.activity.subscribe.SubscriptionPlanActivity
|
||||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||||
import com.abbidot.tracker.vm.SubscriptionManageViewModel
|
import com.abbidot.tracker.vm.SubscriptionManageViewModel
|
||||||
@@ -570,6 +572,24 @@ class Util {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登录成功后的跳转
|
||||||
|
*/
|
||||||
|
fun loginSuccessGo(activity: BaseActivity<*>, view: View) {
|
||||||
|
val hasPermissions = checkNeedPermissionsEnabled(activity)
|
||||||
|
view.postDelayed({
|
||||||
|
if (hasPermissions) {
|
||||||
|
activity.startActivityFinish(checkBindDeviceAndPetGoActivity(activity))
|
||||||
|
} else {
|
||||||
|
activity.startActivityFinish(
|
||||||
|
Intent(
|
||||||
|
activity, FirstPermissionsActivity::class.java
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退出登录
|
* 退出登录
|
||||||
*/
|
*/
|
||||||
@@ -584,9 +604,11 @@ class Util {
|
|||||||
BleManager.getInstance().disconnectAllDevice()
|
BleManager.getInstance().disconnectAllDevice()
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val email = MMKVUtil.getString(MMKVKey.Email)
|
val email = MMKVUtil.getString(MMKVKey.Email)
|
||||||
|
val phone = MMKVUtil.getString(MMKVKey.Phone)
|
||||||
MMKVUtil.clearAll()
|
MMKVUtil.clearAll()
|
||||||
//保存最后一次登录的邮箱
|
//保存最后一次登录的邮箱
|
||||||
MMKVUtil.putString(MMKVKey.Email, email)
|
MMKVUtil.putString(MMKVKey.Email, email)
|
||||||
|
MMKVUtil.putString(MMKVKey.Phone, phone)
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
MyDatabase.deviceDao().deleteAll(MyDatabase.DEVICE_TABLE)
|
MyDatabase.deviceDao().deleteAll(MyDatabase.DEVICE_TABLE)
|
||||||
MyDatabase.creditCardDao().deleteAll(MyDatabase.CREDIT_CARD_TABLE)
|
MyDatabase.creditCardDao().deleteAll(MyDatabase.CREDIT_CARD_TABLE)
|
||||||
|
|||||||
@@ -74,11 +74,13 @@ class UserProfileViewModel : ViewModel() {
|
|||||||
phone: String,
|
phone: String,
|
||||||
password: String,
|
password: String,
|
||||||
userName: String,
|
userName: String,
|
||||||
countryCode: String
|
countryCode: String,
|
||||||
|
wxOpenidId: String=""
|
||||||
) {
|
) {
|
||||||
activity.showLoading(true)
|
activity.showLoading(true)
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val result = NetworkApi.registerV2(email,phone, password, userName, countryCode)
|
val result =
|
||||||
|
NetworkApi.registerV2(email, phone, password, userName, countryCode, wxOpenidId)
|
||||||
mRegisterV2LiveData.value = result
|
mRegisterV2LiveData.value = result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,13 @@
|
|||||||
package com.abbidot.tracker.vm.cn
|
package com.abbidot.tracker.vm.cn
|
||||||
|
|
||||||
import android.content.Intent
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import cn.jpush.android.api.JPushInterface
|
|
||||||
import com.abbidot.baselibrary.constant.EventName
|
|
||||||
import com.abbidot.baselibrary.constant.MMKVKey
|
|
||||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
|
||||||
import com.abbidot.baselibrary.util.MMKVUtil
|
|
||||||
import com.abbidot.tracker.R
|
|
||||||
import com.abbidot.tracker.base.BaseActivity
|
|
||||||
import com.abbidot.tracker.base.BaseFragment
|
import com.abbidot.tracker.base.BaseFragment
|
||||||
import com.abbidot.tracker.bean.UserBean
|
import com.abbidot.tracker.bean.UserBean
|
||||||
import com.abbidot.tracker.constant.ConstantInt
|
|
||||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||||
import com.abbidot.tracker.ui.activity.HomeV2Activity
|
|
||||||
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
import dagger.hilt.android.scopes.ActivityRetainedScoped
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.Random
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,43 +33,6 @@ class LoginCNViewModel @Inject constructor() : ViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理微信、登录成功返回
|
|
||||||
*/
|
|
||||||
fun loginSuccess(
|
|
||||||
activity: BaseActivity<*>,
|
|
||||||
userBean: UserBean,
|
|
||||||
tipRes: Int = R.string.txt_login_successful
|
|
||||||
) {
|
|
||||||
//判断有没有绑定手机号
|
|
||||||
if (userBean.status == ConstantInt.Close) {
|
|
||||||
// activity.apply {
|
|
||||||
// mWXId = userBean.wxId
|
|
||||||
// switchFragment(LoginRegisterCNActivity.Fragment_Bind_Phone)
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
//通知欢迎页面关闭
|
|
||||||
XEventBus.post(EventName.FinishActivity)
|
|
||||||
activity.showToast(tipRes)
|
|
||||||
MMKVUtil.putString(MMKVKey.UserId, userBean.userId)
|
|
||||||
MMKVUtil.putInt(MMKVKey.isBindDevice, userBean.isBindDevice)
|
|
||||||
MMKVUtil.putString(MMKVKey.Token, userBean.token)
|
|
||||||
val rand = Random()
|
|
||||||
//极光推送设置别名
|
|
||||||
JPushInterface.setAlias(activity, rand.nextInt(1000), userBean.userId)
|
|
||||||
|
|
||||||
val intent = Intent()
|
|
||||||
//判断有没有绑定设备
|
|
||||||
// if (userBean.isBindDevice == ConstantInt.Close) {
|
|
||||||
// intent.setClass(activity, AddTrackerDeviceActivity::class.java)
|
|
||||||
// } else {
|
|
||||||
// intent.setClass(activity, HomeActivity::class.java)
|
|
||||||
// }
|
|
||||||
intent.setClass(activity, HomeV2Activity::class.java)
|
|
||||||
activity.startActivityFinish(intent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 微信绑定手机号
|
* 微信绑定手机号
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.lifecycle.ViewModel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.abbidot.baselibrary.util.Utils
|
import com.abbidot.baselibrary.util.Utils
|
||||||
import com.abbidot.tracker.base.BaseFragment
|
import com.abbidot.tracker.base.BaseFragment
|
||||||
|
import com.abbidot.tracker.bean.UserBean
|
||||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ import kotlinx.coroutines.launch
|
|||||||
*/
|
*/
|
||||||
class RegisterCNViewModel : ViewModel() {
|
class RegisterCNViewModel : ViewModel() {
|
||||||
val mSendCodeResultLiveData = MutableLiveData<Result<String>>()
|
val mSendCodeResultLiveData = MutableLiveData<Result<String>>()
|
||||||
val mValidateCodeResultLiveData = MutableLiveData<Result<String>>()
|
val mValidateCodeResultLiveData = MutableLiveData<Result<UserBean>>()
|
||||||
// val mPhoneRegisterResultLiveData = MutableLiveData<Result<String>>()
|
// val mPhoneRegisterResultLiveData = MutableLiveData<Result<String>>()
|
||||||
val mSetNewPasswordResultLiveData = MutableLiveData<Result<String>>()
|
val mSetNewPasswordResultLiveData = MutableLiveData<Result<String>>()
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class WXEntryActivity : WXBaseActivity() {
|
|||||||
|
|
||||||
override fun initData() {
|
override fun initData() {
|
||||||
mLoginCNViewModel.mWXLoginResultLiveData.observe(this) {
|
mLoginCNViewModel.mWXLoginResultLiveData.observe(this) {
|
||||||
LogUtil.e(it.toString())
|
LogUtil.e("mWXLoginResultLiveData:$it")
|
||||||
XEventBus.post(EventName.WXLoginResult, it)
|
XEventBus.post(EventName.WXLoginResult, it)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -37,21 +37,25 @@ class WXEntryActivity : WXBaseActivity() {
|
|||||||
BaseResp.ErrCode.ERR_OK -> {
|
BaseResp.ErrCode.ERR_OK -> {
|
||||||
result = "登录成功"
|
result = "登录成功"
|
||||||
val code = r.code
|
val code = r.code
|
||||||
|
XEventBus.post(EventName.PostValue, code)
|
||||||
LogUtil.e("${result}TAG_WECHAT_CODE", code)
|
LogUtil.e("${result}TAG_WECHAT_CODE", code)
|
||||||
mLoginCNViewModel.wxLogin(code)
|
mLoginCNViewModel.wxLogin(code)
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseResp.ErrCode.ERR_AUTH_DENIED -> {
|
BaseResp.ErrCode.ERR_AUTH_DENIED -> {
|
||||||
result = "用户拒绝微信授权登录"
|
result = "用户拒绝微信授权登录"
|
||||||
LogUtil.e("ERROR", result)
|
LogUtil.e("ERROR", result)
|
||||||
Toaster.show(result)
|
Toaster.show(result)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseResp.ErrCode.ERR_USER_CANCEL -> {
|
BaseResp.ErrCode.ERR_USER_CANCEL -> {
|
||||||
result = "用户取消微信授权登录"
|
result = "用户取消微信授权登录"
|
||||||
LogUtil.e("ERROR", result)
|
LogUtil.e("ERROR", result)
|
||||||
Toaster.show(result)
|
Toaster.show(result)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
result = "微信授权登录失败,${baseResp.errStr},code=${r.code}"
|
result = "微信授权登录失败,${baseResp.errStr},code=${r.code}"
|
||||||
LogUtil.e("ERROR", result)
|
LogUtil.e("ERROR", result)
|
||||||
|
|||||||
@@ -193,7 +193,6 @@
|
|||||||
<string name="login_txt_login_code">验证码登录</string>
|
<string name="login_txt_login_code">验证码登录</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<string name="txt_code_success">验证码已发送</string>
|
<string name="txt_code_success">验证码已发送</string>
|
||||||
<string name="login_txt_no_account">没有账号?</string>
|
<string name="login_txt_no_account">没有账号?</string>
|
||||||
|
|
||||||
@@ -213,7 +212,6 @@
|
|||||||
<string name="register_txt_submit">提交</string>
|
<string name="register_txt_submit">提交</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<string name="system_txt_map">地图</string>
|
<string name="system_txt_map">地图</string>
|
||||||
<string name="system_txt_profile">我的</string>
|
<string name="system_txt_profile">我的</string>
|
||||||
|
|
||||||
@@ -918,5 +916,6 @@
|
|||||||
<string name="txt_terms_html">terms_zh.html</string>
|
<string name="txt_terms_html">terms_zh.html</string>
|
||||||
<string name="txt_privacy_html">privacy_zh.html</string>
|
<string name="txt_privacy_html">privacy_zh.html</string>
|
||||||
<string name="txt_subscription_terms_conditions_html">subscription_terms_conditions_zh.html</string>
|
<string name="txt_subscription_terms_conditions_html">subscription_terms_conditions_zh.html</string>
|
||||||
|
<string name="txt_phone_has_bound">该手机号码已被绑定</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -1087,5 +1087,6 @@
|
|||||||
<string name="txt_terms_html">terms_en.html</string>
|
<string name="txt_terms_html">terms_en.html</string>
|
||||||
<string name="txt_privacy_html">privacy_en.html</string>
|
<string name="txt_privacy_html">privacy_en.html</string>
|
||||||
<string name="txt_subscription_terms_conditions_html">subscription_terms_conditions_en.html</string>
|
<string name="txt_subscription_terms_conditions_html">subscription_terms_conditions_en.html</string>
|
||||||
|
<string name="txt_phone_has_bound">该手机号码已被绑定</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -37,6 +37,7 @@ import androidx.annotation.StringDef
|
|||||||
EventName.SetGoal,
|
EventName.SetGoal,
|
||||||
EventName.RefreshMessage,
|
EventName.RefreshMessage,
|
||||||
EventName.BluetoothSwitch,
|
EventName.BluetoothSwitch,
|
||||||
|
EventName.PostValue,
|
||||||
EventName.BleReport,
|
EventName.BleReport,
|
||||||
EventName.BleFirmwareVersion,
|
EventName.BleFirmwareVersion,
|
||||||
EventName.BleReportData,
|
EventName.BleReportData,
|
||||||
@@ -112,5 +113,6 @@ annotation class EventName {
|
|||||||
|
|
||||||
//蓝牙透传
|
//蓝牙透传
|
||||||
const val BlePassThrough = "blePassThrough"
|
const val BlePassThrough = "blePassThrough"
|
||||||
|
const val PostValue = "value"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user