Commit 256498b2 authored by lidawei1's avatar lidawei1

add 创建生活号页面逻辑修改

parent 27589f35
......@@ -34,5 +34,6 @@ class XRouterPathConstants {
const val ID_CARD_TEST = "/idCardTest"
const val LIFE_ACCOUNT_ENTERPRISE_CERTIFICATION = "/lifeAccountEnterpriseCertification"
const val LIFE_ACCOUNT_PERSONAL_AUTH = "/lifeAccountPersonalAuth"
const val LIFE_ACCOUNT_CREATE = "/createLiveAccountActivity"
}
}
\ No newline at end of file
......@@ -51,5 +51,6 @@ class URLs {
const val getKSYunObjectId = "Ksy/ksyun/buildObectid"
const val getKSYunBucket = "Ksy/ksyun/getBucket"
const val businessLicenseOCR = "/Identify/BusLicense/businessLicenseOcr"
const val createLifeAccount = "/merchant/enterprise/create_life"
}
}
\ No newline at end of file
......@@ -121,6 +121,10 @@
<activity android:name=".ui.LifeAccountEnterpriseCertificationActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.LiveAccountCreateActivity"
android:theme="@style/Transparent"
android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity android:name=".ui.LifeAccountPersonalAuthActivity"
android:theme="@style/Transparent" />
......
package com.yidian.shenghuoquan.newscontent.bean
class CreateLifeAccountBean {
/**
* life_account_name 是 str 生活号名称
* code 是 str 企业社会统一识别码
* user_id 是 str 用id
*/
data class Request(
var life_account_name:String,
var code:String,
var user_id:String
)
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.bean
interface ICreateLifeAccountCallback {
/**
* @param result 创建生活号结果 true 成功过,false 失败
*/
fun createLifeAccountCallback(result:Boolean)
}
\ No newline at end of file
......@@ -13,7 +13,9 @@ import com.yidian.common.http.TransformUtil
import com.yidian.common.http.httpbean.WebResult
import com.yidian.common.utils.ToolsUtil
import com.yidian.http.ServiceFactory
import com.yidian.shenghuoquan.newscontent.bean.CreateLifeAccountBean
import com.yidian.shenghuoquan.newscontent.bean.DynamicExpressionBean
import com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import com.yidian.shenghuoquan.newscontent.http.httpbean.*
import com.yidian.xarc.xbrid.XBridManager
import okhttp3.MultipartBody
......@@ -577,6 +579,20 @@ class ApiService {
})
}
fun createLifeAccount(callback:ICreateLifeAccountCallback,requestParams:CreateLifeAccountBean.Request){
val paramsMap = HttpParamsUtils.getParamsMap()
ServiceFactory.getInstance().createService(CommonService::class.java)
.createLifeAccount(paramsMap,requestParams)
.compose(TransformUtil.defaultSchedulers())
.subscribe(object :HttpResultSubscriber<Any?>(){
override fun onSuccess(result: HttpResult<Any?>?) {
callback.createLifeAccountCallback(true)
}
override fun onFailer(result: HttpResult<Any?>?) {
callback.createLifeAccountCallback(false)
}
})
}
}
}
......@@ -3,6 +3,7 @@ package com.yidian.shenghuoquan.newscontent.http
import com.yidian.common.cardutils.bean.PolymerCommonCardBean
import com.yidian.common.http.HttpResult
import com.yidian.common.http.URLs
import com.yidian.shenghuoquan.newscontent.bean.CreateLifeAccountBean
import com.yidian.shenghuoquan.newscontent.http.httpbean.*
import io.reactivex.rxjava3.core.Observable
import okhttp3.MultipartBody
......@@ -130,4 +131,8 @@ interface CommonService {
@Headers("Content-Type: application/json")
@POST(URLs.businessLicenseOCR)
fun businessLicenseOCR(@QueryMap commonParams: Map<String, String>, @Body requestParams: BusinessLicenseOCRBean.Request) : Observable<HttpResult<BusinessLicenseOCRBean.Response>>
@Headers("Content-Type: application/json")
@POST(URLs.createLifeAccount)
fun createLifeAccount(@QueryMap commonParams: Map<String, String>,@Body requestParams: CreateLifeAccountBean.Request) :Observable<HttpResult<Any?>>
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.ui
import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.databinding.ActivityCreateAccountBinding
class CreateAccountActivity :BaseActivity<ActivityCreateAccountBinding>(){
override fun createViewBinding(): ActivityCreateAccountBinding {
return ActivityCreateAccountBinding.inflate(layoutInflater)
}
override fun getXPageName(): String {
return "create_account"
}
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.ui
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.text.Editable
import androidx.core.view.isVisible
import com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_CREATE
import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import com.yidian.shenghuoquan.newscontent.databinding.ActivityCreateAccountBinding
import com.yidian.shenghuoquan.newscontent.utils.TextWatcherAdapter
class LiveAccountCreateActivity :BaseActivity<ActivityCreateAccountBinding>(),ICreateLifeAccountCallback{
override fun createViewBinding(): ActivityCreateAccountBinding {
return ActivityCreateAccountBinding.inflate(layoutInflater)
}
override fun getXPageName(): String {
return LIFE_ACCOUNT_CREATE
}
private val accountMaxLength = 40
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
initView()
initListener()
initData()
}
private fun initData() {
setUserName("兰小花","15800003242")
}
private fun initView() {
viewBind.btnCreateAccount.alpha = 0.32f
viewBind.btnCreateAccount.isEnabled = false
//设置最大的名称限制
viewBind.etAccount.maxHeight = accountMaxLength+1
}
private fun initListener() {
viewBind.ivBack.setOnClickListener { finish() }
viewBind.etAccount.addTextChangedListener(object :TextWatcherAdapter(){
override fun afterTextChanged(s: Editable?) {
if (s==null) return
checkAccount(s.toString())
}
})
viewBind.btnCreateAccount.setOnClickListener {
createNewAccount()
}
}
private fun createNewAccount() {
// TODO: 2021/5/26 创建生活号
//模拟网络请求成功
// ApiService.createLifeAccount(this,request)
viewBind.btnCreateAccount.postDelayed({
startActivity(Intent(this@LiveAccountCreateActivity,LifeNumberActivity::class.java))
},2000L)
}
@SuppressLint("SetTextI18n")
private fun setUserName(name:String, number:String){
val numberFormat = formatNumber(number)
viewBind.tvUserName.text="$name $numberFormat"
}
private fun formatNumber(number: String):String{
return number.replace("(\\d{3})\\d{4}(\\d{4})".toRegex(), "$1****$2")
}
private fun checkAccount(s: String) {
if (s.isEmpty()){
viewBind.btnCreateAccount.alpha = 0.32f
viewBind.btnCreateAccount.isEnabled = false
viewBind.tvErrorTips.isVisible = false
viewBind.vDivider.setBackgroundResource(R.color.divider_white)
return
}
if (s.length>accountMaxLength){
viewBind.btnCreateAccount.alpha = 0.32f
viewBind.btnCreateAccount.isEnabled = false
viewBind.tvErrorTips.isVisible = true
viewBind.etAccount.setTextColor(resources.getColor(R.color.red_account_tips))
viewBind.vDivider.setBackgroundResource(R.color.red_account_tips)
}else{
viewBind.btnCreateAccount.alpha = 1f
viewBind.btnCreateAccount.isEnabled = true
viewBind.tvErrorTips.isVisible = false
viewBind.etAccount.setTextColor(resources.getColor(R.color.gray_333))
viewBind.vDivider.setBackgroundResource(R.color.divider_white)
}
}
override fun createLifeAccountCallback(result: Boolean) {
//创建生活号的回调
if (result){
//todo 创建成功 页面跳转
}else{
// todo 创建失败,失败逻辑
}
}
}
\ No newline at end of file
......@@ -35,7 +35,7 @@ class TempListActivity : BaseActivity<ActivityTempListBinding>() {
startActivity(Intent(this@TempListActivity, LifeAccountEnterpriseCertificationActivity::class.java))
}
viewBind.btCreateAccount.setOnClickListener {
startActivity(Intent(this@TempListActivity, CreateAccountActivity::class.java))
startActivity(Intent(this@TempListActivity, LiveAccountCreateActivity::class.java))
}
}
}
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.utils
import android.text.Editable
import android.text.TextWatcher
abstract class TextWatcherAdapter: TextWatcher {
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
}
}
\ No newline at end of file
......@@ -20,10 +20,15 @@
android:id="@+id/iv_back"
android:layout_width="28dp"
android:layout_height="28dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="20dp"
android:scaleType="centerCrop"
android:src="@drawable/big_back"/>
android:src="@drawable/big_back"
tools:ignore="ContentDescription" />
<TextView
android:id="@+id/tv_title"
......@@ -51,6 +56,11 @@
android:layout_height="60dp"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:background="@null"
android:textSize="16sp"
android:textCursorDrawable="@drawable/comment_dialog_cursor"
android:textColorHint="@color/account_hint"
android:textColor="@color/gray_333"
android:gravity="center_vertical"
android:hint="@string/account_create_tips" />
<View
......@@ -68,7 +78,7 @@
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:text="@string/account_error_tips"
android:textColor="#FF3A3A"
android:textColor="@color/red_account_tips"
android:textSize="12sp"
android:visibility="gone"
tools:visibility="visible" />
......@@ -90,7 +100,7 @@
android:layout_height="60dp"
android:gravity="center_vertical"
android:paddingStart="20dp"
android:text="@string/account_manager"
tools:text="蓝小花15800000001"
android:textColor="@color/gray_333"
android:textSize="16sp"
android:textStyle="bold"
......@@ -118,7 +128,7 @@
android:layout_marginBottom="34dp"
android:textSize="18sp"
android:gravity="center"
android:alpha="0.68"
android:alpha="0.32"
android:textColor="@color/white"
android:text="@string/create_account"
android:layout_gravity="center_horizontal|bottom"
......
......@@ -157,5 +157,10 @@
android:text="《隐私政策》"/>
</LinearLayout>
<Button
android:layout_marginTop="20dp"
android:id="@+id/btn_open_account"
android:text="打开创建生活号页面"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
\ No newline at end of file
......@@ -34,4 +34,6 @@
<color name="progress_d8d8d8_transparent">#bfd8d8d8</color>
<color name="gray_333">#333333</color>
<color name="divider_white">#FFF2F2F2</color>
<color name="red_account_tips">#FF3A3A</color>
<color name="account_hint">#c2c2c2</color>
</resources>
\ 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