Zhou.xiaoning 3 anni fa
parent
commit
12a868cbb9

+ 51 - 120
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/xhcp/XhcpHomeFragment.kt

@@ -14,6 +14,7 @@ import android.widget.FrameLayout
 import android.widget.TextView
 import android.widget.ViewFlipper
 import androidx.cardview.widget.CardView
+import androidx.fragment.app.Fragment
 import androidx.recyclerview.widget.RecyclerView
 import androidx.viewpager.widget.PagerAdapter
 import androidx.viewpager.widget.ViewPager
@@ -22,6 +23,7 @@ import cn.muchinfo.rma.R
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.BannerData
 import cn.muchinfo.rma.global.data.NoticeData
+import cn.muchinfo.rma.global.data.SiteColumnDetailData
 import cn.muchinfo.rma.lifecycle.bindOptional
 import cn.muchinfo.rma.view.autoWidget.*
 import cn.muchinfo.rma.view.base.BaseFragment
@@ -29,8 +31,11 @@ import cn.muchinfo.rma.view.base.WebActivity
 import cn.muchinfo.rma.view.base.app.Constant
 import cn.muchinfo.rma.view.base.future.trade.itemView
 import cn.muchinfo.rma.view.base.hnstmain.performance.PerformanceInformationActivity
+import cn.muchinfo.rma.view.base.home.HomeViewModel
+import cn.muchinfo.rma.view.base.home.NewInformationUI
 import cn.muchinfo.rma.view.base.home.yrdz.YrAnnouncementUI
 import cn.muchinfo.rma.view.base.home.yrdz.YrdzNoticeActivity
+import cn.muchinfo.rma.view.base.qhjhome.QhjInformationViewHolder
 import cn.muchinfo.rma.view.eventbus.MainTabSelectMessageEvent
 import com.blankj.utilcode.util.ActivityUtils
 import com.blankj.utilcode.util.ConvertUtils
@@ -43,6 +48,7 @@ import com.qmuiteam.qmui.widget.tab.QMUITabSegment
 import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.GlobalScope
 import kotlinx.coroutines.launch
+import mtp.polymer.com.autowidget.adapter.BaseAdapter
 import mtp.polymer.com.information_management.hnstocks.message.MessageDetailsActivity
 import org.greenrobot.eventbus.EventBus
 import org.jetbrains.anko.*
@@ -79,6 +85,7 @@ class XhcpHomeFragment : BaseFragment<XhcpHomeViewModel>(){
             viewModel
         )
     }//公告
+    private val informationUI: XhcpInformationUI by lazy { XhcpInformationUI(this, viewModel) }//咨讯
 
     val thisTag by lazy {
         "XhcpHomeFragment"
@@ -94,6 +101,8 @@ class XhcpHomeFragment : BaseFragment<XhcpHomeViewModel>(){
     private val uiMessageList: ArrayList<_FrameLayout> = arrayListOf()
 
     fun initMessageMenuData() {
+        tabsArray.add("资讯")
+        uiMessageList.add(informationUI.root)
         tabsArray.add("公告")
         uiMessageList.add(xhcpAnnouncementUI.root)
 
@@ -256,126 +265,6 @@ class XhcpHomeFragment : BaseFragment<XhcpHomeViewModel>(){
 
                             itemView()
 
-                            linearLayout {
-                                gravity = Gravity.CENTER_VERTICAL
-                                imageView {
-                                    imageResource = R.mipmap.yrdz_nctice_icon
-                                }.lparams(autoSize(36), autoSize(36)){
-                                    marginStart = autoSize(36)
-                                }
-
-                                viewFlipper {
-                                    noticeViewFlipper = this
-                                    viewModel.noticeDataList.bindOptional(context){
-                                        if (it?.size ?: 0 > 0){
-                                            val newDataList = arrayListOf<NoticeData>()
-                                            newDataList.add(it?.get(0) ?: NoticeData())
-                                            initViewFlipper(newDataList)
-                                        }
-                                    }
-                                }.lparams(matchParent, autoSize(72)){
-                                    marginStart = autoSize(36)
-                                }
-
-                            }.lparams(matchParent, autoSize(72))
-
-                            itemView()
-
-                            linearLayout {
-                                val tjmdMarketList = GlobalDataCollection.instance?.getTjmdShowMarketSectionList()
-                                tjmdMarketList?.forEach { data ->
-                                    relativeLayout {
-                                        verticalLayout {
-                                            onThrottleFirstClick {
-                                                EventBus.getDefault().post(MainTabSelectMessageEvent(tjmdMarketList.indexOf(data).plus(1)))
-                                            }
-
-                                            imageView {
-                                                if (data.pictureurl != null && data.pictureurl.isNotEmpty()) {
-                                                    showImage(
-                                                        SPUtils.getInstance().getString(
-                                                            Constant.uploadUrl).replace("/upload","") + data.pictureurl.substring(1))
-                                                }
-                                            }.lparams(autoSize(72), autoSize(72)) {
-                                                gravity = Gravity.CENTER_HORIZONTAL
-                                            }
-
-                                            textView {
-                                                text = data.marketsectionname
-                                                textColorInt = R.color.black
-                                                textSizeAuto = 26
-                                            }.lparams(wrapContent, wrapContent) {
-                                                topMargin = autoSize(20)
-                                                gravity = Gravity.CENTER_HORIZONTAL
-                                            }
-                                        }.lparams(matchParent, matchParent)
-
-                                        textView {
-                                            visibility = View.GONE
-                                            textColorInt = R.color.p_global_write_color
-                                            textSizeAuto = 15
-                                            setPadding(
-                                                autoSize(10),
-                                                autoSize(6),
-                                                autoSize(10),
-                                                autoSize(6)
-                                            )
-                                            backgroundDrawable =
-                                                createRoundRectDrawable("#fe671a", 45)
-                                        }.lparams(wrapContent, wrapContent) {
-                                            marginStart = autoSize(130)
-                                        }
-                                    }.lparams(autoSize(225), matchParent)
-                                }
-                                //参考行情
-
-                                relativeLayout {
-                                    verticalLayout {
-                                        onThrottleFirstClick {
-                                            val intent = Intent()
-                                            intent.setClass(
-                                                context,
-                                                PerformanceInformationActivity::class.java
-                                            )
-                                            ActivityUtils.startActivity(intent)
-                                        }
-                                        imageView {
-                                            imageResource = R.mipmap.main_business_5
-                                        }.lparams(autoSize(72), autoSize(72)) {
-                                            gravity = Gravity.CENTER_HORIZONTAL
-                                        }
-
-                                        textView {
-                                            text = "履约管理"
-                                            textColorInt = R.color.black
-                                            textSizeAuto = 26
-                                        }.lparams(wrapContent, wrapContent) {
-                                            topMargin = autoSize(20)
-                                            gravity = Gravity.CENTER_HORIZONTAL
-                                        }
-                                    }.lparams(matchParent, matchParent)
-
-                                    textView {
-                                        visibility = View.GONE
-                                        textColorInt = R.color.p_global_write_color
-                                        textSizeAuto = 15
-                                        setPadding(
-                                            autoSize(10),
-                                            autoSize(6),
-                                            autoSize(10),
-                                            autoSize(6)
-                                        )
-                                        backgroundDrawable =
-                                            createRoundRectDrawable("#fe671a", 45)
-                                    }.lparams(wrapContent, wrapContent) {
-                                        marginStart = autoSize(130)
-                                    }
-                                }.lparams(autoSize(225), matchParent)
-
-                            }.lparams(matchParent, autoSize(140)) {
-                                topMargin = autoSize(40)
-                            }
-
                             view {
                                 background = resources.getDrawable(R.color.rma_hint_line_color_eee)
                             }.lparams(matchParent, autoSize(20))
@@ -427,4 +316,46 @@ class XhcpHomeFragment : BaseFragment<XhcpHomeViewModel>(){
             }
         }.view
     }
+}
+
+/**
+ * 咨讯
+ */
+class XhcpInformationUI(private val baseFragment: Fragment, private val viewModule: XhcpHomeViewModel) {
+    private lateinit var swipeToLayout: SwipeToLoadLayout
+    private lateinit var statusLayout: StatusLayout
+
+    lateinit var recyclerView: RecyclerView
+
+    private val informationAdapter: BaseAdapter<SiteColumnDetailData, XhcpInformationViewHolder> =
+        BaseAdapter { _, _ -> XhcpInformationViewHolder(baseFragment, viewModule) }
+    val root = _FrameLayout(baseFragment.context!!).apply {
+        verticalLayout {
+            viewModule.querySiteColumnDetail()
+            statusLayout(contentBlock = {
+                statusLayout = this
+//                bindTaskStatus(viewModule.status)
+                swipeToLoadLayout {
+                    swipeToLayout = this
+                    setEnableRefresh(false)
+                    setEnableLoadMore(false)
+                    setEnableScrollContentWhenLoaded(false)
+                    setEnableLoadMoreWhenContentNotFull(false)
+                    recyclerView {
+                        background = resources.getDrawable(R.color.white)
+                        adapter = informationAdapter
+                        isNestedScrollingEnabled = false
+                    }.lparams(matchParent, matchParent) {
+                        marginStart = autoSize(32)
+                        marginEnd = autoSize(20)
+                    }
+                }
+            }, emptyBlock = {
+                emptyView(hint = resources.getString(R.string.now_no_data))
+            }).lparams(matchParent, matchParent)
+            viewModule.SiteColumnDetailList.bindOptional(context) {
+                informationAdapter.setNewData(it)
+            }
+        }
+    }
 }

+ 20 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/xhcp/XhcpHomeViewModel.kt

@@ -4,6 +4,7 @@ import androidx.lifecycle.MutableLiveData
 import cn.muchinfo.rma.global.GlobalDataCollection
 import cn.muchinfo.rma.global.data.BannerData
 import cn.muchinfo.rma.global.data.NoticeData
+import cn.muchinfo.rma.global.data.SiteColumnDetailData
 import cn.muchinfo.rma.global.data.account.loginQeruy.GoodsInfo
 import cn.muchinfo.rma.global.data.chart.HistoryDatas
 import cn.muchinfo.rma.global.database.DataBase
@@ -36,6 +37,11 @@ class XhcpHomeViewModel : BaseViewModel(){
      */
     val noticeDataList : MutableLiveData<List<NoticeData>> = MutableLiveData()
 
+    /**
+     * 咨询信息
+     */
+    val SiteColumnDetailList : MutableLiveData<List<SiteColumnDetailData>> = MutableLiveData()
+
     fun setOnItemClick() {
 
     }
@@ -61,6 +67,20 @@ class XhcpHomeViewModel : BaseViewModel(){
     }
 
     /**
+     * 查询咨询
+     */
+    fun querySiteColumnDetail(){
+        val params = mutableMapOf<String,String>().apply {
+            put("userid",GlobalDataCollection.instance?.loginRsp?.userID.toString())
+        }
+        MyApplication.getInstance()?.commonManager?.querySiteColumnDetail(params = params){isSuccess, respData, error ->
+            if (isSuccess){
+                SiteColumnDetailList.postValue(respData)
+            }
+        }
+    }
+
+    /**
      * 在请求之前先获取数据库存储的banner信息
      */
     fun getBanner(){

+ 96 - 0
RMA/app/src/main/java/cn/muchinfo/rma/view/base/home/xhcp/XhcpInformatViewHolder.kt

@@ -0,0 +1,96 @@
+package cn.muchinfo.rma.view.base.home.xhcp
+
+import android.content.Intent
+import android.graphics.Typeface
+import android.text.TextUtils
+import android.view.Gravity
+import android.view.View
+import androidx.fragment.app.Fragment
+import cn.muchinfo.rma.R
+import cn.muchinfo.rma.global.data.SiteColumnDetailData
+import cn.muchinfo.rma.lifecycle.bindOptional
+import cn.muchinfo.rma.view.autoWidget.autoSize
+import cn.muchinfo.rma.view.autoWidget.onThrottleFirstClick
+import cn.muchinfo.rma.view.autoWidget.textColorInt
+import cn.muchinfo.rma.view.autoWidget.textSizeAuto
+import cn.muchinfo.rma.view.base.home.InformationDetailsActivity
+import com.blankj.utilcode.util.ActivityUtils
+import mtp.polymer.com.autowidget.adapter.BaseViewHolder
+import org.jetbrains.anko.*
+
+class XhcpInformationViewHolder(
+    private val baseFragment: Fragment,
+    private val viewModel: XhcpHomeViewModel
+) : BaseViewHolder<SiteColumnDetailData>(baseFragment.context!!) {
+    override val itemSize: IntArray = intArrayOf(matchParent, autoSize(160))
+
+    override fun _FrameLayout.createContentView() {
+        verticalLayout {
+
+            onThrottleFirstClick {
+                val intent = Intent()
+                intent.putExtra("data",data.value)
+                intent.setClass(context, InformationDetailsActivity::class.java)
+                ActivityUtils.startActivity(intent)
+            }
+
+            linearLayout {
+                imageView {
+                    data.bindOptional(context){
+                        visibility = View.GONE
+                    }
+                }.lparams(autoSize(56), autoSize(41)) {
+                    marginStart = autoSize(32)
+                }
+
+                textView {
+                    data.bindOptional(context){
+                        text = it?.title
+                    }
+                    maxEms = 14
+                    maxLines = 1
+                    ellipsize = TextUtils.TruncateAt.END
+                    typeface = Typeface.defaultFromStyle(Typeface.BOLD)
+                    textColorInt = R.color.black
+                    textSizeAuto = 34
+                }.lparams(wrapContent, wrapContent) {
+                    marginStart = autoSize(14)
+                }
+
+                view { }.lparams(0, autoSize(1), 1f)
+
+                textView {
+                    data.bindOptional(context){
+                        text = it?.publishdate
+                    }
+                    textColorInt = R.color.text_hit_color
+                    textSizeAuto = 26
+                }.lparams(wrapContent, wrapContent) {
+                    gravity = Gravity.CENTER_VERTICAL
+                    marginEnd = autoSize(32)
+                }
+
+            }.lparams(matchParent, wrapContent) {
+                topMargin = autoSize(30)
+            }
+
+            textView {
+                maxLines = 1
+                ellipsize = TextUtils.TruncateAt.END
+                data.bindOptional(context){
+                    text = it?.brief
+                }
+                textColorInt = R.color.text_hint_color_two
+                textSizeAuto = 26
+            }.lparams(matchParent, wrapContent) {
+                marginStart = autoSize(36)
+                topMargin = autoSize(20)
+            }
+            view { }.lparams(autoSize(1), 0, 1f)
+            view {
+                background = resources.getDrawable(R.color.main_hit_bg_color)
+            }.lparams(matchParent, autoSize(1))
+        }.lparams(matchParent, autoSize(160))
+    }
+
+}