Commit 4ccca7e1 by Wyh

1、外送顯示訂單數量不正確問題

parent 90585346
......@@ -48,6 +48,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
companion object {
//0,1
var fragmentStatus = arrayOf("0,1,2,3,8", "0,1", "2", "3", "3")
//訂單類型:0為所有,2是外送,7是自取。
//第四個為2(外送),是因為第四個頁面是“送貨中”,只有外送有
//第五個為7(自取),因為第五個頁面是待取餐,只有自取有
......@@ -121,7 +122,6 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
launch({
repository.getOrderGroup(restaurantId.toString()).apply {
//先把所有置0
mOrderNum = ArrayList(5)
for (i in mOrderNum) {
i.value = 0
}
......@@ -129,11 +129,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
for (i in data.selfTakeaway) {
when (i.STATUS) {
0 -> //未支付的待確認
if (mOrderNum.size > 1) {
mOrderNum[1].value = mOrderNum[1].value?.plus(i.SumNum)
} else {
mOrderNum[1] = MutableLiveData(i.SumNum)
}
mOrderNum[1].value = mOrderNum[1].value?.plus(i.SumNum)
1 -> //已支付的待確認
mOrderNum[1].value = mOrderNum[1].value?.plus(i.SumNum)
2 -> //製作中
......@@ -159,7 +155,7 @@ class PageViewModel(private val repository: WeatherRepository) : ViewModel() {
num += i.value!!
}
}
mOrderNum[0] = MutableLiveData(num)
mOrderNum[0].value = num
}
}, {
it.printStackTrace()
......
......@@ -111,8 +111,8 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
initAppTop()
//初始化切換餐廳狀態
initSwitchRestStatus()
initTabs()
initViewPager()
initTabs()
//搜索
searchMethod()
//獲取餐廳營業信息展示欄的高度
......@@ -135,6 +135,8 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
getBalance(RestaurantInfoManager.newInstance().brandId)
//第一次獲取數據
getCurrentPageOrderList()
//獲取每個狀態的訂單數量
pageViewModel.getOrderGroupNum()
//餐廳營業信息刷新監聽
restaurantBusinessInfo.observe(this@DeliveryOrderMainActivity, Observer {
binding.data = it
......@@ -460,6 +462,8 @@ class DeliveryOrderMainActivity : BaseActivity<IPresenter>(), View.OnClickListen
}
//獲取每個狀態的訂單數量
pageViewModel.getOrderGroupNum()
//查詢預約單和即時單數量
pageViewModel.getOrderStatistics(fragmentStatus[view_pager.currentItem])
}
}
})
......
......@@ -285,7 +285,7 @@ object OtherOrderUtils {
private var soundPool: SoundPool? = null
var lastTime: Long = 0
private var lastTime: Long = 0
fun initSoundPool(context: Context, resId: Int) {
//限制10秒提示一次
if (System.currentTimeMillis() - lastTime < 10 * 1000) {
......
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