Commit 267bbcf0 by Lin

Merge branch 'saas+v5.8.3' of http://192.168.3.233:8090/glsx/gl_tape into saas+v5.8.3

2 parents f9aec177 e1e013c1
Showing 38 changed files with 2451 additions and 423 deletions
No preview for this file type
......@@ -5,6 +5,8 @@
background-position: calc(100vmin * (1173 / 768) * -0.7357203751065644) calc(100vmin * (1173 / 768) * -0.6146632566069906);}
.icon-active-msg { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.4057971014492754) calc(100vmin * (1173 / 768) * -0.5434782608695652);}
.icon-activeIcon { width: calc(100vmin * (1173 / 768) * 0.017902813299232736); height: calc(100vmin * (1173 / 768) * 0.010230179028132993);
background-position: calc(100vmin * (1173 / 768) * -0.2855924978687127) calc(100vmin * (1173 / 768) * -0.3329070758738278);}
.icon-activity-active { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.045183290707587385);
background-position: calc(100vmin * (1173 / 768) * -0.44671781756180734) calc(100vmin * (1173 / 768) * -0.4825234441602728);}
.icon-activity { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
......@@ -367,6 +369,8 @@
background-position: calc(100vmin * (1173 / 768) * -0.39258312020460356) calc(100vmin * (1173 / 768) * -0.4825234441602728);}
.icon-record { width: calc(100vmin * (1173 / 768) * 0.0443307757885763); height: calc(100vmin * (1173 / 768) * 0.0443307757885763);
background-position: calc(100vmin * (1173 / 768) * -0.15217391304347827) calc(100vmin * (1173 / 768) * -0.5434782608695652);}
.icon-refreshIcon { width: calc(100vmin * (1173 / 768) * 0.0068201193520886615); height: calc(100vmin * (1173 / 768) * 0.0068201193520886615);
background-position: calc(100vmin * (1173 / 768) * -0.7591645353793691) calc(100vmin * (1173 / 768) * -0.476768968456948);}
.icon-report-management { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
background-position: calc(100vmin * (1173 / 768) * -0.6547314578005116) calc(100vmin * (1173 / 768) * -0.28388746803069054);}
.icon-report { width: calc(100vmin * (1173 / 768) * 0.04092071611253197); height: calc(100vmin * (1173 / 768) * 0.04092071611253197);
......@@ -526,8 +530,12 @@
.icon-yw-icon { width: calc(100vmin * (1173 / 768) * 0.015345268542199489); height: calc(100vmin * (1173 / 768) * 0.015345268542199489);
background-position: calc(100vmin * (1173 / 768) * -0.7357203751065644) calc(100vmin * (1173 / 768) * -0.5707587382779199);}
.icon-zj-icon { width: calc(100vmin * (1173 / 768) * 0.013640238704177323); height: calc(100vmin * (1173 / 768) * 0.013640238704177323);
<<<<<<< HEAD
background-position: calc(100vmin * (1173 / 768) * -0.7591645353793691) calc(100vmin * (1173 / 768) * -0.18030690537084398);}
=======
background-position: calc(100vmin * (1173 / 768) * -0.7591645353793691) calc(100vmin * (1173 / 768) * -0.3205456095481671);}
.icon-customer-task-record { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.4352088661551577) calc(100vmin * (1173 / 768) * -0.6888320545609549);}
.icon-customer-task { width: calc(100vmin * (1173 / 768) * 0.020460358056265986); height: calc(100vmin * (1173 / 768) * 0.020460358056265986);
background-position: calc(100vmin * (1173 / 768) * -0.4620630861040068) calc(100vmin * (1173 / 768) * -0.6888320545609549);}
\ No newline at end of file
background-position: calc(100vmin * (1173 / 768) * -0.4620630861040068) calc(100vmin * (1173 / 768) * -0.6888320545609549);}
>>>>>>> 833749e4aca4cf8683ad65ece681562d1027d949
No preview for this file type

3.24 MB | W: | H:

3.23 MB | W: | H:

assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
assets/images/sprite.png
  • 2-up
  • Swipe
  • Onion skin
<template>
<!-- #ifdef APP-PLUS -->
<view v-if="visible" class="ai-ball-root">
<!-- 每日首次引导气泡 -->
<!-- 每日首次引导气泡(样式与分析异常气泡一致) -->
<view
v-if="guideVisible"
class="guide-bubble"
class="abnormal-bubble guide-bubble"
:class="{ 'guide-fade': guideFading }"
>
<text class="guide-text">点击 AI 助手,获取接待话术与实时分析</text>
<view class="guide-arrow" />
<text class="abnormal-msg">遇到难题?点我一下,帮您解答哦!</text>
</view>
<!-- 异常持久气泡 -->
......@@ -29,75 +28,148 @@
@tap.stop="onBallTap"
>
<view class="fab-content-idle">
<text class="ai-text">AI</text>
<image
class="idle-mascot-svg"
src="/static/images/ai-assistant/side-sparkle-rise-export.svg"
mode="scaleToFill"
></image>
</view>
<view class="fab-content-active">
<view class="sound-wave" aria-hidden="true">
<view class="bar" />
<view class="bar" />
<view class="bar" />
<view class="bar" />
<image
class="thinking-orb-svg"
src="/static/images/ai-assistant/122-eye-blink.svg"
mode="scaleToFill"
></image>
<!-- <view class="thinking-capsule-bg"></view> -->
<view class="thinking-status">
<view class="sound-wave" aria-hidden="true">
<view class="bar"></view>
<view class="bar"></view>
<view class="bar"></view>
<view class="bar"></view>
</view>
<text class="fab-active-text">正在思考中,请稍候...</text>
</view>
<text class="fab-active-text">正在思考中,请稍候...</text>
<view class="fab-cancel-btn" @tap.stop="closeResult">✕</view>
<view
v-if="!thinkingTapGuard"
class="fab-cancel-btn"
@tap.stop="closeResult"
>✕</view>
</view>
</view>
<!-- 操作菜单(按原型:锚定 FAB 上方的 popup;不使用全屏遮罩) -->
<view v-if="menuVisible" class="popup-menu" @tap.stop>
<view class="popup-header-row">
<text class="popup-header">您需要什么帮助?</text>
<view class="popup-close-btn" @tap.stop="closeMenu">✕</view>
</view>
<view class="popup-btn primary" @tap="onHelpAnswer">
<text class="popup-btn-title">🎤 帮我回答顾客刚才的问题(近1分钟)</text>
</view>
<view class="popup-btn" @tap="onUsageIntro">
<text class="popup-btn-title">📖 介绍下谈客助手该如何使用</text>
<!-- 操作菜单 Frame 145:锚定 FAB 上方,带底部三角指向悬浮球 -->
<view v-if="menuVisible" class="help-menu-wrap" @tap.stop>
<view class="help-menu-card">
<view class="help-menu-header">
<text class="help-menu-title">您需要什么帮助</text>
<view class="help-menu-close" @tap.stop="closeMenu">✕</view>
</view>
<view class="help-menu-body">
<view class="help-menu-action" @tap.stop="onHelpAnswer">
<text class="help-menu-action-text">✨ 帮我回答顾客刚才的问题(近1分钟)</text>
<image
class="help-menu-action-arrow"
src="/static/images/ai-assistant/Vector.png"
mode="aspectFit"
/>
</view>
<view class="help-menu-action" @tap.stop="onUsageIntro">
<text class="help-menu-action-text">🌟 介绍下谈客助手该如何使用</text>
<image
class="help-menu-action-arrow"
src="/static/images/ai-assistant/Vector.png"
mode="aspectFit"
/>
</view>
<view class="help-menu-divider" />
<view class="help-menu-skip" @tap.stop="toggleSkipMenu">
<view :class="['help-menu-check', { checked: skipMenu }]" />
<text class="help-menu-skip-text">下次点击直接开始思考,不再显示此菜单</text>
</view>
</view>
</view>
<view class="popup-divider" />
<view class="popup-skip" @tap.stop="toggleSkipMenu">
<view :class="['skip-check', { checked: skipMenu }]" />
<text class="popup-skip-text">下次点击直接开始思考,不再显示此菜单</text>
<view class="help-menu-tail">
<view class="help-menu-pointer" />
</view>
</view>
<!-- 使用介绍(按原型:锚定 FAB 上方的 popup;不使用全屏遮罩) -->
<view v-if="introVisible" class="popup-menu" @tap.stop>
<view class="popup-header-row">
<text class="popup-header">使用介绍</text>
<view class="popup-close-btn" @tap.stop="introVisible = false">✕</view>
<!-- 使用介绍(样式与问题列表弹窗一致) -->
<view v-if="introVisible" class="help-menu-wrap" @tap.stop>
<view class="help-menu-card help-menu-card-intro">
<view class="help-menu-header">
<text class="help-menu-title">使用介绍</text>
<view class="help-menu-close" @tap.stop="closeIntro">✕</view>
</view>
<scroll-view scroll-y class="help-menu-intro-scroll">
<mp-html
:content="introText"
:markdown="true"
:selectable="true"
container-style="padding:0;line-height:1.65;font-size:28rpx;color:#292d33;"
/>
</scroll-view>
</view>
<view class="help-menu-tail">
<view class="help-menu-pointer" />
</view>
<text class="popup-body">{{ introText }}</text>
</view>
<!-- 多问题选择(按原型:锚定 FAB 上方的 popup;不使用全屏遮罩) -->
<view v-if="questionMenuVisible" class="popup-menu" @tap.stop>
<view class="popup-header-row">
<text class="popup-header">客户当前更关注:</text>
<view class="popup-close-btn" @tap.stop="closeQuestionMenu">✕</view>
<!-- 多问题选择 Frame 145 -->
<view v-if="questionMenuVisible" class="help-menu-wrap" @tap.stop>
<view class="help-menu-card">
<view class="help-menu-header">
<text class="help-menu-title">客户当前更关注</text>
<view class="help-menu-close" @tap.stop="closeQuestionMenu">✕</view>
</view>
<view class="help-menu-body">
<view
v-for="(item, idx) in qaList"
:key="'qmenu-' + idx"
class="help-menu-action"
@tap.stop="selectQa(idx)"
>
<text class="help-menu-action-text">🌟 {{ item.query }}</text>
<image
class="help-menu-action-arrow"
src="/static/images/ai-assistant/Vector.png"
mode="aspectFit"
/>
</view>
<view class="help-menu-divider" />
<view class="help-menu-refresh" @tap.stop="onRetakeRecording">
<view class="sprite-icon icon-refreshIcon" />
<text class="help-menu-refresh-text">未命中?重新抓取最新录音</text>
</view>
</view>
</view>
<view
v-for="(item, idx) in qaList"
:key="'qmenu-' + idx"
class="popup-btn"
@tap.stop="selectQa(idx)"
>
<text class="popup-btn-title">{{ item.query }}</text>
<view class="help-menu-tail">
<view class="help-menu-pointer" />
</view>
</view>
<!-- AI 流式结果(mp-html 渲染 markdown) -->
<view v-if="resultVisible" class="menu-mask" @tap="closeResult">
<view class="result-panel" @tap.stop>
<view class="result-head">
<view
v-if="resultVisible"
class="menu-mask"
:class="{ 'question-content-mask': qaList.length && selectedQaIndex >= 0 }"
@tap="closeResult"
>
<view
class="result-panel"
:class="{ 'question-content-panel': qaList.length && selectedQaIndex >= 0 }"
@tap.stop
>
<view class="result-head" :class="{ 'question-content-head': qaList.length && selectedQaIndex >= 0 }">
<view class="result-head-main">
<text class="result-title">AI 建议</text>
<text class="result-title">
{{ qaList.length && selectedQaIndex >= 0 && selectedQa ? selectedQa.query : 'AI 建议' }}
</text>
<text class="result-status">
{{ streamStatusText }}<text v-if="costText">({{ costText }})</text>
</text>
</view>
<text class="result-close" @tap.stop="closeResult">关闭</text>
<text class="result-close" :class="{ 'question-content-close': qaList.length && selectedQaIndex >= 0 }" @tap.stop="closeResult">✕</text>
</view>
<scroll-view
scroll-y
......@@ -122,16 +194,19 @@
<text class="qa-q">{{ item.query }}</text>
</view>
</view>
<text class="qa-hint">点击一个问题查看答案</text>
</view>
<!-- 答案页:选择后只展示答案,隐藏问题 -->
<!-- 内容页:展示 markdown -->
<view v-else class="qa-answer-page">
<view class="qa-answer-head">
<text class="qa-back" @tap.stop="backToQaList">返回问题列表</text>
<text class="qa-answer-title">答案</text>
</view>
<text class="qa-a">{{ selectedQa && selectedQa.answer }}</text>
<mp-html
v-if="selectedQa && selectedQa.answer"
:key="'qa-answer-' + selectedQaIndex"
:content="selectedQa.answer"
:markdown="true"
:scroll-table="true"
:selectable="true"
container-style="padding:0;line-height:1.65;font-size:28rpx;color:#292d33;"
/>
</view>
</view>
<!-- 始终挂载 mp-html,靠 :content 增量更新实现流式渲染(v2.5.2 差量 diff) -->
......@@ -153,7 +228,7 @@
<script>
// #ifdef APP-PLUS
import {
getSkipMenu,
clearSkipMenu,
setSkipMenu,
shouldShowDailyGuide,
markDailyGuideShown
......@@ -161,10 +236,35 @@ import {
import RecordService from '@/utils/recordManager/RecordService.js'
import { getAiStreamSession } from '@/utils/aiAssistant/aiStreamSession.js'
import { TransportType } from '@/utils/socket'
import { serializeIfObject } from '@/utils/utils.js'
const DEMO_CAPTURE_SECONDS = 60
const INTRO_TEXT =
'1. 开始接待后,AI 球出现在左下角\n2. 点击「帮我回答」,将截取最近录音并发送至 AI 分析\n3. 分析结果将展示在界面中\n4. 可勾选「跳过菜单」以快速进入分析'
const HELP_ANSWER_REQUEST_TIMEOUT = 90000
/** 模块级会话序号,避免 uni-app 对 data 中 _ 前缀字段初始化异常 */
let helpAnswerSessionSeq = 0
const INTRO_TEXT = `# 谈客智能体使用说明
**点一下,自动提取最近 1 分钟对话,帮你回答客户。**
你不需要打字,不需要回忆客户说了什么。点击 AI 悬浮球后,系统自动截取刚才 1 分钟的录音,分析客户在关心什么,然后生成一份可以直接给客户看的解答。
## 三步搞定
1. 正常接待,系统后台静默录音
2. 被问住了?**点一下右下角 AI 球**
3. 系统自动提取最近 1 分钟对话 → 分析 → 右侧滑出解答卡片
## 它能帮你答什么?
- 客户问产品参数:透光率多少、隔热怎么样、什么材质、多厚
- 客户问质保售后:保几年、起泡褪色怎么办、是不是全国联保
- 客户问施工流程:贴多久、今天能贴吗、怎么预约
- 客户问产品功能:防晒吗、防爆吗、防刮吗、影不影响智驾信号
- 客户在两个自家产品间犹豫:威固和龙膜什么区别
## 它不会回答什么?
- 价格和折扣 —— 这些必须你亲自谈
- 竞品品牌对比 —— 转给你处理
- 赠品、保险、贷款等非轻改业务 —— 转给你处理`
// #endif
/** idle | menu | thinking */
......@@ -201,7 +301,10 @@ export default {
resultScrollTop: 0,
_scrollPending: false,
qaList: [],
selectedQaIndex: -1
selectedQaIndex: -1,
helpAnswerCancelled: false,
thinkingTapGuard: false,
helpAnswerGuardTimer: null
}
},
computed: {
......@@ -247,14 +350,23 @@ export default {
}
}
},
created() {
// #ifdef APP-PLUS
this.helpAnswerAbort = null
// #endif
},
beforeDestroy() {
this.clearGuideTimer()
this.clearThinkingTapGuard()
// #ifdef APP-PLUS
getAiStreamSession().cancel()
// #endif
},
methods: {
onEnterReception() {
// #ifdef APP-PLUS
this.skipMenu = getSkipMenu()
clearSkipMenu()
this.skipMenu = false
this.tryShowDailyGuide()
// #endif
},
......@@ -282,6 +394,8 @@ export default {
},
onBallTap() {
// #ifdef APP-PLUS
if (this.uiState === 'thinking') return
if (this.menuVisible || this.questionMenuVisible || this.introVisible) return
if (this.abnormalBubbleVisible) {
this.abnormalBubbleVisible = false
this._pendingBallTap = true
......@@ -302,6 +416,7 @@ export default {
handleBallAction() {
// #ifdef APP-PLUS
if (this.uiState === 'thinking') return
if (this.menuVisible || this.questionMenuVisible || this.introVisible) return
if (this.skipMenu) {
this.startThinking()
return
......@@ -319,6 +434,12 @@ export default {
closeQuestionMenu() {
this.questionMenuVisible = false
},
onRetakeRecording() {
// #ifdef APP-PLUS
this.closeQuestionMenu()
this._startHelpAnswerFlow('onRetakeRecording tapped')
// #endif
},
toggleSkipMenu() {
// #ifdef APP-PLUS
this.skipMenu = !this.skipMenu
......@@ -326,21 +447,46 @@ export default {
// #endif
},
onHelpAnswer() {
// #ifdef APP-PLUS
this.closeMenu()
this.startThinking()
this._startHelpAnswerFlow('onHelpAnswer tapped')
// #endif
},
_startHelpAnswerFlow(logMsg) {
// #ifdef APP-PLUS
if (logMsg) {
this._logAi('info', logMsg)
}
this.$nextTick(() => {
this.startThinking()
})
// #endif
},
onUsageIntro() {
this.menuVisible = false
this.uiState = 'idle'
this.introVisible = true
// #ifdef APP-PLUS
this.closeMenu()
this.$nextTick(() => {
this.introVisible = true
})
// #endif
},
closeIntro() {
this.introVisible = false
},
async startThinking() {
// #ifdef APP-PLUS
if (this.uiState === 'thinking') {
this._logAi('warn', 'startThinking skipped: already thinking')
return
}
const sessionId = ++helpAnswerSessionSeq
this.helpAnswerCancelled = false
this.helpAnswerAbort = null
this.uiState = 'thinking'
this._armThinkingTapGuard()
this.menuVisible = false
this.introVisible = false
this.questionMenuVisible = false
// 按原型:进入思考态只展开 FAB,不弹出全屏结果面板
this.resultVisible = false
this.streamMarkdown = ''
this.streamStatus = 'uploading'
......@@ -353,15 +499,36 @@ export default {
this.qaList = []
this.selectedQaIndex = -1
this._logAi('info', `startThinking session=${sessionId}`)
await this.$nextTick()
const isCancelled = () =>
this.helpAnswerCancelled || sessionId !== helpAnswerSessionSeq
try {
await this.runHelpAnswerFlowHttp()
await this.runHelpAnswerFlowHttp(sessionId, isCancelled)
if (isCancelled()) {
this._logAi('info', 'startThinking done but cancelled, skip result')
this._resetThinkingIfNeeded()
return
}
this.streamStatus = 'done'
this.uiState = 'idle'
} catch (e) {
if (isCancelled() || this._isHelpAnswerAbortError(e)) {
this._logAi('info', `startThinking cancelled: ${(e && e.message) || e}`)
this._resetThinkingIfNeeded()
return
}
this._logAi('error', `startThinking failed: ${(e && e.message) || e}`)
this.streamStatus = 'error'
this.uiState = 'idle'
this.resultVisible = false
this.showAbnormalBubble(e.message || '分析失败,请稍后重试')
} finally {
if (!isCancelled()) {
this.helpAnswerAbort = null
}
}
// #endif
},
......@@ -372,9 +539,6 @@ export default {
this.resultVisible = true
}
},
backToQaList() {
this.selectedQaIndex = -1
},
/** 打开面板即开始监听/模拟流式 markdown,边收边渲染 */
beginStreamSession() {
// #ifdef APP-PLUS
......@@ -407,15 +571,22 @@ export default {
this._scrollPending = false
})
},
async runHelpAnswerFlowHttp() {
async runHelpAnswerFlowHttp(sessionId, isCancelled) {
// #ifdef APP-PLUS
// 先确保有录音数据(避免空跑)
if (isCancelled()) {
this._logAi(
'warn',
`runHelpAnswerFlowHttp skipped: cancelled before start session=${sessionId} current=${helpAnswerSessionSeq} flag=${this.helpAnswerCancelled}`
)
return
}
const recordService = RecordService.getInstance()
const tTotalStart = Date.now()
const tPcmStart = Date.now()
this._logAi('info', `captureRecentAudio ${DEMO_CAPTURE_SECONDS}s`)
const buffer = recordService.captureRecentAudio(DEMO_CAPTURE_SECONDS, 'pcm')
this.pcmCostMs = Date.now() - tPcmStart
if (!buffer?.byteLength) {
if (!buffer || !buffer.byteLength) {
throw new Error('暂无录音数据,请确认接待录音已开始')
}
......@@ -430,62 +601,90 @@ export default {
const tEncodeStart = Date.now()
const audioBase64 = uni.arrayBufferToBase64(buffer)
this.encodeCostMs = Date.now() - tEncodeStart
uni.$logger?.local?.info('[AiAssistant][HTTP] request POST /api/audio/chat')
if (isCancelled()) {
this._logAi('warn', 'runHelpAnswerFlowHttp cancelled after encode')
return
}
this._logAi(
'info',
`encode ${this.encodeCostMs}ms, request POST /api/audio/chat session=${sessionId}`
)
let res
const tReqStart = Date.now()
try {
res = await client.request({
url: '/api/audio/chat',
method: 'POST',
timeout: 300000,
timeout: HELP_ANSWER_REQUEST_TIMEOUT,
data: {
message: '将语音的内容转写,并提取客户提出的问题',
audio: audioBase64,
sample_rate: 16000,
sample_width: 2,
channels: 1
},
onTask: (task) => {
this.helpAnswerAbort = () => {
try {
task.abort()
} catch (e) {
// ignore abort errors
}
}
if (isCancelled()) {
this.helpAnswerAbort()
}
}
})
} catch (e) {
const errMsg = e?.errMsg || e?.message || ''
const errMsg = (e && (e.errMsg || e.message)) || ''
this.uploadCostMs = Date.now() - tReqStart
uni.$logger?.local?.error(
`[AiAssistant][HTTP] request /api/audio/chat failed: ${errMsg} ${serializeIfObject(e)}`
)
if (isCancelled()) {
this._logAi('info', `request cancelled/failed: ${errMsg}`)
return
}
if (this._isHelpAnswerAbortError(e)) {
if (this._isHelpAnswerNetworkError(e)) {
this._logAi('error', `request /api/audio/chat network failed: ${errMsg}`)
throw new Error('AI 服务连接失败,请稍后重试')
}
this._logAi('info', `request cancelled/failed: ${errMsg}`)
return
}
this._logAi('error', `request /api/audio/chat failed: ${errMsg}`)
throw e
}
this.uploadCostMs = Date.now() - tReqStart
if (isCancelled()) {
this._logAi('warn', 'response ignored: cancelled')
return
}
const status = res?.statusCode
const status = res && res.statusCode
if (typeof status === 'number' && (status < 200 || status >= 300)) {
const bodyPreview = (() => {
try {
return JSON.stringify(res?.data ?? {}).slice(0, 800)
} catch {
return String(res?.data ?? '')
return JSON.stringify((res && res.data) || {}).slice(0, 800)
} catch (e) {
return String((res && res.data) || '')
}
})()
uni.$logger?.local?.error(
`[AiAssistant][HTTP] response /api/audio/chat non-2xx status=${status} body=${bodyPreview}`
)
this._logAi('error', `response non-2xx status=${status} body=${bodyPreview}`)
throw new Error(`HTTP ${status}`)
}
const tParseStart = Date.now()
const payload = res?.data
try {
const preview = JSON.stringify(payload || {}).slice(0, 800)
uni.$logger?.local?.info(`[AiAssistant][HTTP] response /api/audio/chat => ${preview}`)
// #ifdef APP-PLUS
if (typeof plus !== 'undefined' && plus?.console?.log) {
plus.console.log(`[AiAssistant][HTTP] response /api/audio/chat => ${preview}`)
}
// #endif
} catch (e) {
uni.$logger?.local?.warn('[AiAssistant][HTTP] response stringify failed')
const payload = res && res.data
this._logAi(
'info',
`response /api/audio/chat status=${status} => ${JSON.stringify(payload || {}).slice(0, 800)}`
)
if (isCancelled()) {
this._logAi('warn', 'parse skipped: cancelled')
return
}
const list = Array.isArray(payload)
? payload
: payload?.type === 'result' && Array.isArray(payload.content)
: payload && payload.type === 'result' && Array.isArray(payload.content)
? payload.content
: null
if (!Array.isArray(list)) {
......@@ -494,33 +693,100 @@ export default {
this.qaList = list
.map((x) => ({
query: x?.query || '',
answer: x?.answer || ''
query: (x && x.query) || '',
answer: (x && x.answer) || ''
}))
.filter((x) => x.query || x.answer)
this.resultCostMs = Date.now() - tParseStart
this.totalCostMs = Date.now() - tTotalStart
if (!this.qaList.length) {
throw new Error('AI 未返回问题列表')
this._logAi('info', 'response empty, no questions to show')
return
}
if (isCancelled()) {
this._logAi('warn', 'show result skipped: cancelled')
return
}
// 多问题:按原型弹出选择 popup(隐藏结果面板)
if (this.qaList.length > 1) {
this.selectedQaIndex = -1
this.questionMenuVisible = true
this.resultVisible = false
} else {
// 单问题:直接进入答案页
this.questionMenuVisible = false
this.selectedQaIndex = 0
this.resultVisible = true
}
// #endif
},
_logAi(level, msg) {
// #ifdef APP-PLUS
const text = `[AiAssistant] ${msg}`
const logger = uni.$logger && uni.$logger.local
if (logger && logger[level]) {
logger[level](text)
}
if (typeof plus !== 'undefined' && plus.console && plus.console.log) {
plus.console.log(text)
}
// #endif
},
_armThinkingTapGuard() {
this.thinkingTapGuard = true
this.clearThinkingTapGuard()
this.helpAnswerGuardTimer = setTimeout(() => {
this.thinkingTapGuard = false
this.helpAnswerGuardTimer = null
}, 400)
},
clearThinkingTapGuard() {
if (this.helpAnswerGuardTimer) {
clearTimeout(this.helpAnswerGuardTimer)
this.helpAnswerGuardTimer = null
}
},
_isHelpAnswerAbortError(err) {
const msg = String((err && (err.errMsg || err.message)) || '')
return /abort|cancel/i.test(msg)
},
_isHelpAnswerNetworkError(err) {
const msg = String((err && (err.errMsg || err.message)) || '')
return /failed to connect|statusCode:-1|network|econn|timeout/i.test(msg)
},
_resetThinkingIfNeeded() {
if (this.uiState !== 'thinking') return
this.uiState = 'idle'
this.streamStatus = 'idle'
},
_cancelHelpAnswerFlow(reason) {
helpAnswerSessionSeq += 1
this.helpAnswerCancelled = true
this._logAi('info', `helpAnswer flow cancelled: ${reason || 'unknown'}`)
if (this.helpAnswerAbort) {
try {
this.helpAnswerAbort()
} catch (e) {
// ignore abort errors
}
this.helpAnswerAbort = null
}
},
closeResult() {
this.resultVisible = false
if (this.thinkingTapGuard) {
this._logAi('info', 'closeResult ignored: thinking tap guard')
return
}
if (this.uiState === 'thinking' || this.helpAnswerAbort) {
this._cancelHelpAnswerFlow('closeResult')
}
// #ifdef APP-PLUS
getAiStreamSession().cancel()
// #endif
this.resultVisible = false
this.questionMenuVisible = false
this.qaList = []
this.selectedQaIndex = -1
if (this.uiState === 'thinking') {
this.uiState = 'idle'
}
......@@ -529,11 +795,20 @@ export default {
showAbnormalBubble(message) {
this.abnormalMessage = message
this.abnormalBubbleVisible = true
uni.$logger?.local?.warn(`[AiAssistant] ${message}`)
if (uni.$logger && uni.$logger.local && uni.$logger.local.warn) {
uni.$logger.local.warn(`[AiAssistant] ${message}`)
}
},
resetAll() {
this.clearGuideTimer()
this.clearThinkingTapGuard()
this.thinkingTapGuard = false
if (this.uiState === 'thinking' || this.helpAnswerAbort) {
this._cancelHelpAnswerFlow('resetAll')
}
// #ifdef APP-PLUS
getAiStreamSession().cancel()
// #endif
this.uiState = 'idle'
this.menuVisible = false
this.introVisible = false
......@@ -560,48 +835,24 @@ export default {
<style lang="scss" scoped>
.ai-ball-root {
position: fixed;
right: 32rpx;
bottom: 32rpx;
left: 128rpx;
bottom: 184rpx;
z-index: 100015;
pointer-events: none;
}
.guide-bubble {
position: absolute;
right: 0;
bottom: 110rpx;
max-width: 520rpx;
padding: 18rpx 22rpx;
background: rgba(255, 255, 255, 0.95);
border-radius: 16rpx;
pointer-events: none;
opacity: 1;
transition: all 0.3s ease;
border: 1px solid rgba(255, 255, 255, 0.8);
box-shadow: 0 12rpx 32rpx rgba(0, 0, 0, 0.15);
transition: opacity 0.3s ease;
&.guide-fade {
opacity: 0;
}
}
.guide-text {
color: #1f2937;
font-size: 24rpx;
line-height: 1.5;
}
.guide-arrow {
position: absolute;
bottom: -10rpx;
right: 44rpx;
width: 20rpx;
height: 20rpx;
background: rgba(255, 255, 255, 0.95);
transform: rotate(45deg);
box-shadow: 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.05);
}
.abnormal-bubble {
position: absolute;
right: 0;
left: 0;
bottom: 110rpx;
width: 520rpx;
padding: 18rpx 18rpx 18rpx 22rpx;
......@@ -634,9 +885,6 @@ export default {
pointer-events: auto;
height: 112rpx;
border-radius: 56rpx;
background: linear-gradient(135deg, #34d399, #0ea5e9);
box-shadow: 0 12rpx 24rpx rgba(14, 165, 233, 0.4);
border: 2rpx solid rgba(255, 255, 255, 0.4);
display: flex;
align-items: center;
justify-content: center;
......@@ -645,36 +893,72 @@ export default {
}
.fab-container.state-idle {
width: 112rpx;
animation: fab-breathing 3s infinite ease-in-out;
background: transparent;
border: none;
box-shadow: none;
overflow: visible;
animation: none;
}
.fab-container.state-active {
width: 520rpx;
background: linear-gradient(135deg, #3b82f6, #06b6d4);
box-shadow: 0 12rpx 32rpx rgba(59, 130, 246, 0.5);
height: 184rpx;
background: transparent;
box-shadow: none;
border: none;
overflow: visible;
animation: none;
pointer-events: none;
}
.fab-content-idle {
display: flex;
align-items: center;
justify-content: center;
}
.ai-text {
color: #fff;
font-size: 40rpx;
font-weight: 800;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2);
/* Frame 139 SVG: 48px × 48px */
.idle-mascot-svg {
display: block;
width: 160rpx;
height: 160rpx;
}
.fab-content-active {
position: relative;
display: none;
width: 100%;
padding: 0 24rpx 0 28rpx;
width: 520rpx;
height: 184rpx;
padding: 0;
box-sizing: border-box;
align-items: center;
gap: 18rpx;
white-space: nowrap;
color: #fff;
font-size: 26rpx;
font-weight: 500;
justify-content: center;
}
.thinking-orb-svg {
position: absolute;
left: 0;
top: -4px;
width: 520rpx;
height: 184rpx;
display: block;
}
.thinking-capsule-bg {
position: absolute;
left: 0;
bottom: 0;
width: 500rpx;
height: 96rpx;
border-radius: 48rpx;
background: linear-gradient(90deg, #61c0ff 0%, #2c66f7 100%);
z-index: 1;
}
.thinking-status {
position: absolute;
left: 42rpx;
right: 132rpx;
bottom: 6rpx;
height: 96rpx;
display: flex;
align-items: center;
gap: 12rpx;
z-index: 2;
}
.fab-container.state-active .fab-content-idle {
display: none;
......@@ -685,20 +969,31 @@ export default {
.fab-active-text {
flex: 1;
min-width: 0;
color: #fff;
font-size: 30rpx;
font-weight: 500;
line-height: 96rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fab-cancel-btn {
width: 52rpx;
height: 52rpx;
border-radius: 26rpx;
background: rgba(255, 255, 255, 0.2);
border: 1px solid rgba(255, 255, 255, 0.25);
position: absolute;
right: 68rpx;
bottom: 34rpx;
width: 40rpx;
height: 40rpx;
border-radius: 0;
background: transparent;
border: none;
display: flex;
align-items: center;
justify-content: center;
font-size: 24rpx;
flex-shrink: 0;
color: #fff;
font-size: 40rpx;
line-height: 40rpx;
z-index: 3;
pointer-events: auto;
}
@keyframes fab-breathing {
......@@ -719,30 +1014,31 @@ export default {
/* 声波动效 */
.sound-wave {
display: flex;
gap: 8rpx;
height: 48rpx;
gap: 5rpx;
height: 30rpx;
align-items: center;
flex-shrink: 0;
}
.sound-wave .bar {
width: 6rpx;
width: 4rpx;
background: #fff;
border-radius: 4rpx;
animation: fab-wave 1s infinite ease-in-out;
}
.sound-wave .bar:nth-child(1) {
height: 24rpx;
height: 14rpx;
animation-delay: 0s;
}
.sound-wave .bar:nth-child(2) {
height: 48rpx;
height: 30rpx;
animation-delay: 0.2s;
}
.sound-wave .bar:nth-child(3) {
height: 32rpx;
height: 22rpx;
animation-delay: 0.4s;
}
.sound-wave .bar:nth-child(4) {
height: 16rpx;
height: 12rpx;
animation-delay: 0.6s;
}
@keyframes fab-wave {
......@@ -755,10 +1051,171 @@ export default {
}
}
/* Frame 145 帮助菜单 */
.help-menu-wrap {
position: absolute;
left: 0;
bottom: 110rpx;
width: 720rpx;
display: flex;
flex-direction: column;
align-items: flex-start;
pointer-events: auto;
}
.help-menu-card {
width: 720rpx;
box-sizing: border-box;
background: #ffffff;
border-radius: 32rpx;
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.3);
overflow: hidden;
padding-bottom: 48rpx;
}
.help-menu-header {
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 32rpx 48rpx;
background: linear-gradient(180deg, #e6f0ff 0%, #ffffff 40%, #ffffff 100%);
border-radius: 32rpx 32rpx 0 0;
}
.help-menu-title {
flex: 1;
min-width: 0;
font-weight: 500;
font-size: 36rpx;
line-height: 42rpx;
color: #292d33;
}
.help-menu-close {
width: 40rpx;
height: 40rpx;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
color: #999ea8;
font-size: 32rpx;
line-height: 40rpx;
}
.help-menu-body {
display: flex;
flex-direction: column;
padding: 0 48rpx;
gap: 28rpx;
}
.help-menu-action {
display: flex;
flex-direction: row;
align-items: center;
padding: 32rpx 24rpx;
gap: 16rpx;
min-height: 96rpx;
box-sizing: border-box;
background: linear-gradient(180deg, rgba(210, 234, 255, 0.3) 0%, rgba(255, 255, 255, 0.3) 100%);
border: 1px solid #ffffff;
box-shadow: 0 4rpx 12rpx rgba(44, 102, 247, 0.1);
border-radius: 32rpx;
}
.help-menu-action-text {
flex: 1;
min-width: 0;
font-weight: 400;
font-size: 28rpx;
line-height: 32rpx;
color: #292d33;
}
.help-menu-action-arrow {
width: 30rpx;
height: 30rpx;
flex-shrink: 0;
display: block;
min-width: 30rpx;
min-height: 30rpx;
}
.help-menu-divider {
height: 0;
border-top: 1px solid #f5f7fa;
}
.help-menu-skip {
display: flex;
flex-direction: row;
align-items: center;
padding: 8rpx 0;
gap: 8rpx;
}
.help-menu-check {
width: 32rpx;
height: 32rpx;
border: 1px solid #999ea8;
border-radius: 4rpx;
flex-shrink: 0;
box-sizing: border-box;
&.checked {
background: #2c66f7;
border-color: #2c66f7;
position: relative;
&::after {
content: '';
position: absolute;
left: 8rpx;
top: 2rpx;
width: 8rpx;
height: 16rpx;
border: solid #fff;
border-width: 0 2rpx 2rpx 0;
transform: rotate(45deg);
}
}
}
.help-menu-skip-text {
font-weight: 400;
font-size: 26rpx;
line-height: 30rpx;
color: #999ea8;
}
.help-menu-refresh {
display: flex;
flex-direction: row;
align-items: center;
padding: 8rpx 0;
gap: 8rpx;
}
.help-menu-refresh-text {
font-weight: 400;
font-size: 26rpx;
line-height: 30rpx;
color: #999ea8;
}
.help-menu-tail {
width: 100%;
padding: 0 32rpx;
box-sizing: border-box;
}
.help-menu-pointer {
width: 24rpx;
height: 16rpx;
background: #ffffff;
clip-path: polygon(50% 100%, 0 0, 100% 0);
}
.help-menu-card-intro {
max-height: 70vh;
display: flex;
flex-direction: column;
padding-bottom: 24rpx;
}
.help-menu-intro-scroll {
flex: 1;
min-height: 0;
max-height: 58vh;
padding: 0 48rpx 8rpx;
box-sizing: border-box;
}
/* Popup(按原型:锚定 FAB 上方;不使用全屏 overlay) */
.popup-menu {
position: absolute;
right: 32rpx;
left: 0;
bottom: 220rpx; /* FAB 上方 */
width: 620rpx;
background: rgba(255, 255, 255, 0.98);
......@@ -844,6 +1301,11 @@ export default {
align-items: flex-end;
justify-content: center;
}
.menu-mask.question-content-mask {
align-items: stretch;
justify-content: flex-start;
padding-left: 0;
}
.menu-panel,
.intro-panel {
width: 100%;
......@@ -944,6 +1406,14 @@ export default {
box-sizing: border-box;
padding-bottom: env(safe-area-inset-bottom);
}
.result-panel.question-content-panel {
width: 400px;
height: 100%;
max-height: none;
border-radius: 0 24px 24px 0;
box-shadow: 4px 0 16px rgba(44, 102, 247, 0.1);
padding-bottom: 0;
}
.result-head {
display: flex;
align-items: flex-start;
......@@ -951,6 +1421,27 @@ export default {
padding: 28rpx 32rpx 16rpx;
border-bottom: 1px solid #eee;
}
.result-head.question-content-head {
height: 53px;
padding: 16px 24px;
align-items: center;
flex-shrink: 0;
}
.result-head.question-content-head .result-head-main {
overflow: hidden;
}
.result-head.question-content-head .result-title {
font-size: 18px;
line-height: 21px;
font-weight: 500;
color: #292d33;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.result-head.question-content-head .result-status {
display: none;
}
.result-head-main {
flex: 1;
min-width: 0;
......@@ -972,12 +1463,29 @@ export default {
color: #6b7280;
padding: 8rpx 0 8rpx 24rpx;
}
.result-close.question-content-close {
width: 20px;
height: 20px;
min-width: 20px;
padding: 0;
font-size: 20px;
line-height: 20px;
text-align: center;
color: #999ea8;
}
.result-scroll {
flex: 1;
max-height: 62vh;
padding: 20rpx 24rpx 32rpx;
box-sizing: border-box;
}
.question-content-panel .result-scroll {
flex: 1;
min-height: 0;
max-height: none;
height: auto;
padding: 20px 24px 24px;
}
.qa-root {
padding: 8rpx 8rpx 24rpx;
}
......@@ -1032,32 +1540,56 @@ export default {
color: #6b7280;
font-size: 24rpx;
}
.question-content-panel .qa-root {
padding: 0;
}
.qa-answer-page {
padding-top: 8rpx;
padding-top: 0;
}
.qa-answer-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
margin-bottom: 14rpx;
.qa-answer-page ::v-deep .md-table {
display: block;
width: 100%;
overflow-x: auto;
border-collapse: collapse;
margin: 12px 0;
}
.qa-back {
color: #4f46e5;
font-size: 24rpx;
padding: 10rpx 14rpx;
border-radius: 999rpx;
background: #eef2ff;
border: 1px solid #c7d2fe;
.qa-answer-page ::v-deep .md-th,
.qa-answer-page ::v-deep .md-td {
border: 1px solid #e5e7eb;
padding: 8px 10px;
font-size: 26rpx;
line-height: 1.5;
vertical-align: top;
}
.qa-answer-page .qa-answer-title {
margin-bottom: 0;
.qa-answer-page ::v-deep .md-th {
background: #f5f7fa;
font-weight: 500;
color: #292d33;
}
.qa-a {
color: #111827;
font-size: 26rpx;
line-height: 1.6;
white-space: pre-wrap;
.qa-answer-page ::v-deep .md-td {
color: #4b5563;
}
.qa-answer-page ::v-deep h2,
.qa-answer-page ::v-deep h3 {
margin: 16px 0 8px;
font-size: 30rpx;
font-weight: 600;
color: #292d33;
}
.qa-answer-page ::v-deep p {
margin: 8px 0;
}
.qa-answer-page ::v-deep ul,
.qa-answer-page ::v-deep ol {
padding-left: 20px;
margin: 8px 0;
}
.qa-answer-page ::v-deep blockquote {
margin: 12px 0;
padding: 8px 12px;
border-left: 3px solid #2c66f7;
background: #f5f8ff;
color: #4b5563;
}
.result-loading {
padding: 48rpx 0;
......
......@@ -38,7 +38,8 @@
</view>
</template>
<template v-else>
<video :src="item.mediaIds" class="video" :poster="defaultPoster"></video>
<!-- <video controls :src="item.mediaIds" class="video" ></video> -->
<DomVideoPlayer class="video" ref="domVideoPlayer" :src="item.mediaIds" :poster="defaultPoster" controls />
</template>
</template>
<template v-else-if="item.messageType == 4">
......@@ -228,6 +229,7 @@ export default {
background-color: #EAF9F1;
color: #35C376;
}
&.failed {
background-color: #FDECE9;
color: #F24724;
......@@ -272,12 +274,17 @@ export default {
}
}
.video,
.image {
width: toRpx(160);
height: toRpx(160);
border-radius: toRpx(16);
}
.video {
width: toRpx(480);
height: toRpx(320);
border-radius: toRpx(16);
}
.img-box {
......
<!-- eslint-disable -->
<template>
<view
class="player-wrapper"
:id="videoWrapperId"
:parentId="id"
:randomNum="randomNum"
:change:randomNum="domVideoPlayer.randomNumChange"
:viewportProps="viewportProps"
:change:viewportProps="domVideoPlayer.viewportChange"
:videoSrc="videoSrc"
:change:videoSrc="domVideoPlayer.initVideoPlayer"
:command="eventCommand"
:change:command="domVideoPlayer.triggerCommand"
:func="renderFunc"
:change:func="domVideoPlayer.triggerFunc"
/>
</template>
<script>
export default {
props: {
src: {
type: String,
default: ''
},
autoplay: {
type: Boolean,
default: false
},
loop: {
type: Boolean,
default: false
},
controls: {
type: Boolean,
default: false
},
objectFit: {
type: String,
default: 'contain'
},
muted: {
type: Boolean,
default: false
},
playbackRate: {
type: Number,
default: 1
},
isLoading: {
type: Boolean,
default: false
},
poster: {
type: String,
default: ''
},
id: {
type: String,
default: ''
}
},
data() {
return {
randomNum: Math.floor(Math.random() * 100000000),
videoSrc: '',
// 父组件向子组件传递的事件指令(video的原生事件)
eventCommand: null,
// 父组件传递过来的,对 renderjs 层的函数执行(对视频控制的自定义事件)
renderFunc: {
name: null,
params: null
},
// 提供给父组件进行获取的视频属性
currentTime: 0,
duration: 0,
playing: false
}
},
watch: {
// 监听视频资源地址更新
src: {
handler(val) {
if (!val) return
setTimeout(() => {
this.videoSrc = val
}, 0)
},
immediate: true
}
},
computed: {
videoWrapperId() {
return `video-wrapper-${this.randomNum}`
},
// 聚合视图层的所有数据变化,传给renderjs的渲染层
viewportProps() {
return {
autoplay: this.autoplay,
muted: this.muted,
controls: this.controls,
loop: this.loop,
objectFit: this.objectFit,
poster: this.poster,
isLoading: this.isLoading,
playbackRate: this.playbackRate
}
}
},
// 方法
methods: {
// 传递事件指令给父组件
eventEmit({ event, data }) {
this.$emit(event, data)
},
// 修改view视图层的data数据
setViewData({ key, value }) {
key && this.$set(this, key, value)
},
// 重置事件指令
resetEventCommand() {
this.eventCommand = null
},
// 播放指令
play() {
this.eventCommand = 'play'
},
// 暂停指令
pause() {
this.eventCommand = 'pause'
},
// 重置自定义函数指令
resetFunc() {
this.renderFunc = {
name: null,
params: null
}
},
// 自定义函数 - 移除视频
remove(params) {
this.renderFunc = {
name: 'removeHandler',
params
}
},
// 自定义函数 - 全屏播放
fullScreen(params) {
this.renderFunc = {
name: 'fullScreenHandler',
params
}
},
// 自定义函数 - 跳转到指定时间点
toSeek(sec, isDelay = false) {
this.renderFunc = {
name: 'toSeekHandler',
params: { sec, isDelay }
}
}
}
}
</script>
<script module="domVideoPlayer" lang="renderjs">
const PLAYER_ID = 'DOM_VIDEO_PLAYER'
export default {
data() {
return {
num: '',
videoEl: null,
loadingEl: null,
// 延迟生效的函数
delayFunc: null,
renderProps: {}
}
},
computed: {
playerId() {
return `${PLAYER_ID}_${this.num}`
},
wrapperId() {
return `video-wrapper-${this.num}`
}
},
methods: {
isApple() {
const ua = navigator.userAgent.toLowerCase()
return ua.indexOf('iphone') !== -1 || ua.indexOf('ipad') !== -1
},
async initVideoPlayer(src) {
this.delayFunc = null
await this.$nextTick()
if (!src) return
if (this.videoEl) {
// 切换视频源
if (!this.isApple() && this.loadingEl) {
this.loadingEl.style.display = 'block'
}
this.videoEl.src = src
return
}
const videoEl = document.createElement('video')
this.videoEl = videoEl
// 开始监听视频相关事件
this.listenVideoEvent()
const { autoplay, muted, controls, loop, playbackRate, objectFit, poster } = this.renderProps
videoEl.src = src
videoEl.autoplay = autoplay
videoEl.controls = controls
videoEl.loop = loop
videoEl.muted = muted
videoEl.playbackRate = playbackRate
videoEl.id = this.playerId
// videoEl.setAttribute('x5-video-player-type', 'h5')
videoEl.setAttribute('preload', 'auto')
videoEl.setAttribute('playsinline', true)
videoEl.setAttribute('webkit-playsinline', true)
videoEl.setAttribute('crossorigin', 'anonymous')
videoEl.setAttribute('controlslist', 'nodownload')
videoEl.setAttribute('disablePictureInPicture', true)
videoEl.style.objectFit = objectFit
poster && (videoEl.poster = poster)
videoEl.style.width = '100%'
videoEl.style.height = '100%'
// 插入视频元素
// document.getElementById(this.wrapperId).appendChild(videoEl)
const playerWrapper = document.getElementById(this.wrapperId)
playerWrapper.insertBefore(videoEl, playerWrapper.firstChild)
// 插入loading 元素(遮挡安卓的默认加载过程中的黑色播放按钮)
this.createLoading()
},
// 创建 loading
createLoading() {
const { isLoading } = this.renderProps
if (!this.isApple() && isLoading) {
const loadingEl = document.createElement('div')
this.loadingEl = loadingEl
loadingEl.className = 'loading-wrapper'
loadingEl.style.position = 'absolute'
loadingEl.style.top = '0'
loadingEl.style.left = '0'
loadingEl.style.zIndex = '1'
loadingEl.style.width = '100%'
loadingEl.style.height = '100%'
loadingEl.style.backgroundColor = 'black'
document.getElementById(this.wrapperId).appendChild(loadingEl)
// 创建 loading 动画
const animationEl = document.createElement('div')
animationEl.className = 'loading'
animationEl.style.zIndex = '2'
animationEl.style.position = 'absolute'
animationEl.style.top = '50%'
animationEl.style.left = '50%'
animationEl.style.marginTop = '-15px'
animationEl.style.marginLeft = '-15px'
animationEl.style.width = '30px'
animationEl.style.height = '30px'
animationEl.style.border = '2px solid #FFF'
animationEl.style.borderTopColor = 'rgba(255, 255, 255, 0.2)'
animationEl.style.borderRightColor = 'rgba(255, 255, 255, 0.2)'
animationEl.style.borderBottomColor = 'rgba(255, 255, 255, 0.2)'
animationEl.style.borderRadius = '100%'
animationEl.style.animation = 'circle infinite 0.75s linear'
loadingEl.appendChild(animationEl)
// 创建 loading 动画所需的 keyframes
const style = document.createElement('style')
const keyframes = `
@keyframes circle {
0% {
transform: rotate(0);
}
100% {
transform: rotate(360deg);
}
}
`
style.type = 'text/css'
if (style.styleSheet) {
style.styleSheet.cssText = keyframes
} else {
style.appendChild(document.createTextNode(keyframes))
}
document.head.appendChild(style)
}
},
// 监听视频相关事件
listenVideoEvent() {
// 播放事件监听
const playHandler = () => {
this.$ownerInstance.callMethod('eventEmit', { event: 'play' })
this.$ownerInstance.callMethod('setViewData', {
key: 'playing',
value: true
})
if (this.loadingEl) {
this.loadingEl.style.display = 'none'
}
}
this.videoEl.removeEventListener('play', playHandler)
this.videoEl.addEventListener('play', playHandler)
// 暂停事件监听
const pauseHandler = () => {
this.$ownerInstance.callMethod('eventEmit', { event: 'pause' })
this.$ownerInstance.callMethod('setViewData', {
key: 'playing',
value: false
})
}
this.videoEl.removeEventListener('pause', pauseHandler)
this.videoEl.addEventListener('pause', pauseHandler)
// 结束事件监听
const endedHandler = () => {
this.$ownerInstance.callMethod('eventEmit', { event: 'ended' })
this.$ownerInstance.callMethod('resetEventCommand')
}
this.videoEl.removeEventListener('ended', endedHandler)
this.videoEl.addEventListener('ended', endedHandler)
// 加载完成事件监听
const canPlayHandler = () => {
this.$ownerInstance.callMethod('eventEmit', { event: 'canplay' })
this.execDelayFunc()
}
this.videoEl.removeEventListener('canplay', canPlayHandler)
this.videoEl.addEventListener('canplay', canPlayHandler)
// 加载失败事件监听
const errorHandler = (e) => {
if (this.loadingEl) {
this.loadingEl.style.display = 'block'
}
this.$ownerInstance.callMethod('eventEmit', { event: 'error' })
}
this.videoEl.removeEventListener('error', errorHandler)
this.videoEl.addEventListener('error', errorHandler)
// loadedmetadata 事件监听
const loadedMetadataHandler = () => {
this.$ownerInstance.callMethod('eventEmit', { event: 'loadedmetadata' })
// 获取视频的长度
const duration = this.videoEl.duration
this.$ownerInstance.callMethod('eventEmit', {
event: 'durationchange',
data: duration
})
this.$ownerInstance.callMethod('setViewData', {
key: 'duration',
value: duration
})
// 加载首帧视频 模拟出封面图
this.loadFirstFrame()
}
this.videoEl.removeEventListener('loadedmetadata', loadedMetadataHandler)
this.videoEl.addEventListener('loadedmetadata', loadedMetadataHandler)
// 播放进度监听
const timeupdateHandler = (e) => {
const currentTime = e.target.currentTime
this.$ownerInstance.callMethod('eventEmit', {
event: 'timeupdate',
data: currentTime
})
this.$ownerInstance.callMethod('setViewData', {
key: 'currentTime',
value: currentTime
})
}
this.videoEl.removeEventListener('timeupdate', timeupdateHandler)
this.videoEl.addEventListener('timeupdate', timeupdateHandler)
// 倍速播放监听
const ratechangeHandler = (e) => {
const playbackRate = e.target.playbackRate
this.$ownerInstance.callMethod('eventEmit', {
event: 'ratechange',
data: playbackRate
})
}
this.videoEl.removeEventListener('ratechange', ratechangeHandler)
this.videoEl.addEventListener('ratechange', ratechangeHandler)
// 全屏事件监听
if (this.isApple()) {
const webkitbeginfullscreenHandler = () => {
const presentationMode = this.videoEl.webkitPresentationMode
let isFullScreen = null
if (presentationMode === 'fullscreen') {
isFullScreen = true
} else {
isFullScreen = false
}
this.$ownerInstance.callMethod('eventEmit', {
event: 'fullscreenchange',
data: isFullScreen
})
}
this.videoEl.removeEventListener('webkitpresentationmodechanged', webkitbeginfullscreenHandler)
this.videoEl.addEventListener('webkitpresentationmodechanged', webkitbeginfullscreenHandler)
} else {
const fullscreenchangeHandler = () => {
let isFullScreen = null
if (document.fullscreenElement) {
isFullScreen = true
} else {
isFullScreen = false
}
this.$ownerInstance.callMethod('eventEmit', {
event: 'fullscreenchange',
data: isFullScreen
})
}
document.removeEventListener('fullscreenchange', fullscreenchangeHandler)
document.addEventListener('fullscreenchange', fullscreenchangeHandler)
}
},
// 加载首帧视频,模拟出封面图
loadFirstFrame() {
let { autoplay, muted } = this.renderProps
if (this.isApple()) {
this.videoEl.play()
if (!autoplay) {
this.videoEl.pause()
}
} else {
// optimize: timeout 延迟调用是为了规避控制台的`https://goo.gl/LdLk22`这个报错
/**
* 原因:chromium 内核中,谷歌协议规定,视频不允许在非静音状态下进行自动播放
* 解决:在自动播放时,先将视频静音,然后延迟调用 play 方法,播放视频
* 说明:iOS 的 Safari 内核不会有这个,仅在 Android 设备出现,即使有这个报错也不影响的,所以不介意控制台报错的话是可以删掉这个 timeout 的
*/
this.videoEl.muted = true
setTimeout(() => {
this.videoEl.play()
this.videoEl.muted = muted
if (!autoplay) {
setTimeout(() => {
this.videoEl.pause()
}, 100)
}
}, 10)
}
},
triggerCommand(eventType) {
if (eventType) {
this.$ownerInstance.callMethod('resetEventCommand')
this.videoEl && this.videoEl[eventType]()
}
},
triggerFunc(func) {
const { name, params } = func || {}
if (name) {
this[name](params)
this.$ownerInstance.callMethod('resetFunc')
}
},
removeHandler() {
if (this.videoEl) {
this.videoEl.pause()
this.videoEl.src = ''
this.$ownerInstance.callMethod('setViewData', {
key: 'videoSrc',
value: ''
})
this.videoEl.load()
}
},
fullScreenHandler() {
if (this.isApple()) {
this.videoEl.webkitEnterFullscreen()
} else {
this.videoEl.requestFullscreen()
}
},
toSeekHandler({ sec, isDelay }) {
const func = () => {
if (this.videoEl) {
this.videoEl.currentTime = sec
}
}
// 延迟执行
if (isDelay) {
this.delayFunc = func
} else {
func()
}
},
// 执行延迟函数
execDelayFunc() {
this.delayFunc && this.delayFunc()
this.delayFunc = null
},
viewportChange(props) {
this.renderProps = props
const { autoplay, muted, controls, loop, playbackRate } = props
if (this.videoEl) {
this.videoEl.autoplay = autoplay
this.videoEl.controls = controls
this.videoEl.loop = loop
this.videoEl.muted = muted
this.videoEl.playbackRate = playbackRate
}
},
randomNumChange(val) {
this.num = val
}
}
}
</script>
<style scoped>
.player-wrapper {
overflow: hidden;
height: 100%;
padding: 0;
position: relative;
}
</style>
<!-- 异常订单 -->
<template>
<view v-if="show" class="error-order-popup-mask" @click="handleMaskClick">
<view
class="error-order-popup-content"
<view
class="error-order-popup-content"
:style="contentStyle"
@click.stop
>
<!-- 顶部图片 -->
......@@ -46,7 +46,7 @@
},
height: {
type: [Number, String],
default: 1054
default: null
},
title: {
type: String,
......@@ -75,10 +75,13 @@
},
computed: {
contentStyle() {
return {
width: this.formatSize(this.width),
minHeight: this.formatSize(this.height)
const style = {
width: this.formatSize(this.width)
}
if (this.height != null && this.height !== '') {
style.minHeight = this.formatSize(this.height)
}
return style
},
topImageStyle() {
return {
......
......@@ -225,7 +225,7 @@
</template>
</ErrorOrderPopup>
<!-- #ifdef APP-PLUS -->
<AiAssistantBall :visible="showAiAssistant" />
<AiAssistantBall :visible="showAiAssistant && sceneType == 1" />
<!-- #endif -->
<FloatLogPanel v-if="showFloatLog" />
</view>
......
......@@ -39,6 +39,10 @@
:class="['item flex', { active: checkActive(i) }]"
>
<view class="sprite-icon icon-tag-checked"></view>
<view
v-if="shouldShowMarketingIcon(i)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="goods-name text-hide">
{{ replaceItemText(i.goods, 'goodsAlias') || replaceItemText(i.goods, 'upgradeGoodsName') || replaceItemText(i.goodsInfo, 'goodsName') }}
</text>
......@@ -59,6 +63,7 @@
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
import { snapshotOriginalPrice } from '@/utils/marketingFlag'
export default {
mixins: [popupmixin],
name: 'GoodsList',
......@@ -168,6 +173,7 @@ export default {
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.price = subVal.sellPrice
snapshotOriginalPrice(subVal)
subVal.goodsId = subVal.merchantGoodsId
if (goodsType.includes(subVal.merchantGoodsPosition)) arr.push(val)
}
......@@ -260,6 +266,12 @@ export default {
.price {
margin-left: auto;
}
.marketing-icon {
display: inline-block !important;
position: static !important;
margin-right: toRpx(8);
flex-shrink: 0;
}
.goods-name {
max-width: toRpx(600);
}
......
......@@ -23,6 +23,14 @@ export default {
methods: {
async getList () {
const params = this.params
if (this.boutiqueOrderTypesOnly) {
const data = [
{ name: '正常订单', value: '1' },
{ name: '内部结算', value: '6' }
]
this.updateParams(params, data)
return
}
let flag = null
let hasStorage = !!(uni && uni.$storage && uni.$storage.get)
// 默认支持所有订单类型
......
......@@ -23,7 +23,11 @@
class="filled"
></uni-icons>
</view>
{{item.packageGoods.packageAlias||item.packageGoods.packageName}}
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="package-name">{{item.packageGoods.packageAlias||item.packageGoods.packageName}}</text>
<text class="price">¥{{item.packageGoods.upgradePrice}}</text>
</view>
<view class="package-list">
......@@ -32,7 +36,9 @@
class="package-item flex"
:key="ind"
>
<view class="name">{{i.goodsAlias||i.upgradeGoodsAlias||i.upgradeGoodsName}}</view>
<view class="name flex align-center">
<text>{{i.goodsAlias||i.upgradeGoodsAlias||i.upgradeGoodsName}}</text>
</view>
<view class="price">¥{{i.sellPrice}}</view>
</view>
</template>
......@@ -47,6 +53,7 @@
<script type='text/ecmascript-6'>
import NP from 'number-precision'
import popupmixin from './popupmixin'
import { snapshotOrderItemOriginalPrice } from '@/utils/marketingFlag'
export default {
mixins: [popupmixin],
name: 'PackageList',
......@@ -67,11 +74,22 @@ export default {
if (searchValue) this.handleSearch(searchValue)
return
}
const { shopMerchantId, sceneType } = userInfo,
const { shopMerchantId, sceneType } = userInfo
const baseSceneCode = this.data?.baseSceneCodeValue || this.data?.baseSceneCode
let data = []
if (baseSceneCode) {
data = await uni.$api.boutiqueApi.getSelectOrderGoodsList({
merchantId: shopMerchantId,
sceneType,
baseSceneCode
})
} else {
data = await uni.$api.popupApi.getGoodsList({
merchantId: shopMerchantId,
sceneType
sceneType,
baseSceneCode
})
}
this.updateParams(params, data || [])
},
handleSearch (searchValue) {
......@@ -100,6 +118,7 @@ export default {
prev = NP.plus(prev + cur.sellPrice);
return prev;
}, 0), 2)
snapshotOrderItemOriginalPrice(val)
arr.push(val)
}
})
......@@ -160,11 +179,26 @@ export default {
.price {
margin-left: auto;
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.title {
height: toRpx(88);
padding: toRpx(24) 0 toRpx(20);
align-items: center;
min-width: 0;
.icon {
margin-right: toRpx(16);
flex-shrink: 0;
}
.package-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.filled {
display: none;
......@@ -182,6 +216,10 @@ export default {
padding: toRpx(24) 0;
border-bottom: toRpx(2) solid #f0f0ef;
padding-right: toRpx(32);
.name {
flex: 1;
min-width: 0;
}
.price {
margin-left: auto;
}
......
......@@ -28,6 +28,10 @@
class="filled"
></uni-icons>
</view>
<view
v-if="shouldShowMarketingIcon(i)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="goods-name">
<template v-if="sceneType == 1">
{{ replaceItemText(i.goods, 'goodsAlias')
......@@ -68,6 +72,10 @@
class="filled"
></uni-icons>
</view>
<view
v-if="shouldShowMarketingIcon(i)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
{{ i.multipleSpecificationsGoods.baseGoodsName }}
<template v-if="i.multipleSpecificationsGoods.goods && i.multipleSpecificationsGoods.goods.sellPrice">
<text class="price">¥{{ i.multipleSpecificationsGoods.goods.sellPrice }}</text>
......@@ -132,6 +140,10 @@
class="filled"
></uni-icons>
</view>
<view
v-if="shouldShowMarketingIcon(i)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="goods-name">
{{ i.packageGoods.packageAlias || i.packageGoods.packageName }}
</text>
......@@ -143,15 +155,15 @@
class="package-item flex"
:key="`${index}_${specificIndex}`"
>
<view class="label">
{{
<view class="label flex align-center">
<text>{{
replaceItemText(specific, 'goodsAlias')
|| replaceItemText('','',
specific.upgradeGoodsName +( specific.specificationData ? ('/'+specific.specificationData): '')
)
|| replaceItemText('','',
specific.goodsInfo.goodsName+( specific.specificationData? ('/'+specific.specificationData): '')
)}}
)}}</text>
</view>
<view class="value flex">
¥{{ specific.sellPrice }}
......@@ -170,6 +182,7 @@
<script type="text/ecmascript-6">
import popupmixin from './popupmixin'
import NP from 'number-precision'
import { snapshotOriginalPrice, snapshotOrderItemOriginalPrice } from '@/utils/marketingFlag'
export default {
mixins: [popupmixin],
name: 'SkuGoodsList',
......@@ -270,6 +283,7 @@ export default {
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.price = subVal.sellPrice
snapshotOriginalPrice(subVal)
subVal.goodsId = subVal.merchantGoodsId || subVal.id
if (![1, 2, 3, 4, 5, 6, 7].includes(subVal.merchantGoodsPosition)) {
arr.push(val)
......@@ -309,6 +323,7 @@ export default {
pre = NP.plus(pre, item.sellPrice)
return pre
}, 0)
snapshotOrderItemOriginalPrice(val)
arr.push(val)
}
})
......@@ -432,6 +447,7 @@ export default {
goodsList[index].multipleSpecificationsGoods.goods = goodsArr[0]
goodsList[index].multipleSpecificationsGoods.goods.goodsId = goodsList[index].multipleSpecificationsGoods.goods.merchantGoodsId
goodsList[index].multipleSpecificationsGoods.goods.specificationStr = goodsList[index].multipleSpecificationsGoods.goods.specificationData.replace(/;~;/g, '/')
snapshotOriginalPrice(goodsList[index].multipleSpecificationsGoods.goods)
if (addIndex == -1) this.chooseList.push(goodsList[index])
else this.chooseList[addIndex] = goodsList[index]
this.$emit('choose', this.chooseList)
......@@ -571,6 +587,12 @@ export default {
font-weight: 600;
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.title {
min-height: toRpx(88);
padding: toRpx(24) 0 toRpx(20);
......
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
export default {
inject: ['userInfo', 'baseConfigData'],
inject: {
userInfo: { default: () => ({}) },
baseConfigData: { default: () => ({}) }
},
data () {
return {
list: [],
......@@ -16,6 +21,14 @@ export default {
dataKey: String,
isDefeatOrder: Boolean,
positionTypeList: Array,
showMarketingIcon: {
type: Boolean,
default: false
},
boutiqueOrderTypesOnly: {
type: Boolean,
default: false
}
},
computed: {
listData () {
......@@ -49,6 +62,9 @@ export default {
componentLoading (params) {
params.loadComplete = false
this.$emit('update:params', this.params)
},
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, this.showMarketingIcon)
}
}
......
......@@ -17,7 +17,7 @@
</template>
<view v-if="componentObject[popupType]" :class="['popup-body', { 'hide-footer': componentObject[popupType].hideFooter }, { 'hide-search': componentObject[popupType].hideSearch }, { 'hide-footer-search': componentObject[popupType].hideFooter && componentObject[popupType].hideSearch }]">
<scroll-view scroll-y :class="['popup-scroll-view', { show: componentObject[popupType].loadComplete }]">
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="defaultTime" :positionTypeList="positionTypeList" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true" @confirm="confirm"></component>
<component :is="componentObject[popupType].name" :params.sync="componentObject[popupType]" :data="data" :dataKey="dataKey" :isDefeatOrder="isDefeatOrder" :defaultTime="defaultTime" :positionTypeList="positionTypeList" :show-marketing-icon="showMarketingIcon" :boutique-order-types-only="boutiqueOrderTypesOnly" ref="componentRef" @choose="chooseContent = $event" @openSkuPopup="openSkuPopup" @onComplete="componentObject[popupType].loadComplete = true" @confirm="confirm"></component>
<template v-if="componentObject[popupType].noData">
<view class="nothing flex">暂无数据</view>
</template>
......@@ -102,14 +102,23 @@ export default {
default: false
},
defaultTime: String,
popupTitle: String
popupTitle: String,
showMarketingIcon: {
type: Boolean,
default: false
},
boutiqueOrderTypesOnly: {
type: Boolean,
default: false
}
},
provide () {
return {
userInfo: this.userInfo,
baseConfigData: this.baseConfigData,
sceneType: this.sceneType
sceneType: this.sceneType,
showMarketingIcon: this.showMarketingIcon
}
},
data () {
......
......@@ -18,12 +18,16 @@
</view>
</view>
<view>
<view class="goods-list" :style="{ paddingBottom: orderCardDetail.subOrderList && orderCardDetail.subOrderList.length < 1 ? '0' : '' }" v-if="orderCardDetail.subOrderList && orderCardDetail.subOrderList.length > 0">
<view class="goods-list" :style="{ paddingBottom: cardGoodsList.length < 1 ? '0' : '' }" v-if="cardGoodsList.length > 0">
<view>
<view v-for="(i, sindex) in orderCardDetail.subOrderList" :key="sindex" class="goods flex justify-between" :class="{ 'no-margin': orderCardDetail.subOrderList.length === 1 }" v-if="orderCardDetail.showAllGoodsListFlag ? true : sindex < 2">
<view class="goods-name text-hide flex">
<view v-for="(i, sindex) in cardGoodsList" :key="sindex" class="goods flex justify-between" :class="{ 'no-margin': cardGoodsList.length === 1 }" v-if="orderCardDetail.showAllGoodsListFlag ? true : sindex < 2">
<view class="goods-name flex align-center">
<view class="point"></view>
{{ i.upgradeGoodsAlias || i.upgradeGoodsName || i.packageName || '' }}
<view
v-if="shouldShowMarketingIcon(i)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="goods-name-text text-hide">{{ getGoodsDisplayName(i) }}</text>
</view>
<view class="goods-price">
¥
......@@ -31,11 +35,11 @@
</view>
</view>
<view v-if="orderCardDetail.subOrderList.length > 2" class="goods-more">
<view v-if="cardGoodsList.length > 2" class="goods-more">
<text @click.stop="showAllGoodsList">
{{ orderCardDetail.showAllGoodsListFlag ? '收起' : '查看全部' }}
</text>
(共{{ orderCardDetail.subOrderList.length }}件)
(共{{ cardGoodsList.length }}件)
</view>
</view>
</view>
......@@ -161,6 +165,7 @@ import { checkDailyReport, showNextModal } from '@/utils/modalUtils'
import PublishPopup from '@/components/PublishPopup.vue'
import StudyPopup from '@/components/StudyPopup.vue'
import StudyCenterPermissionPopup from '@/components/StudyCenterPermissionPopup.vue'
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
import { debounce } from 'lodash'
export default {
mixins: [interceptionMixin],
......@@ -188,6 +193,16 @@ export default {
},
orderType() {
return order_mixins.data.orderType || {}
},
cardGoodsList() {
const detail = this.orderCardDetail || {}
const subList = detail.subOrderList || []
const packageList = detail.packageGoodsList || []
const singles = subList.filter(item => item.merchantGoodsId && !item.packageName && !item.packageAlias)
if (packageList.length) {
return [...singles, ...packageList]
}
return subList
}
},
data() {
......@@ -252,6 +267,13 @@ export default {
this.localUserInfo = uni.$storage.get('userInfo')
},
methods: {
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, true)
},
getGoodsDisplayName(item) {
if (!item) return ''
return item.upgradeGoodsAlias || item.upgradeGoodsName || item.packageAlias || item.packageName || ''
},
// 查看全部商品
showAllGoodsList: debounce(function (e) {
this.$emit('toggle-goods-list', {
......@@ -637,7 +659,12 @@ export default {
margin-bottom: 0;
}
.goods-name {
flex: 1;
min-width: 0;
margin-right: toRpx(16);
.point {
flex-shrink: 0;
width: toRpx(12);
height: toRpx(12);
opacity: 1;
......@@ -646,6 +673,17 @@ export default {
background: #4673ff;
margin-right: toRpx(16);
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.goods-name-text {
flex: 1;
min-width: 0;
}
}
}
.goods-more {
......
......@@ -30,7 +30,13 @@
<!-- 套餐 -->
<view class="meal-box" v-for="(item, index) in orderInfo.packageGoodsList">
<view class="meal-hd flex justify-between align-center">
<view>{{ item.packageAlias || item.packageName }}</view>
<view class="meal-hd-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<view>{{ item.packageAlias || item.packageName }}</view>
</view>
<view class="price">¥{{ item.finalPrice }}</view>
</view>
<view class="meal-bd">
......@@ -52,7 +58,13 @@
<view class="good-list">
<view class="good mt-16" v-for="(item, index) in orderInfo.subOrderList">
<view class="flex justify-between align-center">
<text class="good-name">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text>
<view class="good-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="good-name-text text-hide">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text>
</view>
<text class="good-price">¥{{ item.price }}</text>
</view>
<view class="flex justify-between align-center pt-12">
......@@ -215,6 +227,7 @@ import order_mixins from '../../order_mixins.js'
import dayjs from 'dayjs'
import PublishPopup from '@/components/PublishPopup.vue'
import OrderPopup from '@/components/OrderPopup/index.vue'
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
import { debounce } from 'lodash'
export default {
name: 'OrderConfirm',
......@@ -264,6 +277,9 @@ export default {
// this.successDate = dayjs().format('YYYY-MM-DD HH:mm:ss')
},
methods: {
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, true)
},
replaceItemText(item) {
var reg = getRegExp(';~;', 'g')
return item ? item.replace(reg, ' ') : ''
......@@ -863,11 +879,22 @@ export default {
padding: toRpx(24) toRpx(32);
box-sizing: border-box;
margin-top: toRpx(16);
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.meal-hd {
color: #333333;
font-size: toRpx(32);
font-weight: 400;
margin-bottom: toRpx(20);
.meal-hd-name {
flex: 1;
min-width: 0;
}
.price {
font-weight: 500;
}
......@@ -884,6 +911,7 @@ export default {
color: #333333;
font-size: toRpx(28);
font-weight: 400;
min-width: 0;
}
.meal-bd-bottom {
color: #999999;
......@@ -913,9 +941,21 @@ export default {
.good-name {
font-weight: 400;
flex: 4;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.good-name-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.good-price {
font-weight: 500;
......
......@@ -6,25 +6,25 @@
<view class="box-content">
<GlCell :formList="formList" :formData="orderObj" @radioChange="radioChange" @inputBlur="inputBlur" @handleCell="handleCell">
<template slot="frontGear">
<Product v-if="orderObj.frontGear" @changeTotalPrice="changeTotalPrice" :list="orderObj.frontGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></Product>
<Product v-if="orderObj.frontGear" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.frontGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template>
<template slot="frontWindow">
<Product v-if="orderObj.frontWindow" @changeTotalPrice="changeTotalPrice" :list="orderObj.frontWindow" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></Product>
<Product v-if="orderObj.frontWindow" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.frontWindow" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template>
<template slot="rearWindow">
<Product v-if="orderObj.rearWindow" @changeTotalPrice="changeTotalPrice" :list="orderObj.rearWindow" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></Product>
<Product v-if="orderObj.rearWindow" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.rearWindow" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template>
<template slot="rearGear">
<Product v-if="orderObj.rearGear" @changeTotalPrice="changeTotalPrice" :list="orderObj.rearGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></Product>
<Product v-if="orderObj.rearGear" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.rearGear" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template>
<template slot="sunRoof">
<Product v-if="orderObj.sunRoof" @changeTotalPrice="changeTotalPrice" :list="orderObj.sunRoof" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></Product>
<Product v-if="orderObj.sunRoof" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.sunRoof" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Product>
</template>
<template slot="package">
<Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" :list="orderObj.package" :positionTypeList="positionTypeList" :orderTypeCode="orderObj.orderTypeCode"></Package>
<Package v-if="orderObj.package" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :list="orderObj.package" :positionTypeList="positionTypeList" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></Package>
</template>
<template slot="skuGoods">
<SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode"></SkuGoods>
<SkuGoods v-if="orderObj.skuGoods" :list="orderObj.skuGoods" @changeTotalPrice="changeTotalPrice" @min-price-warning="handleMinPriceWarning" :positionTypeList="positionTypeList" :baseConfigData="baseConfigData" :orderTypeCode="orderObj.orderTypeCode" :show-marketing-icon="true"></SkuGoods>
<view class="total" v-if="totalPrice > 0">
<view class="total-left">总价</view>
<view class="total-right">¥{{ totalPrice }}</view>
......@@ -39,13 +39,41 @@
</scroll-view>
</view>
<!-- 弹窗 -->
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" />
<order-popup ref="orderPopup" :data="orderObj" :dataKey="valueKey" @onConfirm="onConfirm" :externalData="externalData" :popupType="popupType" :show-marketing-icon="true" :boutique-order-types-only="boutiqueOrderTypesOnly" />
<ErrorOrderPopup
:show.sync="showMinPriceApprovalPopup"
title=""
:width="848"
:topImage="require('@/assets/images/common/warning-notice.webp')"
:topImageWidth="848"
:topImageHeight="248"
style="overflow: hidden"
>
<view>
<view class="error-order-title">需总部运营审批</view>
<view class="error-order-content">当前商品单价低于商品最低价,请提交后经总部运营审批通过后方可下单,确认继续提交?</view>
<view class="error-order-price">当前单价:¥{{ minPriceApprovalPrice }}</view>
</view>
<template #footer>
<view class="flex justify-between error-order-footer">
<view class="footer-btn know flex-1" @click="showMinPriceApprovalPopup = false">我知道了</view>
</view>
</template>
</ErrorOrderPopup>
<MinPriceApprovalDrawer
ref="minPriceApprovalDrawer"
:list="minPriceApprovalList"
@submit="doSubmit"
/>
</view>
</template>
<script>
import utils from '@/utils/utils'
import OrderPopup from '@/components/OrderPopup/index.vue'
import ErrorOrderPopup from '@/components/ErrorOrderPopup.vue'
import GlCell from '../../../../components/Form/GlCell.vue'
import Product from './Product.vue'
import Package from './Package.vue'
......@@ -53,15 +81,20 @@ import SkuGoods from './SkuGoods.vue'
import { FORM_LIST, popupTypeEnum, payTypeList } from '../contant'
import { interceptionMixin } from '@/mixin/index'
import { validateVin, formatVinInput } from '@/utils/vinVaildate'
import { getMarketingFlag, getActivityId, getSubmitMarketingFlag, getSubmitModifyFlag, getSubmitActivityId, snapshotOriginalPrice, snapshotOrderItemsOriginalPrice } from '@/utils/marketingFlag'
import { collectBelowMinSellPriceItems, shouldUseMinPriceApproval } from '@/utils/minSellPrice'
import MinPriceApprovalDrawer from './MinPriceApprovalDrawer.vue'
export default {
name: 'CreateOrder',
mixins: [interceptionMixin],
components: {
GlCell,
OrderPopup,
ErrorOrderPopup,
Product,
Package,
SkuGoods
SkuGoods,
MinPriceApprovalDrawer
},
props: {
transmissionOfData: {
......@@ -259,6 +292,9 @@ export default {
valueKey: '',
totalPrice: 0,
validateState: true,
showMinPriceApprovalPopup: false,
minPriceApprovalPrice: '0',
minPriceApprovalList: [],
// 产品槽位配置,用于循环渲染产品组件
productSlots: {
frontGear: true,
......@@ -273,6 +309,12 @@ export default {
showPayTips() {
if (this.orderObj.payeeType == 0 && this.orderObj.selectPayType == 7) return true
else return false
},
boutiqueOrderTypesOnly() {
return this.orderCreateType === 'createWithPay' && !this.orderObj.id
},
useMinPriceApproval() {
return shouldUseMinPriceApproval(this.orderObj.orderTypeCode)
}
},
mounted() {
......@@ -623,7 +665,7 @@ export default {
if (this.orderCreateType == 'createWithPay' && !this.orderObj.id) this.getLastUserOrderInfo() // 补录订单和有id的情况,不需要设置默认值
},
// 选择行事件
handleCell(val) {
async handleCell(val) {
// 获取当前选中的popupType
const foundKey = Object.keys(this.popupTypeEnum).find(key => this.popupTypeEnum[key].key === val.value)
if (!foundKey) {
......@@ -646,6 +688,12 @@ export default {
const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
if (productFields.includes(val.value)) {
this.valueKey = val.value
if (!this.goodsList?.length && (this.orderObj.baseSceneCodeValue || this.orderObj.baseSceneCode)) {
await this.getSelectOrderGoodsList()
}
if (this.$refs.orderPopup?.clearCacheByTypes) {
this.$refs.orderPopup.clearCacheByTypes([this.popupType])
}
this.externalData = utils.deepClone(this.goodsList)
}
// 确保 orderPopup 引用存在后再调用 open 方法
......@@ -729,6 +777,7 @@ export default {
} else {
this.$set(this.orderObj, _typeValue.key, chooseContent)
}
snapshotOrderItemsOriginalPrice(this.orderObj[_typeValue.key])
// 商品类,需计算总价
setTimeout(() => {
this.changeTotalPrice()
......@@ -1028,6 +1077,16 @@ export default {
return
}
const approvalList = this.useMinPriceApproval ? collectBelowMinSellPriceItems(this.orderObj) : []
if (approvalList.length > 0) {
this.minPriceApprovalList = approvalList
this.$refs.minPriceApprovalDrawer.open()
return
}
this.doSubmit()
},
async doSubmit() {
const { orderCreateType } = this
const obj = utils.deepClone(this.orderObj)
// 场景名称:界面展示用 name;提交入参需要 code
......@@ -1073,7 +1132,8 @@ export default {
discountType: discountFields.discountType,
discountValue: discountFields.discountValue,
discountAmount: discountFields.discountAmount,
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null,
...this.buildSubOrderGoodsFlags(e, e.goods)
})
}
// 套餐
......@@ -1096,7 +1156,8 @@ export default {
discountType: discountFields.discountType,
discountValue: discountFields.discountValue,
discountAmount: discountFields.discountAmount,
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null,
...this.buildSubOrderGoodsFlags(e, g)
})
})
}
......@@ -1119,7 +1180,8 @@ export default {
discountType: discountFields.discountType,
discountValue: discountFields.discountValue,
discountAmount: discountFields.discountAmount,
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null
djOrderType: obj.orderTypeCode ? parseInt(obj.orderTypeCode) : null,
...this.buildSubOrderGoodsFlags(e, goods)
})
}
})
......@@ -1400,6 +1462,7 @@ export default {
subVal.positionStr = subVal.position
subVal.upgradePrice = subVal.sellPrice
subVal.price = subVal.sellPrice
snapshotOriginalPrice(subVal)
subVal.goodsId = subVal.merchantGoodsId
Object.keys(posMap).forEach(key => {
......@@ -1444,6 +1507,7 @@ export default {
// 如果没有 totalPrice,才使用已存在的 price 或计算默认值
e.price = utils.ceilDecimal(Number(e.finalPrice || 0) / Number(e.number || 1))
}
snapshotOriginalPrice(e)
e.sellPrice = e.price
e.goodsId = e.merchantGoodsId
if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
......@@ -1471,12 +1535,19 @@ export default {
const newStrategyConfig = this.buildStrategyConfigFromDiscountFields(e, goodsOrderTypeCode)
this.$set(e, 'strategyConfig', newStrategyConfig)
}
if (e.activityId == null || e.activityId === '') {
const catalogActivityId = this.getCatalogActivityId({ merchantGoodsId: e.merchantGoodsId, goodsId: e.goodsId })
if (catalogActivityId != null && catalogActivityId !== '') {
e.activityId = catalogActivityId
}
}
chooseList.push({
goodsFlag: 1,
goods: e,
number: e.number,
active: true
active: true,
marketingFlag: this.getMarketingFlag({ merchantGoodsId: e.merchantGoodsId, goodsId: e.goodsId })
})
}
// 多规格商品
......@@ -1490,6 +1561,7 @@ export default {
// 如果没有 totalPrice,才使用已存在的 price 或计算默认值
e.price = utils.ceilDecimal(Number(e.finalPrice || 0) / Number(e.number || 1))
}
snapshotOriginalPrice(e)
e.sellPrice = e.price
e.goodsId = e.merchantGoodsId
if (!e.minSellPrice) e.minSellPrice = e.upgradeShopMinPrice
......@@ -1525,7 +1597,10 @@ export default {
// 套餐
if (e && e.packageName) {
e.packageGoodsOrderList.forEach(g => {
g.oldPrice = g.sellPrice || g.upgradePrice
if (g.oldPrice == null || g.oldPrice === '') {
g.oldPrice = g.sellPrice ?? g.upgradePrice
}
snapshotOriginalPrice(g)
// g.sellPrice = g.sellPrice || g.upgradePrice;
// 注意:价格为 0 时也要回显,不能用 truthy 判断
if (g.totalPrice !== undefined && g.totalPrice !== null) {
......@@ -1564,13 +1639,21 @@ export default {
}, 0)
e.price = Number(utils.decimal(e.price, 2)).toFixed(2)
const catalogActivityId = this.getCatalogActivityId({ packageGoods: e })
if (catalogActivityId != null && catalogActivityId !== '') {
if (e.activityId == null || e.activityId === '') {
e.activityId = catalogActivityId
}
}
chooseList.push({
isType: 'meal',
active: true,
goodsFlag: 3,
packageGoods: e,
number: e.number,
totalPrice: e.price
totalPrice: e.price,
marketingFlag: this.getMarketingFlag({ packageGoods: e })
})
}
})
......@@ -1632,7 +1715,8 @@ export default {
goodsFlag: 2,
goods: null,
active: true,
isFlag: true //初始化进来不显示标识
isFlag: true, //初始化进来不显示标识
marketingFlag: null
}
otherProduct.forEach(data => {
if (data.goodsFlag == 2) {
......@@ -1657,6 +1741,7 @@ export default {
goodsId: item.goodsId,
specificationStr: item.specificationData.replace(/;~;/g, '/')
}
snapshotOriginalPrice(goodsData)
if (item.finalPrice !== undefined && item.finalPrice !== null) {
goodsData.finalPrice = parseFloat(item.finalPrice)
}
......@@ -1675,6 +1760,22 @@ export default {
const newStrategyConfig = this.buildStrategyConfigFromDiscountFields(item, goodsOrderTypeCode)
goodsData.strategyConfig = newStrategyConfig
}
const resolvedMarketingFlag =
item.marketingFlag ??
temp.marketingFlag ??
data.multipleSpecificationsGoods?.marketingFlag ??
getMarketingFlag(data)
if (resolvedMarketingFlag != null && resolvedMarketingFlag !== '') {
goodsData.marketingFlag = resolvedMarketingFlag
}
const resolvedActivityId =
item.activityId ??
temp.activityId ??
data.multipleSpecificationsGoods?.activityId ??
getActivityId(data)
if (resolvedActivityId != null && resolvedActivityId !== '') {
goodsData.activityId = resolvedActivityId
}
obj.multipleSpecificationsGoods = {
...data.multipleSpecificationsGoods,
......@@ -1683,6 +1784,16 @@ export default {
// 确保数量字段正确回显
number: item.count !== undefined && item.count !== null ? String(item.count) : '1'
}
if (resolvedMarketingFlag != null && resolvedMarketingFlag !== '') {
obj.multipleSpecificationsGoods.marketingFlag = resolvedMarketingFlag
}
if (resolvedActivityId != null && resolvedActivityId !== '') {
obj.multipleSpecificationsGoods.activityId = resolvedActivityId
}
obj.marketingFlag = resolvedMarketingFlag
if (resolvedActivityId != null && resolvedActivityId !== '') {
obj.activityId = resolvedActivityId
}
skuArr.push(obj)
}
})
......@@ -1691,6 +1802,48 @@ export default {
})
console.log(skuArr)
return skuArr
},
buildSubOrderGoodsFlags(orderItem, goods) {
if (!['createWithPay', 'supplementOrder'].includes(this.orderCreateType)) return {}
const flags = {
marketingFlag: getSubmitMarketingFlag(orderItem, goods),
modifyFlag: getSubmitModifyFlag(goods)
}
const activityId = getSubmitActivityId(orderItem, goods)
if (activityId != null && activityId !== '') {
flags.activityId = activityId
}
return flags
},
findCatalogGoodsMatch({ merchantGoodsId, goodsId, packageGoods } = {}) {
const list = this.goodsList || []
return list.find(item => {
if (item.goodsFlag == 1) {
const id = item.goods?.merchantGoodsId
return id != null && (id == merchantGoodsId || id == goodsId)
}
if (item.goodsFlag == 2) {
const id = item.multipleSpecificationsGoods?.id ?? item.multipleSpecificationsGoods?.merchantGoodsId
return id != null && (id == merchantGoodsId || id == goodsId)
}
if (item.goodsFlag == 3 && packageGoods) {
const pkgId = item.packageGoods?.merchantGoodsId ?? item.packageGoods?.id ?? item.packageGoods?.packageId
const targetId = packageGoods.merchantGoodsId ?? packageGoods.id ?? packageGoods.packageId
return pkgId != null && targetId != null && pkgId == targetId
}
return false
})
},
getMarketingFlag({ merchantGoodsId, goodsId, packageGoods } = {}) {
return getMarketingFlag(this.findCatalogGoodsMatch({ merchantGoodsId, goodsId, packageGoods }))
},
getCatalogActivityId({ merchantGoodsId, goodsId, packageGoods } = {}) {
return getActivityId(this.findCatalogGoodsMatch({ merchantGoodsId, goodsId, packageGoods }))
},
handleMinPriceWarning(price) {
if (!this.useMinPriceApproval) return
this.minPriceApprovalPrice = price
this.showMinPriceApprovalPopup = true
}
}
}
......@@ -1750,4 +1903,51 @@ export default {
border-radius: toRpx(48);
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
.error-order-title {
text-align: center;
color: #333333;
font-size: toRpx(40);
font-weight: 500;
}
.error-order-content {
width: 100%;
box-sizing: border-box;
text-align: center;
color: #666666;
font-size: toRpx(32);
font-weight: 400;
margin-top: toRpx(16);
line-height: 1.5;
white-space: normal;
word-break: break-word;
}
.error-order-price {
text-align: center;
color: #4673ff;
font-size: toRpx(32);
font-weight: 500;
margin-top: toRpx(24);
}
.error-order-footer {
margin-top: toRpx(64);
margin-bottom: toRpx(48);
width: 100%;
padding: 0 toRpx(32);
box-sizing: border-box;
.know {
height: toRpx(88);
border-radius: toRpx(64);
line-height: toRpx(88);
background: #f0f1f5;
color: #666666;
font-size: toRpx(32);
font-weight: 400;
text-align: center;
}
}
</style>
<template>
<uni-popup ref="popup" type="right" :mask-click="false" @change="onPopupChange">
<view class="approval-drawer">
<view class="drawer-header">
<text class="drawer-title">审批商品</text>
<uni-icons class="close-icon" type="closeempty" size="20" color="#999EA8" @click="close" />
<view class="drawer-desc">该订单将提交总部运营审批,审批通过后订单生效</view>
</view>
<scroll-view scroll-y class="drawer-body">
<view class="approval-list">
<view
v-for="(item, index) in list"
:key="index"
class="approval-card"
>
<view class="card-main">
<view class="card-left">
<view class="name-row">
<view class="dot"></view>
<view class="name-block">
<view class="name-tag-wrap">
<text class="name">{{ item.name }}</text>
<view
v-if="shouldShowMarketingIcon(item.sourceItem)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
</view>
<view
v-if="item.type === 'single' && hasMinSellPrice(item.minSellPrice)"
class="min-price"
>活动价 ¥ {{ item.minSellPrice }}</view>
</view>
</view>
</view>
<view class="card-right">
<view class="current-price">¥ {{ item.sellPrice }}</view>
<view v-if="item.type === 'single'" class="quantity">共 {{ item.number }} 件</view>
</view>
</view>
<view v-if="item.type === 'package'" class="package-children">
<view
v-for="(child, childIndex) in item.children"
:key="childIndex"
class="package-child"
>
<view class="child-left">
<view class="child-name-row">
<view class="child-name">{{ child.name }}</view>
</view>
<view
v-if="hasMinSellPrice(child.minSellPrice)"
class="min-price"
>活动价 ¥ {{ child.minSellPrice }}</view>
</view>
<view class="card-right">
<view class="current-price">¥ {{ child.sellPrice }}</view>
<view class="quantity">共 {{ child.number }} 件</view>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
<view class="drawer-footer">
<view class="footer-btn cancel" @click="close">取消</view>
<view class="footer-btn submit" @click="handleSubmit">提交</view>
</view>
</view>
</uni-popup>
</template>
<script>
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
export default {
name: 'MinPriceApprovalDrawer',
props: {
list: {
type: Array,
default: () => []
}
},
methods: {
hasMinSellPrice(value) {
return value != null && value !== ''
},
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, true)
},
open() {
this.$refs.popup.open()
},
close() {
this.$refs.popup.close()
},
onPopupChange(e) {
this.$emit('change', e)
},
handleSubmit() {
this.$emit('submit')
this.close()
}
}
}
</script>
<style lang="scss" scoped>
.approval-drawer {
width: toRpx(1040);
height: 100vh;
display: flex;
flex-direction: column;
background: #fff;
border-radius: toRpx(48) 0 0 toRpx(48);
overflow: hidden;
}
.drawer-header {
position: relative;
flex-shrink: 0;
padding: toRpx(48) toRpx(64) toRpx(32);
background: #ffffff;
background-size: 100% auto;
border-radius: toRpx(48) 0 0 0;
}
.drawer-title {
display: block;
text-align: center;
font-size: toRpx(40);
font-weight: 500;
color: #292d33;
line-height: toRpx(56);
}
.close-icon {
position: absolute;
right: toRpx(48);
top: toRpx(56);
}
.drawer-desc {
margin-top: toRpx(16);
text-align: left;
color: #5A5E66;
font-size: toRpx(30);
line-height: 1.5;
}
.drawer-body {
flex: 1;
min-height: 0;
box-sizing: border-box;
}
.approval-list {
padding: toRpx(8) toRpx(32) toRpx(32);
box-sizing: border-box;
}
.approval-card {
background: #f7f8fa;;
border-radius: toRpx(16);
padding: toRpx(32);
box-sizing: border-box;
& + .approval-card {
margin-top: toRpx(24);
}
}
.card-main,
.package-child {
display: flex;
align-items: flex-start;
justify-content: space-between;
}
.card-left,
.child-left {
flex: 1;
min-width: 0;
}
.name-row {
display: flex;
align-items: flex-start;
}
.dot {
flex-shrink: 0;
width: toRpx(12);
height: toRpx(12);
margin-top: toRpx(14);
margin-right: toRpx(16);
border-radius: 50%;
background: #4673ff;
}
.name-block {
flex: 1;
min-width: 0;
}
.name-tag-wrap,
.child-name-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: toRpx(12);
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
}
.name,
.child-name {
color: #222;
font-size: toRpx(32);
font-weight: 500;
line-height: 1.5;
word-break: break-word;
}
.activity-tag {
flex-shrink: 0;
padding: 0 toRpx(12);
height: toRpx(36);
line-height: toRpx(36);
border-radius: toRpx(8);
background: #ff8a1f;
color: #ffffff;
font-size: toRpx(22);
font-weight: 500;
}
.min-price {
margin-top: toRpx(12);
color: #999ea8;
font-size: toRpx(28);
line-height: 1.4;
}
.card-right {
flex-shrink: 0;
margin-left: toRpx(24);
text-align: right;
}
.current-price {
color: #292d33;
font-size: toRpx(32);
font-weight: 500;
line-height: 1.4;
white-space: nowrap;
}
.quantity {
margin-top: toRpx(8);
color: #999ea8;
font-size: toRpx(24);
line-height: 1.4;
white-space: nowrap;
}
.package-children {
margin-top: toRpx(24);
padding-top: toRpx(8);
border-top: toRpx(2) solid #f0f1f5;
}
.package-child {
padding: toRpx(24) 0;
&:last-child {
padding-bottom: 0;
}
& + .package-child {
border-top: toRpx(2) solid #f0f1f5;
}
}
.drawer-footer {
flex-shrink: 0;
display: flex;
gap: toRpx(24);
padding: toRpx(24) toRpx(40);
padding-bottom: toRpx(64);
background: #ffffff;
box-sizing: border-box;
.footer-btn {
flex: 1;
height: toRpx(88);
line-height: toRpx(88);
border-radius: toRpx(64);
text-align: center;
font-size: toRpx(32);
font-weight: 400;
}
.cancel {
background: #f0f1f5;
color: #666666;
}
.submit {
color: #ffffff;
background: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
}
}
</style>
......@@ -65,7 +65,13 @@
<!-- 套餐 -->
<view class="meal-box" v-for="(item, index) in orderInfo.packageGoodsList">
<view class="meal-hd flex justify-between align-center">
<view>{{ item.packageAlias || item.packageName }}</view>
<view class="meal-hd-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<view>{{ item.packageAlias || item.packageName }}</view>
</view>
<view class="price">¥{{ item.finalPrice }}</view>
</view>
<view class="meal-bd">
......@@ -87,7 +93,13 @@
<view class="good-list">
<view class="good" v-for="(item, index) in orderInfo.subOrderList" :key="index">
<view class="flex justify-between align-center mb-20">
<text class="good-name">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text>
<view class="good-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="good-name-text text-hide">商品名称:{{ replaceItemText(item.upgradeGoodsName) || '' }}</text>
</view>
<text class="good-price">¥{{ item.finalPrice }}</text>
</view>
<view class="flex justify-between align-center mb-12" v-if="item.upgradeGoodsAlias">
......@@ -308,6 +320,7 @@ import order_mixins from '../../order_mixins.js'
import dayjs from 'dayjs'
import { index } from '@/env'
import PublishPopup from '@/components/PublishPopup.vue'
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
export default {
name: 'OrderDetail',
components: {
......@@ -377,6 +390,9 @@ export default {
},
async mounted() {},
methods: {
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, true)
},
replaceItemText(item) {
var reg = getRegExp(';~;', 'g')
return item ? item.replace(reg, ' ') : ''
......@@ -1164,11 +1180,21 @@ export default {
padding: toRpx(24) toRpx(32);
box-sizing: border-box;
margin-top: toRpx(16);
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.meal-hd {
color: #333333;
font-size: toRpx(32);
font-weight: 400;
margin-bottom: toRpx(20);
.meal-hd-name {
flex: 1;
min-width: 0;
}
.price {
font-weight: 500;
}
......@@ -1185,6 +1211,7 @@ export default {
color: #333333;
font-size: toRpx(28);
font-weight: 400;
min-width: 0;
}
.meal-bd-bottom {
color: #999999;
......@@ -1215,9 +1242,21 @@ export default {
.good-name {
font-weight: 400;
flex: 4;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
.good-name-text {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.marketing-icon {
display: inline-block !important;
flex-shrink: 0;
margin-right: toRpx(8);
}
.good-price {
font-weight: 500;
......
......@@ -5,6 +5,10 @@
<view class="header">
<view class="header-left">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<view class="name">{{ item.packageGoods.packageAlias || item.packageGoods.packageName }}</view>
<view class="control">
<view class="minus" @click="decreaseNumber(item)">-</view>
......@@ -12,7 +16,9 @@
<view class="add" @click="increaseNumber(item)">+</view>
</view>
</view>
<view class="price">¥{{ changeTotal(item) }}</view>
<view class="price flex align-center">
<text>¥{{ changeTotal(item) }}</text>
</view>
</view>
<view class="goods-item" v-for="(goods, ind) in item.packageGoods.goodsList" :key="ind">
<view class="goods-name">{{ goods.goodsAlias || goods.upgradeGoodsName }}</view>
......@@ -36,6 +42,8 @@
<script>
import utils from '@/utils/utils'
import OrderStrategy from './OrderStrategy.vue'
import { shouldShowMarketingIcon as checkMarketingIcon, snapshotOriginalPrice } from '@/utils/marketingFlag'
import { isBelowMinSellPrice, normalizeGoodsPrice, shouldUseMinPriceApproval, applyLegacyMinSellPriceClamp } from '@/utils/minSellPrice'
export default {
name: 'Package',
......@@ -54,6 +62,10 @@ export default {
orderTypeCode: {
type: [String, Number],
default: ''
},
showMarketingIcon: {
type: Boolean,
default: false
}
},
created() {
......@@ -127,11 +139,9 @@ export default {
if (!item.packageGoods.number) {
this.$set(item.packageGoods, 'number', '1')
}
// 存储旧值
// 仅首次快照原价,避免 updated 时把改价后的 sellPrice 写回 oldPrice
item.packageGoods.goodsList.forEach(goods => {
if (!goods.price) {
goods.oldPrice = goods.sellPrice
}
snapshotOriginalPrice(goods)
})
})
}
......@@ -186,43 +196,14 @@ export default {
this.$emit('changeTotalPrice')
},
validatePrice(event, goods, ind, index) {
let value = event.detail.value
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
let value = normalizeGoodsPrice(event.detail.value)
if (shouldUseMinPriceApproval(this.orderTypeCode)) {
if (isBelowMinSellPrice(goods, value)) {
this.$emit('min-price-warning', value)
}
} else {
value = applyLegacyMinSellPriceClamp(goods, value)
}
// 限制最大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
// 如果validMinSellPrice为Y,则强制修改值为最小值
if (goods.validMinSellPrice === 'Y' && goods.minSellPrice && parseFloat(value) < parseFloat(goods.minSellPrice)) {
console.log('最小值', goods.minSellPrice)
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
value = goods.minSellPrice.toString()
}
// 更新值
this.$set(this.list[index].packageGoods.goodsList[ind], 'sellPrice', value)
// 价格变动时,清空该商品的折扣/买赠/抵扣配置,并按原价重算 finalPrice
......@@ -468,6 +449,9 @@ export default {
}
})
})
},
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, this.showMarketingIcon)
}
}
}
......@@ -574,10 +558,17 @@ export default {
margin-left: toRpx(26);
color: #333;
}
}
.price {
color: #666;
}
.price {
color: #666;
}
.marketing-icon {
display: inline-block !important;
margin-right: toRpx(8);
margin-left: toRpx(8);
flex-shrink: 0;
}
}
......
......@@ -5,7 +5,13 @@
<view class="flex flex-1 pb-24">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view class="right">
<view class="shop-name">商品名称:{{ item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</view>
<view class="shop-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="text-hide flex-1">商品名称:{{ item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</text>
</view>
<!-- <view class="alias">商品别名:{{ item.goods.goodsAlias }}</view> -->
<view class="front-gear-box">
<view class="front-gear-input-box">
......@@ -35,6 +41,8 @@
<script>
import utils from '@/utils/utils'
import OrderStrategy from './OrderStrategy.vue'
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
import { isBelowMinSellPrice, normalizeGoodsPrice, shouldUseMinPriceApproval, applyLegacyMinSellPriceClamp } from '@/utils/minSellPrice'
export default {
name: 'Product',
......@@ -58,6 +66,10 @@ export default {
orderTypeCode: {
type: [String, Number],
default: ''
},
showMarketingIcon: {
type: Boolean,
default: false
}
},
components: {
......@@ -255,48 +267,16 @@ export default {
},
// 验证价格输入
validatePrice(event, item, index) {
let value = event.detail.value
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
let value = normalizeGoodsPrice(event.detail.value)
if (shouldUseMinPriceApproval(this.orderTypeCode)) {
if (isBelowMinSellPrice(item.goods, value)) {
this.$emit('min-price-warning', value)
}
} else {
value = applyLegacyMinSellPriceClamp(item.goods, value)
}
// 限制最 大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
if (item.goods.validMinSellPrice === 'Y' && item.goods.minSellPrice && parseFloat(value) < parseFloat(item.goods.minSellPrice)) {
console.log('最小值', item.goods.minSellPrice)
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
value = item.goods.minSellPrice.toString()
}
// 更新值
this.$set(this.list[index].goods, 'sellPrice', value)
// 商品价格修改时,清空折扣 / 抵扣配置,避免旧的优惠继续生效
this.resetStrategyWhenPriceChange(this.list[index])
// 价格变化时,如果已选择订单类型,触发策略组件重新计算价格
this.$forceUpdate()
this.$emit('changeTotalPrice')
},
......@@ -377,6 +357,9 @@ export default {
deleteGoods(index) {
this.list.splice(index, 1)
this.$emit('changeTotalPrice')
},
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, this.showMarketingIcon)
}
}
}
......@@ -401,6 +384,12 @@ export default {
color: #ff781f;
}
.marketing-icon {
display: inline-block !important;
margin-right: toRpx(8);
flex-shrink: 0;
}
.alias {
margin-top: toRpx(12);
font-size: toRpx(24);
......
......@@ -5,7 +5,13 @@
<view class="flex flex-1 pb-24">
<view class="sprite-icon icon-blue-delete" @click="deleteGoods(index)"></view>
<view class="right">
<view class="shop-name">商品名称:{{ item.multipleSpecificationsGoods ? item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</view>
<view class="shop-name flex align-center">
<view
v-if="shouldShowMarketingIcon(item)"
class="sprite-icon icon-activeIcon marketing-icon"
></view>
<text class="text-hide flex-1">商品名称:{{ item.multipleSpecificationsGoods ? item.multipleSpecificationsGoods.baseGoodsName : item.goods.goodsAlias || item.goods.upgradeGoodsName || item.goods.goodsInfo.goodsName }}</text>
</view>
<view class="alias" v-if="item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods.goodsAlias">商品别名:{{ item.multipleSpecificationsGoods.goods.goodsAlias }}</view>
<view class="front-gear-box">
<view class="front-gear-input-box">
......@@ -62,6 +68,8 @@
<script>
import utils from '@/utils/utils'
import OrderStrategy from './OrderStrategy.vue'
import { shouldShowMarketingIcon as checkMarketingIcon } from '@/utils/marketingFlag'
import { getSkuGoodsPriceTarget, isBelowMinSellPrice, normalizeGoodsPrice, shouldUseMinPriceApproval, applyLegacyMinSellPriceClamp } from '@/utils/minSellPrice'
export default {
name: 'SkuGoods',
......@@ -88,6 +96,10 @@ export default {
orderTypeCode: {
type: [String, Number],
default: ''
},
showMarketingIcon: {
type: Boolean,
default: false
}
},
created() {
......@@ -143,106 +155,21 @@ export default {
},
// 验证价格输入
validatePrice(event, item, index) {
let value = event.detail.value
console.log('value', value)
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
let value = normalizeGoodsPrice(event.detail.value)
const priceTarget = getSkuGoodsPriceTarget(item)
if (shouldUseMinPriceApproval(this.orderTypeCode)) {
if (isBelowMinSellPrice(priceTarget, value)) {
this.$emit('min-price-warning', value)
}
} else if (priceTarget) {
value = applyLegacyMinSellPriceClamp(priceTarget, value)
}
// 限制最 大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
// 检查最小价格
if (!item.multipleSpecificationsGoods) {
// 普通商品的最小价格检查
if (item.goods.validMinSellPrice === 'Y' && item.goods.minSellPrice && parseFloat(value) < parseFloat(item.goods.minSellPrice)) {
console.log('最小值', item.goods.minSellPrice)
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
value = item.goods.minSellPrice.toString()
}
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 多规格商品的最小价格检查
if (item.multipleSpecificationsGoods.goods.validMinSellPrice === 'Y' && item.multipleSpecificationsGoods.goods.minSellPrice && parseFloat(value) < parseFloat(item.multipleSpecificationsGoods.goods.minSellPrice)) {
console.log('最小值', item.multipleSpecificationsGoods.goods.minSellPrice)
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
value = item.multipleSpecificationsGoods.goods.minSellPrice.toString()
}
}
// 更新值
if (!item.multipleSpecificationsGoods) {
// 如果没有多规格商品,更新普通商品的价格
this.$set(this.list[index].goods, 'sellPrice', value)
} else if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
// 如果有多规格商品,更新多规格商品的价格
this.$set(this.list[index].multipleSpecificationsGoods.goods, 'sellPrice', value)
}
this.$emit('changeTotalPrice')
},
// 验证价格输入
validatePrice(event, item, index) {
let value = event.detail.value
// 如果为空则设置为0
if (!value || value.trim() === '') {
value = '0'
}
// 限制只能输入数字和小数点
value = value.replace(/[^\d.]/g, '')
// 限制只能有一个小数点
if (value.split('.').length > 2) {
value = value.slice(0, value.lastIndexOf('.')) + value.slice(value.lastIndexOf('.') + 1)
}
// 限制最多两位小数
if (value.includes('.')) {
const parts = value.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
value = parts.join('.')
}
}
// 限制最大值为100000
if (parseFloat(value) > 100000) {
value = '100000'
}
// 限制最小值为0
if (parseFloat(value) < 0 || parseFloat(value) == 0) {
value = '0'
}
// 更新价格到对应商品
if (item.multipleSpecificationsGoods && item.multipleSpecificationsGoods.goods) {
this.$set(this.list[index].multipleSpecificationsGoods.goods, 'sellPrice', value)
} else if (item.goods) {
this.$set(this.list[index].goods, 'sellPrice', value)
}
// 商品价格修改时,清空折扣 / 抵扣配置
this.resetStrategyWhenPriceChange(this.list[index])
this.$emit('changeTotalPrice')
},
// 验证数量输入
......@@ -556,6 +483,9 @@ export default {
})
}
})
},
shouldShowMarketingIcon(item) {
return checkMarketingIcon(item, this.showMarketingIcon)
}
}
}
......@@ -580,6 +510,12 @@ export default {
color: #ff781f;
}
.marketing-icon {
display: inline-block !important;
margin-right: toRpx(8);
flex-shrink: 0;
}
.alias {
margin-top: toRpx(12);
font-size: toRpx(24);
......
......@@ -5,7 +5,6 @@
@start="start"
ref="home"
:id="id"
:show-ai-assistant="recording && !!id"
@openStep="openStep"
@backHome="backHome"
@changeTab="changeTab"
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
......@@ -16,6 +16,10 @@ export function setSkipMenu(value) {
uni.setStorageSync(SKIP_MENU_KEY, !!value)
}
export function clearSkipMenu() {
uni.removeStorageSync(SKIP_MENU_KEY)
}
/** 是否应在今日展示引导气泡(每天首次) */
export function shouldShowDailyGuide() {
const last = uni.getStorageSync(GUIDE_DATE_KEY)
......
// 活动标识:marketingFlag 为 1 时显示活动 icon
const SHOW_MARKETING_VALUE = 1
function findActiveMarketingInList(list) {
if (!Array.isArray(list)) return undefined
const activeGoods = list.find(
g => g.marketingFlag == SHOW_MARKETING_VALUE || g.marketingFlag === String(SHOW_MARKETING_VALUE)
)
return activeGoods?.marketingFlag
}
function findActiveActivityInList(list) {
if (!Array.isArray(list)) return undefined
const activeGoods = list.find(
g => g.marketingFlag == SHOW_MARKETING_VALUE || g.marketingFlag === String(SHOW_MARKETING_VALUE)
)
const activityId = activeGoods?.activityId
if (activityId === undefined || activityId === null || activityId === '') return undefined
return activityId
}
function hasActivityValue(value) {
return value != null && value !== ''
}
export function getMarketingFlag(item) {
if (!item) return undefined
if (item.marketingFlag !== undefined && item.marketingFlag !== null && item.marketingFlag !== '') {
return item.marketingFlag
}
const nested =
item.goods?.marketingFlag ??
item.packageGoods?.marketingFlag ??
item.multipleSpecificationsGoods?.marketingFlag ??
item.multipleSpecificationsGoods?.goods?.marketingFlag
if (nested !== undefined && nested !== null && nested !== '') {
return nested
}
const activeFromPackageGoods =
findActiveMarketingInList(item.packageGoods?.goodsList) ??
findActiveMarketingInList(item.packageGoodsOrderList) ??
findActiveMarketingInList(item.goodsList)
if (activeFromPackageGoods !== undefined) return activeFromPackageGoods
return undefined
}
export function shouldShowMarketingIcon(item, enabled = false) {
if (!enabled) return false
const flag = getMarketingFlag(item)
return flag == SHOW_MARKETING_VALUE || flag === String(SHOW_MARKETING_VALUE)
}
export function getActivityId(item) {
if (!item) return undefined
if (hasActivityValue(item.activityId)) {
return item.activityId
}
const nested =
item.goods?.activityId ??
item.packageGoods?.activityId ??
item.multipleSpecificationsGoods?.activityId ??
item.multipleSpecificationsGoods?.goods?.activityId
if (hasActivityValue(nested)) {
return nested
}
const activeFromPackageGoods =
findActiveActivityInList(item.packageGoods?.goodsList) ??
findActiveActivityInList(item.packageGoodsOrderList) ??
findActiveActivityInList(item.goodsList)
if (activeFromPackageGoods !== undefined) return activeFromPackageGoods
return undefined
}
export function getSubmitMarketingFlag(orderItem, goods) {
const flag = getMarketingFlag(orderItem) ?? goods?.marketingFlag
return flag == SHOW_MARKETING_VALUE || flag === String(SHOW_MARKETING_VALUE) ? 1 : 0
}
export function getSubmitActivityId(orderItem, goods) {
if (getSubmitMarketingFlag(orderItem, goods) !== 1) return undefined
const activityId = goods?.activityId ?? getActivityId(orderItem)
if (!hasActivityValue(activityId)) return undefined
return activityId
}
// 商品加入订单时快照原价,供 modifyFlag 提交时对比
export function snapshotOriginalPrice(goods) {
if (!goods) return
if (goods.oldPrice != null && goods.oldPrice !== '') return
const source = goods.upgradePrice ?? goods.price ?? goods.sellPrice
if (source == null || source === '') return
goods.oldPrice = source
}
export function snapshotOrderItemOriginalPrice(item) {
if (!item) return
if (item.goodsFlag == 1 && item.goods) {
snapshotOriginalPrice(item.goods)
} else if (item.goodsFlag == 2 && item.multipleSpecificationsGoods?.goods) {
snapshotOriginalPrice(item.multipleSpecificationsGoods.goods)
} else if (item.goodsFlag == 3 && item.packageGoods?.goodsList) {
item.packageGoods.goodsList.forEach(snapshotOriginalPrice)
}
}
export function snapshotOrderItemsOriginalPrice(items) {
if (!Array.isArray(items)) return
items.forEach(snapshotOrderItemOriginalPrice)
}
export function getSubmitModifyFlag(goods) {
if (!goods) return 0
const current = parseFloat(goods.sellPrice ?? 0)
const originalSource = goods.oldPrice ?? goods.upgradePrice ?? goods.price
if (originalSource == null || originalSource === '') return 0
const original = parseFloat(originalSource)
if (Number.isNaN(current) || Number.isNaN(original)) return 0
return Math.abs(current - original) > 0.001 ? 1 : 0
}
export function isBelowMinSellPrice(goods, value) {
if (!goods || goods.validMinSellPrice !== 'Y' || goods.minSellPrice == null || goods.minSellPrice === '') {
return false
}
return parseFloat(value) < parseFloat(goods.minSellPrice)
}
export function getGoodsDisplayName(goods) {
if (!goods) return ''
return goods.goodsAlias || goods.upgradeGoodsName || goods.goodsInfo?.goodsName || goods.baseGoodsName || ''
}
function buildSingleApprovalItem(item, goods, number) {
const sellPrice = normalizeGoodsPrice(goods.sellPrice)
if (!isBelowMinSellPrice(goods, sellPrice)) return null
return {
type: 'single',
name: getGoodsDisplayName(goods),
sellPrice,
minSellPrice: goods.minSellPrice,
number: number || '1',
sourceItem: item
}
}
function getPackageDisplayTotal(item, orderTypeCode) {
const orderType = String(orderTypeCode || '')
let total = 0
item.packageGoods.goodsList.forEach(goods => {
const sellPrice = parseFloat(goods.sellPrice || 0)
if (orderType === '1' || orderType === '4') {
total += sellPrice
} else if (goods.finalPricePerUnit != null) {
total += parseFloat(goods.finalPricePerUnit || 0)
} else {
total += sellPrice
}
})
return total
}
function buildPackageApprovalItem(item, orderTypeCode) {
const children = (item.packageGoods.goodsList || [])
.map(goods => {
const sellPrice = normalizeGoodsPrice(goods.sellPrice)
if (!isBelowMinSellPrice(goods, sellPrice)) return null
return {
name: getGoodsDisplayName(goods),
sellPrice,
minSellPrice: goods.minSellPrice,
number: item.packageGoods.number || '1',
sourceGoods: goods
}
})
.filter(Boolean)
if (!children.length) return null
return {
type: 'package',
name: item.packageGoods.packageAlias || item.packageGoods.packageName || '',
sellPrice: getPackageDisplayTotal(item, orderTypeCode),
number: item.packageGoods.number || '1',
children,
sourceItem: item
}
}
export function collectBelowMinSellPriceItems(orderObj) {
if (!orderObj) return []
const productFields = ['frontGear', 'frontWindow', 'rearGear', 'rearWindow', 'sunRoof', 'package', 'skuGoods']
const result = []
productFields.forEach(field => {
const list = orderObj[field]
if (!Array.isArray(list)) return
list.forEach(item => {
if (item.goodsFlag == 1 && item.goods) {
const approvalItem = buildSingleApprovalItem(item, item.goods, item.goods.number)
if (approvalItem) result.push(approvalItem)
return
}
if (item.goodsFlag == 2) {
if (item.multipleSpecificationsGoods?.goods) {
const approvalItem = buildSingleApprovalItem(
item,
item.multipleSpecificationsGoods.goods,
item.multipleSpecificationsGoods.number
)
if (approvalItem) result.push(approvalItem)
return
}
if (item.goods) {
const approvalItem = buildSingleApprovalItem(item, item.goods, item.goods.number)
if (approvalItem) result.push(approvalItem)
}
return
}
if (item.goodsFlag == 3 && item.packageGoods) {
const approvalItem = buildPackageApprovalItem(item, orderObj.orderTypeCode)
if (approvalItem) result.push(approvalItem)
}
})
})
return result
}
export function hasBelowMinSellPriceGoods(orderObj) {
return collectBelowMinSellPriceItems(orderObj).length > 0
}
export function shouldUseMinPriceApproval(orderTypeCode) {
return String(orderTypeCode || '') === '1'
}
export function applyLegacyMinSellPriceClamp(goods, value) {
let price = normalizeGoodsPrice(value)
if (isBelowMinSellPrice(goods, price)) {
uni.showToast({
title: '单价不可低于商品最低价',
icon: 'none'
})
price = String(goods.minSellPrice)
}
return price
}
export function normalizeGoodsPrice(value) {
let price = value
if (!price || String(price).trim() === '') {
price = '0'
}
price = String(price).replace(/[^\d.]/g, '')
if (price.split('.').length > 2) {
price = price.slice(0, price.lastIndexOf('.')) + price.slice(price.lastIndexOf('.') + 1)
}
if (price.includes('.')) {
const parts = price.split('.')
if (parts[1].length > 2) {
parts[1] = parts[1].substring(0, 2)
price = parts.join('.')
}
}
if (parseFloat(price) > 100000) {
price = '100000'
}
if (parseFloat(price) < 0 || parseFloat(price) == 0) {
price = '0'
}
return price
}
export function getSkuGoodsPriceTarget(item) {
if (item?.multipleSpecificationsGoods?.goods) {
return item.multipleSpecificationsGoods.goods
}
return item?.goods || null
}
......@@ -295,7 +295,7 @@ class RecordService {
const useWs = !!wsBase
const transport = useWs ? TransportType.WEBSOCKET : TransportType.HTTP
// HTTP 服务端固定为 /health(可在 AiAssistantBall 内按需覆盖)
const httpBaseUrl = 'http://192.168.10.141:8616'
const httpBaseUrl = 'http://192.168.3.84:8616'
const client = new NativeChannelClient(
useWs ? { transport } : { transport, baseUrl: httpBaseUrl }
......
......@@ -64,24 +64,28 @@ class NativeHttpClient {
* @param {object} options uni.request 参数,url 可为相对路径
*/
request(options = {}) {
const url = this._resolveUrl(options.url)
const { onTask, url: rawUrl, header: extraHeader, ...rest } = options
const url = this._resolveUrl(rawUrl)
if (!url) {
return Promise.reject(new Error('request 缺少 url'))
}
const header = { ...this.header, ...(options.header || {}) }
const header = { ...this.header, ...(extraHeader || {}) }
if (this.auth && this.token && !header.token) {
header.token = this.token
}
return new Promise((resolve, reject) => {
uni.request({
const task = uni.request({
timeout: this.timeout,
dataType: this.dataType,
...options,
...rest,
url,
header,
success: (res) => resolve(res),
fail: (err) => reject(err)
})
if (typeof onTask === 'function') {
onTask(task)
}
})
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!