Commit 27af032b authored by shiyl's avatar shiyl

新建发布优惠券相关的选择门店、选择类目服务协议

parent 8972a921
......@@ -16,8 +16,9 @@ class XEventConfig {
const val GIF_DATA: String = "gifData"
const val CHOOSE_CAREER: String = "chooseCareer"
const val LIFE_ACCOUNT_NAME_MODIFY = "lifeAccountNameModify"
// 在搜索页面选择成功关闭当前页面
const val CATEGORY_SEARCH_SUCCESS = "category_search_success"
// 选择类目成功
const val CHOOSE_CATEGORY_SUCCESS = "choose_category_success"
// 选择门店成功
const val CHOOSE_STORE_SUCCESS = "choose_store_success"
}
}
......@@ -14,8 +14,12 @@ class XRouterPathConstants {
const val SUPPORT = "/productSupport"
const val FLASH = "/flash"
// 登录生活圈
const val LOGIN_LIFE_CIRCLE = "/loginLifeCircle"
// 门店管理
const val STORE_MANAGEMENT = "/storeManagement"
// 选择门店
const val CHOOSE_STORE_ACTIVITY = "/chooseStoreActivity"
const val LIFE_ACCOUNT_IDENTITY = "/lifeAccountIdentity"
const val LIFE_ACCOUNT_AUTH = "/lifeAccountAuth"
const val ID_CARD_TEST = "/idCardTest"
......
{"x_resource_version":"0.0.12","routers":[{"name":"xbrid_coupon_publish","local_path":"pages/coupon_publish/index.html","remote_url":"","operation_url":""},{"name":"xbrid_user1","local_path":"pages/user1/index.html","remote_url":"","operation_url":""}]}
body[data-v-3c74f250]{font-size:14px;color:#333;font-family:PingFangSC,PingFangSC-Medium}.title[data-v-3c74f250]{color:#333;font-size:14px;font-weight:900;padding:20px;display:flex;align-items:center}.essentialInfo[data-v-3c74f250] .van-cell,.iptBox[data-v-3c74f250] .van-cell,.otherInfo[data-v-3c74f250] .van-cell{height:80px;padding:0 20px}.essentialInfo[data-v-3c74f250] .van-cell:after,.iptBox[data-v-3c74f250] .van-cell:after,.otherInfo[data-v-3c74f250] .van-cell:after{border:none}.essentialInfo[data-v-3c74f250] .van-cell .van-field__label,.iptBox[data-v-3c74f250] .van-cell .van-field__label,.otherInfo[data-v-3c74f250] .van-cell .van-field__label{height:61px;border-bottom:1px solid #f0f1f4;display:flex;align-items:center;margin-right:0}.essentialInfo[data-v-3c74f250] .van-field__label>span,.iptBox[data-v-3c74f250] .van-field__label>span,.otherInfo[data-v-3c74f250] .van-field__label>span{width:66px;height:24px;font-size:16px}.essentialInfo[data-v-3c74f250] .van-cell .van-field__value,.iptBox[data-v-3c74f250] .van-cell .van-field__value,.otherInfo[data-v-3c74f250] .van-cell .van-field__value{height:60px;border-bottom:1px solid #f0f1f4;display:flex;align-items:center}.couponPage[data-v-3c74f250] .van-field--error .van-field__label,.couponPage[data-v-3c74f250] .van-field--error .van-field__value{border-bottom:1px solid red}.couponPage[data-v-3c74f250] .van-field__error-message{position:absolute;left:-86px;bottom:-26px}.essentialInfo[data-v-3c74f250] .van-cell__right-icon,.iptBox[data-v-3c74f250] .van-cell__right-icon,.otherInfo[data-v-3c74f250] .van-cell__right-icon{font-size:24px;color:#979797;position:absolute;right:20px;top:18px}.tradeName[data-v-3c74f250] input{width:215px}.price[data-v-3c74f250] input{width:247px}.stepper[data-v-3c74f250] button{width:24px;height:24px;border-radius:50%}.stepper[data-v-3c74f250] input{width:50px;height:24px;margin:0 12px;background:#fff}.stepper[data-v-3c74f250] .van-field__label>span{width:100%}.pictureUpload[data-v-3c74f250] .van-uploader__preview,.uploadFile[data-v-3c74f250]{width:106px;height:80px;border-radius:8px}.pictureUpload[data-v-3c74f250] .van-uploader__preview .van-image{width:100%;height:100%;border-radius:8px}.pictureUpload[data-v-3c74f250] .van-uploader__preview .van-uploader__preview-delete{width:13px;height:13px;border-radius:50%;background:rgba(0,0,0,.4);margin:5px}.uploadFile[data-v-3c74f250]{background:#f6f7f7;text-align:center;padding:10px 0;box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center}.uploadFile .icoPlus[data-v-3c74f250]{width:100%;font-size:24px;font-weight:900;margin-bottom:6px;color:#999}.uploadFile .num[data-v-3c74f250]{width:100%;margin:0;color:#999;font-size:12px}.singPurLimit[data-v-3c74f250] .van-field__value{padding-left:24px;box-sizing:border-box;border-radius:1px solid}.moreSetIcoDown[data-v-3c74f250],.moreSetIcoUp[data-v-3c74f250]{font-size:18px;font-weight:900;margin-right:7.5px}.moreSetTitle[data-v-3c74f250]{font-size:16px;color:#333;padding:13px 24px;box-sizing:border-box}.moreSetTxt[data-v-3c74f250]{width:91%;height:142.5px!important;background:#f5f6f7;border-radius:8px;margin:0 auto}.moreSetBox[data-v-3c74f250]{height:auto}.draw-enter-active[data-v-3c74f250],.draw-leave-active[data-v-3c74f250]{transition:all .1s ease}.draw-enter[data-v-3c74f250],.draw-leave-to[data-v-3c74f250]{height:0}.submitBtn[data-v-3c74f250]{margin:112px 30px 34px 30px}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0;"><title>发布优惠卷</title><link href="css/app.08db4f12.css" rel="preload" as="style"><link href="css/chunk-vendors.def3fd65.css" rel="preload" as="style"><link href="js/app.f7b4708a.js" rel="preload" as="script"><link href="js/chunk-vendors.d8296d6e.js" rel="preload" as="script"><link href="css/chunk-vendors.def3fd65.css" rel="stylesheet"><link href="css/app.08db4f12.css" rel="stylesheet"></head><script>// 禁止IOS页面缩放
document.documentElement.addEventListener(
"touchstart",
function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
},
false
);
var lastTouchEnd = 0;
document.documentElement.addEventListener(
"touchend",
function (event) {
var now = Date.now();
if (now - lastTouchEnd <= 300) {
event.preventDefault();
}
lastTouchEnd = now;
},
false
);
document.addEventListener("gesturestart", function (event) {
event.preventDefault();
});</script><body><div id="app"></div><script src="js/chunk-vendors.d8296d6e.js"></script><script src="js/app.f7b4708a.js"></script></body></html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
h3[data-v-d597d288]{margin:40px 0 0}ul[data-v-d597d288]{list-style-type:none;padding:0}li[data-v-d597d288]{display:inline-block;margin:0 10px}a[data-v-d597d288]{color:#42b983}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px}
\ No newline at end of file
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="favicon.ico"><title>vue2.x</title><link href="css/app.e1405110.css" rel="preload" as="style"><link href="js/app.095b967d.js" rel="preload" as="script"><link href="js/chunk-vendors.c5cf1606.js" rel="preload" as="script"><link href="css/app.e1405110.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but vue2.x doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.c5cf1606.js"></script><script src="js/app.095b967d.js"></script></body></html>
\ No newline at end of file
(function(e){function t(t){for(var n,a,u=t[0],s=t[1],i=t[2],p=0,v=[];p<u.length;p++)a=u[p],Object.prototype.hasOwnProperty.call(o,a)&&o[a]&&v.push(o[a][0]),o[a]=0;for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(e[n]=s[n]);c&&c(t);while(v.length)v.shift()();return l.push.apply(l,i||[]),r()}function r(){for(var e,t=0;t<l.length;t++){for(var r=l[t],n=!0,u=1;u<r.length;u++){var s=r[u];0!==o[s]&&(n=!1)}n&&(l.splice(t--,1),e=a(a.s=r[0]))}return e}var n={},o={app:0},l=[];function a(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,a),r.l=!0,r.exports}a.m=e,a.c=n,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(r,n,function(t){return e[t]}.bind(null,n));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var u=window["webpackJsonp"]=window["webpackJsonp"]||[],s=u.push.bind(u);u.push=t,u=u.slice();for(var i=0;i<u.length;i++)t(u[i]);var c=s;l.push([0,"chunk-vendors"]),r()})({0:function(e,t,r){e.exports=r("56d7")},"1eab":function(e,t,r){},2395:function(e,t,r){},"56d7":function(e,t,r){"use strict";r.r(t);r("e260"),r("e6cf"),r("cca6"),r("a79d");var n=r("2b0e"),o=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{attrs:{id:"app"}},[n("img",{attrs:{alt:"Vue logo",src:r("cf05")}}),n("HelloWorld",{attrs:{msg:"Welcome to Your Vue.js App"}})],1)},l=[],a=function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("div",{staticClass:"hello"},[r("h1",[e._v(e._s(e.msg))]),e._m(0),r("h3",[e._v("Installed CLI Plugins")]),e._m(1),r("h3",[e._v("Essential Links")]),e._m(2),r("h3",[e._v("Ecosystem")]),e._m(3)])},u=[function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("p",[e._v(" For a guide and recipes on how to configure / customize this project,"),r("br"),e._v(" check out the "),r("a",{attrs:{href:"https://cli.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-cli documentation")]),e._v(". ")])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel",target:"_blank",rel:"noopener"}},[e._v("babel")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint",target:"_blank",rel:"noopener"}},[e._v("eslint")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Core Docs")])]),r("li",[r("a",{attrs:{href:"https://forum.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Forum")])]),r("li",[r("a",{attrs:{href:"https://chat.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("Community Chat")])]),r("li",[r("a",{attrs:{href:"https://twitter.com/vuejs",target:"_blank",rel:"noopener"}},[e._v("Twitter")])]),r("li",[r("a",{attrs:{href:"https://news.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("News")])])])},function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("ul",[r("li",[r("a",{attrs:{href:"https://router.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-router")])]),r("li",[r("a",{attrs:{href:"https://vuex.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vuex")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/vue-devtools#vue-devtools",target:"_blank",rel:"noopener"}},[e._v("vue-devtools")])]),r("li",[r("a",{attrs:{href:"https://vue-loader.vuejs.org",target:"_blank",rel:"noopener"}},[e._v("vue-loader")])]),r("li",[r("a",{attrs:{href:"https://github.com/vuejs/awesome-vue",target:"_blank",rel:"noopener"}},[e._v("awesome-vue")])])])}],s={name:"HelloWorld",props:{msg:String}},i=s,c=(r("623d"),r("2877")),p=Object(c["a"])(i,a,u,!1,null,"d597d288",null),v=p.exports,f={name:"App",components:{HelloWorld:v}},h=f,_=(r("7c55"),Object(c["a"])(h,o,l,!1,null,null,null)),g=_.exports;n["a"].config.productionTip=!1,new n["a"]({render:function(e){return e(g)}}).$mount("#app")},"623d":function(e,t,r){"use strict";r("1eab")},"7c55":function(e,t,r){"use strict";r("2395")},cf05:function(e,t,r){e.exports=r.p+"img/logo.82b9c7a5.png"}});
\ No newline at end of file
......@@ -3,12 +3,18 @@ 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.xpage.XPageManager
import com.yidian.xpage.node.XPageHandler
import com.yidian.xpage.node.XPageNode
import com.yidian.xpage.node.XPageNodePageType
import com.yidian.yac.core.core.YacModuleSpec
import com.yidian.yac.core.zap.Zap
@YacModuleSpec
class CommodityApplication : YdBaseApplication() {
......@@ -39,6 +45,7 @@ class CommodityApplication : YdBaseApplication() {
}
private fun initService() {
Zap.addService(PublishCouponService.SERVICE_NAME, PublishCouponService())
}
}
package com.yidian.shenghuoquan.commodity.service
import com.google.gson.Gson
import com.yidian.common.XEventConfig
import com.yidian.common.XRouterPathConstants
import com.yidian.shenghuoquan.commodity.dto.SelectCategoryDto
import com.yidian.shenghuoquan.commodity.ui.coupon.ChooseCategoryActivity
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 PublishCouponService : 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) {
"selectCategory" -> {// 选择类目
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)
}
}
/**
* 选择类目
*/
private fun gotoSelectCategory(params: JSONObject) {
val lastSelectCategory = params.optJSONObject("selectedCategory")
if (lastSelectCategory == null) {
XPageManager.push(XRouterPathConstants.chooseCategoryActivity, null)
} else {
val map = HashMap<String, Any?>()
map[ChooseCategoryActivity.lastSelectCategoryKey] = lastSelectCategory
XPageManager.push(XRouterPathConstants.chooseCategoryActivity, map)
}
}
@Subscribe(sticky = false, threadMode = ThreadMode.MAIN)
fun onEvent(event: XBaseEvent?) {
when (event?.name) {
XEventConfig.CHOOSE_CATEGORY_SUCCESS -> {// 选中的类目回传H5
val selectedCategory = event.body as SelectCategoryDto
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))
}
}
}
override fun onExit() {
}
override fun onInit() {
}
companion object {
const val SERVICE_NAME: String = "SelectCategoryService"
}
}
package com.yidian.shenghuoquan.commodity.ui.coupon
import android.graphics.Color
import android.widget.TextView
import androidx.activity.viewModels
import com.yidian.common.XEventConfig
import com.yidian.common.extensions.initTitleBar
import com.yidian.common.mvvm.BaseMvvmActivity
import com.yidian.common.services.XEventService
import com.yidian.common.utils.StringUtils
import com.yidian.common.utils.ToastUtils
import com.yidian.shenghuoquan.commodity.R
import com.yidian.shenghuoquan.commodity.databinding.CommodityActivityCategorySearchBinding
import com.yidian.shenghuoquan.commodity.dto.SelectCategoryDto
......@@ -39,9 +34,8 @@ class CategorySearchActivity : BaseMvvmActivity<CommodityActivityCategorySearchB
adapter.setOnItemClickListener { adapter, _, position ->
val selectCategoryDto = adapter.getItem(position) as SelectCategoryDto
// 关闭选择类目页面
XEventManager.post(XBaseEvent(XEventConfig.CATEGORY_SEARCH_SUCCESS, null))
// todo 选择成功后,回传H5
ToastUtils.showShortSafe("选择${selectCategoryDto.firstCategoryName} > ${selectCategoryDto.secondCategoryName}")
XEventManager.post(XBaseEvent(XEventConfig.CHOOSE_CATEGORY_SUCCESS, selectCategoryDto))
finish()
}
}
......
......@@ -6,10 +6,10 @@ import com.yidian.common.XEventConfig
import com.yidian.common.XRouterPathConstants
import com.yidian.common.extensions.initTitleBar
import com.yidian.common.mvvm.BaseMvvmActivity
import com.yidian.common.utils.ToastUtils
import com.yidian.shenghuoquan.commodity.R
import com.yidian.shenghuoquan.commodity.databinding.CommodityActivityChooseCategoryBinding
import com.yidian.shenghuoquan.commodity.dto.CategoryListDto
import com.yidian.shenghuoquan.commodity.dto.SelectCategoryDto
import com.yidian.shenghuoquan.commodity.dto.SubCategory
import com.yidian.shenghuoquan.commodity.ui.coupon.adapter.CategoryListAdapter
import com.yidian.shenghuoquan.commodity.ui.coupon.adapter.CategorySubListAdapter
......@@ -38,6 +38,7 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
}
override fun initView() {
getIntentData()
XEventManager.register(this)
initTitleBar(binding.include.toolbar, binding.include.tvTitle, "选择类目")
setupRecyclerView()
......@@ -45,6 +46,15 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
vm.requestCategoryList()
}
private fun getIntentData() {
val paramsMap = intent?.getSerializableExtra(XRouterPathConstants.ParamsKey)
paramsMap?.let {
it as HashMap<*, *>
val selectCategoryDto = it[lastSelectCategoryKey] as SelectCategoryDto
vm.setLastSelected(selectCategoryDto)
}
}
/**
* 设置列表
*/
......@@ -59,12 +69,15 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
// 更新列表显示二级分类
binding.rvCategoryList.adapter = subAdapter
subAdapter.setList(firstCategory.sub_list)
vm.showSelectFirstLevelName(firstCategory.name)
vm.showSelectFirstLevelName(firstCategory)
}
subAdapter.setOnItemClickListener { adapter, _, position ->
// 记录选中的二级分类,并回传一级+二级
val secondCategory = adapter.data[position] as SubCategory
ToastUtils.showShortSafe("选中的二级分类:${secondCategory.name}")
val selectCategoryDto = vm.showSelectSecondLevelName(secondCategory)
// 关闭选择类目页面
XEventManager.post(XBaseEvent(XEventConfig.CHOOSE_CATEGORY_SUCCESS, selectCategoryDto))
finish()
}
}
......@@ -75,6 +88,7 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
adapter.setList(it)
} ?: adapter.setList(null)
})
// 点击已经选择的一级类目
vm.showFirstLevelListEvent.observe(this, {
binding.rvCategoryList.adapter = adapter
if (::categoryList.isInitialized) {
......@@ -85,13 +99,27 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
vm.goNextEvent.observe(this, {
startActivity(Intent(this, CategorySearchActivity::class.java))
})
// 匹配上次选中的数据成功,显示赏析选中的二级列表
vm.matchListEvent.observe(this, {
it?.let {
// 给类目列表赋值,便于后续切换使用
categoryList = it
// 更新列表显示二级分类
val lastSelectSecondLevelList = vm.getLastSelectSecondLevelList()
if (lastSelectSecondLevelList != null) {
binding.rvCategoryList.adapter = subAdapter
subAdapter.setList(lastSelectSecondLevelList.sub_list)
vm.showSelectFirstLevelName(lastSelectSecondLevelList)
}
}
})
}
@Subscribe(sticky = false, threadMode = ThreadMode.MAIN)
fun onEvent(event: XBaseEvent?) {
when (event?.name) {
// 在搜索页面选择成功关闭当前页面
XEventConfig.CATEGORY_SEARCH_SUCCESS -> {
// 在当前页面或搜索页面选择成功关闭当前页面
XEventConfig.CHOOSE_CATEGORY_SUCCESS -> {
this.finish()
}
}
......@@ -102,4 +130,8 @@ class ChooseCategoryActivity : BaseMvvmActivity<CommodityActivityChooseCategoryB
XEventManager.unRegister(this)
}
companion object {
const val lastSelectCategoryKey = "lastSelectCategory"
}
}
......@@ -3,8 +3,9 @@ package com.yidian.shenghuoquan.commodity.ui.coupon
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.yidian.common.mvvm.BaseViewModel
import com.yidian.common.utils.ToastUtils
import com.yidian.shenghuoquan.commodity.dto.CategoryListDto
import com.yidian.shenghuoquan.commodity.dto.SelectCategoryDto
import com.yidian.shenghuoquan.commodity.dto.SubCategory
import com.yidian.shenghuoquan.commodity.http.CouponDataSource
import com.yidian.shenghuoquan.commodity.http.callback.ICategoryListCallback
......@@ -13,8 +14,20 @@ import com.yidian.shenghuoquan.commodity.http.callback.ICategoryListCallback
*/
class ChooseCategoryViewModel : BaseViewModel() {
// 根据上次选中的类目匹配成功,获取到一级类目及其子类目
private lateinit var matchSuccessFirstCategory: CategoryListDto
// 是否显示顶部的一级类目名称
var showSelectFirstCategory = MutableLiveData(false)
// 选择的一级类目名称
var selectFirstCategoryName = MutableLiveData<String>()
var selectFirstCategoryId = MutableLiveData<Int>()
// 选择的二级类目名称
var selectSecondCategoryName = MutableLiveData<String>()
var selectSecondCategoryId = MutableLiveData<Int>()
var selectedCategory = MutableLiveData<SelectCategoryDto?>(null)
/**
* 类目列表数据 Event
......@@ -22,6 +35,12 @@ class ChooseCategoryViewModel : BaseViewModel() {
private val _addListEvent = MutableLiveData<MutableList<CategoryListDto>?>()
val addListEvent: LiveData<MutableList<CategoryListDto>?> = _addListEvent
/**
* 在类目列表中匹配上次选择的类目 Event
*/
private val _matchListEvent = MutableLiveData<MutableList<CategoryListDto>?>()
val matchListEvent: LiveData<MutableList<CategoryListDto>?> = _matchListEvent
/**
* 切换显示一级分类 Event
*/
......@@ -39,8 +58,32 @@ class ChooseCategoryViewModel : BaseViewModel() {
private val requestCategoryListCallBack = object : ICategoryListCallback {
override fun getCategoryListSuccess(dto: MutableList<CategoryListDto>?) {
// 更新列表
if (selectedCategory.value == null) {
// 没有上次选中数据
_addListEvent.value = dto
} else {
// 在接口返回数据中匹配上次选中数据是否成功
var matchSuccess = false
dto?.forEachIndexed { _, categoryListDto ->
if (categoryListDto.category_id == selectedCategory.value?.firstCategoryId) {
categoryListDto.sub_list.forEach { sub ->
if (sub.category_id == selectSecondCategoryId.value) {
// 匹配成功的一级类目
matchSuccessFirstCategory = categoryListDto
matchSuccess = true
return
}
}
}
}
if (matchSuccess) {
// 有上次选中数据且在接口中匹配成功
_matchListEvent.value = dto
} else {
// 没有匹配成功上次选中数据
_addListEvent.value = dto
}
}
}
}
......@@ -48,17 +91,51 @@ class ChooseCategoryViewModel : BaseViewModel() {
postNextEvent()
}
fun showSelectFirstLevelName(name: String = "") {
if (name.isBlank()) {
/**
* 显示选择的一级类目
*/
fun showSelectFirstLevelName(dto: CategoryListDto? = null) {
if (dto == null) {
showSelectFirstCategory.value = false
} else {
showSelectFirstCategory.value = true
selectFirstCategoryName.value = name
selectFirstCategoryName.value = dto.name
selectFirstCategoryId.value = dto.category_id
}
}
/**
* 显示选择的二级类目
*/
fun showSelectSecondLevelName(secondCategory: SubCategory): SelectCategoryDto {
selectSecondCategoryId.value = secondCategory.category_id
selectSecondCategoryName.value = secondCategory.name
return SelectCategoryDto(
selectFirstCategoryId.value!!,
selectFirstCategoryName.value!!,
selectSecondCategoryId.value!!,
selectSecondCategoryName.value!!
)
}
fun showFirstLevelList() {
_showFirstLevelListEvent.value = Unit
}
/**
* 设置上次选中的类目
*/
fun setLastSelected(selectCategoryDto: SelectCategoryDto) {
selectedCategory.value = selectCategoryDto
}
/**
* 获取上次选中的二级列表,用于页面显示
*/
fun getLastSelectSecondLevelList(): CategoryListDto? {
if (::matchSuccessFirstCategory.isInitialized) {
return matchSuccessFirstCategory
}
return null
}
}
......@@ -67,19 +67,19 @@
<activity android:name=".ui.LoginLifeCircleActivity" />
<activity
android:name=".ui.StoreManagementActivity"
android:name=".ui.store.StoreManagementActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.EditStoreActivity"
android:name=".ui.store.EditStoreActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.SelectAddressActivity"
android:name=".ui.store.SelectAddressActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.SearchAddActivity"
android:name=".ui.store.SearchAddActivity"
android:theme="@style/Transparent" />
<activity
......@@ -154,6 +154,7 @@
<activity android:name=".wallet.ui.WithdrawActivity" />
<activity android:name=".wallet.ui.TransactionListActivity" />
<activity android:name=".wallet.ui.TransactionDetailsActivity" />
<activity android:name=".ui.store.ChooseStoreActivity" />
</application>
......
......@@ -7,7 +7,7 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.yidian.shenghuoquan.newscontent.R
import com.yidian.shenghuoquan.newscontent.http.httpbean.GetShopListBean
import com.yidian.shenghuoquan.newscontent.ui.EditStoreActivity
import com.yidian.shenghuoquan.newscontent.ui.store.EditStoreActivity
import com.yidian.shenghuoquan.newscontent.viewholder.StoreViewHolder
/**
......
......@@ -3,6 +3,7 @@ package com.yidian.shenghuoquan.newscontent.app
import android.content.Intent
import com.yidian.common.XRouterPathConstants
import com.yidian.common.XRouterPathConstants.Companion.CHOOSE_CAREER
import com.yidian.common.XRouterPathConstants.Companion.CHOOSE_STORE_ACTIVITY
import com.yidian.common.XRouterPathConstants.Companion.FLASH
import com.yidian.common.XRouterPathConstants.Companion.ID_CARD_TEST
import com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_AUTH
......@@ -44,6 +45,8 @@ import com.yidian.shenghuoquan.newscontent.ui.center.MerchantCenterActivity
import com.yidian.shenghuoquan.newscontent.ui.center.MerchantInfoActivity
import com.yidian.shenghuoquan.newscontent.ui.idcard.IDCardTestActivity
import com.yidian.shenghuoquan.newscontent.ui.setting.SystemSettingActivity
import com.yidian.shenghuoquan.newscontent.ui.store.ChooseStoreActivity
import com.yidian.shenghuoquan.newscontent.ui.store.StoreManagementActivity
import com.yidian.shenghuoquan.newscontent.wallet.ui.*
import com.yidian.utils.DensityUtil
import com.yidian.xpage.XPageManager
......@@ -115,6 +118,18 @@ class NewsContentApplication : YdBaseApplication() {
}
}),
XPageNode(CHOOSE_STORE_ACTIVITY, XPageNodePageType.NATIVE, object : XPageHandler {
override fun handler(params: Map<String, Any?>?) {
val intent = Intent()
if (params != null) {
intent.putExtra(XRouterPathConstants.ParamsKey, params as HashMap)
}
intent.setClass(context, ChooseStoreActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(intent)
}
}),
XPageNode(LIFE_ACCOUNT_IDENTITY, XPageNodePageType.NATIVE, object : XPageHandler {
override fun handler(params: Map<String, Any?>?) {
val intent = Intent()
......
......@@ -30,6 +30,7 @@ import com.yidian.shenghuoquan.newscontent.personnel.http.callback.IPersonalGetS
import com.yidian.shenghuoquan.newscontent.ui.ProtocolActivity
import com.yidian.shenghuoquan.newscontent.ui.dialog.HintDialog
import com.yidian.shenghuoquan.newscontent.utils.CountDownTimerUtils
import com.yidian.shenghuoquan.newscontent.utils.StorageUtil
import com.yidian.shenghuoquan.newscontent.utils.TextWatcherAdapter
import com.yidian.utils.ToastUtil
import com.yidian.xpage.XPageManager
......@@ -167,7 +168,7 @@ class ManagerChangeActivity : BaseActivity<ActivityManagerChangeBinding>() {
val paramsMap = HashMap<String, String?>()
paramsMap["mobile"] = managerNewMobile.replace(" ", "")
paramsMap["code"] = code
paramsMap["life_account_id"] = Hawk.get(HawkConfig.LifeAccountId, "")
paramsMap["life_account_id"] = StorageUtil.getLifeAccountId()
PersonalRemoteDataSource.getChangeManager(getChangeAccountCallBack, paramsMap)
}
......
......@@ -17,6 +17,7 @@ import com.yidian.shenghuoquan.newscontent.personnel.bean.AccountListDto
import com.yidian.shenghuoquan.newscontent.personnel.bean.AccountUser
import com.yidian.shenghuoquan.newscontent.personnel.http.callback.IPersonalAccountListCallback
import com.yidian.shenghuoquan.newscontent.personnel.http.PersonalRemoteDataSource
import com.yidian.shenghuoquan.newscontent.utils.StorageUtil
import com.yidian.xpage.XPageManager
/**
......@@ -48,7 +49,7 @@ class MyStaffActivity : BaseActivity<ActivityMyStaffBinding>(), IPersonalAccount
}
private fun requestAccountList() {
val lifeAccountId = Hawk.get(HawkConfig.LifeAccountId, "")
val lifeAccountId = StorageUtil.getLifeAccountId()
if (lifeAccountId.isNotBlank()) {
val paramsMap = HashMap<String, String?>()
paramsMap["life_account_id"] = lifeAccountId
......
......@@ -17,6 +17,7 @@ import com.yidian.shenghuoquan.newscontent.personnel.http.PersonalRemoteDataSour
import com.yidian.shenghuoquan.newscontent.personnel.http.callback.IPersonalDissolveCallBack
import com.yidian.shenghuoquan.newscontent.ui.dialog.HintDialog
import com.yidian.shenghuoquan.newscontent.utils.SensitiveInfoUtil
import com.yidian.shenghuoquan.newscontent.utils.StorageUtil
import com.yidian.xpage.XPageManager
/**
......@@ -96,7 +97,7 @@ class StaffManageActivity : BaseActivity<ActivityStaffManageBinding>() {
private fun requestDissolve() {
val paramsMap = HashMap<String, String?>()
paramsMap["delete_user_id"] = currentUserId.toString()
paramsMap["life_account_id"] = Hawk.get(HawkConfig.LifeAccountId, "")
paramsMap["life_account_id"] = StorageUtil.getLifeAccountId()
PersonalRemoteDataSource.getDissolveRelationship(getDissolveCallBack, paramsMap)
}
......
......@@ -15,6 +15,7 @@ import id.zelory.compressor.constraint.format
import id.zelory.compressor.constraint.quality
import id.zelory.compressor.constraint.resolution
import id.zelory.compressor.constraint.size
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
......@@ -119,8 +120,7 @@ class RequestService : ZapService() {
val activity = YdBaseApplication.activityList[YdBaseApplication.activityList.size - 1]
val filePath = params.optString("profile")
val file = File(filePath)
GlobalScope.launch(Dispatchers.Main) {
GlobalScope.launch(Dispatchers.Main) {
CoroutineScope(Dispatchers.IO).launch {
val compressedImageFile = Compressor.compress(activity, file) {
resolution(360, 360)
quality(80)
......@@ -131,5 +131,4 @@ class RequestService : ZapService() {
ApiService.uploadFile(uploadFileCallback, requestBody)
}
}
}
}
......@@ -4,8 +4,9 @@ import com.yidian.xarc.xrouter.ResultResolver
import com.yidian.yac.core.zap.ZapService
import org.json.JSONObject
class UserService: ZapService(){
companion object{
class UserService : ZapService() {
companion object {
const val serviceName: String = "UserService"
}
......@@ -16,7 +17,7 @@ class UserService: ZapService(){
params as JSONObject
val path = params.optString("path")
val body = params.optJSONObject("body")
when(action){
when (action) {
"addComment" -> addComment(path, body)
"like" -> like(path, body)
}
......@@ -30,11 +31,11 @@ class UserService: ZapService(){
}
private fun addComment(path: String, params: JSONObject){
private fun addComment(path: String, params: JSONObject) {
}
private fun like(path: String, params: JSONObject){
private fun like(path: String, params: JSONObject) {
}
}
package com.yidian.shenghuoquan.newscontent.ui.store
import android.os.Bundle
import com.yidian.common.XRouterPathConstants
import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.databinding.ActivityChooseStoreBinding
/**
* 选择门店
*/
class ChooseStoreActivity : BaseActivity<ActivityChooseStoreBinding>() {
override fun createViewBinding(): ActivityChooseStoreBinding {
return ActivityChooseStoreBinding.inflate(layoutInflater)
}
override fun getXPageName(): String {
return XRouterPathConstants.CHOOSE_STORE_ACTIVITY
}
override fun init(savedInstanceState: Bundle?) {
super.init(savedInstanceState)
}
}
package com.yidian.shenghuoquan.newscontent.ui
package com.yidian.shenghuoquan.newscontent.ui.store
import android.content.Intent
import android.os.Bundle
......@@ -10,11 +10,10 @@ import com.yidian.shenghuoquan.newscontent.utils.StorageUtil
import com.yidian.shenghuoquan.newscontent.widget.CommonTopBarView
/**
* Author: sym
* Date: 2021/6/23 3:05 PM
* Describe:
* 编辑门店
*/
class EditStoreActivity : BaseActivity<ActivityStoreEditBinding>(), CommonTopBarView.OnCommonTopBarActionCallback {
private var store = Store("", "", "", "", "", "")
override fun createViewBinding(): ActivityStoreEditBinding {
......
package com.yidian.shenghuoquan.newscontent.ui
package com.yidian.shenghuoquan.newscontent.ui.store
import android.content.Intent
import android.os.Bundle
......
package com.yidian.shenghuoquan.newscontent.ui
package com.yidian.shenghuoquan.newscontent.ui.store
import android.content.Intent
import android.location.Location
......
package com.yidian.shenghuoquan.newscontent.ui
package com.yidian.shenghuoquan.newscontent.ui.store
import android.content.Intent
import android.os.Bundle
......@@ -11,12 +11,12 @@ import com.yidian.shenghuoquan.newscontent.http.ApiService
import com.yidian.shenghuoquan.newscontent.utils.StorageUtil
/**
* Author: sym
* Date: 2021/6/22 10:25 AM
* Describe:
* 门店管理
*/
class StoreManagementActivity : BaseActivity<ActivityStoreManagementBinding>() {
private lateinit var adapter:StoreAdapter
private lateinit var adapter: StoreAdapter
override fun createViewBinding(): ActivityStoreManagementBinding {
return ActivityStoreManagementBinding.inflate(layoutInflater)
}
......
......@@ -68,19 +68,19 @@
<activity android:name=".ui.LoginLifeCircleActivity" />
<activity
android:name=".ui.StoreManagementActivity"
android:name=".ui.store.StoreManagementActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.EditStoreActivity"
android:name=".ui.store.EditStoreActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.SelectAddressActivity"
android:name=".ui.store.SelectAddressActivity"
android:theme="@style/Transparent" />
<activity
android:name=".ui.SearchAddActivity"
android:name=".ui.store.SearchAddActivity"
android:theme="@style/Transparent" />
<activity
......@@ -155,6 +155,7 @@
<activity android:name=".wallet.ui.WithdrawActivity" />
<activity android:name=".wallet.ui.TransactionListActivity" />
<activity android:name=".wallet.ui.TransactionDetailsActivity" />
<activity android:name=".ui.store.ChooseStoreActivity" />
</application>
</manifest>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:ignore="MissingDefaultResource">
<include
android:id="@+id/include"
layout="@layout/layout_toolbar_menu" />
<com.yidian.common.widget.blank.BlankPageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:visibility="gone" />
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_store"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:gravity="center"
android:orientation="horizontal"
android:paddingStart="@dimen/dp30"
android:paddingEnd="@dimen/dp30">
<TextView
android:id="@+id/tv_save"
android:layout_width="match_parent"
android:layout_height="@dimen/dp44"
android:background="@drawable/store_card_back"
android:gravity="center"
android:text="保 存"
android:textColor="#fff"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -21,8 +21,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_height="@dimen/dp64"
android:gravity="center"
android:orientation="vertical">
......@@ -37,9 +36,10 @@
android:orientation="horizontal">
<TextView
android:id="@+id/tv_add_store"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@mipmap/store_add"
android:drawableStart="@mipmap/store_add"
android:drawablePadding="8dp"
android:text="新增门店"
android:textColor="#fff"
......
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