diff --git a/api/order/order.js b/api/order/order.js index e1d3cf3..325c661 100644 --- a/api/order/order.js +++ b/api/order/order.js @@ -202,4 +202,16 @@ export const getTecByUser = (params) => { method: 'get', params }) +} + +// 查询指定伴宠师近期评价 +export const getTeacherEvaluate = (params) => { + return request({ + headers: { + "isToken": true + }, + url: "/applet/mall/teacher/getTeacherEvaluate", + method: 'get', + params + }) } \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index c4ffb26..9024855 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -883,7 +883,7 @@ onLoad: function() { this.init() - this.getPeopleList() + // this.getPeopleList() this.getProductList() this.getBanner() const accountInfo = wx.getAccountInfoSync(); diff --git a/pages/personalCenter/index.vue b/pages/personalCenter/index.vue index 662ff94..ebbfa0b 100644 --- a/pages/personalCenter/index.vue +++ b/pages/personalCenter/index.vue @@ -341,30 +341,31 @@ // }else{ // this.active=1 // } - - const params = { - orderId: orderInfo.orderId, - pageNumber: this.page, - pageSize: 9999999, - status : 2 - }; + this.active=2 + this.orderDateFrequencyId = orderInfo.orderId + // const params = { + // orderId: orderInfo.orderId, + // pageNumber: this.page, + // pageSize: 9999999, + // status : 2 + // }; - appletOrderDateFrequencyList(params).then(res => { - if (res && res.data) { - this.active=2 - this.orderDateFrequencyList = res.data + // appletOrderDateFrequencyList(params).then(res => { + // if (res && res.data) { + // this.active=2 + // this.orderDateFrequencyList = res.data - for (let index = 0; index < res.data.length; index++) { - const element = res.data[index]; - element.list.forEach(n => { - if (n.status == 2) { - this.orderDateFrequencyId = n.id - } - }) - } - } - }).catch(err => { - }); + // for (let index = 0; index < res.data.length; index++) { + // const element = res.data[index]; + // element.list.forEach(n => { + // if (n.status == 2) { + // this.orderDateFrequencyId = n.id + // } + // }) + // } + // } + // }).catch(err => { + // }); }else if(orderInfo.status==3){ this.active = 3 } @@ -410,13 +411,17 @@ // this.$modal.showToast('暂未匹配到您的会员信息,请先注册成为会员!'); // return; // } + + uni.navigateTo({ + url: `/pages_order/order/serviceRecord?orderId=${this.orderDateFrequencyId}` + }); // 如果点击的是服务中状态(索引为2)且当前订单状态也是服务中 // if (e.index === 2 && this.active === 2) { // 跳转到订单详情页面 - uni.navigateTo({ - url: `/pages/personalCenter/orderDetailImage?id=${this.orderDateFrequencyId}` - }); + // uni.navigateTo({ + // url: `/pages/personalCenter/orderDetailImage?id=${this.orderDateFrequencyId}` + // }); // } }, openOtherPage(type){ diff --git a/pages/personalCenter/personalitySelect.vue b/pages/personalCenter/personalitySelect.vue index e9e4df4..01d0479 100644 --- a/pages/personalCenter/personalitySelect.vue +++ b/pages/personalCenter/personalitySelect.vue @@ -55,6 +55,22 @@ originalPersonality: '' } }, + watch: { + // 监听输入框内容变化,同步快捷选择状态 + personalityDescription: { + handler(newVal) { + this.syncSelectedPersonalities(); + }, + immediate: true + }, + // 监听快捷选择选项加载完成 + personalityOptions: { + handler() { + this.syncSelectedPersonalities(); + }, + immediate: true + } + }, onLoad(options) { // 接收传入的性格数据 if (options.personality) { @@ -66,6 +82,24 @@ this.getPersonalityDataList(); }, methods: { + // 同步快捷选择状态 + syncSelectedPersonalities() { + if (!this.personalityDescription || this.personalityOptions.length === 0) { + this.selectedPersonalities = []; + return; + } + + // 将输入框内容按逗号分割 + const descriptionItems = this.personalityDescription.split(',') + .map(item => item.trim()) + .filter(item => item.length > 0); + + // 找出哪些是快捷选择项 + this.selectedPersonalities = descriptionItems.filter(item => + this.personalityOptions.includes(item) + ); + }, + // 解析传入的性格数据 parsePersonality(personality) { if (!personality) return; @@ -85,42 +119,60 @@ this.personalityOptions.includes(item) ); - // 描述部分是数组中不在快捷选择里的项 - const descriptions = personality.filter(item => - !this.personalityOptions.includes(item) - ); - this.personalityDescription = descriptions.join(','); + // 将所有内容都显示在输入框中 + this.personalityDescription = personality.join(','); } else { // 兼容字符串形式的数据 - const parts = personality.split(','); - if (parts.length > 1) { - // 最后一部分是快捷选择 - const quickSelections = parts[parts.length - 1]; - this.selectedPersonalities = this.personalityOptions.filter(item => - quickSelections.includes(item) - ); - - // 前面的部分是描述 - this.personalityDescription = parts.slice(0, -1).join(','); - } else { - // 只有快捷选择 - this.selectedPersonalities = this.personalityOptions.filter(item => - personality.includes(item) - ); - } + const parts = personality.split(','); + + // 识别哪些是快捷选择项 + this.selectedPersonalities = parts.filter(item => + this.personalityOptions.includes(item.trim()) + ); + + // 将所有内容都显示在输入框中 + this.personalityDescription = personality; } }, // 切换性格选择 togglePersonality(personality) { - const index = this.selectedPersonalities.indexOf(personality); - if (index > -1) { - this.selectedPersonalities.splice(index, 1); + const isSelected = this.selectedPersonalities.includes(personality); + if (isSelected) { + // 取消选择:从输入框中移除对应文本 + this.removeFromDescription(personality); + } else { + // 选择:添加到输入框中 + this.addToDescription(personality); + } + // selectedPersonalities会通过watch自动更新 + }, + + // 添加性格到描述中 + addToDescription(personality) { + if (this.personalityDescription.trim()) { + // 如果输入框已有内容,用逗号分隔 + if (!this.personalityDescription.includes(personality)) { + this.personalityDescription += ',' + personality; + } } else { - this.selectedPersonalities.push(personality); + // 如果输入框为空,直接添加 + this.personalityDescription = personality; } }, + // 从描述中移除性格 + removeFromDescription(personality) { + if (!this.personalityDescription.includes(personality)) return; + + // 将描述按逗号分割 + let parts = this.personalityDescription.split(',').map(item => item.trim()); + // 移除指定的性格 + parts = parts.filter(item => item !== personality); + // 重新组合 + this.personalityDescription = parts.join(','); + }, + // 获取性格数据列表 getPersonalityDataList() { getDictList('pet_personality').then(res => { @@ -139,24 +191,21 @@ savePersonality() { this.loading = true; - // 组合性格描述和快捷选择,保持数组形式 - let finalPersonality = []; - - if (this.personalityDescription.trim()) { - finalPersonality.push(this.personalityDescription.trim()); - } - - if (this.selectedPersonalities.length > 0) { - finalPersonality = finalPersonality.concat(this.selectedPersonalities); - } - - // 验证是否至少选择了一项 - if (finalPersonality.length === 0) { + // 验证是否至少有内容 + if (!this.personalityDescription.trim()) { this.$modal.showToast('请至少选择一项性格特征'); this.loading = false; return; } + // 将输入框内容按逗号分割,去重并过滤空值 + const personalityItems = this.personalityDescription.split(',') + .map(item => item.trim()) + .filter(item => item.length > 0); + + // 去重处理 + const finalPersonality = Array.from(new Set(personalityItems)); + // 延迟一下模拟保存过程 setTimeout(() => { this.loading = false; @@ -166,7 +215,7 @@ // 安全检查:确保有足够的页面 if (!pages || pages.length < 2) { - console.warn('页面栈不足,无法获取上一页') + console.warn('页面栈不足,无法获取上一页') uni.navigateBack(); return; } @@ -301,4 +350,4 @@ border-radius: 8px; } } - \ No newline at end of file + \ No newline at end of file diff --git a/pages_order/companionPetList/companionPetInfo.vue b/pages_order/companionPetList/companionPetInfo.vue index ab5ace3..90fce96 100644 --- a/pages_order/companionPetList/companionPetInfo.vue +++ b/pages_order/companionPetList/companionPetInfo.vue @@ -141,47 +141,6 @@ --> - + @@ -359,15 +324,18 @@ getTeacherPetList, getTeacherAddressList, getTeacherServiceLogList, + getTeacherEvaluate, } from "@/api/order/order" import uniRate from '@/uni_modules/uni-rate/components/uni-rate/uni-rate.vue'; import positionMixin from '../../mixins/position'; import addressMap from '@/components/addressMap.vue' + import RecentReviews from '../components/RecentReviews/RecentReviews.vue' import { mapState } from 'vuex' export default { mixins: [positionMixin], components : { - addressMap + addressMap, + RecentReviews }, data() { return { @@ -394,22 +362,8 @@ // } ], addressList: [], - rewardList: [{ - name: '小咪', - star: 3, - time: '2025-1-1 18:00', - des: '服务贴心,态度热情,非常满意', - }, { - name: '中咪', - star: 4, - time: '2025-1-1 18:00', - des: '服务贴心,态度热情,非常满意', - }, { - name: '大咪', - star: 5, - time: '2025-1-1 18:00', - des: '服务贴心,态度热情,非常满意', - }], + // 近期评价数据 + recentReviews: [], serviceRecordList: [ // { // name: '修狗', @@ -488,8 +442,15 @@ }, mounted() { this.getCurrentCompanionPetInfo(this.currentCompanionPetId) + this.getTeacherEvaluate() }, methods: { + getTeacherEvaluate(){ + getTeacherEvaluate({id: this.currentCompanionPetId}) + .then(res => { + this.recentReviews = res.data.records + }) + }, clickAddress(address){ if(address.appletOutDate && address.appletOutDate.length > 0){ this.selectDate = address.appletOutDate.map(n => n.date); @@ -546,6 +507,15 @@ urls }) }, + // 近期评价组件事件处理 + onReviewClick(data) { + console.log('点击评价:', data); + // 可以在这里处理评价点击事件,比如跳转到详情页 + }, + onAvatarClick(data) { + console.log('点击用户头像:', data); + // 可以在这里处理头像点击事件,比如查看用户信息 + }, } } diff --git a/pages_order/components/RecentReviews/README.md b/pages_order/components/RecentReviews/README.md new file mode 100644 index 0000000..1430473 --- /dev/null +++ b/pages_order/components/RecentReviews/README.md @@ -0,0 +1,117 @@ +# RecentReviews 近期评价组件 + +## 组件说明 + +近期评价组件用于显示用户对服务的评价信息,包含用户头像、姓名、评价时间、星级评分和评价内容。 + +## 功能特性 + +- 📱 符合微信小程序开发规范 +- 🎨 与项目整体UI风格保持一致 +- 🔄 支持uniapp跨平台开发 +- 📊 支持星级评分显示 +- 🖼️ 支持用户头像展示 +- 📝 支持评价内容展示 +- 🎯 支持点击事件处理 +- 📱 响应式布局设计 + +## 使用方法 + +### 1. 引入组件 + +```javascript +import RecentReviews from '@/components/RecentReviews/RecentReviews.vue' + +export default { + components: { + RecentReviews + } +} +``` + +### 2. 在模板中使用 + +```vue + +``` + +### 3. 数据格式 + +```javascript +data() { + return { + reviewData: [ + { + userName: '用户名', + userImage: '用户头像URL', + rating: 5, // 评分 1-5 + reviewDate: '2024-11-01 18:09:32', + comment: '评价内容' + } + ], + defaultAvatar: 'https://example.com/default-avatar.png' + } +} +``` + +## Props 属性 + +| 属性名 | 类型 | 默认值 | 说明 | +|--------|------|--------|------| +| reviewList | Array | [] | 评价数据列表 | +| defaultAvatar | String | 默认头像URL | 默认用户头像 | +| showCount | Boolean | true | 是否显示评价数量 | + +## Events 事件 + +| 事件名 | 说明 | 回调参数 | +|--------|------|----------| +| reviewClick | 点击评价项时触发 | { review, index } | +| avatarClick | 点击用户头像时触发 | { review, index } | + +## 数据结构说明 + +### reviewList 数组项结构 + +```typescript +interface ReviewItem { + userName: string; // 用户名 + userImage?: string; // 用户头像URL(可选) + rating: number; // 评分(1-5) + reviewDate: string; // 评价时间 + comment: string; // 评价内容 +} +``` + +## 样式说明 + +组件使用了项目统一的设计规范: + +- 主色调:#FFB13F(橙色) +- 文字颜色:#333333(深灰)、#7D8196(浅灰) +- 分割线:#EFEFEF +- 圆角:使用rpx单位,适配不同屏幕 + +## 注意事项 + +1. 确保项目中已安装 `uni-rate` 和 `u-avatar` 组件 +2. 评分值应在 1-5 之间 +3. 头像URL建议使用HTTPS协议 +4. 组件内部已处理空状态显示 +5. 支持微信小程序、H5、APP等多端运行 + +## 更新日志 + +### v1.0.0 +- 初始版本发布 +- 支持基础评价展示功能 +- 支持点击事件处理 +- 支持空状态显示 \ No newline at end of file diff --git a/pages_order/components/RecentReviews/RecentReviews.vue b/pages_order/components/RecentReviews/RecentReviews.vue new file mode 100644 index 0000000..2f215ef --- /dev/null +++ b/pages_order/components/RecentReviews/RecentReviews.vue @@ -0,0 +1,176 @@ + + + + + \ No newline at end of file