Commit ea767396 by Lin

feat(HomeFrame, CustomerSide, PreStudyPopup, PreBackPopup):优化客户资料处理并提升用户界面交互体验

- 更新 HomeFrame,使用 getCustomerProfileGroupInfo 方法以更高效地获取客户数据。
- 重构 CustomerSide,按日期分组显示客户资料,提高清晰度和可用性。
- 增强 PreStudyPopup 和 PreBackPopup,动态管理跳过次数及确认按钮状态,改善用户体验。
-用户体验。
- 集成新的计算属性,根据跳过次数更灵活地处理确认文本和按钮状态。
1 parent 78cab289
......@@ -28,114 +28,128 @@
</view>
<scroll-view class="customer-list" scroll-y show-scrollbar="false">
<view class="customer-list-inner">
<view class="customer-count">
<view class="customer-count-left">
<image
class="customer-count-icon"
:src="require('@/assets/images/common/icon-customer-count.png')"
mode="aspectFit"
/>
<text class="customer-count-label">今日({{ todayDate }})已建档</text>
</view>
<view class="customer-count-right">
<text class="customer-count-num">{{ todayCustomerCount }}</text>
<text class="customer-count-unit">位客户</text>
</view>
</view>
<view
v-for="item in customerList"
:key="item.id"
class="customer-item"
v-for="group in customerProfile"
:key="group.date"
class="customer-day-group"
>
<view class="customer-item-avatar">
<text class="customer-item-avatar-text">{{ item.surname }}</text>
</view>
<view class="customer-item-body" @click="handleGoCustomerDetail(item)">
<view class="customer-item-row customer-item-row--name">
<text class="customer-item-name">{{ item.name }}</text>
<view v-if="item.carModel" class="customer-item-car-tag">
<text class="customer-item-car-text">{{ item.carModel }}</text>
<view class="customer-count">
<view class="customer-count-left">
<image
class="customer-count-icon"
:src="require('@/assets/images/common/icon-customer-count.png')"
mode="aspectFit"
/>
<text class="customer-count-label">{{ formatDateLabel(group.date) }}已建档</text>
</view>
<view class="customer-count-right">
<text class="customer-count-num">{{ group.number || 0 }}</text>
<text class="customer-count-unit">位客户</text>
</view>
</view>
<view class="customer-item-row customer-item-row--meta">
<text class="customer-item-meta">{{ item.phone }}</text>
<view class="customer-item-divider"></view>
<text class="customer-item-meta">交付{{ item.deliveryDate }}</text>
<view class="customer-item-divider"></view>
<text class="customer-item-meta">到店{{ item.visitDate }}</text>
</view>
<view class="customer-item-row customer-item-row--group">
<text class="customer-item-group">客户群:{{ item.groupName }}</text>
</view>
</view>
<view class="customer-item-side">
<view
v-if="item.status"
:class="['customer-item-status', `customer-item-status--${item.statusType || 'warning'}`]"
v-for="item in group.customerProfileInfoDTOS || []"
:key="item.id"
class="customer-item"
>
<text class="customer-item-status-text">{{ item.status }}</text>
</view>
<view class="customer-item-arrow">
<view class="sprite-icon icon-arrow-right"></view>
<view class="customer-item-avatar">
<text class="customer-item-avatar-text">{{ getCustomerSurname(item.customerName) }}</text>
</view>
<view class="customer-item-body" @click="handleGoCustomerDetail(item)">
<view class="customer-item-row customer-item-row--name">
<view class="customer-item-name-left">
<text class="customer-item-name">{{ item.customerName || '-' }}</text>
<view v-if="item.carSeriesName" class="customer-item-car-tag">
<text class="customer-item-car-text">{{ item.carSeriesName }}</text>
</view>
</view>
<view
v-if="getCustomerStatusLabel(item.customerStatus)"
:class="['customer-item-status', getCustomerStatusClass(item.customerStatus)]"
>
<text class="customer-item-status-text">{{ getCustomerStatusLabel(item.customerStatus) }}</text>
</view>
</view>
<view class="customer-item-row customer-item-row--meta">
<text class="customer-item-meta">{{ item.customerPhone || '-' }}</text>
<view class="customer-item-divider"></view>
<text class="customer-item-meta">交付{{ formatDisplayDate(item.deliveryDate) }}</text>
<view class="customer-item-divider"></view>
<text class="customer-item-meta">到店{{ formatDisplayDate(item.inviteDate) }}</text>
</view>
<view class="customer-item-row customer-item-row--group">
<text class="customer-item-group">客户群:{{ item.qwGroupName || '-' }}</text>
<view class="customer-item-arrow">
<view class="sprite-icon icon-arrow-right"></view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
</template>
<script>
const MOCK_CUSTOMER_LIST = [
{
id: 1,
surname: '张',
name: '张**',
carModel: '奥迪 A6L',
phone: '136****6789',
deliveryDate: '06-20',
visitDate: '05-12',
groupName: '张先生2827-客户大定精品服务群吉利古拉',
status: '待跟进',
statusType: 'warning'
},
{
id: 2,
surname: '李',
name: '李**',
carModel: '宝马 5系',
phone: '138****1234',
deliveryDate: '06-18',
visitDate: '05-10',
groupName: '李先生1028-客户精品服务群',
status: '待跟进',
statusType: 'warning'
}
]
export default {
name: 'CustomerSide',
props: {
type: {
type: String,
default: 'out'
}
},
data() {
return {
customerList: MOCK_CUSTOMER_LIST,
todayCustomerCount: 8
}
},
computed: {
todayDate() {
const now = new Date()
const month = String(now.getMonth() + 1).padStart(2, '0')
const day = String(now.getDate()).padStart(2, '0')
return `${month}-${day}`
},
customerProfile: {
type: Array,
default: () => []
}
},
methods: {
getCustomerSurname(name) {
if (!name) return ''
return String(name).charAt(0)
},
getCustomerStatusLabel(status) {
const map = {
1: '待跟进',
2: '已升级',
3: '战败',
4: '已退款'
}
return map[status] || ''
},
getCustomerStatusClass(status) {
const map = {
1: 'customer-item-status--warning',
2: 'customer-item-status--success',
3: 'customer-item-status--failed',
4: 'customer-item-status--refund'
}
return map[status] || ''
},
formatDisplayDate(val) {
if (!val) return '-'
if (typeof val === 'number') {
const date = new Date(val)
if (Number.isNaN(date.getTime())) return '-'
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${month}-${day}`
}
const match = String(val).match(/(\d{4})-(\d{2})-(\d{2})/)
if (match) return `${match[2]}-${match[3]}`
return val
},
formatDateLabel(dateStr) {
const display = this.formatDisplayDate(dateStr)
if (!dateStr) return display
const now = new Date()
const todayStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`
if (dateStr === todayStr) {
return `今日(${display})`
}
return display
},
handleGoCustomerFiles() {
uni.navigateTo({
url: '/pages/common/customerPages/addFiles',
......@@ -241,6 +255,14 @@ export default {
box-sizing: border-box;
}
.customer-day-group {
margin-bottom: 8px;
&:last-child {
margin-bottom: 0;
}
}
.customer-count {
display: flex;
align-items: center;
......@@ -337,7 +359,8 @@ export default {
min-width: 0;
&--name {
gap: 6px;
justify-content: space-between;
gap: 8px;
}
&--meta {
......@@ -346,10 +369,20 @@ export default {
}
&--group {
align-items: flex-start;
align-items: center;
justify-content: space-between;
gap: 8px;
}
}
.customer-item-name-left {
display: flex;
align-items: center;
gap: 6px;
min-width: 0;
flex: 1;
}
.customer-item-name {
font-size: 16px;
line-height: 22px;
......@@ -397,19 +430,10 @@ export default {
white-space: nowrap;
}
.customer-item-side {
align-self: stretch;
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: space-between;
flex-shrink: 0;
}
.customer-item-status {
padding: 0 8px;
border-radius: 4px;
background: #FDECE9;
flex-shrink: 0;
&--warning {
background: #FDECE9;
......@@ -418,6 +442,30 @@ export default {
color: #F24724;
}
}
&--success {
background: #EAF9F1;
.customer-item-status-text {
color: #35C376;
}
}
&--failed {
background: #F5F7FA;
.customer-item-status-text {
color: #999EA8;
}
}
&--refund {
background: #FFF5E6;
.customer-item-status-text {
color: #F7A431;
}
}
}
.customer-item-status-text {
......@@ -427,10 +475,11 @@ export default {
.customer-item-arrow {
width: 16px;
height: 16px;
height: 18px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
.icon-arrow-right {
width: 16px !important;
......
......@@ -12,7 +12,11 @@
<view class="cancel-button" @click="handleCancel">
取消
</view>
<view class="confirm-button" @click="deductSkipCount">
<view
class="confirm-button"
:class="{ 'confirm-button--disabled': confirmDisabled }"
@click="deductSkipCount"
>
{{ confirmText }}
</view>
</view>
......@@ -32,14 +36,21 @@ export default {
default: () => ({skipCount: 2})
}
},
computed: {
confirmDisabled() {
return this.prelearnContext?.skipCount === 0
}
},
methods: {
handleCancel() {
this.$emit('cancel')
},
async deductSkipCount() {
if (this.confirmDisabled) return
let requestParams = {
activityId:this.prelearnContext.activityId
}
console.log('deductSkipCountAPI requestParams***', requestParams);
const res = await uni.$api.commonApi.deductSkipCountAPI(requestParams)
console.log('deductSkipCountAPI***', res);
if (res) {
......@@ -128,6 +139,17 @@ export default {
&:active {
opacity: 0.8;
}
&--disabled {
border-color: #d9d9d9;
background-image: linear-gradient(0deg, #2c66f799 0%, #48a6ff99 100%);
color: #ffffff;
pointer-events: none;
&:active {
opacity: 1;
}
}
}
.text-red {
color: #F24724;
......
......@@ -25,7 +25,11 @@
</view>
<!-- 按钮组(始终显示) -->
<view class="button-group">
<view class="confirm-button" @click="handleConfirm">
<view
class="confirm-button"
:class="{ 'confirm-button--disabled': confirmDisabled }"
@click="handleConfirm"
>
{{ confirmText }}
</view>
</view>
......@@ -40,6 +44,10 @@ export default {
type: String,
default: '跳过'
},
confirmDisabled: {
type: Boolean,
default: false
},
prelearnData: {
type: Object,
default: () => ({})
......@@ -55,21 +63,57 @@ export default {
if (!includes?.length) return ''
return `包含:${includes.join(' + ')}`
},
handleStartStudy(item, index) {
async handleStartStudy(item, index) {
if (item.learnStatus !== 'NOT_STUDY') return
this.$emit('start-study', item, index)
const prelearnDataStr = encodeURIComponent(JSON.stringify(this.prelearnData))
uni.navigateTo({
url: `/pages/common/prelearnBridge?prelearnData=${prelearnDataStr}&entrySource=home_popup`,
fail: (err) => {
console.error('预学习桥接页跳转失败:', err)
try {
// const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
const res = {
"activityId": 31,
"activityName": "618年中促活动A",
"packages": [
{
"activityProductId": "16",
"packageName": "tttttttt",
"includes": ['原厂定制车衣','玻璃贴膜'],
"learnStatus": "NOT_STUDY",
"scriptReady": true
}
],
"remainingSkipCount": 0,
"shouldPopup": true,
"muteReason": null,
"remainingActivityCount": null
}
console.log('getPrelernHomePopupAPI res***', res)
if (!res) return
const freshItem = res.packages?.find(
(pkg) => pkg.activityProductId === item.activityProductId
)
console.log('freshItem***', freshItem)
if (!freshItem?.scriptReady) {
uni.showToast({ title: '话术未就绪,请稍后重试', icon: 'none' })
return
}
})
this.$emit('start-study', freshItem, index)
const prelearnDataStr = encodeURIComponent(JSON.stringify(res))
uni.navigateTo({
url: `/pages/common/prelearnBridge?prelearnData=${prelearnDataStr}&entrySource=home_popup`,
fail: (err) => {
console.error('预学习桥接页跳转失败:', err)
}
})
} catch (err) {
console.error('预学习首页弹框查询失败:', err)
}
},
handleCancel() {
this.$emit('cancel')
},
handleConfirm() {
if (this.confirmDisabled) return
this.$emit('confirm')
}
}
......@@ -187,9 +231,11 @@ export default {
}
.confirm-button {
width: toRpx(338);
width: 100%;
height: toRpx(80);
margin: 0 auto;
padding: 0 toRpx(24);
box-sizing: border-box;
border-radius: toRpx(48);
border: toRpx(2) solid #979797;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
......@@ -203,5 +249,16 @@ export default {
&:active {
opacity: 0.8;
}
&--disabled {
border-color: #d9d9d9;
background-image: linear-gradient(0deg, #2c66f799 0%, #48a6ff99 100%);
color: #ffffff;
pointer-events: none;
&:active {
opacity: 1;
}
}
}
</style>
......@@ -20,7 +20,6 @@
class="demo-webview"
:style="webviewShellStyle"
:src="webviewUrl"
:fullscreen="isAppClient ? false : undefined"
:webview-styles="webviewInsetStyle"
@message="handleWebMessage"
@onPostMessage="handleWebMessage"
......@@ -39,6 +38,7 @@
>
<PreBackPopup
:confirmText="backPopInfo.confirmText"
:prelearnContext="prelearnContext"
@cancel="handleBackPopupCancel"
@confirm="handleBackPopupConfirm"
/>
......@@ -70,8 +70,9 @@ export default {
activityProductId: '16',
staffUuid: uni.$storage.get('userInfo').uuid,
staffName: uni.$storage.get('userInfo').name,
merchantId: uni.$storage.get('userInfo').merchantId,
merchantId: String(uni.$storage.get('userInfo').merchantId ?? ''),
entrySource: 'home_popup',
skipCount: 0,
},
pendingAppBackTimer: null,
pendingAppBackRequestId: null,
......@@ -137,12 +138,20 @@ export default {
onLoad(options) {
const defaultUrl = 'http://192.168.1.68:4173/prelearning.html'
this.webviewUrl = options.url ? decodeURIComponent(options.url) : defaultUrl
console.log('[prelearnBridge] 页面入参 options:', options)
if (options.prelearnData) {
try {
const prelearnData = JSON.parse(decodeURIComponent(options.prelearnData))
console.log('[prelearnBridge] 预学习弹窗数据 prelearnData:', prelearnData)
const { activityId, activityProductId, entrySource } = prelearnData
if (activityId != null) {
this.prelearnContext.activityId = String(activityId)
}
if (activityProductId != null) {
this.prelearnContext.activityProductId = String(activityProductId)
}
if (entrySource) {
this.prelearnContext.entrySource = entrySource
}
} catch (error) {
console.error('[prelearnBridge] 解析 prelearnData 失败:', error)
}
......@@ -259,14 +268,76 @@ export default {
// #endif
},
registerCompleteActivityHandler() {
window.completeActivity = (payload) => {
this.handleCompleteActivity(payload)
const handler = (payload) => this.handleCompleteActivity(payload)
this._completeActivityHandler = handler
// #ifdef H5
const globalObj = typeof window !== 'undefined'
? window
: (typeof globalThis !== 'undefined' ? globalThis : null)
if (globalObj) {
globalObj.completeActivity = handler
}
// #endif
// #ifdef APP-PLUS
this.registerAppParentCompleteActivityHandler(handler)
// #endif
},
registerAppParentCompleteActivityHandler(handler) {
if (typeof plus !== 'undefined') {
plus.__prelearnBridgeCompleteActivity = handler
}
const tryRegister = () => {
try {
const wv = this.$scope && this.$scope.$getAppWebview && this.$scope.$getAppWebview()
if (!wv || typeof wv.evalJS !== 'function') return false
wv.evalJS(`
(function() {
window.completeActivity = function(payload) {
try {
if (typeof plus !== 'undefined' && plus.__prelearnBridgeCompleteActivity) {
plus.__prelearnBridgeCompleteActivity(payload || {});
}
} catch (e) {}
};
})();
`)
return true
} catch (error) {
console.log('[prelearnBridge] register parent completeActivity failed:', error)
return false
}
}
if (!tryRegister()) {
this.$nextTick(() => {
setTimeout(() => tryRegister(), 100)
})
}
},
unregisterCompleteActivityHandler() {
if (window.completeActivity) {
delete window.completeActivity
// #ifdef H5
const globalObj = typeof window !== 'undefined'
? window
: (typeof globalThis !== 'undefined' ? globalThis : null)
if (globalObj && globalObj.completeActivity) {
delete globalObj.completeActivity
}
// #endif
// #ifdef APP-PLUS
if (typeof plus !== 'undefined' && plus.__prelearnBridgeCompleteActivity) {
delete plus.__prelearnBridgeCompleteActivity
}
try {
const wv = this.$scope && this.$scope.$getAppWebview && this.$scope.$getAppWebview()
if (wv && typeof wv.evalJS === 'function') {
wv.evalJS('try { delete window.completeActivity; } catch (e) {}')
}
} catch (error) {
console.log('[prelearnBridge] unregister parent completeActivity failed:', error)
}
// #endif
},
buildH5CompleteActivityInjectScript() {
return `
......@@ -391,14 +462,15 @@ export default {
handleWebMessage(event) {
const messages = this.normalizeMessages(event)
messages.forEach((message) => {
console.log('[prelearn bridge demo] receive h5 message:', message)
console.log('***通知APP-POSTMESSAGE***', message)
if (!message || !message.type) return
if (message.type === 'GET_PRELEARN_TICKET') {
this.pushPrelearnSessionToH5(message.requestId)
}
if (message.type === 'PRELEARN_BACK_TO_APP') {
// if (message.type === 'PRELEARN_BACK_TO_APP') {
if (message.type === 'completeActivity') {
this.handleH5BackEvent(message)
}
......@@ -663,16 +735,59 @@ export default {
}
// #endif
},
back() {
this.showBackPopup = true
async back() {
try {
// const res = await uni.$api.commonApi.getPrelernHomePopupAPI()
const res = {
"activityId": 31,
"activityName": "618年中促活动A",
"packages": [
{
"activityProductId": "16",
"packageName": "tttttttt",
"includes": ['原厂定制车衣','玻璃贴膜'],
"learnStatus": "STUDIED",
"scriptReady": true
}
],
"remainingSkipCount": 0,
"shouldPopup": true,
"muteReason": null,
"remainingActivityCount": null
}
console.log('[prelearnBridge] getPrelernHomePopupAPI res:', res)
// if (!res) {
// this.navigateBack()
// return
// }
const packages = res.packages || []
const allStudied = packages.length > 0 && packages.every(
(pkg) => pkg.learnStatus === 'STUDIED'
)
if (allStudied) {
this.navigateBack()
return
}
if (res.activityId != null) {
this.prelearnContext.activityId = String(res.activityId)
}
this.prelearnContext.skipCount = res.remainingSkipCount ?? 0
this.showBackPopup = true
} catch (error) {
console.error('[prelearnBridge] 预学习返回弹框查询失败:', error)
this.showBackPopup = true
}
},
handleBackPopupCancel() {
this.showBackPopup = false
this.backPopInfo.confirmText = '确认已提交'
this.backPopInfo.confirmText = '确认'
},
handleBackPopupConfirm() {
this.showBackPopup = false
this.backPopInfo.confirmText = '确认已提交'
this.backPopInfo.confirmText = '确认'
this.notifyH5AppBackPressed()
},
navigateBack() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!