From c172d3b6342864033e6de5cc2e07fe439fd23902 Mon Sep 17 00:00:00 2001
From: zeyan <258785420@qq.com>
Date: Fri, 1 Aug 2025 02:26:10 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
uniapp/pages/market/clue/add_clues.vue | 241 +----------------
uniapp/pages/market/clue/clue_info.vue | 89 +------
uniapp/pages/market/clue/edit_clues.vue | 321 +----------------------
uniapp/pages/student/knowledge/index.vue | 186 ++++++++++---
uniapp/pages/student/orders/index.vue | 211 +++++++--------
5 files changed, 269 insertions(+), 779 deletions(-)
diff --git a/uniapp/pages/market/clue/add_clues.vue b/uniapp/pages/market/clue/add_clues.vue
index a13043d7..692a7674 100644
--- a/uniapp/pages/market/clue/add_clues.vue
+++ b/uniapp/pages/market/clue/add_clues.vue
@@ -509,12 +509,10 @@
class="img"
:src="$util.img('/uniapp_src/static/images/index/myk.png')">
{{v.name}}
-
首选联系人:{{v.decision_maker}}
-
@@ -550,8 +548,6 @@
-
-
@@ -602,78 +598,10 @@ import dictUtil from '@/common/dictUtil.js';
import dictUtilSimple from '@/common/dictUtilSimple.js';
-const rules = [
- {
- name: "student_name",
- rule: ["required"],
- msg: ["请输入学员姓名"]
- },
- {
- name: "title",
- rule: ["required"],
- msg: ["请输入线索标题"]
- },
- {
- name: "student_phone",
- rule: ["required", "isMobile"],
- msg: ["请输入电话", "请输入正确的手机号"]
- },
- {
- name: "age",
- rule: ["required", "isNumber"],
- msg: ["请输入年龄", "请输入正确的数字"]
- },
- {
- name: "school_name",
- rule: ["required"],
- msg: ["请输入学校"]
- },
- {
- name: "grade",
- rule: ["required"],
- msg: ["请输入年级"]
- },
- {
- name: "class_name",
- rule: ["required"],
- msg: ["请输入班级"]
- },
- {
- name: "customer_source",
- rule: ["required"],
- msg: ["请选择客户来源"]
- },
- {
- name: "add_staff_id",
- rule: ["required"],
- msg: ["请选择顾问"]
- },
- {
- name: "contact_name",
- rule: ["required"],
- msg: ["请输入联系人"]
- },
- {
- name: "full_address",
- rule: ["required"],
- msg: ["请选择所在地区"]
- },
- {
- name: "community_name",
- rule: ["required"],
- msg: ["请输入小区"]
- },
- {
- name: "customer_tags_name",
- rule: ["required"],
- msg: ["请选择客户标签"]
- }
-];
export default {
data() {
return {
switchChange_type: 1,
- rules,
is_submit: true,//是否提交(防止重复提交)|true=可提交,false=不可提交
@@ -787,9 +715,6 @@ export default {
maxDate: new Date().toISOString().split('T')[0], // 最大日期,只取日期部分
- //地区三级联动
- show_area: false,
- options_area: [],
//登录用户信息
userInfo:{},
@@ -1190,93 +1115,10 @@ export default {
await this.get_campus_list()//获取校区
},
- //获取字典-课程id选择
- async getDict_courses_id(){
- let res = await marketApi.selectCourseList({})
- if(res.code != 1){
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- let dictionary = res.data
- let arr = []
- dictionary.forEach((v,k)=>{
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
- this.options_courses_id = arr
- },
- //获取人员列表
- async getStaffList() {
- let res = await memberApi.staffList({type: 2})
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- let arr = []
- res.data.forEach((v,k)=>{
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
- this.options_add_staff_id = arr
- },
-
- //获取人员列表 role_id|5=市场,6=销售
- async getRoleStaffList(role_id) {
- let res = await memberApi.staffList({
- type: 2,
- role_id:role_id
- })
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
-
- let arr = []
- res.data.forEach((v,k)=>{
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
-
- if(role_id == 5){
- this.options_staff_id_5 = arr
- console.log('市场',arr)
- }else{
- this.options_staff_id_6 = arr
- console.log('销售',arr)
- }
- },
-
- //获取地区树形结构
- async getAreaTree() {
- let res = await commonApi.getAreaTree()
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- this.options_area = res.data
- },
//获取字典
async getDict(inputName){
@@ -1513,68 +1355,10 @@ export default {
- //多选客户标签-选中后回调
- onConfirmCustomerTags(e) {
- console.log('多选客户标签', e)
- this.show_customer_tags = false
- let customer_tags_name_arr = []
- let customer_tags_arr = []
- e.options.forEach((v, k) => {
- customer_tags_arr.push(v.value)
- customer_tags_name_arr.push(v.text)
- //根据v.value 设置this.options_customer_tags中对应元素的checked属性为true
- this.options_customer_tags.forEach((v, k) => {
- if (v.value == v.value) {
- v.checked = true
- }
- })
- })
-
- this.formData.customer_tags_name = customer_tags_name_arr.join(',')//数组转字符串
- this.formData.customer_tags = customer_tags_arr//数组转字符串
- },
- //地区选择相关
- changeArea(e) {
- this.show_area = false
- console.log('地区选择', e)
- this.formData.province_id = e.value[0]
- this.formData.city_id = e.value[1]
- this.formData.district_id = e.value[2]
- this.formData.full_address = `${e.text[0]}-${e.text[1]}-${e.text[2]}`
- },
- //开关选择
- switchChange(e) {
- if (e.detail.value) {
- this.switchChange_type = 1
- } else {
- this.switchChange_type = 2
- }
- },
- //性别选择器
- changeSex(e){
- this.formData.gender = e.detail.value
- },
- //监听-是否创建跟进任务
- changeIsFollow(e) {
- console.log(111, e.detail.value)
- this.is_follow = e.detail.value
- //是否创建跟进任务 1跟进
- if (this.is_follow) {
- this.formData.is_follow = '1'
- } else {
- //2不跟进
- this.formData.is_follow = '2'
-
- this.formData.entry_type = ''//跟进类型
- this.formData.staff_id = ''//跟进人员
- this.formData.follow_up_time = ''//跟进时间
- this.formData.follow_up_content = ''//备注
- }
- },
//切换tag列表
@@ -1992,14 +1776,6 @@ export default {
.form-style {
width: 100%;
- // background: #434544;
- }
-
- .form-style-vid {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12rpx 0;
}
.input-style {
@@ -2072,23 +1848,11 @@ export default {
.img {
width: 48rpx;
height: 48rpx;
- border-right: 50%;
+ border-radius: 50%;
}
.name{
margin-left: 20rpx;
}
- .tag{
- margin-left: 20rpx;
- width: 84rpx;
- height: 32rpx;
- line-height: 28rpx;
- border-radius: 0rpx 20rpx 20rpx 20rpx;
- background-color: rgba(236,128,141,0.3);
- color: rgba(240,90,90,1);
- font-size: 20rpx;
- text-align: center;
- border: 0rpx solid rgba(121,121,121,1);
- }
}
.box_2{
display: flex;
@@ -2110,7 +1874,6 @@ export default {
.box_3{
display: flex;
gap: 30rpx;
- .left{}
.right{
display: flex;
align-items: center;
@@ -2118,7 +1881,7 @@ export default {
.img{
width: 16rpx;
height: 16rpx;
- border-right: 50%;
+ border-radius: 50%;
}
}
}
diff --git a/uniapp/pages/market/clue/clue_info.vue b/uniapp/pages/market/clue/clue_info.vue
index 9070f54f..b8274d20 100644
--- a/uniapp/pages/market/clue/clue_info.vue
+++ b/uniapp/pages/market/clue/clue_info.vue
@@ -224,7 +224,6 @@
-
@@ -300,7 +299,6 @@ import OrderListCard from '@/components/order-list-card/index.vue'
import ServiceListCard from '@/components/service-list-card/index.vue'
import OrderFormPopup from '@/components/order-form-popup/index.vue'
// 编辑弹窗
-import CourseEditPopup from '@/components/course-edit-popup/course-edit-popup.vue'
import StudentEditPopup from '@/components/student-edit-popup/student-edit-popup.vue'
import FitnessRecordPopup from '@/components/fitness-record-popup/fitness-record-popup.vue'
import StudyPlanPopup from '@/components/study-plan-popup/study-plan-popup.vue'
@@ -318,7 +316,6 @@ export default {
OrderListCard,
ServiceListCard,
OrderFormPopup,
- CourseEditPopup,
StudentEditPopup,
FitnessRecordPopup,
StudyPlanPopup
@@ -328,8 +325,6 @@ export default {
switch_tags_type: 1,
resource_sharing_id: '',
- // 屏幕信息(保留以备其他地方使用)
- screenHeight: 0,
// 基本数据
clientInfo: { id: '', resource_id: '', customerResource: {} },
@@ -360,10 +355,7 @@ export default {
// 配置数据
tabs: [
{ id: 1, name: '基本资料' },
- // { id: 2, name: '课程信息' },
{ id: 3, name: '通话记录' },
- // { id: 4, name: '体测记录' },
- // { id: 5, name: '学习计划' }
{ id: 7, name: '修改资料' },
{ id: 6, name: '修改记录' }
],
@@ -418,45 +410,6 @@ export default {
return ['fitness_record', 'study_plan'].includes(this.currentPopup)
},
- // 计算年龄(x岁x月)
- calculateAge(birthday) {
- if (!birthday) return ''
-
- const birthDate = new Date(birthday)
- const now = new Date()
-
- let years = now.getFullYear() - birthDate.getFullYear()
- let months = now.getMonth() - birthDate.getMonth()
-
- if (months < 0) {
- years--
- months += 12
- }
-
- // 如果当前日期小于生日的日期,月份减1
- if (now.getDate() < birthDate.getDate()) {
- months--
- if (months < 0) {
- years--
- months += 12
- }
- }
-
- if (years > 0 && months > 0) {
- return `${years}岁${months}月`
- } else if (years > 0) {
- return `${years}岁`
- } else if (months > 0) {
- return `${months}月`
- } else {
- return '新生儿'
- }
- },
-
- // 格式化性别
- formatGender(gender) {
- return gender === 1 ? '男' : gender === 2 ? '女' : ''
- }
},
onLoad(options) {
if (!options?.resource_sharing_id) {
@@ -599,37 +552,6 @@ export default {
}
},
- // 弹窗交互逻辑
- async handleActionClick(action) {
- switch (action.key) {
- case 'course_arrangement':
- this.$navigateToPage(`/pages/market/clue/class_arrangement`, {
- resource_id: this.clientInfo.resource_id,
- student_id: this.currentStudent?.id
- })
- break
- case 'course_info':
- await this.getCourseInfo()
- this.currentPopup = 'course_info'
- break
- case 'fitness_record':
- await this.getFitnessRecords()
- this.currentPopup = 'fitness_record'
- break
- case 'study_plan':
- await this.getStudyPlanList()
- this.currentPopup = 'study_plan'
- break
- case 'order_list':
- await this.getOrderList()
- this.currentPopup = 'order_list'
- break
- case 'service_list':
- await this.getServiceList()
- this.currentPopup = 'service_list'
- break
- }
- },
// 学生卡片操作按钮点击处理 - 传递具体学生信息
async handleStudentActionClick(action, student) {
@@ -686,9 +608,6 @@ export default {
},
- handleCourseEditConfirm(result) {
- uni.showToast({ title: '保存成功', icon: 'success' })
- },
viewCourseDetail(course) {
@@ -702,7 +621,6 @@ export default {
})
},
-
async handleTabChange({ tabId }) {
this.switch_tags_type = tabId
@@ -732,9 +650,6 @@ export default {
case 'study_plan':
this.switch_tags_type = 5
break
- default:
- this.handleActionClick(action)
- break
}
},
@@ -1228,9 +1143,9 @@ export default {
},
// 订单表单确认处理
- async handleOrderFormConfirm(orderData) {
+ async handleOrderFormConfirm() {
try {
- // 关闭弹窗
+ // 关闽弹窗
this.closeOrderForm()
// 刷新订单列表
diff --git a/uniapp/pages/market/clue/edit_clues.vue b/uniapp/pages/market/clue/edit_clues.vue
index 79d56c4f..48954639 100644
--- a/uniapp/pages/market/clue/edit_clues.vue
+++ b/uniapp/pages/market/clue/edit_clues.vue
@@ -74,14 +74,6 @@
-
-
-
-
-
-
-
-
@@ -182,20 +174,6 @@
-
-
-
-
@@ -224,12 +202,6 @@
-
-
@@ -357,78 +329,9 @@
import memberApi from '@/api/member.js';
- const rules = [{
- name: "student_name",
- rule: ["required"],
- msg: ["请输入学员姓名"]
- },
- {
- name: "title",
- rule: ["required"],
- msg: ["请输入线索标题"]
- },
- {
- name: "student_phone",
- rule: ["required", "isMobile"],
- msg: ["请输入电话", "请输入正确的手机号"]
- },
- {
- name: "age",
- rule: ["required", "isNumber"],
- msg: ["请输入年龄", "请输入正确的数字"]
- },
- {
- name: "school_name",
- rule: ["required"],
- msg: ["请输入学校"]
- },
- {
- name: "grade",
- rule: ["required"],
- msg: ["请输入年级"]
- },
- {
- name: "class_name",
- rule: ["required"],
- msg: ["请输入班级"]
- },
- {
- name: "customer_source",
- rule: ["required"],
- msg: ["请选择客户来源"]
- },
- {
- name: "add_staff_id",
- rule: ["required"],
- msg: ["请选择顾问"]
- },
- {
- name: "contact_name",
- rule: ["required"],
- msg: ["请输入联系人"]
- },
- {
- name: "full_address",
- rule: ["required"],
- msg: ["请选择所在地区"]
- },
- {
- name: "community_name",
- rule: ["required"],
- msg: ["请输入小区"]
- },
- {
- name: "customer_tags_name",
- rule: ["required"],
- msg: ["请选择客户标签"]
- }
- ];
export default {
data() {
return {
- switchChange_type: 1,
- rules,
-
is_submit: true, //是否提交(防止重复提交)|true=可提交,false=不可提交
resource_sharing_id: '', //resource_sharing_id(资源共享表id)
@@ -555,15 +458,8 @@
default_date_value: '', // 添加默认日期值
- //地区三级联动
- show_area: false,
- options_area: [],
- //登录用户信息
- userInfo: {},
-
- // 查重相关
- student_name: '', //检索关键字
+ // 查重相关
clientUserList: [], //查重用户列表
showDuplicateCheck: false, //是否显示查重弹出层
@@ -1025,95 +921,10 @@
return null
},
- //获取字典-课程id选择
- async getDict_courses_id() {
- let res = await marketApi.selectCourseList({})
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
-
- let dictionary = res.data
- let arr = []
- dictionary.forEach((v, k) => {
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
- this.options_courses_id = arr
- },
-
- //获取人员列表
- async getStaffList() {
- let res = await memberApi.staffList({
- type: 2
- })
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- let arr = []
- res.data.forEach((v, k) => {
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
- this.options_add_staff_id = arr
- },
- //获取人员列表 role_id|5=市场,6=销售
- async getRoleStaffList(role_id) {
- let res = await memberApi.staffList({
- type: 2,
- role_id: role_id
- })
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
-
- let arr = []
- res.data.forEach((v, k) => {
- arr.push({
- text: v.name,
- value: v.id,
- })
- })
-
- if (role_id == 5) {
- this.options_staff_id_5 = arr
- console.log('市场', arr)
- } else {
- this.options_staff_id_6 = arr
- console.log('销售', arr)
- }
- },
- //获取地区树形结构
- async getAreaTree() {
- let res = await commonApi.getAreaTree()
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- this.options_area = res.data
- },
//获取字典
async getDict(inputName) {
@@ -1208,35 +1019,6 @@
}
},
- //##### 查重相关 #####
- //客户列表--查重
- async clientList() {
-
- if (!this.student_name) {
- uni.showToast({
- title: '请输入检索关键字',
- icon: 'none'
- })
- return
- }
-
- this.clientUserList = []
-
- let param = {
- student_name: this.student_name
- }
- let res = await marketApi.clientList(param)
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
- console.log('查重', res)
- this.clientUserList = res.data
- this.openDuplicateCheck()
- },
//打开结果列表
openDuplicateCheck() {
this.showDuplicateCheck = true
@@ -1247,50 +1029,7 @@
},
- //跳转页面-客户详情
- openViewClueInfo(item) {
- let id = item.id
- this.$navigateTo({
- url: `/pages/market/clue/clue_info?id=${id}`
- })
- },
-
- //跳转页面-我的消息
- openViewMyMessage(item) {
- let hair_staff_id = item.hair_staff_id
- this.$navigateTo({
- url: `/pages/common/im_chat_info?hair_staff_id=${hair_staff_id}`
- })
- },
-
- //拨打电话
- async dialTel(item) {
- let tel = item.student_phone
-
- if (!tel) {
- uni.showToast({
- title: '电话号码为空',
- icon: 'none'
- });
- return;
- }
- let param = {
- sales_id: item.id //线索id
- }
- let res = await marketApi.setCallUp(param) //添加通过记录
- if (res.code != 1) {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- return
- }
-
- uni.makePhoneCall({
- phoneNumber: tel
- })
- },
//联系电话失去焦点时间
@@ -1334,71 +1073,13 @@
- //多选客户标签-选中后回调
- onConfirmCustomerTags(e) {
- console.log('多选客户标签', e)
- this.show_customer_tags = false
- let customer_tags_name_arr = []
- let customer_tags_arr = []
- e.options.forEach((v, k) => {
- customer_tags_arr.push(v.value)
- customer_tags_name_arr.push(v.text)
- //根据v.value 设置this.options_customer_tags中对应元素的checked属性为true
- this.options_customer_tags.forEach((v, k) => {
- if (v.value == v.value) {
- v.checked = true
- }
- })
- })
-
- this.formData.customer_tags_name = customer_tags_name_arr.join(',') //数组转字符串
- this.formData.customer_tags = customer_tags_arr //数组转字符串
- },
- //地区选择相关
- changeArea(e) {
- this.show_area = false
- console.log('地区选择', e)
- this.formData.province_id = e.value[0]
- this.formData.city_id = e.value[1]
- this.formData.district_id = e.value[2]
- this.formData.full_address = `${e.text[0]}-${e.text[1]}-${e.text[2]}`
- },
- //开关选择
- switchChange(e) {
- if (e.detail.value) {
- this.switchChange_type = 1
- } else {
- this.switchChange_type = 2
- }
- },
-
- changeEfficacious(e) {
- this.formData.efficacious = e.detail.value
- },
//性别选择器
changeSex(e) {
this.formData.gender = e.detail.value
},
- //监听-是否创建跟进任务
- changeIsFollow(e) {
- console.log(111, e.detail.value)
- this.is_follow = e.detail.value
- //是否创建跟进任务 1跟进
- if (this.is_follow) {
- this.formData.is_follow = '1'
- } else {
- //2不跟进
- this.formData.is_follow = '2'
-
- this.formData.entry_type = '' //跟进类型
- this.formData.staff_id = '' //跟进人员
- this.formData.follow_up_time = '' //跟进时间
- this.formData.follow_up_content = '' //备注
- }
- },
//切换tag列表
diff --git a/uniapp/pages/student/knowledge/index.vue b/uniapp/pages/student/knowledge/index.vue
index d6482432..19018988 100644
--- a/uniapp/pages/student/knowledge/index.vue
+++ b/uniapp/pages/student/knowledge/index.vue
@@ -210,6 +210,7 @@
showSearchPopup: false,
searchKeyword: '',
searchHistory: [],
+ // 配置项
categoryTabs: [
{ value: 'all', text: '全部', icon: '📖', count: 0 },
{ value: 'training', text: '训练技巧', icon: '💪', count: 0 },
@@ -217,7 +218,19 @@
{ value: 'recovery', text: '恢复康复', icon: '🧘', count: 0 },
{ value: 'psychology', text: '运动心理', icon: '🧠', count: 0 },
{ value: 'equipment', text: '装备指南', icon: '🏃', count: 0 }
- ]
+ ],
+ categoryMap: {
+ 'training': '训练技巧',
+ 'nutrition': '营养健康',
+ 'recovery': '恢复康复',
+ 'psychology': '运动心理',
+ 'equipment': '装备指南'
+ },
+ mockConfig: {
+ maxSearchHistory: 10,
+ pageSize: 10,
+ searchDelay: 300
+ }
}
},
@@ -238,6 +251,109 @@
uni.navigateBack()
},
+ // Mock数据方法
+ getMockArticlesData() {
+ return {
+ code: 1,
+ data: {
+ list: [
+ {
+ id: 1,
+ title: '少儿体适能训练的核心要素',
+ summary: '了解少儿体适能训练的基本原理和核心要素,帮助孩子建立正确的运动基础。',
+ category: 'training',
+ tags: ['体适能', '少儿训练', '基础运动'],
+ cover_image: '/static/knowledge/training1.jpg',
+ author: '张教练',
+ publish_time: '2024-01-15 10:00:00',
+ read_count: 1250,
+ like_count: 88,
+ is_read: false,
+ is_favorite: false
+ },
+ {
+ id: 2,
+ title: '儿童运动营养指南',
+ summary: '科学的营养搭配是儿童运动能力提升的重要保障。',
+ category: 'nutrition',
+ tags: ['运动营养', '儿童健康', '饮食搭配'],
+ cover_image: '/static/knowledge/nutrition1.jpg',
+ author: '李营养师',
+ publish_time: '2024-01-14 15:30:00',
+ read_count: 980,
+ like_count: 65,
+ is_read: true,
+ is_favorite: true
+ },
+ {
+ id: 3,
+ title: '运动后的恢复与拉伸',
+ summary: '正确的恢复和拉伸能够有效防止运动损伤。',
+ category: 'recovery',
+ tags: ['运动恢复', '拉伸运动', '损伤预防'],
+ cover_image: '/static/knowledge/recovery1.jpg',
+ author: '王康复师',
+ publish_time: '2024-01-13 09:20:00',
+ read_count: 756,
+ like_count: 42,
+ is_read: false,
+ is_favorite: false
+ }
+ ],
+ total: 25,
+ has_more: true,
+ stats: {
+ total_articles: 25,
+ favorites: 8,
+ read_articles: 12
+ }
+ }
+ }
+ },
+
+ getMockRecommendData() {
+ return [
+ {
+ id: 101,
+ title: '新手家长必看:如何陪伴孩子开始运动',
+ summary: '专为运动新手家长准备的指导文章。',
+ cover_image: '/static/knowledge/recommend1.jpg',
+ read_count: 2580,
+ publish_time: '2024-01-10 16:00:00'
+ },
+ {
+ id: 102,
+ title: '冬季儿童运动注意事项',
+ summary: '冬季天气寒冷,儿童运动需要特别注意保暖和安全。',
+ cover_image: '/static/knowledge/recommend2.jpg',
+ read_count: 1890,
+ publish_time: '2024-01-09 10:30:00'
+ }
+ ]
+ },
+
+ // 数据验证方法
+ validateArticleData(article) {
+ if (!article || typeof article !== 'object') {
+ return false
+ }
+
+ const requiredFields = ['id', 'title', 'category']
+ return requiredFields.every(field => article.hasOwnProperty(field) && article[field])
+ },
+
+ validateResponseData(response) {
+ if (!response || response.code !== 1) {
+ return false
+ }
+
+ if (!response.data || !Array.isArray(response.data.list)) {
+ return false
+ }
+
+ return response.data.list.every(item => this.validateArticleData(item))
+ },
+
async initPage() {
await this.loadStudentInfo()
await this.loadArticles()
@@ -395,28 +511,10 @@
async loadRecommendArticles() {
try {
- // 模拟推荐文章数据
- const mockRecommend = [
- {
- id: 101,
- title: '新手家长必看:如何陪伴孩子开始运动',
- summary: '专为运动新手家长准备的指导文章,教你如何正确引导孩子爱上运动。',
- cover_image: '/static/knowledge/recommend1.jpg',
- read_count: 2580,
- publish_time: '2024-01-10 16:00:00'
- },
- {
- id: 102,
- title: '冬季儿童运动注意事项',
- summary: '冬季天气寒冷,儿童运动需要特别注意保暖和安全问题。',
- cover_image: '/static/knowledge/recommend2.jpg',
- read_count: 1890,
- publish_time: '2024-01-09 10:30:00'
- }
- ]
- this.recommendArticles = mockRecommend
+ this.recommendArticles = this.getMockRecommendData()
} catch (error) {
console.error('获取推荐文章失败:', error)
+ this.recommendArticles = []
}
},
@@ -458,14 +556,7 @@
},
getCategoryText(category) {
- const categoryMap = {
- 'training': '训练技巧',
- 'nutrition': '营养健康',
- 'recovery': '恢复康复',
- 'psychology': '运动心理',
- 'equipment': '装备指南'
- }
- return categoryMap[category] || category
+ return this.categoryMap[category] || category
},
formatDate(dateString) {
@@ -658,6 +749,40 @@