Commit f2161946 by wangzhihui

修复标签显示

1 parent 15923b64
// packageCustomer/pages/merchantDetail/merchantDetail.js
import CustomerApi from "~/api/customerApi/index"
import { IMG_URL, COOPERATIONMODELIST, TRSFFICSTATUSLIST, SCENELIST, ROLELIST } from '~/utils/constantData'
import {
IMG_URL,
COOPERATIONMODELIST,
TRSFFICSTATUSLIST,
SCENELIST,
ROLELIST
} from '~/utils/constantData'
import dayjs from 'dayjs'
Page({
options: {
styleIsolation: 'shared'
},
/**
* 页面的初始数据
*/
data: {
IMG_URL: IMG_URL,
listTabs: ['KPI进度', '经营指标', '门店信息', '资料详情'],
tabIndex: 0,
infoDetail: {},
statusText: {
1: {label: '新店', color: '#35C376', background: '#35c37614'},
2: {label: '老店', color: '#347BFF', background: '#347bff14'}
},
scrollTop: 0
},
options: {
styleIsolation: 'shared'
},
/**
* 页面的初始数据
*/
data: {
IMG_URL: IMG_URL,
listTabs: ['KPI进度', '经营指标', '门店信息', '资料详情'],
tabIndex: 0,
infoDetail: {},
statusText: {
1: {
label: '新店',
color: '#35C376',
background: '#35c37614'
},
2: {
label: '老店',
color: '#347BFF',
background: '#347bff14'
},
3: {
label: '关店',
color: '#666666',
background: '#66666614'
},
},
scrollTop: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let { query } = options
if (query) {
const pageQuery = JSON.parse(decodeURIComponent(query))
this.setData({pageQuery})
this.getMerchantDetail(pageQuery)
if (pageQuery.currentTab) {
this.setData({tabIndex: Number(pageQuery.currentTab)})
}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
let {
query
} = options
if (query) {
const pageQuery = JSON.parse(decodeURIComponent(query))
this.setData({
pageQuery
})
this.getMerchantDetail(pageQuery)
if (pageQuery.currentTab) {
this.setData({
tabIndex: Number(pageQuery.currentTab)
})
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
},
navbarReady(e) {
let navBarHeight = e.detail.height
this.setData({
navBarHeight
})
},
onScroll(e) {
const scrollTop = e.detail.scrollTop
this.setData({ scrollTop })
},
onScroll(e) {
const scrollTop = e.detail.scrollTop
this.setData({
scrollTop
})
},
recordTabTop() {
const query = wx.createSelectorQuery().in(this)
query.select('.tabbar-anchor').boundingClientRect()
query.exec(res => {
const top = res[0]?.top
const height = res[0]?.height
this.setData({
initialTabTop: top,
tabHeight: height
})
})
},
recordTabTop() {
const query = wx.createSelectorQuery().in(this)
query.select('.tabbar-anchor').boundingClientRect()
query.exec(res => {
const top = res[0]?.top
const height = res[0]?.height
this.setData({
initialTabTop: top,
tabHeight: height
})
})
},
buildInfoBoard() {
const { infoDetail } = this.data
const items = [
{ label: '主营品牌', value: infoDetail.mainCategory },
{ label: '合作模式', value: infoDetail.coopMode },
{ label: '拜访次数', value: infoDetail.visitCount != null ? `${infoDetail.visitCount}` : '', highlight: true },
{ label: '流量情况', value: infoDetail.flowScale },
{ label: '展业时间', value: infoDetail.expectedOperationDate ? dayjs(infoDetail.expectedOperationDate).format('YYYY-MM-DD') : '' },
{ label: '分润规则', value: infoDetail.profitRule },
{ label: '业务类型', value: infoDetail.bizType, full: true }
].filter(Boolean)
this.setData({ infoBoardItems: items })
},
buildInfoBoard() {
const {
infoDetail
} = this.data
const items = [{
label: '主营品牌',
value: infoDetail.mainCategory
},
{
label: '合作模式',
value: infoDetail.coopMode
},
{
label: '拜访次数',
value: infoDetail.visitCount != null ? `${infoDetail.visitCount}` : '',
highlight: true
},
{
label: '流量情况',
value: infoDetail.flowScale
},
{
label: '展业时间',
value: infoDetail.expectedOperationDate ? dayjs(infoDetail.expectedOperationDate).format('YYYY-MM-DD') : ''
},
{
label: '分润规则',
value: infoDetail.profitRule
},
{
label: '业务类型',
value: infoDetail.bizType,
full: true
}
].filter(Boolean)
this.setData({
infoBoardItems: items
})
},
getMerchantDetail(pageQuery) {
wx.$api.showLoading()
if (!pageQuery.merchantId) {
wx.$sentry.reportParamError(
'门店详情参数异常: merchantId',
pageQuery
)
}
CustomerApi.getMaterialData({id: pageQuery.merchantId}).then(res => {
wx.$api.hideLoading()
this.setData({showPage: true})
// 处理数据回显
this.progressData(res)
})
},
getMerchantDetail(pageQuery) {
wx.$api.showLoading()
if (!pageQuery.merchantId) {
wx.$sentry.reportParamError(
'门店详情参数异常: merchantId',
pageQuery
)
}
CustomerApi.getMaterialData({
id: pageQuery.merchantId
}).then(res => {
wx.$api.hideLoading()
this.setData({
showPage: true
})
// 处理数据回显
this.progressData(res)
})
},
progressData(data) {
if (!data || typeof data !== 'object') {
wx.$sentry.reportError(
'门店详情数据异常: data',
data
)
this.setData({
infoDetail: {}
})
return
}
try {
const businessSceneNames = {0: '轻改', 1: '权益', 2: '延保'}
// 主营品牌
data.mainCategory = data.mainBrand || ''
// 合作模式
data.coopMode = ''
if (Array.isArray(data?.cooperationModeList)) {
data.coopMode = data.cooperationModeList.map(val => {
try {
if (!val || typeof val !== 'object') return ''
const sceneName = businessSceneNames[val.businessSceneType] || ''
const cooperationItem = COOPERATIONMODELIST?.find(v =>
val.directSalesFlag && v?.value == val.directSalesFlag
)
const cooperationName = cooperationItem?.name || ''
return sceneName && cooperationName ? `${sceneName}:${cooperationName}` : ''
} catch (error) {
wx.$sentry.reportError(
'合作模式数据异常: data.cooperationModeList',
data.cooperationModeList
)
return ''
}
}).filter(item => item && item !== ':') // 过滤空项和只有冒号的项
.join('/') || ''
}
// 流量情况
data.flowScale = ''
if (data.flowSituation) {
try {
data.flowScale = TRSFFICSTATUSLIST?.find(val => val?.value == data.flowSituation)?.name || ''
} catch (error) {
wx.$sentry.reportError(
'流量情况数据异常: data.flowSituation',
data.flowSituation
)
}
}
// 业务类型 - 添加保护
data.bizType = ''
if (Array.isArray(data?.businessTypeList)) {
data.bizType = data.businessTypeList.map(val => {
try {
return SCENELIST?.find(v => v?.value == val)?.name || ''
} catch (error) {
wx.$sentry.reportError(
'业务类型数据异常: data.businessTypeList',
data.businessTypeList
)
return ''
}
}).filter(item => item) // 过滤空字符串
.join('/') || ''
}
// 人员类型
if (Array.isArray(data?.salePotentialCustomerPersonnelInfoDTOList)) {
data.salePotentialCustomerPersonnelInfoDTOList.forEach(val => {
try {
if (val && typeof val === 'object') {
val.roleName = ROLELIST?.find(v => v?.value == val.personnelType)?.label || ''
}
} catch (error) {
wx.$sentry.reportError(
'人员信息数据异常: data.salePotentialCustomerPersonnelInfoDTOList',
data.salePotentialCustomerPersonnelInfoDTOList
)
val.roleName = ''
}
})
}
// 店面门头照片
data.storePhotoList = []
if (typeof data.storePhoto === 'string') {
try {
data.storePhotoList = data.storePhoto.split(',')
} catch (error) {
wx.$sentry.reportError(
'店面照片数据异常: data.storePhoto',
data.storePhoto
)
}
}
// 设置数据
this.setData({
infoDetail: data
}, () => {
try {
this.buildInfoBoard && this.buildInfoBoard()
this.recordTabTop && this.recordTabTop()
} catch (error) {
console.error('执行回调函数时出错:', error)
}
})
} catch (error) {
wx.$sentry.reportParamError(
'门店详情数据异常: data',
data
)
// 确保即使出错也有基本的数据结构
this.setData({
infoDetail: {
...data,
mainCategory: '',
coopMode: '',
flowScale: '',
bizType: '',
salePotentialCustomerPersonnelInfoDTOList: [],
storePhotoList: []
}
})
}
},
progressData(data) {
if (!data || typeof data !== 'object') {
wx.$sentry.reportError(
'门店详情数据异常: data',
data
)
this.setData({
infoDetail: {}
})
return
}
try {
const businessSceneNames = {
0: '轻改',
1: '权益',
2: '延保'
}
// 主营品牌
data.mainCategory = data.mainBrand || ''
// 合作模式
data.coopMode = ''
if (Array.isArray(data?.cooperationModeList)) {
data.coopMode = data.cooperationModeList.map(val => {
try {
if (!val || typeof val !== 'object') return ''
const sceneName = businessSceneNames[val.businessSceneType] || ''
const cooperationItem = COOPERATIONMODELIST?.find(v =>
val.directSalesFlag && v?.value == val.directSalesFlag
)
const cooperationName = cooperationItem?.name || ''
return sceneName && cooperationName ? `${sceneName}:${cooperationName}` : ''
} catch (error) {
wx.$sentry.reportError(
'合作模式数据异常: data.cooperationModeList',
data.cooperationModeList
)
return ''
}
}).filter(item => item && item !== ':') // 过滤空项和只有冒号的项
.join('/') || ''
}
// 流量情况
data.flowScale = ''
if (data.flowSituation) {
try {
data.flowScale = TRSFFICSTATUSLIST?.find(val => val?.value == data.flowSituation)?.name || ''
} catch (error) {
wx.$sentry.reportError(
'流量情况数据异常: data.flowSituation',
data.flowSituation
)
}
}
// 业务类型 - 添加保护
data.bizType = ''
if (Array.isArray(data?.businessTypeList)) {
data.bizType = data.businessTypeList.map(val => {
try {
return SCENELIST?.find(v => v?.value == val)?.name || ''
} catch (error) {
wx.$sentry.reportError(
'业务类型数据异常: data.businessTypeList',
data.businessTypeList
)
return ''
}
}).filter(item => item) // 过滤空字符串
.join('/') || ''
}
// 人员类型
if (Array.isArray(data?.salePotentialCustomerPersonnelInfoDTOList)) {
data.salePotentialCustomerPersonnelInfoDTOList.forEach(val => {
try {
if (val && typeof val === 'object') {
val.roleName = ROLELIST?.find(v => v?.value == val.personnelType)?.label || ''
}
} catch (error) {
wx.$sentry.reportError(
'人员信息数据异常: data.salePotentialCustomerPersonnelInfoDTOList',
data.salePotentialCustomerPersonnelInfoDTOList
)
val.roleName = ''
}
})
}
tabClick(e) {
const index = typeof e?.detail === 'number' ? e.detail : 0
this.setData({
tabIndex: index,
showVisitButton: index != 1
})
wx.nextTick(() => { this.measureLayout() })
},
// 店面门头照片
data.storePhotoList = []
if (typeof data.storePhoto === 'string') {
try {
data.storePhotoList = data.storePhoto.split(',')
} catch (error) {
wx.$sentry.reportError(
'店面照片数据异常: data.storePhoto',
data.storePhoto
)
}
}
// 设置数据
this.setData({
infoDetail: data
}, () => {
try {
this.buildInfoBoard && this.buildInfoBoard()
this.recordTabTop && this.recordTabTop()
} catch (error) {
console.error('执行回调函数时出错:', error)
}
})
measureLayout() {
const { scrollTop, initialTabTop, navBarHeight } = this.data
if (scrollTop >= (initialTabTop - navBarHeight)) {
this.setData({
setScrollTop: (initialTabTop - navBarHeight)
})
}
},
} catch (error) {
wx.$sentry.reportParamError(
'门店详情数据异常: data',
data
)
// 确保即使出错也有基本的数据结构
this.setData({
infoDetail: {
...data,
mainCategory: '',
coopMode: '',
flowScale: '',
bizType: '',
salePotentialCustomerPersonnelInfoDTOList: [],
storePhotoList: []
}
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
tabClick(e) {
const index = typeof e?.detail === 'number' ? e.detail : 0
this.setData({
tabIndex: index,
showVisitButton: index != 1
})
wx.nextTick(() => {
this.measureLayout()
})
},
},
measureLayout() {
const {
scrollTop,
initialTabTop,
navBarHeight
} = this.data
if (scrollTop >= (initialTabTop - navBarHeight)) {
this.setData({
setScrollTop: (initialTabTop - navBarHeight)
})
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
}
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
......@@ -83,7 +83,7 @@ Component({
// 4: 2 // 未签约
}
const obj = {
keyword:this.data.searchKeyword,
storeName:this.data.searchKeyword,
isAll: boardScopeActive ? 1 : 0,
year: boardScopeActive ? undefined : new Date(monthPickerValue).getFullYear(),
month: boardScopeActive ? undefined : new Date(monthPickerValue).getMonth() + 1,
......
......@@ -69,7 +69,7 @@ Component({
getParams() {
let { boardScopeActive, monthPickerValue, searchObj, statusIndex, userInfo, personParams } = this.data
const obj = {
keyword:this.data.searchKeyword,
merchantName:this.data.searchKeyword,
isAll: boardScopeActive ? 1 : 0,
year: boardScopeActive ? undefined : new Date(monthPickerValue).getFullYear(),
month: boardScopeActive ? undefined : new Date(monthPickerValue).getMonth() + 1,
......
<view class="store-layout">
<!-- 数据看板(门店) -->
<view class="data-board">
<view class="board">
<view class="board-header">
<view class="board-title">数据看板</view>
<view class="board-actions">
<view class="board-action {{boardMonthActive ? 'active' : ''}}" bindtap="chooseBoard" data-type="month">
<text>{{boardMonthText}}</text>
<image src="{{IMG_URL}}customer/arrow.png" mode=""/>
</view>
<view class="board-action {{boardScopeActive ? 'active' : ''}}" bindtap="chooseBoard" data-type="scope">
<text>{{boardScopeText}}</text>
</view>
</view>
</view>
<view class="board-grid">
<view class="grid-item wid-128">
<view class="label">门店总数</view>
<view class="value">{{dashboard.storeCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">新店</view>
<view class="value">{{dashboard.newStoreCount}}</view>
</view>
<view class="grid-item wid-67">
<view class="label">老店</view>
<view class="value">{{dashboard.oldStoreCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">未出单</view>
<view class="value">{{dashboard.notSignedCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">已出单</view>
<view class="value">{{dashboard.signedCount}}</view>
</view>
<view class="grid-item wid-67">
<view class="label">关店</view>
<view class="value">{{dashboard.signedCount}}</view>
</view>
</view>
</view>
</view>
<view class="search-wrap">
<search-input value="{{searchKeyword}}" bind:input="onSearchInput" placeholder="搜索" bind:search="onSearchConfirm" />
</view>
<!-- 列表状态筛选 TabBar(与父页吸顶逻辑保持一致类名) -->
<view class="tabbar-anchor" id="storeListTop">
<tab-bar tabList="{{ listTabs }}" notInitialLoading="{{true}}" bindclick="tabClick" activeIndex="{{ statusIndex }}" />
</view>
<!-- 数据看板(门店) -->
<view class="data-board">
<view class="board">
<view class="board-header">
<view class="board-title">数据看板</view>
<view class="board-actions">
<view class="board-action {{boardMonthActive ? 'active' : ''}}" bindtap="chooseBoard" data-type="month">
<text>{{boardMonthText}}</text>
<image src="{{IMG_URL}}customer/arrow.png" mode="" />
</view>
<view class="board-action {{boardScopeActive ? 'active' : ''}}" bindtap="chooseBoard" data-type="scope">
<text>{{boardScopeText}}</text>
</view>
</view>
</view>
<view class="board-grid">
<view class="grid-item wid-128">
<view class="label">门店总数</view>
<view class="value">{{dashboard.storeCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">新店</view>
<view class="value">{{dashboard.newStoreCount}}</view>
</view>
<view class="grid-item wid-67">
<view class="label">老店</view>
<view class="value">{{dashboard.oldStoreCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">未出单</view>
<view class="value">{{dashboard.notSignedCount}}</view>
</view>
<view class="grid-item wid-128">
<view class="label">已出单</view>
<view class="value">{{dashboard.signedCount}}</view>
</view>
<view class="grid-item wid-67">
<view class="label">关店</view>
<view class="value">{{dashboard.closedStoreCount}}</view>
</view>
</view>
</view>
</view>
<view class="search-wrap">
<search-input value="{{searchKeyword}}" bind:input="onSearchInput" placeholder="搜索" bind:search="onSearchConfirm" />
</view>
<!-- 列表状态筛选 TabBar(与父页吸顶逻辑保持一致类名) -->
<view class="tabbar-anchor" id="storeListTop">
<tab-bar tabList="{{ listTabs }}" notInitialLoading="{{true}}" bindclick="tabClick" activeIndex="{{ statusIndex }}" />
</view>
<!-- 列表(门店) -->
<view class="list-section" style="min-height: calc(100vh - {{tabHeight}}px - {{navBarHeight}}px - 24rpx - 172rpx);">
<block wx:if="{{storeList.length}}">
<block wx:for="{{storeList}}" wx:key="index">
<view class="list-card" bindtap="goDetail" data-item="{{item}}">
<view class="card-header">
<view class="status-tag {{item.storeType == 1 ? 'new': item.storeType == 2? 'old':'close'}}">{{ item.storeType == 1 ? '新店' : '老店' }}</view>
<view class="title">{{item.merchantName || '-'}} </view>
</view>
<view class="card-row">
<view class="label">拜访次数</view>
<view class="value">{{item.visitTimes != null ? item.visitTimes + '次' : '-'}}</view>
</view>
<view class="card-row">
<view class="label">销售人员</view>
<view class="value">{{item.salesUser || '-'}} </view>
</view>
<view class="card-row">
<view class="label">门店地址</view>
<view class="value">{{item.address}}</view>
</view>
<view class="card-row">
<view class="label">签约时间</view>
<view class="value">{{item.signedTime || '-'}} </view>
</view>
<view class="card-row">
<view class="label">展业时间</view>
<view class="value">{{item.expectedOperationDate || '-'}} </view>
</view>
<view class="card-row">
<view class="label">关店时间</view>
<view class="value">{{item.signedTime || '-'}} </view>
</view>
<view class="card-row">
<view class="label">关店原因</view>
<view class="value">{{item.expectedOperationDate || '-'}} </view>
</view>
</view>
</block>
<view class="list-footer" wx:if="{{loading}}">加载中...</view>
<view class="list-footer" wx:if="{{!hasMore && storeList.length}}">到底了~</view>
</block>
<block wx:else>
<nothing-tips tips="暂无数据" bgColor="{{'#F7F8FA'}}" emptyDataStyle="height: calc(100vh - {{tabHeight}}px - {{navBarHeight}}px - 24rpx - 172rpx);" />
</block>
</view>
<!-- 列表(门店) -->
<view class="list-section" style="min-height: calc(100vh - {{tabHeight}}px - {{navBarHeight}}px - 24rpx - 172rpx);">
<block wx:if="{{storeList.length}}">
<block wx:for="{{storeList}}" wx:key="index">
<view class="list-card" bindtap="goDetail" data-item="{{item}}">
<view class="card-header">
<view class="status-tag {{item.storeType == 1 ? 'new': item.storeType == 2? 'old':'close'}}">{{ item.storeType == 1 ? '新店':item.storeType == 2?'老店' : '关店' }}</view>
<view class="title">{{item.merchantName || '-'}} </view>
</view>
<view class="card-row">
<view class="label">拜访次数</view>
<view class="value">{{item.visitTimes != null ? item.visitTimes + '次' : '-'}}</view>
</view>
<view class="card-row">
<view class="label">销售人员</view>
<view class="value">{{item.salesUser || '-'}} </view>
</view>
<view class="card-row">
<view class="label">门店地址</view>
<view class="value">{{item.address}}</view>
</view>
<view class="card-row">
<view class="label">签约时间</view>
<view class="value">{{item.signedTime || '-'}} </view>
</view>
<view class="card-row">
<view class="label">展业时间</view>
<view class="value">{{item.expectedOperationDate || '-'}} </view>
</view>
<block wx:if="{{item.status == 3}}">
<view class="card-row">
<view class="label">关店时间</view>
<view class="value">{{item.closeTime || '-'}} </view>
</view>
<view class="card-row">
<view class="label">关店原因</view>
<view class="value">{{item.confirmReason || '-'}} </view>
</view>
</block>
<!-- 月份选择弹窗(门店) -->
<popup bind:hidePopup="cancel" bind:confirm="popupConfirm" customPopupSlotStyle="{{'height: calc(100% - 210rpx)'}}" show="{{monthPickerShow}}" title="选择月份" height="50%">
<van-datetime-picker
type="year-month"
model:value="{{pendingMonthValue}}"
min-date="{{minMonthDate}}"
max-date="{{maxMonthDate}}"
show-toolbar="{{false}}"
bind:change="onMonthChange"
/>
</popup>
</view>
</block>
<view class="list-footer" wx:if="{{loading}}">加载中...</view>
<view class="list-footer" wx:if="{{!hasMore && storeList.length}}">到底了~</view>
</block>
<block wx:else>
<nothing-tips tips="暂无数据" bgColor="{{'#F7F8FA'}}" emptyDataStyle="height: calc(100vh - {{tabHeight}}px - {{navBarHeight}}px - 24rpx - 172rpx);" />
</block>
</view>
<!-- 月份选择弹窗(门店) -->
<popup bind:hidePopup="cancel" bind:confirm="popupConfirm" customPopupSlotStyle="{{'height: calc(100% - 210rpx)'}}" show="{{monthPickerShow}}" title="选择月份" height="50%">
<van-datetime-picker type="year-month" model:value="{{pendingMonthValue}}" min-date="{{minMonthDate}}" max-date="{{maxMonthDate}}" show-toolbar="{{false}}" bind:change="onMonthChange" />
</popup>
</view>
\ No newline at end of file
......@@ -21,7 +21,7 @@ const h5Obj = {
2测试
3生产
*/
let index = 2
let index =2
const accountInfo = wx.getAccountInfoSync()
const systemInfo = wx.getSystemInfoSync()
// console.log(systemInfo);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!