Commit a8e1526b by 范玉宾

add minetipviewmodel

parent 4be77c5d
package com.yidianling.user
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
class MineTipViewModel : ViewModel() {
var show = MutableLiveData<Boolean>()
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import android.os.Bundle
import android.text.TextUtils
import android.view.View
import androidx.core.content.ContextCompat
import androidx.fragment.app.activityViewModels
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.ydl.course.api.ICourseService
import com.ydl.webview.H5Params
......@@ -34,6 +35,7 @@ import com.yidianling.dynamic.api.IDynamicService
import com.yidianling.im.api.service.IImService
import com.yidianling.im.message.param.MsgListParam
import com.yidianling.user.BuildConfig
import com.yidianling.user.MineTipViewModel
import com.yidianling.user.R
import com.yidianling.user.UserHelper.getUserInfo
import com.yidianling.user.UserHelper.getUsetSetting
......@@ -202,6 +204,7 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
refreshCouponData()
}
private val model:MineTipViewModel = MineTipViewModel()
private fun getConfideOrder(uid: String) {
MineHttpImpl.getInstance().getHasConfideOrder(uid)
......@@ -213,30 +216,48 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
if (response.data.listenOrder == true) {
iv_confide_tip.visibility = View.VISIBLE
getLocal().setConfide(true)
model.show.postValue(true)
} else {
iv_confide_tip.visibility = View.GONE
getLocal().setConfide(false)
model.show.postValue(false)
}
if (response.data.consultOrder == true) {
iv_order_tip.visibility = View.VISIBLE
getLocal().setConsult(true)
model.show.postValue(true)
} else {
iv_order_tip.visibility = View.GONE
getLocal().setConfide(false)
model.show.postValue(false)
}
}else{
getLocal().setConfide(false)
getLocal().setConsult(false)
model.show.postValue(false)
}
}else{
getLocal().setConfide(false)
getLocal().setConsult(false)
model.show.postValue(false)
}
},{
getLocal().setConfide(false)
getLocal().setConsult(false)
model.show.postValue(false)
})
}
......@@ -250,6 +271,8 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
getLocal().setConfide(false)
getLocal().setConsult(false)
model.show.postValue(false)
val userInfo = getUserInfo() ?: return
if (userInfo.uid != null) {
......@@ -266,15 +289,19 @@ class MineFragment : BaseFragment(), SwipeRefreshLayout.OnRefreshListener, View.
if (response.data?.count ?: 0 > 0) {
view_new_coupon.visibility = View.VISIBLE
getLocal().setCoupon(true)
model.show.postValue(true)
} else {
view_new_coupon.visibility = View.GONE
getLocal().setCoupon(false)
model.show.postValue(false)
}
}else{
getLocal().setCoupon(false)
model.show.postValue(false)
}
}) { throwable: Throwable? ->
getLocal().setCoupon(false)
model.show.postValue(false)
}
}
......
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