Commit 83bf0342 by 张立顺

feat 首页刷新功能

1 parent 43aa0db3
......@@ -140,6 +140,21 @@ Component({
})
// 请求我的团队
this.getMyTeam()
},
// 首页切回时统一刷新:我的团队 + 我的门店(KPI) + 预警
refresh() {
console.log('refresh', '大区')
// 刷新团队数据
this.getMyTeam()
// 刷新门店 KPI
const stat = this.selectComponent('#storeStatistics')
if (stat) {
if (typeof stat.getTotal === 'function') stat.getTotal()
if (typeof stat.getKpiProgress === 'function') stat.getKpiProgress()
}
// 刷新预警列表
const warn = this.selectComponent('#storeWarning')
if (warn && typeof warn.refresh === 'function') warn.refresh()
}
}
})
......@@ -20,7 +20,7 @@
></table>
</view>
</view>
<storeStatistics regionId="{{ regionId }}"></storeStatistics>
<storeStatistics id="storeStatistics" regionId="{{ regionId }}"></storeStatistics>
<view class="storeWaring">
<store-waring regionId="{{ regionId }}"></store-waring>
<store-waring id="storeWarning" regionId="{{ regionId }}"></store-waring>
</view>
\ No newline at end of file
......@@ -31,5 +31,16 @@ Component({
/**
* 组件的方法列表
*/
methods: {}
methods: {
// 切回首页时,刷新内部门店统计与预警列表
refresh() {
const stat = this.selectComponent('#storeStatistics')
if (stat) {
if (typeof stat.getTotal === 'function') stat.getTotal()
if (typeof stat.getKpiProgress === 'function') stat.getKpiProgress()
}
const warn = this.selectComponent('#storeWarning')
if (warn && typeof warn.refresh === 'function') warn.refresh()
}
}
})
<!--packageIndex/pages/staff/staff.wxml-->
<storeStatistics regionId="{{ regionId }}" staffUuid="{{ staffUuid }}"></storeStatistics>
<store-waring regionId="{{ regionId }}" staffUuid="{{ staffUuid }}"></store-waring>
\ No newline at end of file
<!--packageIndex/pages/staff/staff.wxml-->
<storeStatistics id="storeStatistics" regionId="{{ regionId }}" staffUuid="{{ staffUuid }}"></storeStatistics>
<store-waring id="storeWarning" regionId="{{ regionId }}" staffUuid="{{ staffUuid }}"></store-waring>
\ No newline at end of file
......@@ -9,7 +9,7 @@ Page({
data: {
navStyle: 'background-color: rgba(0,0,0,0);',
track_event_code: 'sales_index_view_page',
navTitleStyle: "font-weight: 600; font- size: 32rpx; color: #000;",
navTitleStyle: 'font-weight: 600; font- size: 32rpx; color: #000;'
},
// navbar高度设置
// navbarReady(e) {
......@@ -43,7 +43,7 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () { },
onReady: function () {},
onReachBottom() {
console.log('滑到底部了')
......@@ -53,6 +53,7 @@ Page({
*/
onShow: async function () {
this.onPageShow()
this.refreshActiveTab()
},
/**
* 生命周期函数--监听页面隐藏
......@@ -71,11 +72,33 @@ Page({
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () { },
onPullDownRefresh: function () {},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () { },
onShareTimeline: function () { }
onShareAppMessage: function () {},
onShareTimeline: function () {},
// 每次切换到首页 tab,刷新当前角色组件的数据
refreshActiveTab() {
const { loginRole } = this.data
const comp = this.selectComponent('#roleComp')
if (!comp) return
// 1-总监 2-大区经理 3-销售人员
if (loginRole == 1) {
// 总监页封装了 refreshList
if (typeof comp.refreshList === 'function') comp.refreshList()
} else if (loginRole == 2) {
// 大区经理页,统一刷新(我的团队、门店KPI、预警)
if (typeof comp.refresh === 'function') {
comp.refresh()
} else if (typeof comp.getMyTeam === 'function') {
// 兼容旧实现
comp.getMyTeam()
}
} else if (loginRole == 3) {
// 员工页,转发刷新到内部门店统计
if (typeof comp.refresh === 'function') comp.refresh()
}
}
})
......@@ -5,8 +5,8 @@
<view style="height:100vh;overflow: hidden;">
<view class="layout" style="height:calc(100vh - {{ navBarHeight}}px); margin-top:{{ navBarHeight + 'px' }}">
<!-- 登录角色 1-总监 2-大区经理 3-销售人员 -->
<staff wx:if="{{ loginRole == 3 }}"></staff>
<regionalLeaders wx:if="{{ loginRole == 2 }}"></regionalLeaders>
<directorLeaders wx:if="{{ loginRole == 1 }}"></directorLeaders>
<staff id="roleComp" wx:if="{{ loginRole == 3 }}"></staff>
<regionalLeaders id="roleComp" wx:if="{{ loginRole == 2 }}"></regionalLeaders>
<directorLeaders id="roleComp" wx:if="{{ loginRole == 1 }}"></directorLeaders>
</view>
</view>
\ No newline at end of file
</view>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!