From 7a8bc3d03c06bff52716548e610ec8c868f0f7b5 Mon Sep 17 00:00:00 2001
From: ZhaoYang <565837861@qq.com>
Date: Thu, 5 Mar 2026 18:39:34 +0800
Subject: [PATCH] =?UTF-8?q?WebSocket=E5=AE=9E=E6=97=B6=E8=81=8A=E5=A4=A9?=
=?UTF-8?q?=EF=BC=8C=E4=B8=80=E5=AF=B9=E4=B8=80=E8=81=8A=E5=A4=A9=EF=BC=8C?=
=?UTF-8?q?=E5=8F=8D=E9=A6=88=E5=BB=BA=E8=AE=AE=EF=BC=8C=E6=9C=8D=E5=8A=A1?=
=?UTF-8?q?=E8=AF=84=E4=BB=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/personal/personal.js | 172 +++-
pages/personal/personal.wxml | 23 +-
pages/personal/personal.wxss | 42 +
pagesA/images/wj.png | Bin 2061 -> 0 bytes
pagesA/pages/expert/expert.js | 3 +-
pagesA/pages/expertChat/expertChat.js | 1212 +++++++++++++++++------
pagesA/pages/expertChat/expertChat.wxml | 23 +-
utils/api.js | 24 +-
utils/baseUrl.js | 4 +-
9 files changed, 1105 insertions(+), 398 deletions(-)
delete mode 100644 pagesA/images/wj.png
diff --git a/pages/personal/personal.js b/pages/personal/personal.js
index 2ccfd8c..e2c4256 100644
--- a/pages/personal/personal.js
+++ b/pages/personal/personal.js
@@ -22,6 +22,11 @@ Page({
feedbackContent: '',
canSubmit: false,
isSubmitting: false,
+
+ // 反馈类型相关
+ feedbackTypes: [], // 反馈类型列表
+ currentFeedbackType: '', // 当前选中的反馈类型
+ selectedFeedbackTypeLabel: '', // 当前选中的反馈类型名称
// 编辑相关
newNickname: '',
@@ -40,12 +45,68 @@ Page({
isUpdatingNickname: false,
// 消息数字
- totalToday: 0
+ totalToday: 0,
+
+ // 文本域焦点
+ textareaFocus: false
},
onLoad() {
this.gettoday()
+ this.getfwpj()
+ },
+
+ // 反馈建议和服务评价
+ getfwpj() {
+ http.fkfw({
+ data: {
+ dictType: 'feedback_type'
+ },
+ success: res => {
+ console.log('获取反馈类型成功', res)
+ if (res.code === 200 && res.rows && res.rows.length > 0) {
+ this.setData({
+ feedbackTypes: res.rows,
+ // 默认选中第一个
+ currentFeedbackType: res.rows[0].dictValue,
+ selectedFeedbackTypeLabel: res.rows[0].dictLabel
+ })
+ } else {
+ // 如果没有获取到数据,设置默认值
+ this.setDefaultFeedbackTypes()
+ }
+ },
+ fail: err => {
+ console.error('获取反馈类型失败', err)
+ // 失败时设置默认值
+ this.setDefaultFeedbackTypes()
+ }
+ })
+ },
+
+ // 设置默认反馈类型
+ setDefaultFeedbackTypes() {
+ const defaultTypes = [
+ { dictValue: '1', dictLabel: '功能建议' },
+ { dictValue: '2', dictLabel: '体验反馈' },
+ { dictValue: '3', dictLabel: '问题反馈' },
+ { dictValue: '4', dictLabel: '其他' }
+ ]
+ this.setData({
+ feedbackTypes: defaultTypes,
+ currentFeedbackType: '1',
+ selectedFeedbackTypeLabel: '功能建议'
+ })
+ },
+ // 选择反馈类型
+ selectFeedbackType(e) {
+ const type = e.currentTarget.dataset.type
+ const label = e.currentTarget.dataset.label
+ this.setData({
+ currentFeedbackType: type,
+ selectedFeedbackTypeLabel: label
+ })
},
onShow() {
@@ -56,7 +117,6 @@ Page({
this.gettoday()
},
-
// 获取用户信息
getUserInfo() {
http.UserInfo({
@@ -71,11 +131,9 @@ Page({
})
// 更新缓存
wx.setStorageSync('userInfo', res.data)
-
},
fail: (err) => {
console.error('获取用户信息失败:', err)
-
}
})
},
@@ -107,9 +165,7 @@ Page({
return
}
- const {
- avatarUrl
- } = e.detail
+ const { avatarUrl } = e.detail
if (!avatarUrl) {
this.showToast('选择头像失败')
return
@@ -133,47 +189,47 @@ Page({
filePath: avatarUrl,
name: 'file',
success: (uploadRes) => {
-
- const result = JSON.parse(uploadRes.data)
- console.log('上传结果', result)
-
- if (result && result.fileName) {
- // 获取上传后的文件路径
- const uploadedFilePath = result.fileName
- this.setData({
- avatarUrl: uploadedFilePath,
- })
-
- // 更新缓存中的用户信息
- const cachedUserInfo = wx.getStorageSync('userInfo') || {}
- if (!cachedUserInfo.user) {
- cachedUserInfo.user = {}
- }
- cachedUserInfo.user.avatar = uploadedFilePath
- wx.setStorageSync('userInfo', cachedUserInfo)
- // 更新头像的API
- http.revise({
- data: {
- avatar: uploadedFilePath
- },
- success: (res) => {
- console.log('头像更新成功')
- wx.hideLoading()
- this.showToast('头像更新成功')
- // 4. 重新获取用户信息以确保数据同步
- setTimeout(() => {
- this.getUserInfo()
- }, 500)
- },
- fail: (err) => {
- console.error('头像更新失败:', err)
- wx.hideLoading()
- this.showToast('头像保存失败,请重试')
- }
- })
- } else {
- throw new Error('上传失败:返回数据格式错误')
+ const result = JSON.parse(uploadRes.data)
+ console.log('上传结果', result)
+
+ if (result && result.fileName) {
+ // 获取上传后的文件路径
+ const uploadedFilePath = result.fileName
+ this.setData({
+ avatarUrl: uploadedFilePath,
+ })
+
+ // 更新缓存中的用户信息
+ const cachedUserInfo = wx.getStorageSync('userInfo') || {}
+ if (!cachedUserInfo.user) {
+ cachedUserInfo.user = {}
}
+ cachedUserInfo.user.avatar = uploadedFilePath
+ wx.setStorageSync('userInfo', cachedUserInfo)
+
+ // 更新头像的API
+ http.revise({
+ data: {
+ avatar: uploadedFilePath
+ },
+ success: (res) => {
+ console.log('头像更新成功')
+ wx.hideLoading()
+ this.showToast('头像更新成功')
+ // 4. 重新获取用户信息以确保数据同步
+ setTimeout(() => {
+ this.getUserInfo()
+ }, 500)
+ },
+ fail: (err) => {
+ console.error('头像更新失败:', err)
+ wx.hideLoading()
+ this.showToast('头像保存失败,请重试')
+ }
+ })
+ } else {
+ throw new Error('上传失败:返回数据格式错误')
+ }
},
fail: (err) => {
wx.hideLoading()
@@ -303,6 +359,8 @@ Page({
// 显示反馈弹窗
showFeedback() {
+ // 刷新反馈类型数据
+ this.getfwpj()
this.setData({
showFeedbackModal: true,
feedbackContent: '',
@@ -322,7 +380,7 @@ Page({
// 反馈内容输入
onFeedbackInput(e) {
const content = e.detail.value
- const canSubmit = content.trim().length > 0
+ const canSubmit = content.trim().length > 0 && this.data.currentFeedbackType
this.setData({
feedbackContent: content,
@@ -333,19 +391,26 @@ Page({
// 提交反馈
submitFeedback() {
if (!this.data.canSubmit || this.data.isSubmitting) return
+
const content = this.data.feedbackContent.trim()
if (content.length < 5) {
this.showToast('请填写详细的反馈内容')
return
}
+ if (!this.data.currentFeedbackType) {
+ this.showToast('请选择反馈类型')
+ return
+ }
+
this.setData({
isSubmitting: true
})
http.feedback({
data: {
- content: content
+ content: content,
+ feedbackType: this.data.currentFeedbackType // 添加反馈类型字段
},
success: res => {
if (res.code == 200) {
@@ -356,7 +421,10 @@ Page({
this.setData({
isSubmitting: false,
showFeedbackModal: false,
- textareaFocus: false
+ textareaFocus: false,
+ feedbackContent: '',
+ currentFeedbackType: this.data.feedbackTypes.length > 0 ? this.data.feedbackTypes[0].dictValue : '',
+ selectedFeedbackTypeLabel: this.data.feedbackTypes.length > 0 ? this.data.feedbackTypes[0].dictLabel : ''
})
},
fail: (err) => {
@@ -411,11 +479,11 @@ Page({
onPullDownRefresh() {
this.getUserInfo()
this.gettoday() // 刷新消息数
+ this.getfwpj() // 刷新反馈类型
setTimeout(() => {
wx.stopPullDownRefresh()
this.showToast('刷新成功')
}, 1000)
- },
-
+ }
})
\ No newline at end of file
diff --git a/pages/personal/personal.wxml b/pages/personal/personal.wxml
index eaa4275..e505a0a 100644
--- a/pages/personal/personal.wxml
+++ b/pages/personal/personal.wxml
@@ -1,6 +1,6 @@
-
-
+
+
-
@@ -96,6 +95,24 @@
+
+
+
+
+
+ {{item.dictLabel}}
+
+
+
+
+
-
-
-
-
-
- 文件
-
diff --git a/utils/api.js b/utils/api.js
index 85b609a..057a5b7 100644
--- a/utils/api.js
+++ b/utils/api.js
@@ -250,6 +250,28 @@ function today(params) {
http('/muhu/consultation/today', 'get', params)
}
+// 反馈意见和服务评价字典
+function fkfw(params) {
+ http('/system/dict/data/list', 'get', params)
+}
+
+
+// 获取聊天记录列表
+function sessions(params) {
+ http('/system/chat/sessions', 'get', params)
+}
+
+// 建立兽医一对一聊天
+function create(params) {
+ http('/system/chat/session/create', 'post', params)
+}
+
+// 查找一对一聊天的记录
+function direct(params) {
+ http('/system/chat/messages/direct', 'get', params)
+}
+
+
export default { // 暴露接口
login,carousel,disaster,pharmacy,guidance,getPhoneNumber,inquiry,policyeDetails,shareAdd,
@@ -257,5 +279,5 @@ export default { // 暴露接口
recommendationXq,queryList,tipList,article,articleDetails,articleZd,policyelucidation,
areaChildren,userCode,UserInfo,videoList,videoZd,videoDetails,forumList,forumAdd,forumDetails,
forumReply,commentReply,experience,experiencezd,experienceDetails,realName,revise,feedback,
- warningType,disasterDetail,today,carouselDetail,planDetails,wzdDetails
+ warningType,disasterDetail,today,carouselDetail,planDetails,wzdDetails,create,direct,fkfw,
}
diff --git a/utils/baseUrl.js b/utils/baseUrl.js
index 3de0bb9..a56677d 100644
--- a/utils/baseUrl.js
+++ b/utils/baseUrl.js
@@ -1,5 +1,5 @@
// var baseUrl = 'https://wx.chenhaitech.com/ymtx-prod-api'
-var baseUrl = 'http://192.168.101.109:8080'
+// var baseUrl = 'http://192.168.101.109:8080'
// var baseUrl = 'http://192.168.101.105:8082'
-// var baseUrl = 'http://192.168.101.111:8081'
+var baseUrl = 'http://192.168.101.111:8081'
module.exports = baseUrl