Commit ae3ed87f authored by 张释方's avatar 张释方

对接获取个人信息接口

parent a6fac0d4
...@@ -3,43 +3,58 @@ package com.mints.street.adapter ...@@ -3,43 +3,58 @@ package com.mints.street.adapter
import android.content.Context import android.content.Context
import android.graphics.Paint import android.graphics.Paint
import com.alibaba.android.vlayout.layout.GridLayoutHelper import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin import com.fry.base.binding.setMargin
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.VipBean
import com.mints.street.databinding.ItemGridPaymentAdpaterBinding import com.mints.street.databinding.ItemGridPaymentAdpaterBinding
import me.goldze.mvvmhabit.utils.AppUtils import me.goldze.mvvmhabit.utils.AppUtils
class GridPaymentAdapter(val context: Context, val list: List<String>) : AbstractVLayoutBaseAdapter<ItemGridPaymentAdpaterBinding, List<String>>(context, list, 3) { class GridPaymentAdapter(val context: Context, val list: List<VipBean.ConsumerBean>) : AbstractVLayoutBaseAdapter<ItemGridPaymentAdpaterBinding, List<VipBean.ConsumerBean>>(context, list, 3) {
private var datalist: List<VipBean.ConsumerBean>? = list
private var mposition: Int = -1 private var mposition: Int = -1
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridPaymentAdpaterBinding>, position: Int) { override fun onBindViewHolder(holder: BindingViewHolder<ItemGridPaymentAdpaterBinding>, position: Int) {
holder.binding.text1.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG holder.binding.tvOldprice.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
var a = holder.binding.bg.layoutParams var a = holder.binding.bg.layoutParams
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), 0, AppUtils.dp2Px(context, 10F), 0, null, null, null) holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), 0, AppUtils.dp2Px(context, 10F), 0, null, null, null)
if (mposition == position) {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
} else {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment)
}
datalist?.let {
val databean = it[position]
holder.itemView.setOnClickListener { holder.itemView.setOnClickListener {
mposition = holder.adapterPosition mposition = holder.adapterPosition
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down) holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
notifyDataSetChanged() notifyDataSetChanged()
} }
holder.binding.tvDays.text = "${databean.days}天"
if (mposition == position) { holder.binding.tvOldprice.text = "原价¥${databean.oldPrice}"
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down) holder.binding.tvPrice.text = "¥${databean.price}"
} else { }
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment)
} }
override fun getItemCount(): Int {
return if (datalist == null) {
0
} else {
datalist!!.size
}
} }
override fun getItemCount() = list.size
override fun onCreateLayoutHelper() = GridLayoutHelper(3) override fun onCreateLayoutHelper() = GridLayoutHelper(3)
override fun getLayoutId(viewType: Int) = R.layout.item_grid_payment_adpater override fun getLayoutId(viewType: Int) = R.layout.item_grid_payment_adpater
} }
package com.mints.street.api package com.mints.street.api
import com.mints.street.bean.BaseResponse import com.mints.street.bean.*
import com.mints.street.bean.UserBean
import com.mints.street.bean.VipBean
import com.mints.street.netwrok.common.HttpManager import com.mints.street.netwrok.common.HttpManager
import io.reactivex.Observable import io.reactivex.Observable
import retrofit2.Response import retrofit2.Response
...@@ -13,7 +11,7 @@ import retrofit2.http.POST ...@@ -13,7 +11,7 @@ import retrofit2.http.POST
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
*/ */
interface MainApi { interface MainApi {
companion object{ companion object {
fun newInstance(): MainApi { fun newInstance(): MainApi {
return HttpManager.getInstance().defaultClient.create(MainApi::class.java) return HttpManager.getInstance().defaultClient.create(MainApi::class.java)
} }
...@@ -41,7 +39,22 @@ interface MainApi { ...@@ -41,7 +39,22 @@ interface MainApi {
@POST("api/saveTerminalInfo") @POST("api/saveTerminalInfo")
fun saveTerminalInfo(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>> fun saveTerminalInfo(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 开通vip
*/
@POST("api/getVipProductsByType") @POST("api/getVipProductsByType")
fun getVipProductsByType(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<VipBean>>> fun getVipProductsByType(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<VipBean>>>
/**
* 获取vip支付渠道
*/
@POST("api/getPayChannels")
fun getPayChannels(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<PaymentBean>>>
/**
* 获取用户登录信息
*/
@POST("api/baseMsg")
fun baseMsg():Observable<Response<BaseResponse<MyInfo>>>
} }
\ No newline at end of file
package com.mints.street.bean
import java.io.Serializable
class MyInfo {
val token: String = ""
val consumer: ConsumerBean? = null
inner class ConsumerBean : Serializable {
val openid: String = ""
val nickname: String = ""
val mobile: String = ""
val idcode: String = ""
val isForever: Boolean = false
val expireTime: Long = 0
val pk_id: Long = 0
}
}
package com.mints.street.bean
import java.io.Serializable
class PaymentBean:Serializable {
var list: List<String>?=null
}
\ No newline at end of file
package com.mints.street.bean package com.mints.street.bean
class VipBean { import java.io.Serializable
class VipBean : Serializable {
var list: List<ConsumerBean>? = null
inner class ConsumerBean : Serializable {
var id: Int = 0 // 1
var price: Int = 0// 78
var days: Int = 0 // 365
var remarks: String = "" // 看更多地图
var title: String = ""// 包年会员
var activityType: Int = 0 // 0
var oldPrice: Int = 0 // 138
var pid: String = ""// 1
}
} }
package com.mints.street.login package com.mints.street.login
import android.graphics.Color import android.Manifest
import android.os.Bundle import android.os.Bundle
import android.os.PersistableBundle
import android.text.TextUtils
import android.view.View import android.view.View
import androidx.lifecycle.Observer import androidx.lifecycle.Observer
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.databinding.ActivityLoginBinding import com.mints.street.databinding.ActivityLoginBinding
import com.mints.street.manager.UserManager import com.mints.street.main.MainActivity
import com.mints.street.utils.BackInputUtil import com.mints.street.utils.BackInputUtil
import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_bindmobile.* import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.activity_login.* import kotlinx.android.synthetic.main.activity_login.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
...@@ -36,10 +35,6 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -36,10 +35,6 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
private fun initListener() { private fun initListener() {
binding.button.setOnClickListener {
viewModel.login("18311400069", "123456")
}
binding.tvSendSms.setOnClickListener { binding.tvSendSms.setOnClickListener {
// ToastUtils.showLong("点击获取验证码") // ToastUtils.showLong("点击获取验证码")
...@@ -55,6 +50,34 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -55,6 +50,34 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
} }
binding.button.setOnClickListener {
var mobile = et_phone.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showLong("请输入手机号")
return@setOnClickListener
}
val code = et_sms.text.toString().trim()
if (code.length < 4) {
ToastUtils.showLong("请输入验证码")
return@setOnClickListener
}
RxPermissions(this@LoginActivity)
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean ->
if (granted) {
mobile = mobile.replace(" ".toRegex(), "")
// 登录
viewModel.login(mobile, code)
} else {
// showMissingPermissionDialog("设备")
}
}
}
iv_left_icon.setOnClickListener(this) iv_left_icon.setOnClickListener(this)
iv_left_icon.setOnClickListener(this) iv_left_icon.setOnClickListener(this)
} }
...@@ -78,6 +101,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View ...@@ -78,6 +101,7 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
super.initViewObservable() super.initViewObservable()
viewModel.data.observe(this, Observer<String> { viewModel.data.observe(this, Observer<String> {
ToastUtils.showLong("初始化成功") ToastUtils.showLong("初始化成功")
startActivityThenKill(MainActivity::class.java)
}) })
} }
......
...@@ -65,7 +65,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) { ...@@ -65,7 +65,6 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
UserManager.INSTANCE.saveUserInfo(response.result) UserManager.INSTANCE.saveUserInfo(response.result)
KLog.e("login", response.result.toString()) KLog.e("login", response.result.toString())
ToastUtils.showShort("登录信息="+response.result.consumer?.idcode) ToastUtils.showShort("登录信息="+response.result.consumer?.idcode)
......
...@@ -2,10 +2,10 @@ package com.mints.street.main.my ...@@ -2,10 +2,10 @@ package com.mints.street.main.my
import android.app.Application import android.app.Application
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse
import com.mints.street.model.ApiModel import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap import java.util.HashMap
......
...@@ -2,6 +2,7 @@ package com.mints.street.main.my ...@@ -2,6 +2,7 @@ package com.mints.street.main.my
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.text.TextUtils
import android.util.Log import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
...@@ -12,22 +13,33 @@ import android.widget.TextView ...@@ -12,22 +13,33 @@ import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.appcompat.widget.LinearLayoutCompat import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.lifecycle.Observer
import com.fry.base.base.BaseFragment import com.fry.base.base.BaseFragment
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.bean.MyInfo
import com.mints.street.bean.UserBean
import com.mints.street.databinding.FragmentMyBinding import com.mints.street.databinding.FragmentMyBinding
import com.mints.street.login.LoginActivity import com.mints.street.login.LoginActivity
import com.mints.street.main.home.HistoricalimageActivity import com.mints.street.main.home.HistoricalimageActivity
import com.mints.street.manager.UserManager
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.activity_moresettings.* import kotlinx.android.synthetic.main.activity_moresettings.*
import kotlinx.android.synthetic.main.fragment_my.* import kotlinx.android.synthetic.main.fragment_my.*
import me.goldze.mvvmhabit.utils.KLog
/** /**
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
* 个人中心页面 * 个人中心页面
*/ */
class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickListener { class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), OnRefreshListener,
View.OnClickListener {
private val userManager by lazy { UserManager.INSTANCE }
private var userConfig: MyInfo? = null
//弹窗 //弹窗
private var mBottomSheetDialog: BottomSheetDialog? = null private var mBottomSheetDialog: BottomSheetDialog? = null
...@@ -35,6 +47,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -35,6 +47,7 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
private var ly_phone: LinearLayoutCompat? = null private var ly_phone: LinearLayoutCompat? = null
private var cb_checked: CheckBox? = null private var cb_checked: CheckBox? = null
override fun initContentView(inflater: LayoutInflater?, override fun initContentView(inflater: LayoutInflater?,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?) = R.layout.fragment_my savedInstanceState: Bundle?) = R.layout.fragment_my
...@@ -46,9 +59,23 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -46,9 +59,23 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
initListener() initListener()
} }
override fun onResume() {
super.onResume()
// if (!TextUtils.isEmpty(userManager.getUserID())) {
//查询用户登录信息
viewModel.getmyInfo()
// refreshHighTask()
// } else {
// 游客登录
// myPresenter.userLogin()
// }
}
private fun initListener() { private fun initListener() {
//设置登录点击事件 //设置登录点击事件
binding.llMyLogin.setOnClickListener { binding.llMyLogin.setOnClickListener {
if (!userManager.userIsLogin()) {
//创建弹窗 //创建弹窗
mBottomSheetDialog = BottomSheetDialog(context!!) mBottomSheetDialog = BottomSheetDialog(context!!)
val view1: View = layoutInflater.inflate(R.layout.layout_popupwindow, null) val view1: View = layoutInflater.inflate(R.layout.layout_popupwindow, null)
...@@ -62,6 +89,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -62,6 +89,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
ly_phone?.setOnClickListener(this) ly_phone?.setOnClickListener(this)
} }
}
//设置立即领取点击事件 //设置立即领取点击事件
binding.btTry.setOnClickListener { binding.btTry.setOnClickListener {
// startActivity(PermissionsActivity::class.java) // startActivity(PermissionsActivity::class.java)
...@@ -98,13 +127,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -98,13 +127,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
R.id.moresettings -> { R.id.moresettings -> {
startActivity(MoresettingsActivity::class.java) startActivity(MoresettingsActivity::class.java)
} }
R.id.ll_my_login -> {
Log.e("aaa", "aaaaaa")
}
R.id.iv_weixin -> { R.id.iv_weixin -> {
if (cb_checked!!.isChecked) { if (cb_checked!!.isChecked) {
Toast.makeText(context, "未完成微信登录对接", Toast.LENGTH_SHORT).show() Toast.makeText(context, "未完成微信登录对接", Toast.LENGTH_SHORT).show()
}else { } else {
Toast.makeText(context, "请先同意用户协议与隐私政策", Toast.LENGTH_SHORT).show() Toast.makeText(context, "请先同意用户协议与隐私政策", Toast.LENGTH_SHORT).show()
} }
} }
...@@ -120,5 +146,38 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL ...@@ -120,5 +146,38 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
} }
} }
override fun initViewObservable() {
super.initViewObservable()
viewModel.MyInfodata.observe(this, Observer<MyInfo> {
srl_my.finishRefresh(true)
if (it == null) {
userConfig = null
return@Observer
}
userConfig = it
//获取我的数据
setUserLoginStatus()
})
}
private fun setUserLoginStatus() {
// if (userManager.userIsLogin()) {
// if (userManager.getMobile().isNotEmpty()) {
item_title_id.text = userManager.getMobile()
// } else {
// item_title_id.text = "未登录"
// }
// }
}
override fun onRefresh(refreshLayout: RefreshLayout) {
}
// if (it.consumer!!.mobile.isNotEmpty()) {
// item_title_id.text = it.consumer.mobile
// }
} }
package com.mints.street.main.my package com.mints.street.main.my
import android.app.Application import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.MyInfo
import com.mints.street.bean.UserBean
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
/** /**
* Created by 冯瑞雨 on 2021/7/2. * Created by 冯瑞雨 on 2021/7/2.
*/ */
class MyViewModel(application: Application):BaseViewModel(application) { class MyViewModel(application: Application) : BaseViewModel(application) {
val MyInfodata: MutableLiveData<MyInfo> = MutableLiveData()
fun getmyInfo() {
ApiModel.getuserInfo(lifecycleProvider).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<MyInfo>>(
this@MyViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<MyInfo>) {
MyInfodata.value = response.result
KLog.e("getmyInfo", response.result.toString())
}
override fun onError(e: Throwable) {
KLog.e("getmyInfo", "用户登录信息请求失败")
super.onError(e)
}
}
)
}
} }
\ No newline at end of file
package com.mints.street.main.my package com.mints.street.main.my
import android.graphics.Color import android.graphics.Color
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.lifecycle.Observer
import com.alibaba.android.vlayout.DelegateAdapter import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseActivity import com.fry.base.base.BaseActivity
import com.mints.street.BR import com.mints.street.BR
import com.mints.street.R import com.mints.street.R
import com.mints.street.adapter.EnterDestinationAdapter
import com.mints.street.adapter.GridMapAdapter
import com.mints.street.adapter.GridPaymentAdapter import com.mints.street.adapter.GridPaymentAdapter
import com.mints.street.bean.PaymentBean
import com.mints.street.bean.VipBean
import com.mints.street.databinding.ActivityOpenvipBinding import com.mints.street.databinding.ActivityOpenvipBinding
import kotlinx.android.synthetic.main.activity_openvip.* import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.* import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.ToastUtils
class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), View.OnClickListener { class OpenvipActivity : BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), View.OnClickListener {
// private var vLayout: VirtualLayoutManager? = null private var vLayout: VirtualLayoutManager? = null
// private var mAdapter: DelegateAdapter? = null private var mAdapter: DelegateAdapter? = null
private var vLayout:VirtualLayoutManager?=null
private var mAdapter:DelegateAdapter?=null
override fun initVariableId() = BR.viewModel override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_openvip
override fun initData() { override fun initData() {
super.initData() super.initData()
//获取vip福利信息
viewModel.openvipInfo()
//获取支付方式
viewModel.getpaymentwey("android")
initView() initView()
initListener() initListener()
} }
private fun initListener() { private fun initListener() {
iv_left_icon.setOnClickListener(this) iv_left_icon.setOnClickListener(this)
bt_try.setOnClickListener(this)
} }
private fun initView() { private fun initView() {
...@@ -51,25 +57,50 @@ class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), ...@@ -51,25 +57,50 @@ class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(),
//设置显示的数据 //设置显示的数据
cfp_data_viewpager.setViewList(list) cfp_data_viewpager.setViewList(list)
tv_title.text="成为会员" tv_title.text = "成为会员"
tv_title.setTextColor(Color.WHITE) tv_title.setTextColor(Color.WHITE)
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back) iv_left_icon.setImageResource(R.mipmap.tt_shadow_lefterback_titlebar)
iv_left_icon.visibility= View.VISIBLE iv_left_icon.visibility = View.VISIBLE
//recycleView管理 //recycleView管理
vLayout= VirtualLayoutManager(this) vLayout = VirtualLayoutManager(this)
mAdapter= DelegateAdapter(vLayout,false) mAdapter = DelegateAdapter(vLayout, false)
binding.listview.adapter = mAdapter
binding.listview.layoutManager = vLayout
binding.listview.adapter=mAdapter
binding.listview.layoutManager=vLayout
mAdapter?.addAdapter(GridPaymentAdapter(this, listOf("1","2","3"))) }
override fun initViewObservable() {
super.initViewObservable()
viewModel.Vipdata.observe(this, Observer<VipBean> {
mAdapter?.addAdapter(GridPaymentAdapter(this, it.list!!))
})
viewModel.Paymentdata.observe(this, Observer<PaymentBean> {
if (it.list.isNullOrEmpty()) {
return@Observer
} else {
for (str in it.list!!) {
if (str.equals("WEIXIN")) {
ly_weixin.visibility = View.VISIBLE
}
if (str.equals("ALIPAY")) {
ly_alipay.visibility = View.VISIBLE
}
}
}
})
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
when(v?.id){ when (v?.id) {
R.id.iv_left_icon->finish() R.id.iv_left_icon -> finish()
R.id.bt_try -> {
}
} }
} }
......
package com.mints.street.main.my package com.mints.street.main.my
import android.app.Application import android.app.Application
import androidx.core.graphics.PathParser
import androidx.lifecycle.MutableLiveData 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.model.ApiModel import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap import java.util.HashMap
class OpenvipViewModel (application: Application): BaseViewModel(application) { class OpenvipViewModel(application: Application) : BaseViewModel(application) {
val data : MutableLiveData<String> = MutableLiveData()
val Vipdata: MutableLiveData<VipBean> = MutableLiveData()
val Paymentdata: MutableLiveData<PaymentBean> = MutableLiveData()
/** /**
* 手机验证码 * 开通Vip
* *
* @param mobile * @param mobile
*/ */
fun sendMobileCode(mobile: String) { fun openvipInfo() {
val vo = HashMap<String, Any>() val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["type"] = 1 vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe( ApiModel.openvip(lifecycleProvider, vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>( object : HttpSubscribeImpl<BaseResponse<VipBean>>(
this@OpenvipViewModel, true) { this@OpenvipViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) { override fun onBusinessSuccess(response: BaseResponse<VipBean>) {
KLog.e("sendMobileCode", response.result.toString()) Vipdata.value = response.result
KLog.e("openvip", response.result.toString())
} }
override fun onError(e: Throwable) { override fun onError(e: Throwable) {
data.value = "失败" KLog.e("openvip", "发送验证码错误")
KLog.e("sendMobileCode", "发送验证码错误")
} }
}) })
} }
/**
* Vip支付方式
*/
fun getpaymentwey(os: String) {
val vo = HashMap<String, Any>()
vo["os"] = os
ApiModel.getpaymentwey(lifecycleProvider, vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<PaymentBean>>(
this@OpenvipViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<PaymentBean>) {
Paymentdata.value = response.result
KLog.e("getpaymentwey", response.result.toString())
}
override fun onError(e: Throwable) {
KLog.e("getpaymentwey", "获取支付方式失败")
}
}
)
}
} }
package com.mints.street.model package com.mints.street.model
import com.mints.street.api.MainApi import com.mints.street.api.MainApi
import com.mints.street.bean.BaseResponse import com.mints.street.bean.*
import com.mints.street.bean.UserBean
import com.mints.street.netwrok.common.HttpManager import com.mints.street.netwrok.common.HttpManager
import com.trello.rxlifecycle2.LifecycleProvider import com.trello.rxlifecycle2.LifecycleProvider
import io.reactivex.Observable import io.reactivex.Observable
...@@ -16,36 +15,49 @@ object ApiModel { ...@@ -16,36 +15,49 @@ object ApiModel {
/** /**
* 发送验证码 * 发送验证码
*/ */
fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>? fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance() return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().sendMobileCode(map)) .execute(lifecycleProvider, MainApi.newInstance().sendMobileCode(map))
} }
/** /**
* 登录 * 登录
*/ */
fun login(lifecycleProvider: LifecycleProvider<Any>? fun login(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<UserBean>>> {
,map: Map<String, Any>): Observable<Response<BaseResponse<UserBean>>> {
return HttpManager.getInstance() return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().mobileLogin(map)) .execute(lifecycleProvider, MainApi.newInstance().mobileLogin(map))
} }
/** /**
* 设备信息 * 设备信息
*/ */
fun saveTerminalInfo(lifecycleProvider: LifecycleProvider<Any>? fun saveTerminalInfo(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance() return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().saveTerminalInfo(map)) .execute(lifecycleProvider, MainApi.newInstance().saveTerminalInfo(map))
} }
/** /**
* 开通会员 * 开通会员
*/ */
fun openvip(lifecycleProvider: LifecycleProvider<Any>? fun openvip(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<VipBean>>> {
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> { return HttpManager.getInstance()
.execute(lifecycleProvider, MainApi.newInstance().getVipProductsByType(map))
}
/**
* 获取开通vip支付方式
*/
fun getpaymentwey(lifecycleProvider: LifecycleProvider<Any>?, map: Map<String, Any>): Observable<Response<BaseResponse<PaymentBean>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider, MainApi.newInstance().getPayChannels(map))
}
/**
* 获取用户登录信息
*/
fun getuserInfo(lifecycleProvider: LifecycleProvider<Any>?): Observable<Response<BaseResponse<MyInfo>>> {
return HttpManager.getInstance() return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().getVipProductsByType(map)) .execute(lifecycleProvider, MainApi.newInstance().baseMsg())
} }
} }
\ No newline at end of file
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
android:id="@+id/imageView5" android:id="@+id/imageView5"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:src="@mipmap/icon_me1"
app:layout_constraintEnd_toStartOf="@+id/guideline5" app:layout_constraintEnd_toStartOf="@+id/guideline5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline7" app:layout_constraintTop_toTopOf="@+id/guideline7"
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
android:id="@+id/imageView4" android:id="@+id/imageView4"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:src="@mipmap/icon_me2"
app:layout_constraintEnd_toStartOf="@+id/guideline4" app:layout_constraintEnd_toStartOf="@+id/guideline4"
app:layout_constraintStart_toStartOf="@+id/guideline5" app:layout_constraintStart_toStartOf="@+id/guideline5"
app:layout_constraintTop_toTopOf="@+id/guideline7" app:layout_constraintTop_toTopOf="@+id/guideline7"
...@@ -113,8 +113,8 @@ ...@@ -113,8 +113,8 @@
android:text="国内外街景" android:text="国内外街景"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="10sp" android:textSize="10sp"
app:layout_constraintBottom_toTopOf="@+id/guideline8"
app:layout_constraintEnd_toEndOf="@+id/imageView4" app:layout_constraintEnd_toEndOf="@+id/imageView4"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/imageView4" app:layout_constraintStart_toStartOf="@+id/imageView4"
app:layout_constraintTop_toBottomOf="@+id/imageView4" /> app:layout_constraintTop_toBottomOf="@+id/imageView4" />
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
android:id="@+id/imageView6" android:id="@+id/imageView6"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:src="@mipmap/icon_me3"
app:layout_constraintEnd_toStartOf="@+id/guideline6" app:layout_constraintEnd_toStartOf="@+id/guideline6"
app:layout_constraintStart_toStartOf="@+id/guideline4" app:layout_constraintStart_toStartOf="@+id/guideline4"
app:layout_constraintTop_toTopOf="@+id/guideline7" app:layout_constraintTop_toTopOf="@+id/guideline7"
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
android:id="@+id/imageView7" android:id="@+id/imageView7"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:src="@mipmap/icon_me4"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline6" app:layout_constraintStart_toStartOf="@+id/guideline6"
app:layout_constraintTop_toTopOf="@+id/guideline7" app:layout_constraintTop_toTopOf="@+id/guideline7"
...@@ -165,7 +165,8 @@ ...@@ -165,7 +165,8 @@
android:id="@+id/imageView12" android:id="@+id/imageView12"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:layout_marginTop="10dp"
android:src="@mipmap/icon_me5"
app:layout_constraintEnd_toEndOf="@+id/imageView5" app:layout_constraintEnd_toEndOf="@+id/imageView5"
app:layout_constraintStart_toStartOf="@+id/imageView5" app:layout_constraintStart_toStartOf="@+id/imageView5"
app:layout_constraintTop_toTopOf="@+id/guideline8" app:layout_constraintTop_toTopOf="@+id/guideline8"
...@@ -188,7 +189,8 @@ ...@@ -188,7 +189,8 @@
android:id="@+id/imageView13" android:id="@+id/imageView13"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:layout_marginTop="10dp"
android:src="@mipmap/icon_me6"
app:layout_constraintEnd_toEndOf="@+id/imageView4" app:layout_constraintEnd_toEndOf="@+id/imageView4"
app:layout_constraintStart_toStartOf="@+id/imageView4" app:layout_constraintStart_toStartOf="@+id/imageView4"
app:layout_constraintTop_toTopOf="@+id/guideline8" app:layout_constraintTop_toTopOf="@+id/guideline8"
...@@ -199,7 +201,8 @@ ...@@ -199,7 +201,8 @@
android:id="@+id/imageView14" android:id="@+id/imageView14"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:layout_marginTop="10dp"
android:src="@mipmap/icon_me7"
app:layout_constraintEnd_toEndOf="@+id/imageView6" app:layout_constraintEnd_toEndOf="@+id/imageView6"
app:layout_constraintStart_toStartOf="@+id/imageView6" app:layout_constraintStart_toStartOf="@+id/imageView6"
app:layout_constraintTop_toTopOf="@+id/guideline8" app:layout_constraintTop_toTopOf="@+id/guideline8"
...@@ -234,7 +237,8 @@ ...@@ -234,7 +237,8 @@
android:id="@+id/imageView15" android:id="@+id/imageView15"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:src="@mipmap/ic_avatar_ph" android:layout_marginTop="10dp"
android:src="@mipmap/icon_me8"
app:layout_constraintEnd_toEndOf="@+id/imageView7" app:layout_constraintEnd_toEndOf="@+id/imageView7"
app:layout_constraintStart_toStartOf="@+id/imageView7" app:layout_constraintStart_toStartOf="@+id/imageView7"
app:layout_constraintTop_toTopOf="@+id/guideline8" app:layout_constraintTop_toTopOf="@+id/guideline8"
...@@ -369,18 +373,20 @@ ...@@ -369,18 +373,20 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ly_weixin"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp"> android:padding="10dp"
android:visibility="gone">
<ImageView <ImageView
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_marginStart="15dp" android:layout_marginStart="15dp"
android:src="@mipmap/iv_about_us" /> android:src="@mipmap/icon_pay_wx" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -405,18 +411,20 @@ ...@@ -405,18 +411,20 @@
android:background="#979797" /> android:background="#979797" />
<LinearLayout <LinearLayout
android:id="@+id/ly_alipay"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="10dp"> android:padding="10dp"
android:visibility="gone">
<ImageView <ImageView
android:layout_width="20dp" android:layout_width="20dp"
android:layout_height="20dp" android:layout_height="20dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_marginStart="15dp" android:layout_marginStart="15dp"
android:src="@mipmap/iv_about_us" /> android:src="@mipmap/icon_pay_zfb" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -10,6 +10,15 @@ ...@@ -10,6 +10,15 @@
type="com.mints.street.main.my.MyViewModel" /> type="com.mints.street.main.my.MyViewModel" />
</data> </data>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_my"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/gray"
app:srlPrimaryColor="@color/white">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout <LinearLayout
android:id="@+id/llMyRoot" android:id="@+id/llMyRoot"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -38,7 +47,7 @@ ...@@ -38,7 +47,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:ellipsize="end" android:ellipsize="end"
android:maxLength="10" android:maxLength="11"
android:maxLines="1" android:maxLines="1"
android:text="未登录" android:text="未登录"
android:textColor="@color/black" android:textColor="@color/black"
...@@ -135,7 +144,6 @@ ...@@ -135,7 +144,6 @@
<ImageView <ImageView
android:id="@+id/imageView4" android:id="@+id/imageView4"
android:layout_width="50dp" android:layout_width="50dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
...@@ -369,9 +377,9 @@ ...@@ -369,9 +377,9 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="15dp" android:layout_margin="15dp"
android:layout_marginTop="19dp" android:paddingBottom="5dp"
android:layout_marginEnd="15dp" android:paddingTop="5dp"
android:background="@drawable/shape_gold_card" android:background="@drawable/shape_gold_card"
android:elevation="5dp" android:elevation="5dp"
android:orientation="vertical"> android:orientation="vertical">
...@@ -387,4 +395,6 @@ ...@@ -387,4 +395,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</layout> </layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layout <layout xmlns:android="http://schemas.android.com/apk/res/android">
xmlns:android="http://schemas.android.com/apk/res/android">
<data> <data>
<variable <variable
name="viewModel" name="viewModel"
type="com.mints.street.adapter.GridPaymentAdapter" /> type="com.mints.street.adapter.GridPaymentAdapter" />
</data> </data>
<LinearLayout <LinearLayout
android:id="@+id/bg" android:id="@+id/bg"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
android:orientation="vertical" android:gravity="center"
android:gravity="center"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/tv_days"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="6个月"
android:textColor="@color/black" android:textColor="@color/black"
android:textStyle="bold"/> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="¥68.0" android:textColor="#FF5722"
android:textStyle="bold"
android:textSize="20dp" android:textSize="20dp"
android:textColor="#FF5722"/> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/text1" android:id="@+id/tv_oldprice"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="原价¥108.0" android:textColor="#25000000"
android:textSize="10dp" android:textSize="10dp" />
android:textColor="#25000000"/>
</LinearLayout> </LinearLayout>
</layout> </layout>
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:background="@drawable/shape_bt_disagree" android:background="@mipmap/icon_card"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree" android:background="@mipmap/icon_card1"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree" android:background="@mipmap/icon_card3"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
......
...@@ -88,6 +88,10 @@ public class ExceptionHandle { ...@@ -88,6 +88,10 @@ public class ExceptionHandle {
ex = new ResponseThrowable(e, ERROR.TIMEOUT_ERROR); ex = new ResponseThrowable(e, ERROR.TIMEOUT_ERROR);
ex.message = "主机地址未知"; ex.message = "主机地址未知";
return ex; return ex;
} else if (e instanceof java.lang.StringIndexOutOfBoundsException) {
ex = new ResponseThrowable(e, ERROR.PARAM_ERROR);
ex.message = "参数异常";
return ex;
} else { } else {
ex = new ResponseThrowable(e, ERROR.UNKNOWN); ex = new ResponseThrowable(e, ERROR.UNKNOWN);
ex.message = "未知错误"; ex.message = "未知错误";
...@@ -127,6 +131,10 @@ public class ExceptionHandle { ...@@ -127,6 +131,10 @@ public class ExceptionHandle {
* 连接超时 * 连接超时
*/ */
public static final int TIMEOUT_ERROR = 1006; public static final int TIMEOUT_ERROR = 1006;
/**
* 参数异常
*/
public static final int PARAM_ERROR = 1007;
} }
} }
......
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