Commit 14df108f authored by UIUANG\Zsc's avatar UIUANG\Zsc

新增大屏自助收银

parent b6ff6cd1
......@@ -32,6 +32,7 @@ class HttpRequestManger {
*/
suspend fun applyPos(applyPosMachineRequest: ApplyPosMachineRequest): ApiResponse<PosMachineResponse> {
CacheUtil.setUpdateTimeBigger("")
CacheUtil.setLoginResponse(null)
PosDatabase.clearAllTables()
val applyPosData = apiService.applyPos(applyPosMachineRequest)
if (applyPosData.isSuccess()) {
......
......@@ -2,6 +2,7 @@ package com.ypsx.yppos.ui.activity
import android.os.Bundle
import androidx.activity.viewModels
import androidx.lifecycle.Observer
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.list.SingleChoiceListener
import com.afollestad.materialdialogs.list.listItemsSingleChoice
......@@ -24,6 +25,7 @@ import com.ypsx.common.app.base.BaseActivity
import com.ypsx.common.app.ext.getIntent
import com.ypsx.common.app.ext.showServerHostExt
import com.ypsx.common.app.ext.startKtxActivityFinish
import com.ypsx.yppos.utils.toast
import com.ypsx.yppos.viewmodel.request.RequestRegisterViewModel
import com.ypsx.yppos.viewmodel.state.RegisterViewModel
......@@ -31,18 +33,11 @@ import com.ypsx.yppos.viewmodel.state.RegisterViewModel
* 注册页
*/
class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding>() {
private var exitTime: Long = 0
private var clickNum = 1
private val requestMeViewModel: RequestRegisterViewModel by viewModels()
override fun layoutId(): Int = R.layout.activity_register
private val hostMap = mapOf(
"sit开发环境Host" to "https://sit-cpos.ypshengxian.com/",
"预发Host" to "https://pre-cpos.ypshengxian.com/",
"线上正式Host" to "https://cpos.ypshengxian.com/",
)
private val hosts = hostMap.values.toTypedArray()
private val names = hostMap.keys.toList()
override fun initView(savedInstanceState: Bundle?) {
mDatabind.vm = mViewModel
......@@ -83,7 +78,8 @@ class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding
)
XLog.d("提交申请信息:${applyPosMachineRequest.toJson()}")
mViewModel.submitState.set(false)
mViewModel.submitText.set("审核中")
// showLoading("请求网络中...")
requestMeViewModel.applyPos(applyPosMachineRequest)
}
......@@ -116,7 +112,16 @@ class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding
PosStatus.APPLY_FAILED.name -> {
val applyFailedMessage = data.applyFailedMessage
LogUtils.debugInfo("错误原因:${applyFailedMessage}")
showError("提示", "您的审核未通过,请重新提交", "我知道了")
// showError("提示", "您的审核未通过,请重新提交", "我知道了")
val messagePopupWindow = MessagePopupWindow(this)
messagePopupWindow.showPopupWindow()
messagePopupWindow.setData("提示", "您的审核未通过,请重新提交", sure = "我知道了", gone = false)
messagePopupWindow.setMessageClick {
messagePopupWindow.dismiss()
mViewModel.submitState.set(true)
mViewModel.submitText.set("提交申请")
requestMeViewModel.cancelJob()
}
}
PosStatus.DISABLED.name -> {
val messagePopupWindow = MessagePopupWindow(this)
......@@ -124,8 +129,9 @@ class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding
messagePopupWindow.setData("提示", "该POS机已停用,是否将删除本地数据", "取消", "确定", false)
messagePopupWindow.setMessageClick {
messagePopupWindow.dismiss()
CacheUtil.setUpdateTimeBigger("")
CacheUtil.setLoginResponse(null)
mViewModel.submitState.set(true)
mViewModel.submitText.set("提交申请")
requestMeViewModel.cancelJob()
}
}
}
......@@ -133,6 +139,16 @@ class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding
})
requestMeViewModel.posState.observe(this, Observer {
if (it.isSuccess) {
it.errorMsg.toast()
mViewModel.submitState.set(true)
mViewModel.submitText.set("提交申请")
requestMeViewModel.cancelJob()
}
})
}
private fun startLogin() {
......@@ -157,32 +173,5 @@ class RegisterActivity : BaseActivity<RegisterViewModel, ActivityRegisterBinding
}
private fun showServerHostPopWindow() {
//选中的host
val checkHost = CacheUtil.getHost()
var checkedIndex = hosts.indexOf(checkHost)
if (checkedIndex < 0) checkedIndex = names.size - 1//也就是研发Native那个
//启用输入的host
MaterialDialog(this).title(text = "切换Server接口")
.cancelable(false)
.cancelOnTouchOutside(false)
.listItemsSingleChoice(
items = names,
initialSelection = checkedIndex,
selection = object : SingleChoiceListener {
override fun invoke(dialog: MaterialDialog, index: Int, text: CharSequence) {
//如果选择了研发native,index就会超过host的index
if (index < hosts.size) {
CacheUtil.setHost(hosts[index])
CacheUtil.clearAll()
PosDatabase.clearAllTables()
PosApp.instance.restartApplication()
}
}
})
.positiveButton(text = "确定")
.negativeButton(text = "取消")
.show()
}
}
\ No newline at end of file
......@@ -163,6 +163,7 @@ class SplashActivity : BaseActivity<BaseViewModel, ActivitySplashBinding>() {
PosStatus.APPLY.name -> {
val arrayOf = arrayOf(Pair<String, Any>("state", true),Pair<String, Any>("posId", data.id))
startKtxActivity<RegisterActivity>(values = arrayOf)
finish()
}
PosStatus.ACTIVE.name -> {
startLogin()
......
......@@ -11,29 +11,34 @@ import com.ypsx.yppos.http.data.request.ApplyPosMachineRequest
import com.ypsx.yppos.http.repository.request.HttpRequestCoroutine
import com.ypsx.yppos.room.repository.PosConfigRepository
import com.ypsx.base.util.eXLog
import com.ypsx.yppos.http.state.UpdateUiState
import kotlinx.coroutines.Job
class RequestRegisterViewModel : BaseViewModel() {
var posDetails = MutableLiveData<PosMachineResponse>()
var posState = MutableLiveData<UpdateUiState<String>>()
private var job1: Job? = null
private var job2: Job? = null
fun applyPos(applyPosMachineRequest: ApplyPosMachineRequest) {
request({ HttpRequestCoroutine.applyPos(applyPosMachineRequest) }, {
job1 = request({ HttpRequestCoroutine.applyPos(applyPosMachineRequest) }, {
posDetails.postValue(it)
}, {
val errorMsg = it.errorMsg
errorMsg.toast()
LogUtils.debugInfo(errorMsg)
},isShowDialog = true)
posState.postValue(UpdateUiState(false, "", errorMsg))
}, isShowDialog = true)
}
fun getById(id: String) {
request({ HttpRequestCoroutine.getById(id) }, {
job2 = request({ HttpRequestCoroutine.getById(id) }, {
posDetails.postValue(it)
},{
it.errorMsg.eXLog()
},isShowDialog = true)
}, {
it.errorMsg.eXLog()
posState.postValue(UpdateUiState(false, "", it.errorMsg))
}, isShowDialog = true)
}
fun savePosConfig(posMachineResponse: PosMachineResponse) {
......@@ -43,4 +48,9 @@ class RequestRegisterViewModel : BaseViewModel() {
LogUtils.debugInfo("保存数据库PosConfig失败")
})
}
fun cancelJob() {
job1!!.cancel()
job2!!.cancel()
}
}
\ No newline at end of file
......@@ -8,11 +8,11 @@ android {
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.ypsx.self_yppos"
applicationId "com.ypsx.ypselfpos"
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
versionName "1.00.000"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
......
package com.ypsx.self_yppos
package com.ypsx.ypselfpos
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
......@@ -19,6 +19,6 @@ class ExampleInstrumentedTest {
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.ypsx.self_yppos", appContext.packageName)
assertEquals("com.ypsx.ypselfpos", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ypsx.self_yppos">
package="com.ypsx.ypselfpos">
<application
android:allowBackup="true"
......@@ -9,6 +9,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.YPPos">
<activity android:name=".ui.activity.MemberLoginActivity"></activity>
<activity android:name=".ui.activity.DeviceLoginActivity" />
<activity android:name=".ui.activity.RegisterActivity" />
<activity android:name=".ui.activity.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
......@@ -16,9 +19,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ui.activity.MainActivity">
</activity>
<activity android:name=".ui.activity.MainActivity" />
</application>
</manifest>
\ No newline at end of file
package com.ypsx.ypselfpos.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ypsx.ypselfpos.R
class DeviceLoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_device_login)
}
}
\ No newline at end of file
package com.ypsx.self_yppos.ui.activity
package com.ypsx.ypselfpos.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ypsx.self_yppos.R
import com.ypsx.ypselfpos.R
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
......
package com.ypsx.ypselfpos.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ypsx.ypselfpos.R
class MemberLoginActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_member_login)
}
}
\ No newline at end of file
package com.ypsx.ypselfpos.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ypsx.ypselfpos.R
class RegisterActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_register)
}
}
\ No newline at end of file
package com.ypsx.self_yppos.ui.activity
package com.ypsx.ypselfpos.ui.activity
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.ypsx.self_yppos.R
import com.ypsx.ypselfpos.R
class SplashActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.DeviceLoginActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.MemberLoginActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activity.RegisterActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/ic_splash_image"
tools:context=".ui.activity.SplashActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ 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