Просмотр исходного кода

feat(frontend): 我的页面新增当前意图展示与重新选择入口

liaoxg 2 месяцев назад
Родитель
Сommit
cff8ed75cc
1 измененных файлов с 95 добавлено и 3 удалено
  1. 95 3
      cfc-frontend/pages/profile-main/profile.vue

+ 95 - 3
cfc-frontend/pages/profile-main/profile.vue

@@ -222,23 +222,39 @@
           <text class="logout-text">退出登录</text>
           <text class="logout-text">退出登录</text>
         </view>
         </view>
       </view>
       </view>
+
+      <!-- 当前意图 + 重新选择 -->
+      <view class="intent-section" v-if="userIntent && userIntent.intentType">
+        <view class="intent-info">
+          <text class="intent-label">当前选择</text>
+          <text class="intent-value">{{ intentLabel }}</text>
+        </view>
+        <view class="intent-reselect" @click="showIntentPicker = true">
+          <text class="intent-reselect-text">重新选择</text>
+        </view>
+      </view>
     </template>
     </template>
     <AIFloatingAvatar />
     <AIFloatingAvatar />
+    <IntentPicker
+      :show="showIntentPicker"
+      @select="handleReSelect"
+      @close="showIntentPicker = false" />
   </view>
   </view>
 </template>
 </template>
 
 
 <script>
 <script>
 import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
 import AIFloatingAvatar from '../../components/AIFloatingAvatar.vue'
+import IntentPicker from '../../components/intent-picker.vue'
 import {
 import {
   getChildren, getFamilyMemberList,
   getChildren, getFamilyMemberList,
   getTodayTasksByCategory, getChallengeList, getMyMembership,
   getTodayTasksByCategory, getChallengeList, getMyMembership,
   verifyPassword, getPointsBalance, getUserInfo,
   verifyPassword, getPointsBalance, getUserInfo,
   cartCount, getOrderCounts, getReferralSummary,
   cartCount, getOrderCounts, getReferralSummary,
-  getProfileStats
+  getProfileStats, getUserIntent, chooseUserIntent
 } from '../../utils/api.js'
 } from '../../utils/api.js'
 
 
 export default {
 export default {
-  components: { AIFloatingAvatar },
+  components: { AIFloatingAvatar, IntentPicker },
   data() {
   data() {
     return {
     return {
       nickname: '',
       nickname: '',
@@ -266,13 +282,23 @@ export default {
       cartCount: 0,
       cartCount: 0,
       // 待办
       // 待办
       pendingTasks: 0,
       pendingTasks: 0,
-      profileProgress: 0
+      profileProgress: 0,
+      // 用户意图(A/B/C)
+      userIntent: null,
+      showIntentPicker: false
     }
     }
   },
   },
   computed: {
   computed: {
     isLoggedIn() {
     isLoggedIn() {
       return !!uni.getStorageSync('token')
       return !!uni.getStorageSync('token')
     },
     },
+    intentLabel() {
+      var type = this.userIntent && this.userIntent.intentType
+      if (type === 'A') return '随便看看'
+      if (type === 'B') return '智能问卷'
+      if (type === 'C') return '解决问题'
+      return ''
+    },
     roleLabel() {
     roleLabel() {
       var map = { parent: '家长', child: '孩子', teacher: '规划师' }
       var map = { parent: '家长', child: '孩子', teacher: '规划师' }
       return map[this.role] || '用户'
       return map[this.role] || '用户'
@@ -304,6 +330,7 @@ export default {
     this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
     this.isSwitchedChild = uni.getStorageSync('isSwitchedChild') || false
     this.nickname = (uni.getStorageSync('userInfo') || {}).nickname || ''
     this.nickname = (uni.getStorageSync('userInfo') || {}).nickname || ''
     this.loadAllData()
     this.loadAllData()
+    this.loadUserIntent()
   },
   },
   methods: {
   methods: {
     loadAllData() {
     loadAllData() {
@@ -411,6 +438,35 @@ export default {
         }
         }
       }).catch(function() {})
       }).catch(function() {})
     },
     },
+    loadUserIntent() {
+      var self = this
+      getUserIntent().then(function(res) {
+        self.userIntent = res && res.data ? res.data : null
+      }).catch(function() {
+        self.userIntent = null
+      })
+    },
+    handleReSelect(payload) {
+      var self = this
+      this.showIntentPicker = false
+      uni.showLoading({ title: '保存中...', mask: true })
+      var data = { intentType: payload.intentType }
+      if (payload.intentType === 'C' && payload.problemDomainCode) {
+        data.problemDomainCode = payload.problemDomainCode
+      }
+      chooseUserIntent(data).then(function(res) {
+        uni.hideLoading()
+        if (res && (res.code === 0 || res.code === 200)) {
+          self.loadUserIntent()
+          uni.showToast({ title: '已更新你的选择', icon: 'none' })
+        } else {
+          uni.showToast({ title: res.message || '保存失败', icon: 'none' })
+        }
+      }).catch(function() {
+        uni.hideLoading()
+        uni.showToast({ title: '保存失败,请重试', icon: 'none' })
+      })
+    },
     goLogin: function() {
     goLogin: function() {
       uni.navigateTo({ url: '/pages/login/login' })
       uni.navigateTo({ url: '/pages/login/login' })
     },
     },
@@ -1008,4 +1064,40 @@ export default {
   color: #FF4D4F;
   color: #FF4D4F;
   font-weight: 500;
   font-weight: 500;
 }
 }
+
+/* 当前意图 + 重新选择 */
+.intent-section {
+  margin: 20rpx 30rpx 0;
+  background: #fff;
+  border-radius: 16rpx;
+  padding: 24rpx;
+  display: flex;
+  align-items: center;
+  box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
+}
+.intent-info {
+  flex: 1;
+  display: flex;
+  align-items: center;
+}
+.intent-label {
+  font-size: 24rpx;
+  color: #999;
+  margin-right: 12rpx;
+}
+.intent-value {
+  font-size: 26rpx;
+  color: #F97316;
+  font-weight: bold;
+}
+.intent-reselect {
+  background: #F97316;
+  border-radius: 28rpx;
+  padding: 12rpx 28rpx;
+}
+.intent-reselect-text {
+  font-size: 24rpx;
+  color: #fff;
+  font-weight: 600;
+}
 </style>
 </style>