Commit 8cbc1a6e authored by shiyl's avatar shiyl

拆分选择门店和选择类目服务

parent 67d3e410
......@@ -3,12 +3,8 @@ package com.yidian.shenghuoquan.commodity.app
import android.content.Intent
import com.yidian.common.XRouterPathConstants
import com.yidian.common.YdBaseApplication
import com.yidian.common.services.AppUpgradeService
import com.yidian.common.services.XEventService
import com.yidian.common.services.XPageService
import com.yidian.common.services.http.MBHttpReqService
import com.yidian.news.util.ProcessUtil
import com.yidian.shenghuoquan.commodity.service.PublishCouponService
import com.yidian.shenghuoquan.commodity.service.SelectCategoryService
import com.yidian.xpage.XPageManager
import com.yidian.xpage.node.XPageHandler
import com.yidian.xpage.node.XPageNode
......@@ -45,7 +41,7 @@ class CommodityApplication : YdBaseApplication() {
}
private fun initService() {
Zap.addService(PublishCouponService.SERVICE_NAME, PublishCouponService())
Zap.addService(SelectCategoryService.serviceName, SelectCategoryService())
}
}
......@@ -17,7 +17,7 @@ import org.json.JSONObject
/**
* 发布优惠券相关服务
*/
class PublishCouponService : ZapService() {
class SelectCategoryService : ZapService() {
private lateinit var resolver: ResultResolver
......@@ -25,27 +25,9 @@ class PublishCouponService : ZapService() {
this.resolver = resolver
params as JSONObject
when (action) {
"selectCategory" -> {// 选择类目
"selectGoodsCategory" -> {// 选择类目
gotoSelectCategory(params)
}
"selectStore" -> {// 选择门店
gotoSelectStore(params)
}
}
}
/**
* 选择门店
*/
private fun gotoSelectStore(params: JSONObject) {
val lastSelectStore = params.optJSONArray("selectedStore")
if (lastSelectStore == null) {
XPageManager.push(XRouterPathConstants.chooseCategoryActivity, null)
} else {
val map = HashMap<String, Any?>()
map[ChooseCategoryActivity.lastSelectCategoryKey] = lastSelectCategory
XPageManager.push(XRouterPathConstants.chooseCategoryActivity, map)
}
}
......@@ -71,11 +53,6 @@ class PublishCouponService : ZapService() {
val params = Gson().toJson(selectedCategory)
resolver.success(JSONObject(params))
}
XEventConfig.CHOOSE_STORE_SUCCESS -> {// 选中的门店回传H5
val list = event.body as List<*>
val params = Gson().toJson(list)
resolver.success(JSONArray(params))
}
}
}
......@@ -86,7 +63,7 @@ class PublishCouponService : ZapService() {
}
companion object {
const val SERVICE_NAME: String = "SelectCategoryService"
const val serviceName: String = "selectCategoryService"
}
}
......@@ -494,5 +494,6 @@ class NewsContentApplication : YdBaseApplication() {
Zap.addService(UserService.serviceName, UserService())
Zap.addService(CacheService.serviceName, CacheService())
Zap.addService(DeepLinkService.serviceName, DeepLinkService())
Zap.addService(SelectStoreService.serviceName, SelectStoreService())
}
}
......@@ -50,7 +50,7 @@ class MyStaffActivity : BaseActivity<ActivityMyStaffBinding>(), IPersonalAccount
private fun requestAccountList() {
val lifeAccountId = StorageUtil.getLifeAccountId()
if (lifeAccountId.isNotBlank()) {
if (lifeAccountId.isNullOrBlank()) {
val paramsMap = HashMap<String, String?>()
paramsMap["life_account_id"] = lifeAccountId
PersonalRemoteDataSource.getAccountList(this, paramsMap)
......
package com.yidian.shenghuoquan.newscontent.service
import com.google.gson.Gson
import com.yidian.common.XEventConfig
import com.yidian.common.XRouterPathConstants
import com.yidian.shenghuoquan.newscontent.ui.store.ChooseStoreActivity
import com.yidian.xarc.xevent.XBaseEvent
import com.yidian.xarc.xrouter.ResultResolver
import com.yidian.xpage.XPageManager
import com.yidian.yac.core.zap.ZapService
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.json.JSONArray
import org.json.JSONObject
/**
* 选择门店服务
*/
class SelectStoreService : ZapService() {
private lateinit var resolver: ResultResolver
override fun onAction(path: String, action: String, params: Any, options: Any, resolver: ResultResolver) {
this.resolver = resolver
params as JSONObject
when (action) {
"selectStore" -> {// 选择门店
gotoSelectStore(params)
}
}
}
/**
* 选择门店
*/
private fun gotoSelectStore(params: JSONObject) {
val lastSelectStore = params.optJSONArray("selectedStore")
if (lastSelectStore == null) {
XPageManager.push(XRouterPathConstants.CHOOSE_STORE_ACTIVITY, null)
} else {
val map = HashMap<String, Any?>()
map[ChooseStoreActivity.lastSelectStoreKey] = lastSelectStore
XPageManager.push(XRouterPathConstants.CHOOSE_STORE_ACTIVITY, map)
}
}
@Subscribe(sticky = false, threadMode = ThreadMode.MAIN)
fun onEvent(event: XBaseEvent?) {
when (event?.name) {
XEventConfig.CHOOSE_STORE_SUCCESS -> {// 选中的门店回传H5
val list = event.body as List<*>
val params = Gson().toJson(list)
resolver.success(JSONArray(params))
}
}
}
override fun onExit() {
}
override fun onInit() {
}
companion object {
const val serviceName: String = "selectStoreService"
}
}
......@@ -24,4 +24,8 @@ class ChooseStoreActivity : BaseActivity<ActivityChooseStoreBinding>() {
}
companion object {
const val lastSelectStoreKey = "lastSelectStore"
}
}
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