feat: ui update
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { request } from '../../utils/request'
|
||||
import { AiRecommendResult, ClothesItem } from '../../types/models'
|
||||
import { navScroll } from '../../utils/nav'
|
||||
import { logger } from '../../utils/logger'
|
||||
|
||||
// 日志模块名
|
||||
@@ -14,8 +15,24 @@ Page({
|
||||
result: null as AiRecommendResult | null,
|
||||
clothes: [] as ClothesItem[],
|
||||
generating: false,
|
||||
// 滚动收缩:由 utils/nav.ts 的共享 handler 驱动
|
||||
navScrolled: false,
|
||||
// v2 玻璃弹层
|
||||
confirmVisible: false,
|
||||
confirmButtons: [
|
||||
{ text: '取消', value: '' },
|
||||
{ text: '开始生成', value: 'ok', type: 'main' },
|
||||
],
|
||||
limitVisible: false,
|
||||
limitButtons: [
|
||||
{ text: '取消', value: '' },
|
||||
{ text: '去购买', value: 'ok', type: 'main' },
|
||||
],
|
||||
},
|
||||
|
||||
// scroll-view 滚动 → 导航收缩为玻璃小标题
|
||||
onNavScroll: navScroll,
|
||||
|
||||
noop() {},
|
||||
|
||||
selectDaily() {
|
||||
@@ -42,16 +59,20 @@ Page({
|
||||
|
||||
startGenerate(sceneType: number, scene: string) {
|
||||
if (this.data.generating) return
|
||||
wx.showModal({
|
||||
title: 'AI 穿搭推荐',
|
||||
content: '本次将消耗 1 次 AI 推荐额度,生成后可保存到我的穿搭',
|
||||
confirmText: '开始生成',
|
||||
cancelText: '取消',
|
||||
success: (res) => {
|
||||
if (res.confirm) this.doGenerate(sceneType, scene)
|
||||
},
|
||||
fail: (e) => logger.debug(LOG, '取消生成确认, err=', e && e.errMsg),
|
||||
})
|
||||
// 待生成的场景参数暂存到实例,确认后再发起
|
||||
;(this as any).pendingScene = { sceneType, scene }
|
||||
this.setData({ confirmVisible: true })
|
||||
},
|
||||
|
||||
onConfirmCancel() {
|
||||
this.setData({ confirmVisible: false })
|
||||
},
|
||||
|
||||
onConfirmGenerate(e: WechatMiniprogram.CustomEvent) {
|
||||
this.setData({ confirmVisible: false })
|
||||
if (e.detail.value !== 'ok') return
|
||||
const pending = (this as any).pendingScene || { sceneType: 1, scene: '' }
|
||||
this.doGenerate(pending.sceneType, pending.scene)
|
||||
},
|
||||
|
||||
doGenerate(sceneType: number, scene: string) {
|
||||
@@ -82,7 +103,8 @@ Page({
|
||||
logger.warn(LOG, 'AI 推荐生成失败, code=', code)
|
||||
if (code === 90400) {
|
||||
this.setData({ state: 'empty' })
|
||||
} else if (code === 90401) {
|
||||
} else if (code === 90401 || code === 80000) {
|
||||
// 90401=AI 推荐次数上限;80000=额度不足兜底,统一弹窗引导购买
|
||||
this.setData({ state: 'scene', showSceneSheet: true })
|
||||
this.showLimitModal()
|
||||
} else if (code === 10003) {
|
||||
@@ -95,20 +117,19 @@ Page({
|
||||
},
|
||||
|
||||
showLimitModal() {
|
||||
wx.showModal({
|
||||
title: 'AI 推荐额度不足',
|
||||
content: '购买额度包后可继续生成 AI 穿搭推荐',
|
||||
confirmText: '去购买',
|
||||
cancelText: '取消',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
wx.navigateTo({
|
||||
url: '/pages/mall/mall',
|
||||
fail: (e) => logger.warn(LOG, 'navigateTo 商城失败, err=', e && e.errMsg),
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (e) => logger.warn(LOG, '额度弹窗失败, err=', e && e.errMsg),
|
||||
this.setData({ limitVisible: true })
|
||||
},
|
||||
|
||||
onLimitCancel() {
|
||||
this.setData({ limitVisible: false })
|
||||
},
|
||||
|
||||
onLimitConfirm(e: WechatMiniprogram.CustomEvent) {
|
||||
this.setData({ limitVisible: false })
|
||||
if (e.detail.value !== 'ok') return
|
||||
wx.navigateTo({
|
||||
url: '/pages/mall/mall',
|
||||
fail: (err) => logger.warn(LOG, 'navigateTo 商城失败, err=', err && err.errMsg),
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user