Commit 5f46575c authored by 张释方's avatar 张释方

提交支付界面代码

parent 49d0ee24
package com.mints.street.adapter
import android.content.Context
import android.graphics.Paint
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.street.R
import com.mints.street.databinding.ItemGridPaymentAdpaterBinding
import me.goldze.mvvmhabit.utils.AppUtils
class GridPaymentAdapter(val context: Context, val list: List<String>) : AbstractVLayoutBaseAdapter<ItemGridPaymentAdpaterBinding, List<String>>(context, list, 3) {
private var mposition: Int = -1
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridPaymentAdpaterBinding>, position: Int) {
holder.binding.text1.paint.flags = Paint.FAKE_BOLD_TEXT_FLAG
var a = holder.binding.bg.layoutParams
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), 0, AppUtils.dp2Px(context, 10F), 0, null, null, null)
holder.itemView.setOnClickListener {
mposition = holder.adapterPosition
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
notifyDataSetChanged()
}
if (mposition == position) {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
} else {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment)
}
}
override fun getItemCount() = list.size
override fun onCreateLayoutHelper() = GridLayoutHelper(3)
override fun getLayoutId(viewType: Int) = R.layout.item_grid_payment_adpater
}
\ No newline at end of file
......@@ -3,12 +3,17 @@ package com.mints.street.login
import android.graphics.Color
import android.os.Bundle
import android.os.PersistableBundle
import android.text.TextUtils
import android.view.View
import androidx.lifecycle.Observer
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityLoginBinding
import com.mints.street.manager.UserManager
import com.mints.street.utils.BackInputUtil
import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.activity_login.*
import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.ToastUtils
......@@ -17,6 +22,8 @@ import me.goldze.mvvmhabit.utils.ToastUtils
*/
class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View.OnClickListener {
private var mobile: String? = null
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login
override fun initVariableId() = BR.viewModel
......@@ -30,7 +37,22 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
private fun initListener() {
binding.button.setOnClickListener {
viewModel.login("18311400069","123456")
viewModel.login("18311400069", "123456")
}
binding.tvSendSms.setOnClickListener {
// ToastUtils.showLong("点击获取验证码")
var mobile = et_phone.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showLong("请输入手机号")
return@setOnClickListener
}
mobile = mobile.replace(" ".toRegex(), "")
viewModel.sendMobileCode(mobile)
}
iv_left_icon.setOnClickListener(this)
......@@ -42,11 +64,19 @@ class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
iv_left_icon.visibility = View.VISIBLE
//手机号设置格式
BackInputUtil.phoneNumAddSpace(et_phone)
/*mobile = UserManager.INSTANCE.getMobile()
if (!TextUtils.isEmpty(mobile)) {
et_sms.setText(mobile)
et_sms.setSelection(mobile!!.length + 2)
}*/
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.data.observe(this, Observer<String>{
viewModel.data.observe(this, Observer<String> {
ToastUtils.showLong("初始化成功")
})
......
......@@ -47,6 +47,10 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
......@@ -62,10 +66,9 @@ class LoginViewModel(application: Application) : BaseViewModel(application) {
override fun onBusinessSuccess(response: BaseResponse<UserBean>) {
data.value = response.message
KLog.e("login", response.result.toString())
ToastUtils.showShort("登录信息="+response.result.ConsumerBean().idcode)
// ToastUtils.showShort("登录信息="+response.result.ConsumerBean().idcode)
//展示业务逻辑
UserManager.INSTANCE.saveUserInfo(response.result)
this@LoginViewModel.saveTerminalInfo()
}
......
......@@ -60,6 +60,7 @@ class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileVie
mobile = mobile.replace(" ".toRegex(), "")
// loginPresenter.sendMobileBindingCode(mobile)
viewModel.sendMobileCode(mobile)
}
R.id.tvLoginNext -> {
var mobile = etLoginMobile.text.toString().trim()
......
package com.mints.street.main.my
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
class BindMobileViewModel (application: Application): BaseViewModel(application) {
val data : MutableLiveData<String> = MutableLiveData()
/**
* 手机验证码
*
* @param mobile
*/
fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@BindMobileViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
}
......@@ -40,7 +40,6 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
override fun initData() {
super.initData()
initView()
}
private fun initView() {
......
......@@ -2,9 +2,14 @@ package com.mints.street.main.my
import android.graphics.Color
import android.os.Bundle
import android.view.View
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseActivity
import com.mints.street.BR
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.databinding.ActivityOpenvipBinding
import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.*
......@@ -12,6 +17,11 @@ import kotlinx.android.synthetic.main.include_header.*
class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), View.OnClickListener {
// private var vLayout: VirtualLayoutManager? = null
// private var mAdapter: DelegateAdapter? = null
private var vLayout:VirtualLayoutManager?=null
private var mAdapter:DelegateAdapter?=null
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip
override fun initData() {
......@@ -45,6 +55,16 @@ class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(),
tv_title.setTextColor(Color.WHITE)
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.visibility= View.VISIBLE
//recycleView管理
vLayout= VirtualLayoutManager(this)
mAdapter= DelegateAdapter(vLayout,false)
binding.listview.adapter=mAdapter
binding.listview.layoutManager=vLayout
mAdapter?.addAdapter(GridPaymentAdapter(this, listOf("1","2","3")))
}
override fun onClick(v: View?) {
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_bg_payment" android:state_enabled="true"/>
<item android:drawable="@drawable/shape_bg_payment_down" android:state_enabled="false"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="2dp" />
<stroke android:color="#FF9800" android:width="1dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#F6CF82"/>
<corners android:radius="2dp"/>
<stroke android:color="#FF9800" android:width="1dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.main.my.BindMobileViewModel" />
</data>
<data>
<variable
name="viewModel"
type="com.mints.street.main.my.BindMobileViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
......
......@@ -55,6 +55,7 @@
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:paddingRight="20dp"
android:background="@null"
android:gravity="center_vertical"
android:hint="@string/str_input_phone"
......
......@@ -356,36 +356,17 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:orientation="horizontal">
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginRight="10dp"
android:background="@drawable/shape_bt_disagree"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_marginRight="10dp"
android:background="@drawable/shape_bt_disagree"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
<View
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/shape_bt_disagree"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="100dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridMapAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bg"
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/shape_gold_card_20"
>
android:background="@drawable/shape_gold_card_20">
<ImageView
android:id="@+id/image"
app:layout_constraintTop_toTopOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridPaymentAdapter" />
</data>
<LinearLayout
android:id="@+id/bg"
android:layout_width="100dp"
android:layout_height="100dp"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6个月"
android:textColor="@color/black"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥68.0"
android:textStyle="bold"
android:textSize="20dp"
android:textColor="#FF5722"/>
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="原价¥108.0"
android:textSize="8dp"
android:textColor="#25000000"/>
</LinearLayout>
</layout>
\ 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