Feat(云灵AI):首页送礼重构&交互使用模拟数据书写对应逻辑
This commit is contained in:
+100
-20
@@ -21,29 +21,35 @@ export const chatMixinsV2 = {
|
||||
token: cookie.get('login_status'),
|
||||
userInfo: cookie.get('userInfo'),
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
bottomTools: Object.freeze([
|
||||
bottomTools: [
|
||||
{
|
||||
icon: 'icon-50',
|
||||
text: '我要送礼',
|
||||
type: 'prompt',
|
||||
prompt: '我要送礼,请给我推荐一些平台的礼品',
|
||||
url: ''
|
||||
name: '我要送礼',
|
||||
icon: 'https://resource.xdd618.com/3/20260526/1779781836792_icon-50.png',
|
||||
navType: 'prompt',
|
||||
promptContent: '我要送礼,请给我推荐一些平台的礼品',
|
||||
url: '',
|
||||
giftCardEnabled: 1,
|
||||
display: true
|
||||
},
|
||||
{
|
||||
icon: 'icon-51',
|
||||
text: '订单查询',
|
||||
type: 'prompt',
|
||||
prompt: '帮我查询我的待发货、待收货订单信息',
|
||||
url: ''
|
||||
name: '订单查询',
|
||||
icon: 'https://resource.xdd618.com/3/20260526/1779781836793_icon-51.png',
|
||||
navType: 'prompt',
|
||||
promptContent: '帮我查询我的待发货、待收货订单信息',
|
||||
url: '',
|
||||
giftCardEnabled: 0,
|
||||
display: true
|
||||
},
|
||||
{
|
||||
icon: 'icon-52',
|
||||
text: '拍照识图',
|
||||
type: 'link',
|
||||
prompt: '',
|
||||
url: '/aiChat/views/imageRecognition'
|
||||
name: '拍照识图',
|
||||
icon: 'https://resource.xdd618.com/3/20260526/1779781836794_icon-52.png',
|
||||
navType: 'url',
|
||||
promptContent: '',
|
||||
url: '/aiChat/views/imageRecognition',
|
||||
giftCardEnabled: 0,
|
||||
display: true
|
||||
}
|
||||
]),
|
||||
],
|
||||
scrollData: {},
|
||||
scrollTop: 0,
|
||||
isScrollToBottom: false,
|
||||
@@ -695,13 +701,32 @@ export const chatMixinsV2 = {
|
||||
}
|
||||
},
|
||||
bottomToolClickHandle(item) {
|
||||
if (item.type === 'prompt') {
|
||||
// 非界面跳转的需要校验登录状态
|
||||
if (!this.token && item.navType !== 'url') {
|
||||
handleLoginFailure()
|
||||
return
|
||||
}
|
||||
const idx = this.bottomTools.findIndex((i) => i.giftCardEnabled === 1)
|
||||
if (item.giftCardEnabled === 1) {
|
||||
// 新建会话
|
||||
this.createNewHandle('giftChat')
|
||||
this.$set(this, 'showGiftSteps', true)
|
||||
if (idx > -1) {
|
||||
this.$set(this.bottomTools[idx], 'display', false)
|
||||
}
|
||||
return
|
||||
}
|
||||
this.$set(this, 'showGiftSteps', false)
|
||||
if (idx > -1) {
|
||||
this.$set(this.bottomTools[idx], 'display', true)
|
||||
}
|
||||
if (item.navType === 'prompt') {
|
||||
this.streamReq({
|
||||
prompt: item.prompt,
|
||||
prompt: item.promptContent,
|
||||
init: 0
|
||||
})
|
||||
}
|
||||
if (item.type === 'link') {
|
||||
if (item.navType === 'url') {
|
||||
uni.navigateTo({
|
||||
url: item.url
|
||||
})
|
||||
@@ -711,6 +736,61 @@ export const chatMixinsV2 = {
|
||||
uni.navigateTo({
|
||||
url: '/pagesOrder/order/OrderDetails/index?id=' + order.orderId
|
||||
})
|
||||
},
|
||||
isGiftOptionSelected(configId, optionId) {
|
||||
if (!this.giftSelections[configId]) return false
|
||||
return this.giftSelections[configId].includes(optionId)
|
||||
},
|
||||
toggleGiftOption(configId, optionId) {
|
||||
if (!this.giftSelections[configId]) {
|
||||
this.$set(this.giftSelections, configId, [])
|
||||
}
|
||||
const index = this.giftSelections[configId].indexOf(optionId)
|
||||
if (index > -1) {
|
||||
this.giftSelections[configId].splice(index, 1)
|
||||
} else {
|
||||
this.giftSelections[configId].push(optionId)
|
||||
}
|
||||
},
|
||||
prevGiftStep() {
|
||||
if (this.currentGiftStepIndex > 0) {
|
||||
this.currentGiftStepIndex--
|
||||
}
|
||||
},
|
||||
nextGiftStep() {
|
||||
if (this.currentGiftStepIndex < this.giftBuyOptions.length - 1) {
|
||||
this.currentGiftStepIndex++
|
||||
} else {
|
||||
this.finishGiftSteps()
|
||||
}
|
||||
},
|
||||
skipGiftStep() {
|
||||
if (this.currentGiftStepIndex < this.giftBuyOptions.length - 1) {
|
||||
this.currentGiftStepIndex++
|
||||
} else {
|
||||
this.finishGiftSteps()
|
||||
}
|
||||
},
|
||||
finishGiftSteps() {
|
||||
let promptStr = '我想送礼'
|
||||
this.giftBuyOptions.forEach(step => {
|
||||
if (step.type === 'option_card') {
|
||||
const selectedIds = this.giftSelections[step.id] || []
|
||||
if (selectedIds.length > 0) {
|
||||
const selectedNames = step.options.filter(opt => selectedIds.includes(opt.id)).map(opt => opt.optionName)
|
||||
promptStr += `,${step.title.replace('?', '')}:${selectedNames.join('、')}`
|
||||
}
|
||||
} else if (step.type === 'price_input') {
|
||||
if (this.giftBudget) {
|
||||
promptStr += `,${step.title.replace('?', '')}:${this.giftBudget}`
|
||||
}
|
||||
}
|
||||
});
|
||||
this.showGiftSteps = false
|
||||
this.streamReq({
|
||||
prompt: promptStr,
|
||||
init: 0
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user