Commit f27f2ce8 authored by 刘用法's avatar 刘用法

订单徽标和下拉刷新

parent ab1f0f76
......@@ -282,26 +282,26 @@
"list": [
{
"pagePath": "pages/index/index",
"iconPath": "static/logo.png",
"selectedIconPath": "static/logo.png",
"iconPath": "static/tab/shouye-1@3x.png",
"selectedIconPath": "static/tab/shouye-1@3x.png",
"text": "首页"
},
{
"pagePath": "pages/order/index",
"iconPath": "static/logo.png",
"selectedIconPath": "static/logo.png",
"iconPath": "static/tab/dingdan-0@3x.png",
"selectedIconPath": "static/tab/dingdan-1@3x.png",
"text": "订单"
},
{
"pagePath": "pages/learn/index",
"iconPath": "static/logo.png",
"selectedIconPath": "static/logo.png",
"iconPath": "static/tab/xuexi-0@3x.png",
"selectedIconPath": "static/tab/xuexi-1@3x.png",
"text": "学习"
},
{
"pagePath": "pages/mine/index",
"iconPath": "static/logo.png",
"selectedIconPath": "static/logo.png",
"iconPath": "static/tab/wode-0@3x.png",
"selectedIconPath": "static/tab/wode-0@3x.png",
"text": "我的"
}
]
......
......@@ -125,7 +125,9 @@
return process.uniEnv.qn_base_url + 'weiruzhu.png'
},
},
onLoad() {},
onLoad() {
this.getOrderCount()
},
onShow() {
// 每次进入页面都刷新入驻状态
if (this.vuex_token) {
......@@ -274,6 +276,29 @@
});
}
},
// 获取订单数量
getOrderCount() {
var self = this; // 加载订单列表
self.$u.api.listOrderCount().then((res) => {
if (res.code == 200) {
console.log("===", res.data)
if (res.data) {
var count = 0
for (var i in res.data) {
count += res.data[i]
}
// 修改tab总数
uni.setTabBarBadge({
index: 1,
text: String(count)
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
});
},
},
};
</script>
......
......@@ -18,16 +18,21 @@
bar-width="44" :offset="[0,0]" :list="list" count="total" :current="current" @change="change"
:is-scroll="false" font-size="28" bold></u-tabs>
</view>
<NoOrder v-if="noMore" customStyle="margin-top: 100rpx;background-color: #F4F5F7" />
<view v-else class="tab-view">
<view class="tab-view">
<!-- <swiper-item class="swiper-item" v-for="(res, ind) in orderList" :key="ind"> -->
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom" scroll-anchoring>
<view v-for="(item, index) in orderList" :key="item.orderId">
<OrderCell :orderData="item" :type="orderType" :location="dataValue" @click="handleClick(item)"
@action="handleAction(item)"> </OrderCell>
</view>
<u-loadmore :status="loadStatus" bgColor="#F4F5F7"></u-loadmore>
<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom" scroll-anchoring
scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered" :refresher-threshold="100"
refresher-background="#F4F5F7" @refresherpulling="triggered = true" @refresherrefresh="onRefresh"
@refresherrestore="onRestore" @refresherabort="onAbort">
<NoOrder v-if="noMore" customStyle="margin-top: 100rpx;background-color: #F4F5F7" />
<template v-else>
<view v-for="(item, index) in orderList" :key="item.orderId">
<OrderCell :orderData="item" :type="orderType" :location="dataValue" @click="handleClick(item)"
@action="handleAction(item)"> </OrderCell>
</view>
<u-loadmore :status="loadStatus" bgColor="#F4F5F7"></u-loadmore>
</template>
</scroll-view>
<!-- </swiper-item> -->
</view>
......@@ -80,16 +85,19 @@
current: 0,
loadStatus: 'loading',
dataValue: [],
loaded: false
loaded: false,
triggered: false,
_freshing: false,
};
},
onLoad() {
onLoad() {
this._freshing = false;
this.getLocation();
// this.getOrderCount();
this.getOrderList(0);
},
onShow() {
this.getOrderCount()
},
onShow() {
this.getOrderCount()
},
computed: {
subList() {
......@@ -137,7 +145,7 @@
this.pageNumber = 0
this.orderList = []
this.loadStatus = 'loading'
this.getOrderList(index === 0 ? this.currentIndex : 5)
this.getOrderList(this.currentIndex)
},
// tab栏切换
change(index) {
......@@ -190,7 +198,7 @@
/*↓↓↓↓↓↓↓↓↓↓测试数据↓↓↓↓↓↓↓↓↓↓*/
res.data.type = self.orderType
if (res.data.list) {
if (res.data.list.length == 0 && res.data.total > 0) {
if (res.data.list.length == 0 && res.data.total > 0) {
res.data.total = 15
res.data.list = [{
orderServiceType: '安装', // 服务类型:安装、维修
......@@ -210,12 +218,13 @@
submissionTime: '2021.04.19 16:24:48', // 提交时间
auditResults: {}, // 审核结果
orderBusinessType: 'R', // 业务类型 R 为抢单
orderId:'1100000216'
}]
res.data.list = [...res.data.list, ...res.data.list, ...res.data.list, ...res.data
.list,
...res.data.list, ...res.data.list, ...res.data.list, ...res.data.list, ...res
.data.list, ...res.data.list
orderId: '1100000216'
}]
res.data.list = [...res.data.list, ...res.data.list, ...res.data.list, ...res.data
.list,
...res.data.list, ...res.data.list, ...res.data.list, ...res.data.list, ...
res
.data.list, ...res.data.list
]
}
}
......@@ -223,6 +232,8 @@
// 后台需要返回type,防止数据返回延迟期间点击了其他的tab
if (res.data.type != self.orderType) return
self.triggered = false;
self._freshing = false;
if (res.data.list) {
self.orderList.push(...res.data.list)
if (self.list[self.types[res.data.type]]) {
......@@ -245,6 +256,7 @@
if (res.code == 200) {
console.log("===", res.data)
if (res.data) {
var count = 0
self.list.forEach(item => {
if (item.name === '待预约') {
item.count = res.data.toAppointmentCount
......@@ -258,9 +270,16 @@
item.count = res.data.exceptionCount
}
})
}
// 修改tab总数
// ...
var count = 0
for (var i in res.data) {
count += res.data[i]
}
// 修改tab总数
uni.setTabBarBadge({
index: 1,
text: String(count)
})
}
} else {
console.log(res.message, "获取订单数量失败!");
}
......@@ -283,6 +302,25 @@
uni.navigateTo({
url: 'pages/order/search'
})
},
onPulling(e) {
console.log("onpulling", e);
},
onRefresh() {
if (this._freshing) return;
this._freshing = true;
this.pageNumber = 0
this.orderList = []
this.loadStatus = 'loading'
this.getOrderCount();
this.getOrderList(this.currentIndex);
},
onRestore() {
this.triggered = 'restore'; // 需要重置
console.log("onRestore");
},
onAbort() {
console.log("onAbort");
}
}
};
......
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