Commit bc4f39b7 authored by mengcuiguang's avatar mengcuiguang

添加微信登录方式,账号合并

parent 0eec1ad6
......@@ -63,11 +63,6 @@ object Constant {
*/
const val FIRST_SHARE_INVITED = "first_share_invited"
/**
* 存储地址 /storage/emulated/0/test/
*/
var ICASH_PATH = Environment.getExternalStorageDirectory().path + "/money/" + "apk/"
/**
* app应用首页 0-主页 1-横屏视频 2-pan 3-friends 4-我
*/
......@@ -96,9 +91,6 @@ object Constant {
const val MAIN_CARRIER_TYPE = "main_carrier_type" //载体
const val LOGIN_FLAG = "login_flag" //登录标识
// 载体
const val CARRIER_VERSUS_VIDEO = "CHALLENGE_VEDIO" //任务-视频
const val CARRIER_CHALLENGE_TURN = "CHALLENGE_TURN" //大转盘
......@@ -173,7 +165,7 @@ object Constant {
const val SHARE_TITLE = "发现一个二傻子平台,人傻钱多,速来~一起薅死他~~"
var SHARE_CONTENT = "邀请码【${UserManager.getInstance().codeID}】,共享新模式,快来加入跟我一起赚钱吧"
// var SHARE_URL: String = BuildConfig.MainIp + "share/shareFriend.html?ruid=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
var SHARE_URL: String = BuildConfig.MainIp + "wxShare/toShare?shareId=" + UserManager.getInstance().getUserID() + "&channel=" + CommonUtils.getAppMetaData(MintsApplication.getContext(), "CHANNEL_NAME")
var SHARE_URL: String = BuildConfig.MainIp + "wxShare/toShare?shareId=" + UserManager.getInstance().getUserID()
// 首页视频时长 单位-秒
const val MAIN_VEDIO_TIME = "main_vedio_time"
......@@ -183,4 +175,9 @@ object Constant {
// 游客首次登录弹窗
const val FIRST_VISITOR_FLAG = "first_visitor_flag"
// 账号合并
const val MERGE_MOBILE="merge_mobile"
const val MERGE_WXOPENID="merge_wxopenid"
const val MERGE_KEY="merge_key"
}
\ No newline at end of file
......@@ -394,6 +394,7 @@ public class UserManager {
ps.removeByKey(USER_CASH);
// ps.removeByKey(GAME_INFO);
ps.removeByKey(USER_OLD);
ps.removeByKey(WX_OPENID);
ps.removeByKey(WX_NAME);
ps.removeByKey(WX_HEADER);
......
......@@ -11,12 +11,17 @@ import java.io.Serializable;
public class UserBean implements Serializable {
private String token;
private String toKeepAnAccount;
private ConsumerBean consumer;
public String getToken() {
return token;
}
public String getToKeepAnAccount() {
return toKeepAnAccount;
}
public ConsumerBean getConsumer() {
return consumer;
}
......
......@@ -64,7 +64,7 @@ public class DrawcashPresenter extends BasePresenter<DrawcashView> {
/**
* 修改用户信息
*/
public void editUserMsg(String wxInfo) {
public void editUserMsg(String wxOpenid,String wxInfo) {
HashMap<String, Object> vo = new HashMap<>();
vo.put("type", "OPENID");
vo.put("value", wxInfo);
......@@ -102,6 +102,9 @@ public class DrawcashPresenter extends BasePresenter<DrawcashView> {
view.editUserMsgSuc();
}
break;
case 612 :
view.mergeAccount(UserManager.getInstance().getMobile(), wxOpenid, baseResponse.getData().getToKeepAnAccount());
break;
default:
view.showToast(message);
break;
......
......@@ -59,6 +59,44 @@ class LoginPresenter : BasePresenter<LoginView>() {
})
}
/**
* 绑定验证码
*
* @param mobile
*/
fun sendMobileBindingCode(mobile: String) {
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
AppHttpManager.getInstance(loanApplication)
.call(loanService.sendMobileBindingCode(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
val message: String = baseResponse.getMessage()
when (code) {
200 -> {
}
else -> {
view.showToast(message)
}
}
}
})
}
/**
* 绑定
*/
......@@ -93,6 +131,7 @@ class LoginPresenter : BasePresenter<LoginView>() {
UserManager.getInstance().saveUserInfo(data)
view.loginSuc()
}
612 -> view.mergeAccount(mobile, UserManager.getInstance().wxOpenid, data?.toKeepAnAccount!!)
else -> view.showToast(message)
}
}
......@@ -185,7 +224,7 @@ class LoginPresenter : BasePresenter<LoginView>() {
*
* @param context
*/
fun saveTerminalInfo(userId:Long) {
fun saveTerminalInfo(userId: Long) {
val vo = HashMap<String, Any>()
val deviceInfo: DeviceInfo = DeviceInfo.instance
val macAddress: String = deviceInfo.getMacAddress()
......
......@@ -14,7 +14,7 @@ class SettingsPresenter : BasePresenter<SettingsView>() {
/**
* 修改用户信息
*/
fun editUserMsg(wxInfo: String) {
fun editUserMsg(openId:String,wxInfo: String) {
val vo = HashMap<String, Any>()
vo["type"] = "OPENID"
vo["value"] = wxInfo
......@@ -44,6 +44,7 @@ class SettingsPresenter : BasePresenter<SettingsView>() {
view.editUserMsgSuc()
}
}
612 -> view.mergeAccount(UserManager.getInstance().mobile, openId, baseResponse.data?.toKeepAnAccount!!)
else -> view.showToast(message)
}
}
......
......@@ -13,4 +13,6 @@ public interface DrawcashView extends BaseView {
* 修改用户信息
*/
void editUserMsgSuc();
void mergeAccount(String mobile, String wxOpenId, String key);
}
......@@ -6,4 +6,5 @@ interface LoginView : BaseView {
*/
fun loginSuc()
fun sendCodeSuc()
fun mergeAccount(mobile:String,wxOpenId:String,key:String)
}
\ No newline at end of file
......@@ -12,4 +12,6 @@ interface SettingsView : BaseView {
* 获取用户配置信息成功
*/
fun getUserTaskMsgSuc(data: DrawcashBean)
fun mergeAccount(mobile: String, wxOpenId: String, key: String)
}
\ No newline at end of file
......@@ -131,6 +131,14 @@ public interface LoanService {
@POST("api/sendMobileCode")
Observable<BaseResponse<Object>> sendMobileCode(@Body Map<String, Object> vo);
/**
* 绑定验证码
*
* @return
*/
@POST("api/sendMobileBindingCode")
Observable<BaseResponse<Object>> sendMobileBindingCode(@Body Map<String, Object> vo);
/**
* 登录
*
......
package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.mvp.presenters.AccountMergePresenter
import com.mints.goodmoney.mvp.views.AccountMergeView
import com.mints.goodmoney.ui.activitys.base.BaseActivity
......@@ -15,7 +17,9 @@ import kotlinx.android.synthetic.main.header_layout.*
*/
class AccountMergeActivity : BaseActivity(), View.OnClickListener, AccountMergeView {
private var keepOneAccountKey: String? = null
private lateinit var mobile: String
private lateinit var wxOpenId: String
private lateinit var keepOneAccountKey: String
private val accountMergePresenter by lazy { AccountMergePresenter() }
......@@ -23,6 +27,15 @@ class AccountMergeActivity : BaseActivity(), View.OnClickListener, AccountMergeV
override fun isApplyKitKatTranslucency() = false
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
mobile = it.getString(Constant.MERGE_MOBILE, "")
wxOpenId = it.getString(Constant.MERGE_WXOPENID, "")
keepOneAccountKey = it.getString(Constant.MERGE_KEY, "")
}
}
override fun initViewsAndEvents() {
tv_title.text = "账号绑定"
iv_left_icon.visibility = View.VISIBLE
......
package com.mints.goodmoney.ui.activitys
import android.Manifest
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.manager.UserManager
import com.mints.goodmoney.mvp.presenters.LoginPresenter
import com.mints.goodmoney.mvp.views.LoginView
......@@ -56,7 +58,7 @@ class BindMobileActivity : BaseActivity()
sendCodeThread()
mobile = mobile.replace(" ".toRegex(), "")
loginPresenter.sendMobileCode(mobile)
loginPresenter.sendMobileBindingCode(mobile)
}
R.id.tvLoginNext -> {
var mobile = etLoginMobile.getText().toString().trim()
......@@ -96,6 +98,14 @@ class BindMobileActivity : BaseActivity()
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
}
private fun initView() {
tv_title.text = "绑定手机号"
iv_left_icon.visibility = View.VISIBLE
......
package com.mints.goodmoney.ui.activitys
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.login.LoginApi
import com.mints.goodmoney.login.OnLoginListener
import com.mints.goodmoney.manager.UserManager
......@@ -173,6 +175,14 @@ class DrawcashActivity : BaseActivity(),
drawcashPresenter.getUserTaskMsg()
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
......@@ -188,7 +198,7 @@ class DrawcashActivity : BaseActivity(),
}
if (!isFinishing) {
drawcashPresenter.editUserMsg(JsonUtil.toJson(wxInfo))
drawcashPresenter.editUserMsg(res["openid"].toString(),JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -112,6 +112,10 @@ class MobileLoginActivity : BaseActivity()
}
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
}
private fun initView() {
tv_title.text = "手机号登录"
iv_left_icon.visibility = View.VISIBLE
......
......@@ -301,7 +301,7 @@ class SettingsActivity : BaseActivity(), View.OnClickListener, OnLoginListener,
}
if (!isFinishing) {
settingsPresenter.editUserMsg(JsonUtil.toJson(wxInfo))
settingsPresenter.editUserMsg(res["openid"].toString(),JsonUtil.toJson(wxInfo))
}
} catch (e: Exception) {
e.printStackTrace()
......@@ -318,4 +318,12 @@ class SettingsActivity : BaseActivity(), View.OnClickListener, OnLoginListener,
override fun getUserTaskMsgSuc(data: DrawcashBean) {
item_wechat.findViewById<TextView>(R.id.tv_right).text = data.nickName
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
}
}
\ No newline at end of file
......@@ -131,6 +131,10 @@ class WxLoginActivity : BaseActivity()
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
......
......@@ -84,7 +84,7 @@ class CoinRecordAdapter(context: Context, coinData: MutableList<GoldRecordBean.L
holder.tv_goldrecord_cash_type.text = "钻石"
}
holder.tv_goldrecord_cash.text = "-" + coinData.unitCoin
holder.tv_goldrecord_cash.setTextColor(ContextCompat.getColor(mContext, R.color.color_7CCD7C))
holder.tv_goldrecord_cash.setTextColor(ContextCompat.getColor(mContext, R.color.color_4BB93F))
}
}
}
......
......@@ -54,7 +54,7 @@ class DrawcashRecordAdapter(context: Context, invitedData: MutableList<DrawcashR
viewHolder.tv_drawcashrecord_account.setTextColor(ContextCompat.getColor(mContext, R.color.color_7EE2FF))
} else {
viewHolder.tv_drawcashrecord_account.text = "提现账户:微信"
viewHolder.tv_drawcashrecord_account.setTextColor(ContextCompat.getColor(mContext, R.color.color_7CCD7C))
viewHolder.tv_drawcashrecord_account.setTextColor(ContextCompat.getColor(mContext, R.color.color_4BB93F))
}
val errormsg: String = data.errormsg
if (TextUtils.isEmpty(errormsg)) {
......
......@@ -23,6 +23,7 @@ import com.mints.goodmoney.mvp.views.HomeView
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.ui.activitys.WebActivity
import com.mints.goodmoney.ui.fragment.base.BaseFragment
import com.mints.goodmoney.ui.widgets.BindWxDialog
import com.mints.goodmoney.ui.widgets.DialogListener
import com.mints.goodmoney.ui.widgets.PowerDialog
import com.mints.goodmoney.utils.LogUtil
......@@ -48,6 +49,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
private val userManager by lazy { UserManager.getInstance() }
private val ps by lazy { AppPreferences(context) }
private var powerDialog: PowerDialog? = null
private var bindWxDialog: BindWxDialog? = null
private var userMsgBean: UserTaskMsgBean? = null
......@@ -180,7 +182,7 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
// 新人福利 放到个人中心展示 防止首页红包转动异常
// 设置视频权限
vedioAdingManager?.initAdWeight(data.vedioRules.csJ_VEDIO.rate, data.vedioRules.ylH_VEDIO.rate,data.vedioRules.sdhZ_VEDIO.rate)
vedioAdingManager?.initAdWeight(data.vedioRules.csJ_VEDIO.rate, data.vedioRules.ylH_VEDIO.rate, data.vedioRules.sdhZ_VEDIO.rate)
LogUtil.d(TAG, "首页权重值:csjWeight:${data.vedioRules.csJ_VEDIO.rate} ylhWeight:${data.vedioRules.ylH_VEDIO.rate} sdhzWeight:${data.vedioRules.sdhZ_VEDIO.rate}")
// 广告视频数
AppConfig.csjVedioAdCount = data.vedioRules.csJ_VEDIO.surplus
......@@ -190,6 +192,18 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
// 调用金币视频信息接口
homePresenter.getHomeVedioMsg()
// 手机号登录未绑定微信 弹出界面不能关闭
if (userManager.userIsLogin() && TextUtils.isEmpty(userManager.wxOpenid)) {
if (bindWxDialog == null) {
bindWxDialog = BindWxDialog(requireActivity())
bindWxDialog!!.show()
}
} else {
if (bindWxDialog != null && bindWxDialog!!.isShowing) {
bindWxDialog?.dismiss()
}
}
}
override fun getHomeVedioMsgSuc(data: MainVedioMsgBean) {
......
package com.mints.goodmoney.ui.widgets
import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.os.Bundle
import android.view.Gravity
import android.view.KeyEvent
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat
import com.mints.goodmoney.MintsApplication
import com.mints.goodmoney.R
import com.mints.goodmoney.common.Constant
import com.mints.goodmoney.login.LoginApi
import com.mints.goodmoney.login.OnLoginListener
import com.mints.goodmoney.mvp.model.DrawcashBean
import com.mints.goodmoney.mvp.model.WXInfo
import com.mints.goodmoney.mvp.presenters.SettingsPresenter
import com.mints.goodmoney.mvp.views.SettingsView
import com.mints.goodmoney.ui.activitys.AccountMergeActivity
import com.mints.goodmoney.ui.activitys.AwardActivity
import com.mints.goodmoney.utils.ToastUtil
import com.mints.library.utils.json.JsonUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import java.util.*
/**
* 微信授权弹窗
*/
class BindWxDialog(context: Activity) :
Dialog(context, R.style.dialog), OnLoginListener, SettingsView, View.OnClickListener {
private var loginApi: LoginApi? = null
private var settingsPresenter: SettingsPresenter? = null
private var wxInfo: WXInfo? = null
init {
setContentView(R.layout.dialog_bindwx)
// 设置window属性
val lp = window!!.attributes
lp.gravity = Gravity.CENTER
lp.width = WindowManager.LayoutParams.MATCH_PARENT
lp.windowAnimations = R.style.DialogAnimBottom
window!!.attributes = lp
// 设置外部不可关闭
setCancelable(false)
setCanceledOnTouchOutside(false)
setOnKeyListener { _, i, _ ->
i == KeyEvent.KEYCODE_BACK
}
findViewById<View>(R.id.btn_dialogper_next).setOnClickListener(this)
loginApi = LoginApi()
settingsPresenter = SettingsPresenter()
settingsPresenter?.attachView(this)
}
override fun dismiss() {
super.dismiss()
loginApi?.setOnLoginListener(null)
settingsPresenter?.detachView()
}
override fun onClick(v: View) {
if (AntiShake.check(v?.id)) return
when (v.id) {
R.id.btn_dialogper_next -> {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
return
}
loginApi?.let {
it.setOnLoginListener(this)
it.setPlatform(Wechat.NAME)
it.login(context)
}
}
}
}
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.setUnionid(res["unionid"].toString() + "")
it.setOpenid(res["openid"].toString() + "")
it.setProvince(res["province"].toString() + "")
it.setCity(res["city"].toString() + "")
it.setCountry(res["country"].toString() + "")
it.setHeadimgurl(res["headimgurl"].toString() + "")
it.setNickname(res["nickname"].toString() + "")
it.setSex((res["sex"].toString() + "").toInt())
}
settingsPresenter?.editUserMsg(res["openid"].toString(), JsonUtil.toJson(wxInfo))
} catch (e: Exception) {
e.printStackTrace()
}
return false
}
override fun mergeAccount(mobile: String, wxOpenId: String, key: String) {
val bundle = Bundle()
bundle.putString(Constant.MERGE_MOBILE, mobile)
bundle.putString(Constant.MERGE_WXOPENID, wxOpenId)
bundle.putString(Constant.MERGE_KEY, key)
readyGo(AccountMergeActivity::class.java, bundle)
dismiss()
}
protected fun readyGo(clazz: Class<*>?, bundle: Bundle?) {
val intent = Intent(context, clazz)
if (null != bundle) {
intent.putExtras(bundle)
}
context.startActivity(intent)
}
override fun editUserMsgSuc() {
ToastUtil.show(context, "微信绑定成功")
dismiss()
}
override fun getUserTaskMsgSuc(data: DrawcashBean) {
}
override fun showLoading(msg: String?) {
}
override fun showToast(msg: String?) {
ToastUtil.showLong(context, msg)
}
override fun hideLoading() {
}
override fun getBaseApplication(): MintsApplication {
return MintsApplication.getContext() as MintsApplication
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="@color/color_7CCD7C" />
<solid android:color="@color/color_4BB93F" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="30dip" />
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="420dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:background="@drawable/shape_bg_write"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:text="温馨提示"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="bold" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:background="#E1E1E1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:gravity="center_horizontal"
android:text="为了保证您的账户安全\n请先绑定微信"
android:textColor="@color/gray"
android:textSize="14sp" />
<ImageView
android:layout_width="50dp"
android:src="@mipmap/ic_share_wx"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:layout_marginBottom="10dp"
android:layout_height="50dp"/>
<TextView
android:id="@+id/btn_dialogper_next"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:gravity="center"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_green"
android:text="去绑定"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
</RelativeLayout>
......@@ -60,7 +60,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:textColor="@color/color_7CCD7C"
android:textColor="@color/color_4BB93F"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="@id/item_task_pb"
app:layout_constraintStart_toEndOf="@id/item_task_pb"
......
......@@ -24,7 +24,7 @@
<color name="color_666">#666666</color>
<color name="color_454A69">#454A69</color>
<color name="color_333">#333333</color>
<color name="color_7CCD7C">#7CCD7C</color>
<color name="color_4BB93F">#4BB93F</color>
<color name="color_FEB63D">#FEB63D</color>
<color name="color_FF5E5E">#FF5E5E</color>
<color name="color_172B54">#172B54</color>
......
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