Bläddra i källkod

自定义方案列表、详情对接

liyuliangjiazai 2 månader sedan
förälder
incheckning
b6307beff2

+ 3 - 2
code/ajyApp/pages/device/acupointEdit/acupointEdit.vue

@@ -216,9 +216,10 @@ export default {
 			})
 		}
 	},
-	onLoad() {
+	onLoad(options) {
 		const sysInfo = uni.getSystemInfoSync()
 		this.statusBarHeight = sysInfo.statusBarHeight || 44
+		this.profileId = decodeURIComponent(options.profileId || '')
 		this.checkOrientation(sysInfo)
 		this.loadAcupoints()
 	},
@@ -248,7 +249,7 @@ export default {
 		async loadAcupoints() {
 			this.loading = true
 			try {
-				const data = await getBackAcupoints(4)
+				const data = await getBackAcupoints(this.profileId)
 				if (Array.isArray(data)) {
 					// 按名称分组并计算平均 Y 坐标,以处理对称穴位
 					const nameMap = new Map()

+ 4 - 1
code/ajyApp/pages/device/deviceInfo/deviceInfo.nvue

@@ -410,12 +410,15 @@ export default {
 		},
 		/** 加载当前用户信息 */
 		loadCurrentUser() {
-			uni.removeStorageSync('current_manage_user')
+			// uni.removeStorageSync('current_manage_user')
 			const user = uni.getStorageSync('current_manage_user')
+			console.log("user",user)
 			if (user && user.name) {
 				this.currentUserName = user.name
+				this.profileId = user.id || ''
 			} else {
 				this.currentUserName = ''
+				this.profileId = ''
 			}
 		},
 		/** 跳转用户管理页 */

+ 2 - 1
code/ajyApp/pages/device/deviceInfo/mixins/acupoint-mixin.js

@@ -20,8 +20,9 @@ export default {
 		picModeChange(value) {
 			if (value === 2) {
 				// 穴位编辑跳转到独立vue页面(支持更灵活的坐标渲染)
+				const profileId = this.profileId || ''
 				uni.navigateTo({
-					url: '/pages/device/acupointEdit/acupointEdit'
+					url: '/pages/device/acupointEdit/acupointEdit?profileId=' + encodeURIComponent(profileId)
 				})
 				return
 			}

+ 44 - 20
code/ajyApp/pages/device/deviceInfo/mixins/plan-mixin.js

@@ -2,7 +2,7 @@
  * 方案管理 mixin
  * 负责:方案列表加载、子方案选择、模式切换时刷新方案
  */
-import { getCareList, getCareDetail } from '@/utils/api/care.js'
+import { getCareList, getCareDetail, getCustomPlanList, getCustomPlanDetail } from '@/utils/api/care.js'
 
 export default {
 	data() {
@@ -36,28 +36,45 @@ export default {
 
 		/**
 		 * 加载指定模式的方案列表
-		 * @param {Number} mode - 1专业 2自定义 3专家
+		 * @param {Number} mode - 1专业 2自定义 3延年圣手
 		 */
 		async loadPlanList(mode) {
 			this.planLoading = true
 			try {
-				// modeType映射为后端模式标识
-				const modeMap = {
-					1: 'PROFESSIONAL',
-					2: 'CUSTOM',
-					3: 'EXPERT'
-				}
-				const res = await getCareList({ modeType: modeMap[mode] || '' })
-				if (res && res.records) {
-					this.planList = res.records.map(item => ({
-						id: item.id,
-						name: item.title || item.name || '未命名方案',
-						description: item.description || item.remark || '',
-						steps: item.stepCount || item.steps || 0,
-						duration: item.totalDuration || 0
-					}))
+				if (mode === 2) {
+					// 自定义模式 - 使用自定义方案列表接口
+					const res = await getCustomPlanList()
+					if (res && Array.isArray(res)) {
+						this.planList = res.map(item => ({
+							id: item.id,
+							name: item.name || '未命名方案',
+							description: item.description || '',
+							symptoms: item.symptoms || '',
+							status: item.status,
+							useCount: item.useCount || 0,
+							avgRating: item.avgRating
+						}))
+					} else {
+						this.planList = []
+					}
 				} else {
-					this.planList = []
+					// 专业模式/延年圣手模式 - 使用原有调理方案列表接口
+					const modeMap = {
+						1: 'PROFESSIONAL',
+						3: 'EXPERT'
+					}
+					const res = await getCareList({ modeType: modeMap[mode] || '' })
+					if (res && res.records) {
+						this.planList = res.records.map(item => ({
+							id: item.id,
+							name: item.title || item.name || '未命名方案',
+							description: item.description || item.remark || '',
+							steps: item.stepCount || item.steps || 0,
+							duration: item.totalDuration || 0
+						}))
+					} else {
+						this.planList = []
+					}
 				}
 			} catch (e) {
 				console.error('加载方案列表失败', e)
@@ -84,16 +101,23 @@ export default {
 
 		/**
 		 * 将方案数据应用到当前穴位配置
-		 * TODO: 后续对接方案详情接口,获取具体步骤和穴位坐标
 		 */
 		async _applyPlanToCase(plan) {
 			if (!plan || !plan.id) return
 			try {
-				const res = await getCareDetail(plan.id)
+				let res
+				if (this.modeType === 2) {
+					// 自定义模式 - 使用自定义方案详情接口
+					res = await getCustomPlanDetail(plan.id)
+				} else {
+					res = await getCareDetail(plan.id)
+				}
 				if (res && res.steps) {
 					this.curCase = res.steps.map(step => ({
 						id: step.acupointId || step.id,
+						name: step.acupointName || '',
 						time: step.duration || 15,
+						temperature: step.temperature || 42,
 						_x: step.x || 0,
 						_y: step.y || 0
 					}))

+ 18 - 0
code/ajyApp/utils/api/care.js

@@ -19,6 +19,24 @@ export function getCareList(params = {}) {
 	})
 }
 
+/**
+ * 获取当前用户的自定义方案列表
+ * 通过 Token 获取当前 APP 账号下创作人属于自己的自定义模式方案
+ * @returns {Promise<Array<{id, planCode, name, modeType, symptoms, applicableGender, ageMin, ageMax, description, authorId, authorName, authorType, useCount, avgRating, lastUseTime, status, createTime, updateTime}>>}
+ */
+export function getCustomPlanList() {
+	return http.get('/app/custom-plan/list')
+}
+
+/**
+ * 获取用户自定义方案详情
+ * @param {string|number} id - 方案ID
+ * @returns {Promise<Object>} 方案详情含steps
+ */
+export function getCustomPlanDetail(id) {
+	return http.get(`/app/custom-plan/${id}`)
+}
+
 /**
  * 获取调理方案详情
  * @param {string|number} id - 方案ID