Browse Source

feat: invite log

tongmengxiao 7 tháng trước cách đây
mục cha
commit
d5d6bc15d4

+ 2 - 2
baseswago/src/main/java/com/swago/baseswago/dialog/InviteBindingDialog.kt

@@ -35,8 +35,8 @@ class InviteBindingDialog : BaseXDFragment<DialogInviteBindingBinding>() {
     }
 
     override fun initOther() {
-        arguments?.let {
-            bindAnchorData = it.getParcelable("data")
+        arguments?.let { bundle ->
+            bindAnchorData = bundle.getParcelable("data")
             bindAnchorData?.let {
                 binding.tvInviteDetail.text =
                     AppContext.getContext().resources.getString(R.string.invites_you_to_join_his_guild)

+ 8 - 0
baseswago/src/main/java/com/swago/baseswago/inter/HomeApi.kt

@@ -2,6 +2,7 @@ package com.swago.baseswago.inter
 
 import com.swago.baseswago.model.home.BannerModel
 import com.swago.baseswago.model.home.HomeModel
+import com.swago.baseswago.model.home.InviteLogModel
 import com.swago.baseswago.model.home.OfficialMsgModel
 import com.swago.baseswago.model.home.OfficialSumModel
 import okhttp3.ResponseBody
@@ -53,4 +54,11 @@ interface HomeApi {
     @GET
     suspend fun downFile(@Url fileUrl: String): Response<ResponseBody>
 
+    /**
+     * 用户主播邀请记录
+     *
+     */
+    @POST("/v1/user/last/invite/log")
+    suspend fun getInviteLog():InviteLogModel
+
 }

+ 24 - 0
baseswago/src/main/java/com/swago/baseswago/model/home/InviteLogModel.java

@@ -0,0 +1,24 @@
+package com.swago.baseswago.model.home;
+
+import com.swago.baseswago.model.MomentModel;
+import com.swago.baseswago.model.im.BindAnchorData;
+
+import java.util.List;
+
+/**
+ * @date 2021/11/28 10:25
+ * description:
+ */
+public class InviteLogModel {
+
+
+    private List<BindAnchorData> list;
+
+    public List<BindAnchorData> getList() {
+        return list;
+    }
+
+    public void setList(List<BindAnchorData> list) {
+        this.list = list;
+    }
+}

+ 13 - 4
home/src/main/java/com/swago/home/HomeActivity.kt

@@ -4,12 +4,10 @@ import android.text.TextUtils
 import android.widget.Toast
 import androidx.activity.viewModels
 import androidx.fragment.app.FragmentActivity
-import androidx.fragment.app.viewModels
 import androidx.lifecycle.lifecycleScope
 import androidx.viewpager.widget.ViewPager
 import com.alibaba.android.arouter.facade.annotation.Route
 import com.android.billingclient.api.Purchase
-import com.google.gson.Gson
 import com.swago.baseswago.PayVm
 import com.swago.baseswago.SwagoAdapter
 import com.swago.baseswago.UserVm
@@ -17,7 +15,6 @@ import com.swago.baseswago.activity.BaseXActivity
 import com.swago.baseswago.constant.ARouteConstant
 import com.swago.baseswago.constant.UrlConstant
 import com.swago.baseswago.dialog.CloseAccountDialog
-import com.swago.baseswago.dialog.ForceOfflineDialog
 import com.swago.baseswago.dialog.InviteBindingDialog
 import com.swago.baseswago.dialog.OrderLostDialog
 import com.swago.baseswago.im.GroupMsgParser
@@ -62,7 +59,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
         TUIKit.init(this, UrlConstant.getImId(), TUIKitConfigs.getConfigs())
         PayManager.init()
         IMMessageManager.groupMessageParser.add(GroupMsgParser())
-
+        SpUtil.putInt("isHomeBack" , 1)
         //检查版本更新
         checkVersionForUpdate()
 
@@ -203,6 +200,12 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
                 CloseAccountDialog.newInstance().show(currentActivity.supportFragmentManager,"CloseAccountDialog")
             }
         }
+
+        homeVm.inviteLogData.observe(this){
+            if (!it.isNullOrEmpty()){
+                InviteBindingDialog.newInstance(it[0]).show(supportFragmentManager,"InviteBindingDialog")
+            }
+        }
     }
 
     override fun onResume() {
@@ -211,6 +214,11 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
         if (!IMUtil.checkIsLogin()) {
             IMUtil.joinGroup(loginFun)
         }
+        val isHomeBack = SpUtil.readInt("isHomeBack")
+        if (isHomeBack == 1){
+            homeVm.getInviteLog()
+            SpUtil.putInt("isHomeBack" , 0)
+        }
     }
 
     override fun onPause() {
@@ -269,6 +277,7 @@ class HomeActivity : BaseXActivity<ActivityHomeBinding>(), IPayCallback {
     override fun toCreateNewOrder(productId: String) {}
 
     override fun onBackPressed() {
+        SpUtil.putInt("isHomeBack" , 1)
         moveTaskToBack(true)
     }
 

+ 12 - 0
home/src/main/java/com/swago/home/innerhome/HomeVm.kt

@@ -115,4 +115,16 @@ class HomeVm(application: Application) : BaseViewModel(application) {
         }
     }
 
+    val inviteLogData by lazy {
+        MutableLiveData<List<BindAnchorData>?>()
+    }
+    fun getInviteLog(){
+        requestData2 (false){
+            requestData {
+                val inviteLog = ApiManager.homeApi.getInviteLog()
+                inviteLogData.value = inviteLog.list
+            }
+        }
+    }
+
 }