diff --git a/app/src/main/java/com/cheng/bole/bean/SupplierGoodsBean.kt b/app/src/main/java/com/cheng/bole/bean/SupplierGoodsBean.kt deleted file mode 100644 index 23947d0..0000000 --- a/app/src/main/java/com/cheng/bole/bean/SupplierGoodsBean.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.cheng.bole.bean - -import java.io.Serializable - -data class SupplierGoodsBean( - val city_id: String, - val city_name: String, - val company: CompanyBean, - val contact: List, - val create_time: String, - val file: List, - val goods_description: String, - val goods_name: String, - val goods_price: String, - val goods_price_show: String, - val goods_price_type: String, - val id: String, - val remark: String, - val review_time: String, - val status: String, - val type: String, - val update_time: String, - val user_id: String, - val view_count: String, - val is_broadcast: Boolean -) : Serializable \ No newline at end of file diff --git a/app/src/main/java/com/cheng/bole/common/EventConstants.kt b/app/src/main/java/com/cheng/bole/common/EventConstants.kt index e8e26e6..d030015 100644 --- a/app/src/main/java/com/cheng/bole/common/EventConstants.kt +++ b/app/src/main/java/com/cheng/bole/common/EventConstants.kt @@ -11,8 +11,6 @@ object EventConstants { const val HOME_BOTTOM_TAB_CHECK = "client.main.bottom.tab.check" //底部tab切换 - const val HOME_NOTICE_CHECK = "client.main.notice.check" //首页通知点击 - const val GOODS_SELECT = "client.goods.select" //点击切换支付的会员类型 const val PAY_SELECT = "client.pay.select" //点击切换支付类型 @@ -34,6 +32,8 @@ object EventConstants { const val BID_TYPE_CHECK = "client.bid.type.check" //标讯类型切换 + const val GOODS_TYPE_CHECK = "client.goods.type.check" //商品类型切换 + const val JUMP_TO_TOOLS = "client.jump.to.tools" //跳转到企业工具 const val JUMP_TO_BID_DETAIL = "client.jump.to.bid.detail" //跳转到标讯详情页 diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/bid/publish/goods/PublishGoodsMessageFragment.kt b/app/src/main/java/com/cheng/bole/ui/fragment/bid/publish/goods/PublishGoodsMessageFragment.kt index 16ee649..c10bf45 100644 --- a/app/src/main/java/com/cheng/bole/ui/fragment/bid/publish/goods/PublishGoodsMessageFragment.kt +++ b/app/src/main/java/com/cheng/bole/ui/fragment/bid/publish/goods/PublishGoodsMessageFragment.kt @@ -8,7 +8,7 @@ import android.view.ViewTreeObserver import androidx.constraintlayout.widget.ConstraintLayout import com.cheng.bole.R import com.cheng.bole.bean.AreaBean -import com.cheng.bole.bean.SupplierGoodsBean +import com.cheng.bole.bean.MerchantGoodsBean import com.cheng.bole.bean.UploadFileEntity import com.cheng.bole.common.Constants import com.cheng.bole.databinding.FragmentPublishGoodsMessageBinding @@ -40,7 +40,7 @@ import okhttp3.RequestBody.Companion.toRequestBody class PublishGoodsMessageFragment: BaseFragment() { private val from by lazy { arguments?.getInt("from") ?: 0 } - private var goodsDetail: SupplierGoodsBean? = null + private var goodsDetail: MerchantGoodsBean? = null private val imageAdapter by lazy { AddBidImageAdapter(requireContext(), uploadedImgList) } private var uploadedImgList: ArrayList = ArrayList() @@ -90,9 +90,9 @@ class PublishGoodsMessageFragment: BaseFragment= Build.VERSION_CODES.TIRAMISU) { - arguments?.getSerializable("item", SupplierGoodsBean::class.java) + arguments?.getSerializable("item", MerchantGoodsBean::class.java) } else { - arguments?.getSerializable("item") as? SupplierGoodsBean + arguments?.getSerializable("item") as? MerchantGoodsBean } if (goodsDetail != null) { setData(goodsDetail!!) @@ -280,7 +280,7 @@ class PublishGoodsMessageFragment: BaseFragment() { city = it[0] binding.tvArea.text = city!!.name } - f.show(childFragmentManager, SelectAreaDialog::class.java.simpleName) + f.show(childFragmentManager, "") } binding.tvSendCode.onClick { diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/home/zzdb/detail/ZZDBDetailFragment.kt b/app/src/main/java/com/cheng/bole/ui/fragment/home/zzdb/detail/ZZDBDetailFragment.kt index 4590357..2f60f8c 100644 --- a/app/src/main/java/com/cheng/bole/ui/fragment/home/zzdb/detail/ZZDBDetailFragment.kt +++ b/app/src/main/java/com/cheng/bole/ui/fragment/home/zzdb/detail/ZZDBDetailFragment.kt @@ -89,7 +89,7 @@ class ZZDBDetailFragment : BaseFragment() { + private val keyword by lazy { arguments?.getString("keyword") ?: "" } + private val tabText = listOf("全部", "服务", "产品", "其他") + private val fragmentList by lazy { mutableListOf() } + private val pageAdapter by lazy { + BasePageAdapter( + childFragmentManager, + tabText, + fragmentList, + FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT + ) + } + + private var city: AreaBean? = AreaBean(0, name = "全国") + + private val textWatcher = object : TextWatcherImpl() { + @SuppressLint("SetTextI18n") + override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { + binding.ivClearText.visibility = if (TextUtils.isEmpty(s)) View.GONE else View.VISIBLE + } + } + + override fun initView() { + super.initView() + initFragment() + binding.viewPager.adapter = pageAdapter + binding.viewPager.offscreenPageLimit = fragmentList.size + binding.tabLayout.setupViewPager(ViewPager1Delegate.install(binding.viewPager, binding.tabLayout)) + } + + private fun initFragment() { + fragmentList.add(MerchantGoodsListFragment.newInstance("")) + fragmentList.add(MerchantGoodsListFragment.newInstance("1")) + fragmentList.add(MerchantGoodsListFragment.newInstance("2")) + fragmentList.add(MerchantGoodsListFragment.newInstance("3")) + } + + override fun initData() { + super.initData() + binding.etSearch.setText(keyword) + fragmentList.forEach { + val fragment = it as MerchantGoodsListFragment + fragment.setKeyword(keyword) + } + } + + override fun initListener() { + super.initListener() + binding.etSearch.addTextChangedListener(textWatcher) + + binding.tvCity.onClick { + val f = SelectAreaDialog.newInstance(if (city != null) listOf(city!!) else emptyList(), true, showAll = true) + f.setOnSelectListener { + city = if (it.size == 1) it[0] else null + binding.tvCity.text = if (city != null) city!!.name else "全国" + fragmentList.forEach { f -> + val fragment = f as MerchantGoodsListFragment + fragment.setCity(if (city != null) "${city!!.id}" else "") + } + } + f.show(childFragmentManager, "") + } + + binding.ivClearText.onClick { + binding.etSearch.setText("") + } + + binding.etSearch.setOnEditorActionListener { _, _, event -> + if (event != null && event.keyCode == KeyEvent.KEYCODE_ENTER && event.action == KeyEvent.ACTION_DOWN) { + val keyword = binding.etSearch.text.toString().trim() + fragmentList.forEach { + val fragment = it as MerchantGoodsListFragment + fragment.setKeyword(keyword) + } + SearchHistoryManager.addHistory(keyword) + return@setOnEditorActionListener true + } + false + } + + binding.tabLayout.observeIndexChange { fromIndex, toIndex, _, _ -> + binding.viewPager.currentItem = toIndex + if (fromIndex != -1) { + (binding.tabLayout.getChildAt(fromIndex) as TextView).typeface = Typeface.DEFAULT + (binding.tabLayout.getChildAt(fromIndex) as TextView).setBackgroundResource(R.drawable.shape_push_bid_type_default) + } + (binding.tabLayout.getChildAt(toIndex) as TextView).typeface = Constants.douyinsansB + (binding.tabLayout.getChildAt(toIndex) as TextView).setBackgroundResource(R.drawable.shape_push_bid_type_checked) + EventReportManager.eventReport(EventConstants.GOODS_TYPE_CHECK, "", (binding.tabLayout.getChildAt(toIndex) as TextView).text.toString()) + } + } + + override fun initObserve() { + super.initObserve() + } + + override fun onDestroyView() { + binding.etSearch.removeTextChangedListener(textWatcher) + super.onDestroyView() + } } \ No newline at end of file diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsAdapter.kt b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsAdapter.kt new file mode 100644 index 0000000..32d59fb --- /dev/null +++ b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsAdapter.kt @@ -0,0 +1,32 @@ +package com.cheng.bole.ui.fragment.merchant.list + +import android.text.TextUtils +import android.widget.ImageView +import android.widget.TextView +import coil.load +import coil.transform.RoundedCornersTransformation +import com.chad.library.adapter.base.viewholder.BaseViewHolder +import com.cheng.bole.R +import com.cheng.bole.bean.MerchantGoodsBean +import com.cheng.bole.common.Constants +import com.example.base.ui.list.LoadMoreAdapter +import com.example.base.utils.DensityUtils + +class MerchantGoodsAdapter: LoadMoreAdapter(R.layout.listitem_merchant_goods) { + override fun convert(holder: BaseViewHolder, item: MerchantGoodsBean) { + if (item.file.isNotEmpty()) { + holder.getView(R.id.iv_cover).load(item.file[0].url){ + transformations(RoundedCornersTransformation(DensityUtils.dp2px(8f).toFloat())) + } + } + holder.setText(R.id.tv_name, item.goods_name) + holder.setText(R.id.tv_desc, item.goods_description) + holder.setText(R.id.tv_price, item.goods_price_show) + holder.setText(R.id.tv_location, if (TextUtils.isEmpty(item.city_name)) "全国" else item.city_name) + holder.setText(R.id.tv_company_avatar, item.company.company_name.take(2) + "\n" + item.company.company_name.substring(2, 4)) + holder.setText(R.id.tv_company_name, item.company.company_name) + holder.setText(R.id.tv_view_count, "已浏览${if (!TextUtils.isEmpty(item.view_count)) item.view_count else 0}") + holder.getView(R.id.tv_price).typeface = Constants.dDIN_PRO_M + holder.getView(R.id.tv_company_avatar).typeface = Constants.almmsht + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListFragment.kt b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListFragment.kt new file mode 100644 index 0000000..b84a7a6 --- /dev/null +++ b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListFragment.kt @@ -0,0 +1,92 @@ +package com.cheng.bole.ui.fragment.merchant.list + +import android.os.Bundle +import com.cheng.bole.R +import com.cheng.bole.bean.MerchantGoodsBean +import com.cheng.bole.databinding.FragmentMerchantGoodsListBinding +import com.cheng.bole.ui.activity.PublicActivity +import com.cheng.bole.ui.fragment.mine.vip.VipFragment +import com.example.base.decoration.FirstItemOffsetDecoration +import com.example.base.ui.list.ListFragment +import com.example.base.utils.DensityUtils + +class MerchantGoodsListFragment : ListFragment() { + private val type by lazy { arguments?.getString("type") ?: "" } + private val userId by lazy { arguments?.getString("userId") ?: "" } + + private var keyword: String = "" + + private var item: MerchantGoodsBean? = null + + companion object { + fun newInstance(type: String, userId: String = ""): MerchantGoodsListFragment { + val args = Bundle() + args.putString("type", type) + args.putString("userId", userId) + val fragment = MerchantGoodsListFragment() + fragment.arguments = args + return fragment + } + } + + override fun noDataClick() { + + } + + override fun bindAdapter() = MerchantGoodsAdapter() + + override fun initView() { + super.initView() + + binding.mRecyclerView.addItemDecoration(FirstItemOffsetDecoration(DensityUtils.dp2px(7f), FirstItemOffsetDecoration.top)) + mEmptyView.setNoDataLogo(R.mipmap.ic_empty_data) + mEmptyView.setNoDataText("暂无合作商") + } + + override fun initData() { + super.initData() + mViewModel.params["query"] = keyword + mViewModel.params["type"] = type + mViewModel.params["user_id"] = userId + firstLoad() + } + + override fun initListener() { + super.initListener() + mAdapter.setOnItemClickListener { _, _, i -> + item = mAdapter.getItem(i) + mViewModel.checkAuth() + } + } + + override fun initObserve() { + super.initObserve() + mViewModel.authLiveData.observe(this) { + if (it.auth) { +// PublicActivity.start(requireActivity(), SupplierGoodsDetailFragment::class.java, Pair("item", item)) + } else { + PublicActivity.start(requireContext(), VipFragment::class.java, Pair("origin", "view_goods")) + } + } + } + + + fun setKeyword(keyword: String) { + this.keyword = keyword + if (isResumed) { + mViewModel.params["query"] = keyword + mViewModel.params["type"] = type + mViewModel.params["user_id"] = userId + firstLoad() + } + } + + fun setCity(cityId: String) { + if (isResumed) { + mViewModel.params["city_id"] = cityId + mViewModel.params["type"] = type + mViewModel.params["user_id"] = userId + firstLoad() + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListViewModel.kt b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListViewModel.kt new file mode 100644 index 0000000..aee6965 --- /dev/null +++ b/app/src/main/java/com/cheng/bole/ui/fragment/merchant/list/MerchantGoodsListViewModel.kt @@ -0,0 +1,31 @@ +package com.cheng.bole.ui.fragment.merchant.list + +import androidx.collection.ArrayMap +import androidx.lifecycle.MutableLiveData +import com.cheng.bole.bean.MerchantGoodsBean +import com.cheng.bole.bean.UserAuthBean +import com.cheng.bole.net.ApiFactory +import com.cheng.bole.net.model.toListResult +import com.example.base.extensions.toast +import com.example.base.utils.L +import com.example.base.viewmodel.ListViewModel + +class MerchantGoodsListViewModel: ListViewModel() { + override suspend fun requestApi(params: ArrayMap): Result> { + return ApiFactory.apiService.searchSupplier(params).toListResult() + } + + val authLiveData = MutableLiveData() + + fun checkAuth() { + launchOnUiTryCatch({ + val response = ApiFactory.apiService.checkAuth() + if (response.status) { + authLiveData.postValue(response.data) + } else toast(response.message, true) + }, { + setError(it) + L.d(it) + }) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/cheng/bole/ui/fragment/push/list/PushListFragment.kt b/app/src/main/java/com/cheng/bole/ui/fragment/push/list/PushListFragment.kt index 22535c0..fd0825a 100644 --- a/app/src/main/java/com/cheng/bole/ui/fragment/push/list/PushListFragment.kt +++ b/app/src/main/java/com/cheng/bole/ui/fragment/push/list/PushListFragment.kt @@ -22,6 +22,7 @@ import com.example.base.decoration.FirstItemOffsetDecoration import com.example.base.ui.list.ListFragment import com.example.base.utils.DensityUtils import com.example.base.widget.PageStatus +import androidx.core.view.isNotEmpty class PushListFragment : ListFragment() { private val subId by lazy { arguments?.getString("subId") ?: "" } @@ -107,7 +108,7 @@ class PushListFragment : ListFragment + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_merchant_goods_list.xml b/app/src/main/res/layout/fragment_merchant_goods_list.xml new file mode 100644 index 0000000..45d7d43 --- /dev/null +++ b/app/src/main/res/layout/fragment_merchant_goods_list.xml @@ -0,0 +1,21 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/listitem_merchant_goods.xml b/app/src/main/res/layout/listitem_merchant_goods.xml new file mode 100644 index 0000000..d07b709 --- /dev/null +++ b/app/src/main/res/layout/listitem_merchant_goods.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xxhdpi/ic_company_name_avater_bg.webp b/app/src/main/res/mipmap-xxhdpi/ic_company_name_avater_bg.webp new file mode 100644 index 0000000..7975eca Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_company_name_avater_bg.webp differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_merchant_top_bg.webp b/app/src/main/res/mipmap-xxhdpi/ic_merchant_top_bg.webp new file mode 100644 index 0000000..88bc4c9 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_merchant_top_bg.webp differ