| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <view class="pc-wrap">
- <view class="pc-header">
- <text class="pc-title">方案确认</text>
- <text class="pc-sub">查看报告方案,确认后生成执行任务</text>
- </view>
- <view class="pc-loading" v-if="loading">加载中...</view>
- <view class="pc-waiting" v-else-if="!reportReady">
- <text class="pc-waiting-icon">⏳</text>
- <text class="pc-waiting-text">报告尚未生成</text>
- <text class="pc-waiting-sub">请耐心等待报告完成,系统会自动通知你</text>
- <view class="pc-waiting-btn" @click="refresh">
- <text class="pc-waiting-btn-text">刷新</text>
- </view>
- </view>
- <view class="pc-content" v-else>
- <view class="pc-report-section">
- <text class="pc-section-title">报告摘要</text>
- <text class="pc-section-text">{{ reportSummary || '暂无摘要信息' }}</text>
- </view>
- <view class="pc-report-section" v-if="planItems && planItems.length > 0">
- <text class="pc-section-title">建议方案</text>
- <view class="pc-plan-item" v-for="(item, i) in planItems" :key="getPlanKey(i)">
- <text class="pc-plan-num">{{ i + 1 }}</text>
- <view class="pc-plan-body">
- <text class="pc-plan-title">{{ item.title }}</text>
- <text class="pc-plan-desc" v-if="item.desc">{{ item.desc }}</text>
- </view>
- </view>
- </view>
- <view class="pc-confirm-btn" @click="confirmPlan">
- <text class="pc-confirm-btn-text">确认方案,生成任务</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getUserIntent } from '../../utils/api.js'
- import { confirmProblemPlan } from '../../utils/api.js'
- export default {
- data() {
- return {
- code: '',
- loading: false,
- reportReady: false,
- reportSummary: '',
- planItems: []
- }
- },
- onLoad(options) {
- this.code = (options && options.code) || ''
- this.loadPlan()
- },
- methods: {
- getPlanKey: function(i) { return 'p' + i },
- loadPlan() {
- var self = this
- self.loading = true
- uni.showLoading({ title: '加载中...', mask: true })
- getUserIntent().then(function(res) {
- uni.hideLoading()
- self.loading = false
- var intent = res && res.data
- if (intent) {
- var stage = intent.journeyStage || 0
- self.reportReady = stage >= 5
- if (self.reportReady) {
- // 从 survey_result_json 获取方案快照
- var resultJson = intent.survey_result_json
- if (resultJson) {
- var parsed = typeof resultJson === 'string' ? JSON.parse(resultJson) : resultJson
- self.reportSummary = parsed.summary || parsed.reportSummary || '报告已生成,请查看详情。'
- var items = parsed.items || parsed.planItems || parsed.recommendations || []
- self.planItems = Array.isArray(items) ? items : []
- } else {
- self.reportSummary = '报告已生成,建议方案已就绪。'
- self.planItems = [
- { title: '个性化饮食调整', desc: '根据报告结果调整日常饮食结构' },
- { title: '运动计划', desc: '定制运动方案,每周执行' },
- { title: '作息优化', desc: '调整作息习惯,改善睡眠质量' }
- ]
- }
- }
- } else {
- self.reportReady = false
- }
- }).catch(function() {
- uni.hideLoading()
- self.loading = false
- self.reportReady = false
- })
- },
- confirmPlan() {
- var self = this
- uni.showLoading({ title: '处理中...', mask: true })
- // 方案确认:后端生成方案任务(memberOnly=1)并推进旅程 stage=6
- confirmProblemPlan('').then(function(res) {
- uni.hideLoading()
- if (res && (res.code === 0 || res.code === 200)) {
- uni.showToast({ title: '方案已确认,任务已生成', icon: 'success' })
- setTimeout(function() {
- uni.navigateTo({ url: '/pages/tasks/tasks' })
- }, 500)
- } else {
- uni.showToast({ title: res.message || '确认失败', icon: 'none' })
- }
- }).catch(function() {
- uni.hideLoading()
- uni.showToast({ title: '确认失败,请重试', icon: 'none' })
- })
- },
- refresh() {
- this.loadPlan()
- }
- }
- }
- </script>
- <style scoped>
- .pc-wrap {
- min-height: 100vh;
- background: #FFF7ED;
- padding: 40rpx 32rpx;
- box-sizing: border-box;
- }
- .pc-header {
- margin-bottom: 32rpx;
- }
- .pc-title {
- display: block;
- font-size: 38rpx;
- font-weight: bold;
- color: #333;
- text-align: center;
- }
- .pc-sub {
- display: block;
- font-size: 26rpx;
- color: #999;
- text-align: center;
- margin-top: 10rpx;
- }
- .pc-loading {
- text-align: center;
- font-size: 28rpx;
- color: #999;
- padding: 80rpx 0;
- }
- .pc-waiting {
- text-align: center;
- padding: 80rpx 0;
- }
- .pc-waiting-icon {
- font-size: 80rpx;
- display: block;
- }
- .pc-waiting-text {
- display: block;
- font-size: 32rpx;
- font-weight: 600;
- color: #333;
- margin-top: 20rpx;
- }
- .pc-waiting-sub {
- display: block;
- font-size: 26rpx;
- color: #999;
- margin-top: 10rpx;
- }
- .pc-waiting-btn {
- display: inline-block;
- margin-top: 32rpx;
- background: #F97316;
- border-radius: 40rpx;
- padding: 18rpx 60rpx;
- }
- .pc-waiting-btn:active {
- opacity: 0.9;
- }
- .pc-waiting-btn-text {
- color: #fff;
- font-size: 28rpx;
- font-weight: 600;
- }
- .pc-report-section {
- background: #fff;
- border-radius: 20rpx;
- padding: 28rpx 30rpx;
- margin-bottom: 24rpx;
- box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
- }
- .pc-section-title {
- display: block;
- font-size: 30rpx;
- font-weight: 600;
- color: #333;
- margin-bottom: 16rpx;
- }
- .pc-section-text {
- display: block;
- font-size: 26rpx;
- color: #666;
- line-height: 1.6;
- }
- .pc-plan-item {
- display: flex;
- align-items: flex-start;
- margin-bottom: 20rpx;
- }
- .pc-plan-item:last-child {
- margin-bottom: 0;
- }
- .pc-plan-num {
- width: 40rpx;
- height: 40rpx;
- border-radius: 50%;
- background: #F97316;
- color: #fff;
- font-size: 22rpx;
- font-weight: bold;
- text-align: center;
- line-height: 40rpx;
- margin-right: 16rpx;
- flex-shrink: 0;
- }
- .pc-plan-body {
- flex: 1;
- }
- .pc-plan-title {
- display: block;
- font-size: 28rpx;
- font-weight: 600;
- color: #333;
- }
- .pc-plan-desc {
- display: block;
- font-size: 24rpx;
- color: #999;
- margin-top: 4rpx;
- }
- .pc-confirm-btn {
- background: linear-gradient(135deg, #F97316, #FB923C);
- border-radius: 48rpx;
- padding: 26rpx 0;
- text-align: center;
- margin-top: 16rpx;
- }
- .pc-confirm-btn:active {
- opacity: 0.9;
- }
- .pc-confirm-btn-text {
- color: #fff;
- font-size: 32rpx;
- font-weight: 600;
- }
- </style>
|