Zhou.xiaoning 3 年 前
コミット
ba49704f1d

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

@@ -266,6 +266,21 @@ class XhcpHomeFragment : BaseFragment<XhcpHomeViewModel>(){
 
                             itemView()
 
+                            // 推广图片
+                            viewModel.imageList.bindOptional(context) {
+                                it?.forEachIndexed { index, bannerData ->
+                                    imageView {
+                                        if (bannerData.imagepath != null && bannerData.imagepath.isNotEmpty()) {
+                                            showImage(SPUtils.getInstance().getString(Constant.uploadUrl).replace("/upload","") + bannerData.imagepath.substring(1))
+                                        }
+                                    }.lparams(autoSize(72), autoSize(72)) {
+                                        gravity = Gravity.CENTER_HORIZONTAL
+                                    }
+                                }
+                            }
+
+                            itemView()
+
                             view {
                                 background = resources.getDrawable(R.color.rma_hint_line_color_eee)
                             }.lparams(matchParent, autoSize(20))

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

@@ -30,9 +30,17 @@ class XhcpHomeViewModel : BaseViewModel(){
      */
     val loadingDialogStatus: MutableLiveData<TaskUiModel> = MutableLiveData()
 
+    /**
+     * 首页广告
+     */
     val bannerList : MutableLiveData<List<BannerData>> = MutableLiveData()
 
     /**
+     * 推广图片
+     */
+    var imageList: MutableLiveData<List<BannerData>> = MutableLiveData()
+
+    /**
      * 公告信息
      */
     val noticeDataList : MutableLiveData<List<NoticeData>> = MutableLiveData()
@@ -85,7 +93,8 @@ class XhcpHomeViewModel : BaseViewModel(){
      */
     fun getBanner(){
         val params = mutableMapOf<String,String>()
-        params.put("imageType","1")
+        // 获取目标:1,4
+//        params.put("imageType","1")
         MyOkHttpUtils().query(URL = SPUtils.getInstance().getString(Constant.goCommonSearchUrl) + "/Common/QueryImageConfigs",
             callback = object : ResponseCallback<BaseResult<List<BannerData>>>() {
                 override fun onResponse(response: BaseResult<List<BannerData>>?, id: Int) {
@@ -103,17 +112,28 @@ class XhcpHomeViewModel : BaseViewModel(){
      * @param datalist List<BannerEntity>
      */
     fun getBannerUrlList(datalist : List<BannerData>){
-        val bannerUrlList = arrayListOf<String>()
-        datalist.forEach {
-            if (SPUtils.getInstance().getString(Constant.uploadUrl).contains("upload")){
-
-                bannerUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl).replace("/upload","") + it.imagepath.substring(1))
-            }else{
-                bannerUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl) + it.imagepath.substring(1))
-            }
-        }
+//        val bannerUrlList = arrayListOf<String>()
+//        val imageUrlList = arrayListOf<String>()
+//        datalist.forEach {
+//            if (SPUtils.getInstance().getString(Constant.uploadUrl).contains("upload")){
+//                if (it.imagetype == "1") {
+//                    bannerUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl).replace("/upload","") + it.imagepath.substring(1))
+//                } else if (it.imagetype == "4") {
+//                    imageUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl).replace("/upload","") + it.imagepath.substring(1))
+//                }
+//            }else{
+//                if (it.imagetype == "1") {
+//                    bannerUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl) + it.imagepath.substring(1))
+//                } else if (it.imagetype == "4") {
+//                    imageUrlList.add(SPUtils.getInstance().getString(Constant.uploadUrl) + it.imagepath.substring(1))
+//                }
+//            }
+//        }
         bannerList.postValue(datalist.remove {
-            it.isshow == "0"
+            it.isshow == "0" || it.imagetype != "1"
+        })
+        imageList.postValue(datalist.remove {
+            it.isshow == "0" || it.imagetype != "4"
         })
     }
 }