Commit 5b4ed42e authored by 赵鹏翔's avatar 赵鹏翔

渠道配置暂由本地资源文件来处理

parent f3a7046d
......@@ -3,12 +3,12 @@
"ChannelId": -1,
"ChannelName": "通用",
"ChannelNameEn": "common",
"ChannelAccountArray": []
"ChannelAccountArray": ["6038001"]
},
{
"ChannelId": 1,
"ChannelName": "匡威",
"ChannelNameEn": "converse",
"ChannelAccountArray": ["6011","6013","6014","6017","6021"]
"ChannelAccountArray": ["6011001","6013001","6014001","6017001","6021001"]
}
]
\ No newline at end of file
......@@ -43,6 +43,8 @@ class MiyaApplication : BaseApplication() {
instance = this
ContextUtils.init(this)
//初始化账号数据
ChannelManageKit.initChannelRes(this)
//打印机初始化
PrinterManager.getInstance().init(this)
//屏幕适配
......
......@@ -16,7 +16,7 @@ public class ChannelInfoBean extends BaseBean {
/**
* ChannelId : 1
* ChannelName : 匡威
* ChannelNameDesc : converse
* ChannelNameEn : converse
* ChannelAccountArray : ["6011","6013","6014","6017","6021"]
*/
......
......@@ -17,6 +17,8 @@ import com.blankj.utilcode.util.ToastUtils
import com.fastcashier.lib_common.function.account.AccountService
import com.fastcashier.lib_common.util.clickWithTrigger
import com.miya.fastcashier.databinding.ActivityLoginBinding
import com.miya.fastcashier.util.CenterToasty
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.fastcashier.viewmodel.LoginViewModel
import com.permissionx.guolindev.PermissionX
......@@ -112,7 +114,7 @@ class LoginActivity : AppCompatActivity() {
setOnEditorActionListener { _, actionId, _ ->
when (actionId) {
EditorInfo.IME_ACTION_DONE -> {
if (!TextUtils.isEmpty(binding.etUsername.text.toString())){
if (!TextUtils.isEmpty(binding.etUsername.text.toString())) {
checkPermissions()
}
}
......@@ -152,12 +154,18 @@ class LoginActivity : AppCompatActivity() {
}
}
private fun login(){
private fun login() {
binding.vLoading.visibility = View.VISIBLE
val userName = binding.etUsername.text.toString()
if (ChannelManageKit.containsAccount(this, userName)) {
loginViewModel.login(
binding.etUsername.text.toString(),
userName,
binding.etPassword.text.toString()
)
} else {
binding.vLoading.visibility = View.GONE
CenterToasty.error(this, "账号有误,请检查后重试").show()
}
}
/**
......
......@@ -15,6 +15,7 @@ import com.fastcashier.lib_common.util.getVersionCode
import com.fastcashier.lib_common.util.getWifyName
import com.miya.fastcashier.R
import com.miya.fastcashier.databinding.DialogSystemParameterBinding
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.print.PrinterManager
import java.util.*
......@@ -52,7 +53,7 @@ class SystemParameterDialog(context: Context) : Dialog(context, R.style.CommonDi
viewBinding.tvPrintType,
if (PrinterManager.getInstance().printer == null) context.resources.getString(R.string.app_unkown) else PrinterManager.getInstance().printer.printerName
)
setInfo(viewBinding.tvChannel, BuildConfig.CHANNEL)
setInfo(viewBinding.tvChannel, ChannelManageKit.getAppChannelName(context))
viewBinding.ivClose.setOnClickListener(View.OnClickListener { dismiss() })
resize()
}
......
......@@ -27,9 +27,10 @@ import java.util.Map;
*/
public class ChannelManageKit {
private static Map<String, ChannelInfoBean> channelMap;
private static Map<String, ChannelInfoBean> channelMap;//key为账号,value为所属的品牌信息
private static final String CHANNEL_OFFICIAL_ACCOUNT = "-1";
private static final String CHANNEL_OFFICIAL_CHANNELNAME = "通用";
private static final String CHANNEL_OFFICIAL_CHANNELNAME_EN = "common";
/**
* 初始化本地渠道数据
......@@ -46,32 +47,46 @@ public class ChannelManageKit {
initDefaultChannelRes();
return;
}
ArrayList<ChannelInfoBean> channelInfoList = GsonUtils.fromJson(assetsJson, new TypeToken<List<ChannelInfoBean>>() {}.getType());
ArrayList<ChannelInfoBean> channelInfoList = GsonUtils.fromJson(assetsJson, new TypeToken<List<ChannelInfoBean>>() {
}.getType());
channelMap = new HashMap<>();
if (!channelInfoList.isEmpty()) {
for (int i = 0; i < channelInfoList.size(); i++) {
ChannelInfoBean channelInfoBean = channelInfoList.get(i);
List<String> channelAccountArray = channelInfoBean.getChannelAccountArray();
if (channelAccountArray.isEmpty()){
if (channelAccountArray.isEmpty()) {
initDefaultChannelRes();
return;
continue;
}
for (int j = 0; j < channelAccountArray.size(); i++) {
for (int j = 0; j < channelAccountArray.size(); j++) {
String account = channelAccountArray.get(j);
channelMap.put(account,channelInfoBean);
channelMap.put(account, channelInfoBean);
}
}
}
}
private static void initDefaultChannelRes() {
if (channelMap == null){
channelMap = new HashMap<>();
}
ChannelInfoBean commonChannel = new ChannelInfoBean();
commonChannel.setChannelId("-1");
commonChannel.setChannelName(CHANNEL_OFFICIAL_CHANNELNAME);
commonChannel.setChannelNameEn(CHANNEL_OFFICIAL_CHANNELNAME);
channelMap.put(CHANNEL_OFFICIAL_ACCOUNT,commonChannel);
commonChannel.setChannelNameEn(CHANNEL_OFFICIAL_CHANNELNAME_EN);
channelMap.put(CHANNEL_OFFICIAL_ACCOUNT, commonChannel);
}
/**
* 判断本地是否包含本品牌账户,此处暂时用来处理区别大屏和手持账号
*/
public static boolean containsAccount(Context context, String account) {
if (channelMap == null || channelMap.isEmpty()) {
initChannelRes(context);
}
return channelMap.containsKey(account);
}
/**
......
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