Commit 06a65178 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 01027762
......@@ -43,6 +43,16 @@ public class UserBean implements Serializable {
private int rewardFirst;//是否弹出过领取奖励的框,0 没有, 1弹过了
private int rewardCoin;//领取奖励的金币
private boolean alipaySet;//支付宝授权状态
private boolean wechatSet;//授权状态
public boolean isWechatSet() {
return wechatSet;
}
public void setWechatSet(boolean wechatSet) {
this.wechatSet = wechatSet;
}
public String getToken() {
return token;
......
......@@ -12,16 +12,13 @@ import java.util.HashMap
class DrawCashPresenter : BasePresenter<DrawCashView>() {
/**
* 微信登录
*/
fun wxLogin(wxInfo: String) {
fun reportWeixinMsg(openid: String) {
view.showLoading("加载中...")
val vo = HashMap<String, Any>()
vo["wxInfo"] = wxInfo
vo["openid"] = openid
AppHttpManager.getInstance(loanApplication)
.call(loanService.wechatlogin(vo),
object : BaseSubscriber<BaseResponse<UserBean>>() {
.call(loanService.reportWeixinMsg(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
......@@ -33,15 +30,13 @@ class DrawCashPresenter : BasePresenter<DrawCashView>() {
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<UserBean>) {
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
val data = baseResponse.data
when (code) {
200 -> if (data != null) {
UserManager.getInstance().saveUserInfo(data)
200 -> {
view.showToast("微信授权成功")
}
else -> view.showToast(message)
......
......@@ -80,6 +80,14 @@ public interface LoanService {
@POST("api/user/wechatlogin")
Observable<BaseResponse<UserBean>> wechatlogin(@Body Map<String, Object> vo);
/**
* 微信授权
*
* @return
*/
@POST("api/user/reportWeixinMsg")
Observable<BaseResponse<Object>> reportWeixinMsg(@Body Map<String, Object> vo);
/**
* 提交设备信息
*
......
package com.duben.miniplaylet.ui.activitys
import android.content.Context
import android.content.Intent
import android.media.AudioManager
import android.os.Bundle
import android.view.KeyEvent
......@@ -13,7 +14,10 @@ import com.duben.miniplaylet.R
import com.duben.miniplaylet.common.AppConfig
import com.duben.miniplaylet.common.Constant
import com.duben.miniplaylet.ui.activitys.base.BaseActivity
import com.duben.miniplaylet.ui.fragment.*
import com.duben.miniplaylet.ui.fragment.MainFragment
import com.duben.miniplaylet.ui.fragment.MusicFragment
import com.duben.miniplaylet.ui.fragment.MyFragment
import com.duben.miniplaylet.ui.fragment.RedpkgFragment
import com.duben.miniplaylet.utils.UIUtils
import com.duben.miniplaylet.video.csj.DPHolderManager
import kotlinx.android.synthetic.main.activity_main.*
......@@ -37,6 +41,15 @@ class MainActivity : BaseActivity(), View.OnClickListener {
override fun getContentViewLayoutID() = R.layout.activity_main
override fun initViewsAndEvents() {
if (intent?.action == Intent.ACTION_MAIN && intent?.categories?.contains(Intent.CATEGORY_LAUNCHER) == true) {
// 应用是通过点击桌面图标进入的
println("mcg -->>>>> 应用是通过点击桌面图标进入的")
} else {
// 应用是从后台进入前台的
// 应用是通过点击桌面图标进入的
println("mcg -->>>>> 应用是通过点击桌面图标进入的")
}
DPHolderManager.initDpSdk(MintsApplication.getContext())
audioManager = getSystemService(Context.AUDIO_SERVICE) as AudioManager
......
......@@ -70,6 +70,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
private var currentDrawInfo: DrawInfoBean.DrawInfoItemBean? = null
var payChannel = ALIPAY
var alipayStatus = false
var weixinStatus = false
private var currentPosition = 0
override fun getContentViewLayoutID() = R.layout.fragment_draw
......@@ -116,6 +117,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
override fun getRedpkgSuc(data: DrawInfoBean) {
this.redPkgBean = data
this.alipayStatus = data.userMsg.isAlipaySet
this.weixinStatus = data.userMsg.isWechatSet
tv_title.text = "红包余额(元)"
tv_cash.text = SpanUtils()
......@@ -162,6 +164,12 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
currentDrawInfo = redPkgBean?.list?.get(position)
}
if (currentDrawInfo?.cash!! < 0.3) {
rb_wechat.visibility = View.GONE
} else {
rb_wechat.visibility = View.VISIBLE
}
/**
* 21 任务弹框,
* 11 直接在当前页面观看视频,-- 立即赚钱
......@@ -202,9 +210,8 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
1 -> {
//1、支付渠道
if (TextUtils.equals(payChannel, WEIXIN_PAY)) {
// 微信授权
if (TextUtils.isEmpty(UserManager.getInstance().wxOpenid)) {
if (!weixinStatus) {
val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) {
showToast("请先安装微信")
......@@ -217,7 +224,7 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
loginApi.login(requireActivity())
return
}
}else if (TextUtils.equals(payChannel, ALIPAY)){
} else if (TextUtils.equals(payChannel, ALIPAY)) {
// 2、授权支付宝
if (!alipayStatus) {
// 去授权
......@@ -384,20 +391,10 @@ class DrawCashFragment : LazyLoadBaseFragment(), OnLoginListener, DrawCashView,
override fun onLogin(platform: String?, res: HashMap<String, Any>): Boolean {
try {
wxInfo = WXInfo()
wxInfo?.let {
it.unionid = res["unionid"].toString() + ""
it.openid = res["openid"].toString() + ""
it.province = res["province"].toString() + ""
it.city = res["city"].toString() + ""
it.country = res["country"].toString() + ""
it.headimgurl = res["headimgurl"].toString() + ""
it.nickname = res["nickname"].toString() + ""
it.sex = (res["sex"].toString() + "").toInt()
}
var tempOpid = res["openid"].toString() + ""
if (isAdded) {
drawCashPresenter.wxLogin(JsonUtil.toJson(wxInfo))
drawCashPresenter.reportWeixinMsg(tempOpid)
}
} catch (e: Exception) {
e.printStackTrace()
......
......@@ -16,8 +16,8 @@
<Tumblr Enable="false" />
<Email Enable="false" />
<ShortMessage Enable="false" />
<Wechat AppId="wx7e946f66585ca00a" AppSecret="6fe41783e736bea36504b271cea484f1" userName="gh_afb25ac019c9" path="pages/index/index.html?id=1" WithShareTicket="true" MiniprogramType="0" />
<WechatMoments AppId="wx7e946f66585ca00a" AppSecret="6fe41783e736bea36504b271cea484f1" />
<Wechat AppId="wx8d69898f9fb291e6" AppSecret="ad6245d18872ed53a33c0f71418f6cde" userName="gh_afb25ac019c9" path="pages/index/index.html?id=1" WithShareTicket="true" MiniprogramType="0" />
<WechatMoments AppId="wx8d69898f9fb291e6" AppSecret="ad6245d18872ed53a33c0f71418f6cde" />
<QQ Enable="false" />
<Instapaper Enable="false" />
<Pocket Enable="false" />
......
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