Commit e2efe09d authored by mengcuiguang2's avatar mengcuiguang2

微信登录重构

parent d20322f8
......@@ -18,7 +18,7 @@ import java.util.*
*/
object CsjGroMoreManager {
const val TT_AD_APPID = "12345"
const val TT_AD_APPID = "5198591"
private var sInit: Boolean = false
......
......@@ -44,7 +44,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
// KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
......@@ -79,7 +78,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("LoginViewModel", "登录错误")
}
......
......@@ -31,6 +31,7 @@ import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager
import com.mints.street.utils.json.JsonUtil
import com.mints.street.webview.MintsWebViewActivity
import com.mints.street.widget.dialog.WxLoginDialog
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import com.tbruyelle.rxpermissions2.RxPermissions
......@@ -46,22 +47,12 @@ import java.util.*
* Created by 冯瑞雨 on 2021/7/2.
* 个人中心页面
*/
class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshListener,
View.OnClickListener, OnLoginListener {
class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshListener {
private val userManager by lazy { UserManager.INSTANCE }
private var userConfig: UserBean? = null
private val loginApi by lazy { LoginApi() }
private var wxInfo: WXInfo? = null
//弹窗
private var mBottomSheetDialog: BottomSheetDialog? = null
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
private val loginDialog by lazy { WxLoginDialog(requireActivity()).init() }
override fun initContentView(inflater: LayoutInflater?,
container: ViewGroup?,
......@@ -91,135 +82,33 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
private fun initListener() {
//设置登录点击事件
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)
RxUtils.onMultiClick(ly_phone) {
if (cb_checked!!.isChecked) {
startActivity(LoginActivity::class.java)
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
loginDialog.show()
}
}
//设置立即领取点击事件
binding.btTry.setOnClickListener {
// startActivity(PermissionsActivity::class.java)
startActivity(OpenvipActivity::class.java)
}
RxUtils.onMultiClick(aboutus) {
startActivity(AboutusActivity::class.java)
}
RxUtils.onMultiClick(moresettings) {
startActivity(MoresettingsActivity::class.java)
}
}
private fun initView() {
aboutus.findViewById<TextView>(R.id.tv_title).text = "关于我们"
val userAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_about_us)
userAgree?.setBounds(0, 0, 56, 56)
aboutus.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(userAgree, null, null, null)
aboutus.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
aboutus.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
moresettings.findViewById<TextView>(R.id.tv_title).text = "更多设置"
val privacyAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_more_settings)
privacyAgree?.setBounds(0, 0, 56, 56)
moresettings.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(privacyAgree, null, null, null)
moresettings.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
moresettings.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
ic_theme.findViewById<TextView>(R.id.tv_theme_name).text="享8大特权"
ic_theme.findViewById<TextView>(R.id.tv_me1).text = "无线缩放"
ic_theme.findViewById<TextView>(R.id.tv_me2).text = "国内外街景"
ic_theme.findViewById<TextView>(R.id.tv_me3).text = "VR全景"
ic_theme.findViewById<TextView>(R.id.tv_me4).text = "3D地图"
ic_theme.findViewById<TextView>(R.id.tv_me5).text = "国外搜索"
ic_theme.findViewById<TextView>(R.id.tv_me6).text = "高清地图"
ic_theme.findViewById<TextView>(R.id.tv_me7).text = "历史影像"
ic_theme.findViewById<TextView>(R.id.tv_me8).text = "景点推荐"
ic_theme.findViewById<ImageView>(R.id.iv_decorate1).setImageResource(R.mipmap.icon_me_tiao)
ic_theme.findViewById<ImageView>(R.id.iv_decorate2).setImageResource(R.mipmap.icon_me_tiao)
ic_theme.findViewById<ImageView>(R.id.iv_me1).setImageResource(R.mipmap.icon_me1)
ic_theme.findViewById<ImageView>(R.id.iv_me2).setImageResource(R.mipmap.icon_me2)
ic_theme.findViewById<ImageView>(R.id.iv_me3).setImageResource(R.mipmap.icon_me3)
ic_theme.findViewById<ImageView>(R.id.iv_me4).setImageResource(R.mipmap.icon_me4)
ic_theme.findViewById<ImageView>(R.id.iv_me5).setImageResource(R.mipmap.icon_me5)
ic_theme.findViewById<ImageView>(R.id.iv_me6).setImageResource(R.mipmap.icon_me6)
ic_theme.findViewById<ImageView>(R.id.iv_me7).setImageResource(R.mipmap.icon_me7)
ic_theme.findViewById<ImageView>(R.id.iv_me8).setImageResource(R.mipmap.icon_me8)
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_weixin -> {
if (cb_checked!!.isChecked) {
// ToastUtils.showShort("未完成微信登录对接")
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
ToastUtils.showShort("请先安装微信")
return
}
RxPermissions(this)
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean ->
if (granted) {
loginApi.setOnLoginListener(this@MyFragment)
loginApi.setPlatform(Wechat.NAME)
loginApi.login(context)
} else {
// showMissingPermissionDialog("设备")
}
}
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 -> {
MintsWebViewActivity.startWebView(name = "用户协议", url = Constant.REGISTER_URL)
}
R.id.tv_private -> {
MintsWebViewActivity.startWebView(name = "隐私协议", url = Constant.PRIVACY_URL)
loginDialog.setListener(object:WxLoginDialog.WxLoginListener{
override fun loginSuc(wxInfo: String) {
if (!isHidden) {//当前fragment正在显示调用微信登陆接口
viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
}
}
})
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.myInfodata.observe(this, Observer<UserBean> {
......@@ -231,9 +120,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
userConfig = it
//获取我的数据
setUserLoginStatus()
})
}
private fun setUserLoginStatus() {
......@@ -267,32 +154,46 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshList
override fun onDestroy() {
super.onDestroy()
loginApi.setOnLoginListener(null)
}
override fun onLogin(platform: String?, res: HashMap<String, Any>?): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.unionid = res?.get("unionid").toString() + ""
it.openid = res?.get("openid").toString() + ""
it.province = res?.get("province").toString() + ""
it.city = res?.get("city").toString() + ""
it.country = res?.get("country").toString() + ""
it.headimgurl = res?.get("headimgurl").toString() + ""
it.nickname = res?.get("nickname").toString() + ""
it.sex = (res?.get("sex").toString() + "").toInt()
loginDialog.setListener(null)
loginDialog.onDestroy()
}
if (!isHidden) {//当前fragment正在显示调用微信登陆接口
viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
private fun initView() {
aboutus.findViewById<TextView>(R.id.tv_title).text = "关于我们"
val userAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_about_us)
userAgree?.setBounds(0, 0, 56, 56)
aboutus.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(userAgree, null, null, null)
aboutus.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
aboutus.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
moresettings.findViewById<TextView>(R.id.tv_title).text = "更多设置"
val privacyAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_more_settings)
privacyAgree?.setBounds(0, 0, 56, 56)
moresettings.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(privacyAgree, null, null, null)
moresettings.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
moresettings.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
ic_theme.findViewById<TextView>(R.id.tv_theme_name).text="享8大特权"
ic_theme.findViewById<TextView>(R.id.tv_me1).text = "无线缩放"
ic_theme.findViewById<TextView>(R.id.tv_me2).text = "国内外街景"
ic_theme.findViewById<TextView>(R.id.tv_me3).text = "VR全景"
ic_theme.findViewById<TextView>(R.id.tv_me4).text = "3D地图"
ic_theme.findViewById<TextView>(R.id.tv_me5).text = "国外搜索"
ic_theme.findViewById<TextView>(R.id.tv_me6).text = "高清地图"
ic_theme.findViewById<TextView>(R.id.tv_me7).text = "历史影像"
ic_theme.findViewById<TextView>(R.id.tv_me8).text = "景点推荐"
ic_theme.findViewById<ImageView>(R.id.iv_decorate1).setImageResource(R.mipmap.icon_me_tiao)
ic_theme.findViewById<ImageView>(R.id.iv_decorate2).setImageResource(R.mipmap.icon_me_tiao)
ic_theme.findViewById<ImageView>(R.id.iv_me1).setImageResource(R.mipmap.icon_me1)
ic_theme.findViewById<ImageView>(R.id.iv_me2).setImageResource(R.mipmap.icon_me2)
ic_theme.findViewById<ImageView>(R.id.iv_me3).setImageResource(R.mipmap.icon_me3)
ic_theme.findViewById<ImageView>(R.id.iv_me4).setImageResource(R.mipmap.icon_me4)
ic_theme.findViewById<ImageView>(R.id.iv_me5).setImageResource(R.mipmap.icon_me5)
ic_theme.findViewById<ImageView>(R.id.iv_me6).setImageResource(R.mipmap.icon_me6)
ic_theme.findViewById<ImageView>(R.id.iv_me7).setImageResource(R.mipmap.icon_me7)
ic_theme.findViewById<ImageView>(R.id.iv_me8).setImageResource(R.mipmap.icon_me8)
}
}
......@@ -22,8 +22,10 @@ import com.mints.street.bean.WxPayParamBean
import com.mints.street.databinding.ActivityOpenvipBinding
import com.mints.street.main.MainActivity
import com.mints.street.manager.UserManager
import com.mints.street.utils.json.JsonUtil
import com.mints.street.widget.dialog.DialogListener
import com.mints.street.widget.dialog.DialogUtils
import com.mints.street.widget.dialog.WxLoginDialog
import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.activity_openvip.bt_try
import kotlinx.android.synthetic.main.fragment_my.*
......@@ -42,6 +44,8 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
private var vipList: MutableList<VipBean.ListBean>? = null
private var currentPayType=""
private val loginDialog by lazy { WxLoginDialog(this).init() }
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip
......@@ -61,11 +65,24 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
initListener()
}
override fun onDestroy() {
super.onDestroy()
loginDialog.setListener(null)
loginDialog.onDestroy()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
bt_try.setOnClickListener(this)
ly_weixin.setOnClickListener(this)
ly_alipay.setOnClickListener(this)
loginDialog.setListener(object:WxLoginDialog.WxLoginListener{
override fun loginSuc(wxInfo: String) {
viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
}
})
}
private fun initView() {
......@@ -171,7 +188,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
})
viewModel.isPaySuc.observe(this, Observer<Boolean> {
if(it){
ToastUtils.showShort("支付成功")
finish()
}
})
......@@ -236,7 +252,7 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
if (UserManager.INSTANCE.userIsLogin()) {
payVip()
} else {
startActivity(OpenvipActivity::class.java)
loginDialog.show()
}
}
}
......@@ -260,7 +276,11 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
}
when (v?.id) {
R.id.tv_payment -> {//继续支付
if (UserManager.INSTANCE.userIsLogin()) {
payVip()
} else {
loginDialog.show()
}
}
R.id.tv_close -> {//取消
finish()
......@@ -320,9 +340,6 @@ class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>()
com.blankj.utilcode.util.ToastUtils.showShort("支付成功")
finish()
}
// viewModel.queryVipOrder(wxParanBean.tid.toString())
com.blankj.utilcode.util.ToastUtils.showShort("支付成功")
finish()
}) { throwable ->
ToastUtils.showShort("支付异常,请联系管理员")
}
......
......@@ -3,18 +3,26 @@ package com.mints.street.main.my
import android.app.Application
import androidx.core.graphics.PathParser
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.PaymentBean
import com.mints.street.bean.VipBean
import com.mints.street.bean.WxPayParamBean
import com.blankj.utilcode.util.ToastUtils
import com.mints.street.bean.*
import com.mints.street.common.DeviceInfo
import com.mints.street.manager.UserManager
import com.mints.street.manager.oaid.OaidManager
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.utils.DeviceUuidFactory
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
class OpenvipViewModel(application: Application) : BaseViewModel(application) {
val deviceInfo: DeviceInfo
get() {
return DeviceInfo.instance
}
val Vipdata: MutableLiveData<VipBean> = MutableLiveData()
val Paymentdata: MutableLiveData<PaymentBean> = MutableLiveData()
val vippayParams: MutableLiveData<WxPayParamBean> = MutableLiveData()
......@@ -102,4 +110,55 @@ class OpenvipViewModel(application: Application) : BaseViewModel(application) {
}
)
}
fun wechatlogin(wxInfo: String) {
val vo = HashMap<String, Any>()
vo["wxInfo"] = wxInfo
// vo["shumeiId"] = ShumeiManager.getInstance().shumeiDeviceId
vo["device"] = DeviceUuidFactory().deviceUuid.toString()
ApiModel.wechatlogin(lifecycleProvider,vo).safeSubscribe(object : HttpSubscribeImpl<BaseResponse<UserBean>>(
this@OpenvipViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<UserBean>) {
//保存用户信息到Usermanager
UserManager.INSTANCE.saveUserInfo(response.result)
this@OpenvipViewModel.saveTerminalInfo()//提交设备信息
KLog.e("wechatlogin","微信登录接口成功")
ToastUtils.showLong("登录成功")
}
override fun onError(e: Throwable) {
super.onError(e)
KLog.e("wechatlogin", "微信登录接口失败")
}
})
}
/**
* 提交设备信息
*/
fun saveTerminalInfo() {
val vo = hashMapOf<String, Any>()
val macAddress: String = deviceInfo.getMacAddress()
val mac = macAddress.replace(":", "")
vo["mac"] = mac
vo["mac1"] = macAddress
vo["androidid"] = deviceInfo.getAndroidId(null)
vo["imei"] = deviceInfo.iMEI
vo["oaid"] = OaidManager.getOaid()
vo["os"] = "android"
vo["model"] = deviceInfo.newModel
vo["uuid"] = DeviceUuidFactory().deviceUuid
vo["osversion"] = deviceInfo.oSVersion
vo["appversion"] = deviceInfo.versionName
ApiModel.saveTerminalInfo(lifecycleProvider, vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@OpenvipViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("saveTerminalInfo", response.result.toString())
}
})
}
}
......@@ -182,7 +182,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
}
private fun showPowerDialog() {
if (MMKV.mmkvWithID(Constant.LOAN_PERMISSION_FLAG).decodeBool(Constant.LOAN_PERMISSION_FLAG, false)) {
if (MMKV.mmkvWithID(Constant.LOAN_PERMISSION_FLAG).decodeBool(Constant.LOAN_PERMISSION_FLAG, true)) {
powerDialog()
} else {
isClickAgree = true
......@@ -229,7 +229,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
isClickAgree = true
MMKV.mmkvWithID(Constant.LOAN_PERMISSION_FLAG).encode(Constant.LOAN_PERMISSION_FLAG, true)
MMKV.mmkvWithID(Constant.LOAN_PERMISSION_FLAG).encode(Constant.LOAN_PERMISSION_FLAG, false)
}
}
}
......
package com.mints.street.widget.dialog
import android.Manifest
import android.content.Intent
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.fragment.app.FragmentActivity
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.R
import com.mints.street.bean.WXInfo
import com.mints.street.common.Constant
import com.mints.street.login.LoginActivity
import com.mints.street.login.LoginApi
import com.mints.street.login.OnLoginListener
import com.mints.street.utils.json.JsonUtil
import com.mints.street.webview.MintsWebViewActivity
import com.tbruyelle.rxpermissions2.RxPermissions
import me.goldze.mvvmhabit.utils.RxUtils
import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.*
/**
* 描述:微信登录
* 作者:孟崔广
* 时间:2021/7/29 10:51
*/
class WxLoginDialog(context: FragmentActivity) : OnLoginListener {
var wxLoginListener: WxLoginListener? = null
private var mBottomSheetDialog: BottomSheetDialog? = null
private var context:FragmentActivity
private val loginApi by lazy { LoginApi() }
init {
this.context=context
}
/**
* 初始化
*/
fun init():WxLoginDialog{
//创建弹窗
if(mBottomSheetDialog!=null) return this
mBottomSheetDialog = BottomSheetDialog(context)
val view1: View = LayoutInflater.from(context).inflate(R.layout.layout_popupwindow, null)
mBottomSheetDialog!!.setContentView(view1)
mBottomSheetDialog!!.window!!.findViewById<View>(R.id.design_bottom_sheet).setBackgroundColor(Color.TRANSPARENT)
val iv_weixin: ImageView = view1.findViewById(R.id.iv_weixin)
val ly_phone: LinearLayoutCompat = view1.findViewById(R.id.ly_phone)
val cb_checked: CheckBox = view1.findViewById(R.id.cb_checked)
val tv_private: TextView = view1.findViewById(R.id.tv_private)
val tv_regist: TextView = view1.findViewById(R.id.tv_regist)
tv_regist.setOnClickListener{
MintsWebViewActivity.startWebView(name = "用户协议", url = Constant.REGISTER_URL)
}
tv_private.setOnClickListener{
MintsWebViewActivity.startWebView(name = "隐私协议", url = Constant.PRIVACY_URL)
}
iv_weixin.setOnClickListener{
if (cb_checked!!.isChecked) {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
ToastUtils.showShort("请先安装微信")
return@setOnClickListener
}
RxPermissions(context)
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean ->
if (granted) {
loginApi.setOnLoginListener(this)
loginApi.setPlatform(Wechat.NAME)
loginApi.login(context)
} else {
// showMissingPermissionDialog("设备")
}
}
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
RxUtils.onMultiClick(ly_phone) {
if (cb_checked!!.isChecked) {
context.startActivity(Intent(context, LoginActivity::class.java))
mBottomSheetDialog!!.dismiss()
} else {
ToastUtils.showShort("请先同意用户协议与隐私政策")
}
}
return this
}
/**
* 展示
*/
fun show(){
mBottomSheetDialog?.show()
}
override fun onLogin(platform: String?, res: HashMap<String, Any>?): Boolean {
try {
val wxInfo = WXInfo()
wxInfo?.let {
it.unionid = res?.get("unionid").toString() + ""
it.openid = res?.get("openid").toString() + ""
it.province = res?.get("province").toString() + ""
it.city = res?.get("city").toString() + ""
it.country = res?.get("country").toString() + ""
it.headimgurl = res?.get("headimgurl").toString() + ""
it.nickname = res?.get("nickname").toString() + ""
it.sex = (res?.get("sex").toString() + "").toInt()
}
// if (!isHidden) {//当前fragment正在显示调用微信登陆接口
// viewModel.wechatlogin(JsonUtil.toJson(wxInfo))
// }
wxLoginListener?.loginSuc(JsonUtil.toJson(wxInfo))
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
fun onDestroy(){
loginApi.setOnLoginListener(null)
mBottomSheetDialog=null
}
fun setListener(listener: WxLoginListener?) {
wxLoginListener = listener
}
interface WxLoginListener {
fun loginSuc(wxInfo: String)
}
}
\ No newline at end of file
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