diff --git a/app.json b/app.json index dedf6ec..af1578b 100644 --- a/app.json +++ b/app.json @@ -11,7 +11,10 @@ "pages": [ "pages/carouselDetail/carouselDetail", "pages/askingSy/askingSy", - "pages/askingSyDetails/askingSyDetails" + "pages/askingSyDetails/askingSyDetails", + "pages/advisory/advisory", + "pages/releaseSuffer/releaseSuffer", + "pages/precept/precept" ] }, { @@ -21,7 +24,11 @@ "pages/training/training", "pages/wzDetails/wzDetails", "pages/spDetails/spDetails", - "pages/publishAdd/publishAdd" + "pages/publishAdd/publishAdd", + "pages/forumlist/forumlist", + "pages/onlineAsk/onlineAsk", + "pages/experienceList/experienceList", + "pages/experienceDetails/experienceDetails" ], "independent": true } diff --git a/pages/home/home.js b/pages/home/home.js index 50c0168..9fbf1d3 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -6,9 +6,11 @@ Page({ currentSwiper: 0, baseUrl: baseUrl, swiperList: [], - articleList:[ - {title:'发布信息',describe:'快速发布养殖知识|视频培训发布',icon:'/pages/images/fkjy.png'}, - ], + articleList: [{ + title: '发布信息', + describe: '快速发布养殖知识|视频培训发布', + icon: '/pages/images/fkjy.png' + }, ], // 通知公告数据 currentNotice: 0, noticeList: [], @@ -24,7 +26,7 @@ Page({ http.UserInfo({ data: {}, success: res => { - console.log(111,res); + console.log(111, res); this.setData({ user: res.data.user.area }) @@ -40,15 +42,31 @@ Page({ }) }, - // 远程诊疗 - bindYczl() { - wx.navigateTo({ - url: '/pagesA/pages/askingSy/askingSy', - }) - }, + // 远程诊疗 + bindYczl() { + wx.navigateTo({ + url: '/pagesA/pages/askingSy/askingSy', + }) + }, - // 在线问答列表 + // 在线问答列表页 + bindwdlist() { + wx.navigateTo({ + url: '/pagesB/pages/forumlist/forumlist', + }) + }, + + // 问答详情 + bindTw(e) { + console.log(e); + const id = e.currentTarget.dataset.id + wx.navigateTo({ + url: `/pagesB/pages/onlineAsk/onlineAsk?id=${id}`, + }) + }, + + // 在线问答 getforumList() { http.forumList({ data: {}, @@ -104,10 +122,10 @@ Page({ }) }, - // 问兽医 + // 接收咨询 bindWsy() { wx.navigateTo({ - url: '/pagesA/pages/askingSy/askingSy', + url: '/pagesA/pages/advisory/advisory', }) }, @@ -118,10 +136,10 @@ Page({ }) }, - // 去买药 + // 方案制定 bindYao() { wx.navigateTo({ - url: '/pagesA/pages/medicine/medicine', + url: '/pagesA/pages/precept/precept', }) }, @@ -130,18 +148,10 @@ Page({ bindwdlist() { wx.navigateTo({ url: '/pagesB/pages/forumlist/forumlist', - }) - }, - - // 问答详情 - bindTw(e) { - console.log(e); - const id = e.currentTarget.dataset.id - wx.navigateTo({ - url: `/pagesB/pages/onlineAsk/onlineAsk?id=${id}`, }) }, + // 经验分享列表 viewexperience() { wx.navigateTo({ @@ -231,16 +241,16 @@ Page({ onSwiperTap(e) { console.log(1111, e); var id = e.currentTarget.dataset.value.carouselId - wx.navigateTo({ - url: `/pagesA/pages/carouselDetail/carouselDetail?id=${id}`, - }) + wx.navigateTo({ + url: `/pagesA/pages/carouselDetail/carouselDetail?id=${id}`, + }) }, onReady() { // 当前网络状态 wx.getNetworkType({ - success: function (res) { + success: function (res) { // 返回网络类型, 有效值: // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) console.log(res); @@ -259,7 +269,7 @@ Page({ // 下拉刷新 onPullDownRefresh() { wx.showNavigationBarLoading() - + // 重新加载所有数据 Promise.all([ new Promise(resolve => this.getUserInfo(resolve)), diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 3e1b99e..c4cfc69 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -49,7 +49,7 @@ 接受咨询 - 回复问诊单信息 + 一对一在线咨询 快捷回复 diff --git a/pages/images/bj.png b/pages/images/bj.png new file mode 100644 index 0000000..1dfe6dd Binary files /dev/null and b/pages/images/bj.png differ diff --git a/pages/personal/personal.js b/pages/personal/personal.js index 74b5804..9ee7228 100644 --- a/pages/personal/personal.js +++ b/pages/personal/personal.js @@ -1,66 +1,356 @@ -// pages/personal/personal.js -Page({ +import http from '../../utils/api' +const baseUrl = require('../../utils/baseUrl') - /** - * 页面的初始数据 - */ +Page({ data: { + // 用户信息 + avatarUrl: '', // 原始头像路径(相对路径) + avatarFullUrl: '', // 完整的头像URL(用于显示) + userInfo: { + user: {} + }, + baseUrl: baseUrl, + displayNickName: '', // 显示用的昵称 - }, + // 弹窗状态 + showFeedbackModal: false, + showNicknameModal: false, + showLogoutModal: false, + showToast: false, + + // 反馈相关 + feedbackContent: '', + canSubmit: false, + isSubmitting: false, + + // 编辑相关 + newNickname: '', + + // 提示信息 + toastText: '', - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { + // 表单数据 + formData: { + avatar: null, + nickName: null + }, + // 上传状态 + isUploadingAvatar: false, + isUpdatingNickname: false, + + // 消息数字 + totalToday: 0 }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { + onLoad() { + this.gettoday() }, - /** - * 生命周期函数--监听页面显示 - */ onShow() { + console.log('个人中心页面显示,重新获取用户信息') + // 每次显示页面都从服务器获取最新数据 + this.getUserInfo() + // 刷新消息数 + this.gettoday() + }, + + + // 获取用户信息 + getUserInfo() { + http.UserInfo({ + data: {}, + success: (res) => { + console.log('获取用户信息成功', res) + // 更新数据 + this.setData({ + userInfo: res.data, + displayNickName: res.data.user.nickName, + avatarUrl: baseUrl + res.data.user.avatar + }) + // 更新缓存 + wx.setStorageSync('userInfo', res.data) + + }, + fail: (err) => { + console.error('获取用户信息失败:', err) + + } + }) + }, + // 问诊消息 - 获取今日消息数 + gettoday() { + http.today({ + data: {}, + success: res => { + if (res.rows && res.rows[0]) { + const num = res.rows[0].totalTodayReplyCount || 0 + this.setData({ + totalToday: num + }) + } + }, + fail: err => { + console.error('获取消息数失败', err) + } + }) }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { + // 选择头像 + onChooseAvatar(e) { + console.log(7788, e); + // 防止重复上传 + if (this.data.isUploadingAvatar) { + this.showToast('正在上传中...') + return + } + + const { + avatarUrl + } = e.detail + if (!avatarUrl) { + this.showToast('选择头像失败') + return + } + + this.setData({ + isUploadingAvatar: true + }) + + wx.showLoading({ + title: '上传中...', + mask: true + }) + + // 上传头像到服务器 + wx.uploadFile({ + url: baseUrl + '/common/upload', + header: { + 'Authorization': 'Bearer ' + wx.getStorageSync('token') + }, + 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('上传失败:返回数据格式错误') + } + }, + fail: (err) => { + wx.hideLoading() + console.error('上传失败:', err) + this.showToast('上传失败,请检查网络') + }, + complete: () => { + this.setData({ + isUploadingAvatar: false + }) + } + }) }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { + // 编辑昵称 + editNickname() { + this.setData({ + showNicknameModal: true, + newNickname: this.data.userInfo.user?.nickName || this.data.displayNickName || '' + }) + }, + hideNicknameModal() { + this.setData({ + showNicknameModal: false + }) }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { + onNicknameInput(e) { + this.setData({ + newNickname: e.detail.value + }) + }, + + saveNickname() { + const newNickname = this.data.newNickname.trim() + + if (!newNickname) { + this.showToast('昵称不能为空') + return + } + + if (newNickname.length > 10) { + this.showToast('昵称不能超过10个字符') + return + } + // 如果昵称没有变化,直接关闭弹窗 + const currentNickName = this.data.userInfo.user?.nickName || this.data.displayNickName + if (newNickname === currentNickName) { + this.hideNicknameModal() + return + } + + this.setData({ + isUpdatingNickname: true + }) + + // 立即更新本地显示 + this.setData({ + 'userInfo.user.nickName': newNickname, + displayNickName: newNickname, + 'formData.nickName': newNickname + }) + + // 更新缓存 + const cachedUserInfo = wx.getStorageSync('userInfo') || {} + if (!cachedUserInfo.user) { + cachedUserInfo.user = {} + } + cachedUserInfo.user.nickName = newNickname + wx.setStorageSync('userInfo', cachedUserInfo) + + // 更新到服务器 + http.revise({ + data: { + nickName: newNickname + }, + success: (res) => { + console.log('昵称更新成功') + this.setData({ + showNicknameModal: false, + isUpdatingNickname: false, + 'formData.nickName': null + }) + this.showToast('昵称修改成功') + + // 重新获取用户信息以确保数据同步 + setTimeout(() => { + this.getUserInfo() + }, 500) + }, + fail: (err) => { + console.error('昵称更新失败:', err) + this.setData({ + isUpdatingNickname: false + }) + this.showToast('修改失败,请重试') + } + }) + }, + + // 查看问诊消息 + goToConsultation() { + wx.navigateTo({ + url: '/pagesA/pages/todayInquiry/todayInquiry' + }) + }, + + // 查看问答消息 + goToQA() { + wx.navigateTo({ + url: '' // 请填写实际的问答消息页面路径 + }) + }, + + // 实名认证 + goToAuth() { + if (this.data.userInfo.authStatus == '已认证') { + this.showToast('您已完成实名认证') + } else { + wx.navigateTo({ + url: '/pagesA/pages/attestation/attestation' + }) + } + }, + + + + + // 退出登录相关 + showLogoutConfirm() { + this.setData({ + showLogoutModal: true + }) + }, + + hideLogoutModal() { + this.setData({ + showLogoutModal: false + }) }, - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { + doLogout() { + // 清除本地存储 + wx.clearStorageSync() + // 跳转到登录页 + wx.reLaunch({ + url: '/pages/login/login' + }) + this.showToast('已退出登录') }, - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { + // 显示提示 + showToast(text) { + this.setData({ + toastText: text, + showToast: true + }) + + setTimeout(() => { + this.setData({ + showToast: false + }) + }, 2000) + }, + + // 下拉刷新 + onPullDownRefresh() { + this.getUserInfo() + this.gettoday() // 刷新消息数 + + setTimeout(() => { + wx.stopPullDownRefresh() + this.showToast('刷新成功') + }, 1000) + }, - } }) \ No newline at end of file diff --git a/pages/personal/personal.json b/pages/personal/personal.json index 8835af0..e2ceaf6 100644 --- a/pages/personal/personal.json +++ b/pages/personal/personal.json @@ -1,3 +1,4 @@ { + "navigationBarTitleText":"个人中心", "usingComponents": {} } \ No newline at end of file diff --git a/pages/personal/personal.wxml b/pages/personal/personal.wxml index dfe0524..65f5e5f 100644 --- a/pages/personal/personal.wxml +++ b/pages/personal/personal.wxml @@ -1,2 +1,134 @@ - -pages/personal/personal.wxml \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + 实名认证 + + + {{userInfo.authStatus}} + + + + + + + + 服务评价 + + + + + + + + 退出登录 + + + + + + + + + + + + + 修改昵称 + + + + 最多10个字符 + + + + + + + + + + + + + + 确认退出登录? + 退出后需要重新登录才能使用完整功能 + + + + + + + + + + + {{toastText}} + + \ No newline at end of file diff --git a/pages/personal/personal.wxss b/pages/personal/personal.wxss index 565c5ad..d803b86 100644 --- a/pages/personal/personal.wxss +++ b/pages/personal/personal.wxss @@ -1 +1,611 @@ -/* pages/personal/personal.wxss */ \ No newline at end of file +.personal-center { + min-height: 100vh; + background: linear-gradient(180deg, #86D8D0 0%, #a9dfda 30%, #cfe9e7 60%, #ECF8F7 90%); + padding-bottom: 40rpx; +} + +/* 淡入动画 */ +.fade-in { + animation: fadeIn 0.6s ease forwards; + opacity: 0; + transform: translateY(20rpx); +} + +.fade-in-delay-1 { + animation: fadeIn 0.6s 0.2s ease forwards; + opacity: 0; + transform: translateY(20rpx); +} + +.fade-in-delay-2 { + animation: fadeIn 0.6s 0.4s ease forwards; + opacity: 0; + transform: translateY(20rpx); +} + +@keyframes fadeIn { + to { + opacity: 1; + transform: translateY(0); + } +} + +/* 用户信息区域 */ +.user-section { + padding: 40rpx 30rpx 30rpx; +} + +.user-card { + background: white; + border-radius: 24rpx; + padding: 40rpx 30rpx; + box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.08); + display: flex; + align-items: center; + transition: all 0.3s ease; +} + +.user-card:active { + transform: scale(0.99); + box-shadow: 0 5rpx 20rpx rgba(0, 0, 0, 0.05); +} + +.avatar-btn { + position: relative; + width: 140rpx; + height: 140rpx; + margin-right: 30rpx; + flex-shrink: 0; + padding: 0; + background: transparent; + border: none; + border-radius: 50%; + overflow: visible; +} + +.avatar-btn::after { + border: none; +} + +.avatar { + width: 100%; + height: 100%; + border-radius: 50%; + border: 4rpx solid white; + box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.1); + transition: all 0.3s ease; +} + +.avatar-btn:active .avatar { + transform: scale(0.95); +} + +.avatar-edit-tip { + position: absolute; + bottom: -10rpx; + left: 50%; + transform: translateX(-50%); + background: rgba(0, 0, 0, 0.7); + color: white; + font-size: 20rpx; + padding: 4rpx 12rpx; + border-radius: 20rpx; + white-space: nowrap; + opacity: 0; + transition: all 0.3s ease; +} + +.avatar-btn:hover .avatar-edit-tip { + opacity: 1; + bottom: -20rpx; +} + +.user-info { + flex: 1; +} + +.nickname-section { + display: flex; + align-items: center; + margin-bottom: 16rpx; + padding: 8rpx 0; + border-radius: 8rpx; + transition: all 0.3s ease; +} + +.nickname-section:active { + background: rgba(0, 0, 0, 0.05); +} + +.nickname { + font-size: 36rpx; + font-weight: 700; + color: #1e293b; + margin-right: 20rpx; + max-width: 300rpx; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.nickname-section image { + width: 26rpx; + height: 26rpx; + opacity: 0.6; + transition: all 0.3s ease; +} + +.nickname-section:active image { + opacity: 0.8; + transform: scale(1.1); +} + +.user-meta { + display: flex; + align-items: center; + flex-wrap: wrap; + gap: 16rpx; +} + +.auth-tag { + display: flex; + align-items: center; + padding: 6rpx 16rpx; + background: #fef3c7; + border-radius: 20rpx; + transition: all 0.3s ease; +} + +.auth-tag.verified { + background: #d1fae5; +} + +.auth-tag:active { + transform: scale(0.95); + opacity: 0.8; +} + +.auth-tag text { + font-size: 24rpx; + color: #92400e; + font-weight: 500; +} + +.auth-tag.verified text { + color: #065f46; +} + +/* 卡片样式 */ +.section-card { + background: white; + margin: 0 30rpx 30rpx; + border-radius: 20rpx; + overflow: hidden; + box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.05); +} + +.section-header { + padding: 30rpx 30rpx 20rpx; + border-bottom: 1rpx solid #f1f5f9; + display: flex; + align-items: center; + justify-content: space-between; +} + +.section-title { + font-size: 32rpx; + font-weight: 600; + color: #1e293b; + position: relative; + padding-left: 20rpx; +} + +.section-title::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + width: 6rpx; + height: 24rpx; + background: linear-gradient(135deg, #667eea, #764ba2); + border-radius: 3rpx; +} + +/* 消息行 */ +.message-row { + display: flex; + align-items: center; + padding: 30rpx; +} + +.message-item { + flex: 1; + display: flex; + flex-direction: column; + align-items: center; + transition: all 0.3s ease; +} + +.message-item:active { + transform: scale(0.95); + opacity: 0.8; +} + +.message-icon-wrapper { + position: relative; + width: 80rpx; + height: 80rpx; + margin-bottom: 16rpx; + display: flex; + align-items: center; + justify-content: center; + background: #f8fafc; + border-radius: 50%; + border: 1rpx solid #e2e8f0; + transition: all 0.3s ease; +} + +.message-item:active .message-icon-wrapper { + background: #e2e8f0; +} + +.message-icon { + width: 60rpx; + height: 60rpx; +} + +/* 数字气泡 - 定位在顶部 */ +.badge { + position: absolute; + top: -10rpx; + right: -10rpx; + display: flex; + align-items: center; + justify-content: center; + z-index: 2; +} + +.badge-num { + background: linear-gradient(135deg, #ff6b6b, #ee5253); + border-radius: 36rpx; + color: white; + font-size: 22rpx; + font-weight: 600; + display: flex; + align-items: center; + justify-content: center; + padding: 0 10rpx; + box-shadow: 0 4rpx 8rpx rgba(238, 82, 83, 0.3); +} + +/* 动画效果:跳动+呼吸 */ +.animation-badge { + animation: badgeBounce 2.5s ease-in-out infinite; +} + +@keyframes badgeBounce { + 0%, 100% { + transform: scale(1); + } + 30% { + transform: scale(1.2); + } + 50% { + transform: scale(1.1); + } + 70% { + transform: scale(1.15); + } +} + +/* 可选的小红点效果(如果有需要可以保留,当前用的是数字) */ +.badge-dot { + display: none; /* 隐藏,用数字替代 */ +} + +.message-label { + font-size: 26rpx; + color: #475569; + font-weight: 500; +} + +.divider { + width: 1rpx; + height: 60rpx; + background: #e2e8f0; + margin: 0 40rpx; +} + +/* 功能列表 */ +.function-list { + padding: 0 30rpx 20rpx; +} + +.function-item { + display: flex; + align-items: center; + justify-content: space-between; + padding: 30rpx 0; + border-bottom: 1rpx solid #f1f5f9; + transition: all 0.3s ease; +} + +.function-item:last-child { + border-bottom: none; +} + +.function-item:active { + background: #f8fafc; + border-radius: 12rpx; +} + +.item-left { + display: flex; + align-items: center; +} + +.item-icon { + width: 40rpx; + height: 40rpx; + margin-right: 20rpx; +} + +.item-title { + font-size: 30rpx; + color: #1e293b; + font-weight: 500; +} + +.logout-title { + color: #ef4444; +} + +.item-status { + font-size: 26rpx; + color: #f59e0b; + font-weight: 500; +} + +.item-status.verified { + color: #10b981; +} + + + +/* 昵称修改弹窗 */ +.nickname-modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1000; + display: flex; + align-items: center; + justify-content: center; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; + pointer-events: none; +} + +.nickname-modal.show { + opacity: 1; + visibility: visible; + pointer-events: auto; +} + +.nickname-modal .modal-content { + width: 600rpx; + background: white; + border-radius: 20rpx; + overflow: hidden; + box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.2); + transform: scale(0.8); + transition: all 0.3s ease; +} + +.nickname-modal.show .modal-content { + transform: scale(1); +} + +.nickname-modal .modal-header { + padding: 40rpx 40rpx 20rpx; + border-bottom: 1rpx solid #f1f5f9; +} + +.nickname-modal .modal-body { + padding: 40rpx; +} + +.nickname-input { + width: 100%; + height: 80rpx; + background: #f8fafc; + border: 2rpx solid #e2e8f0; + border-radius: 12rpx; + font-size: 28rpx; + color: #1e293b; + text-align: center; + transition: all 0.3s ease; +} + +.nickname-input:focus { + border-color: #667eea; + background: white; + box-shadow: 0 0 0 4rpx rgba(102, 126, 234, 0.1); +} + +.input-tip { + display: block; + font-size: 24rpx; + color: #94a3b8; + text-align: center; + margin-top: 16rpx; +} + +.nickname-modal .modal-footer { + padding: 0 40rpx 40rpx; + display: flex; + gap: 20rpx; +} + +.cancel-btn, +.confirm-btn { + flex: 1; + padding: 5rpx 0; + border-radius: 40rpx; + font-size: 28rpx; + font-weight: 500; + transition: all 0.3s ease; + border: none; +} + +.cancel-btn { + background: #f1f5f9; + color: #64748b; +} + +.cancel-btn::after{ + border: none; +} + +.cancel-btn:active { + background: #e2e8f0; +} + +.confirm-btn { + background: linear-gradient(135deg, #667eea, #764ba2); + color: white; + box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.3); +} + +.confirm-btn:active { + transform: scale(0.98); + opacity: 0.9; +} + +/* 退出登录确认弹窗 */ +.logout-modal { + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + z-index: 1000; + display: flex; + align-items: center; + justify-content: center; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; + pointer-events: none; +} + +.logout-modal.show { + opacity: 1; + visibility: visible; + pointer-events: auto; +} + +.logout-modal .modal-content { + width: 600rpx; + background: white; + border-radius: 24rpx; + overflow: hidden; + box-shadow: 0 20rpx 60rpx rgba(0, 0, 0, 0.2); + transform: scale(0.8); + transition: all 0.3s ease; +} + +.logout-modal.show .modal-content { + transform: scale(1); +} + +.logout-modal-body { + padding: 60rpx 40rpx 40rpx; + text-align: center; +} + +.logout-title { + font-weight: 700; + color: #1e293b; + display: block; +} + +.logout-desc { + font-size: 28rpx; + color: #64748b; + line-height: 1.5; +} + +.logout-modal-footer { + padding: 0 40rpx 40rpx; + display: flex; + gap: 20rpx; +} + +.logout-cancel-btn, +.logout-confirm-btn { + flex: 1; + border-radius: 44rpx; + font-size: 30rpx; + font-weight: 600; + transition: all 0.3s ease; + border: none; +} + +.logout-cancel-btn::after{ + border: none; +} + +.logout-cancel-btn { + background: #f1f5f9; + color: #64748b; +} + +.logout-cancel-btn:active { + background: #e2e8f0; + transform: scale(0.98); +} + +.logout-confirm-btn { + background: linear-gradient(135deg, #ef4444, #dc2626); + color: white; + box-shadow: 0 8rpx 24rpx rgba(239, 68, 68, 0.3); +} + +.logout-confirm-btn:active { + transform: scale(0.98); + opacity: 0.9; +} + +/* 提示信息 */ +.toast { + position: fixed; + top: 150rpx; + left: 50%; + transform: translateX(-50%) translateY(-100rpx); + background: rgba(30, 41, 59, 0.95); + backdrop-filter: blur(20rpx); + color: white; + padding: 24rpx 48rpx; + border-radius: 16rpx; + font-size: 28rpx; + font-weight: 500; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; + z-index: 1001; + box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.2); + max-width: 80%; + text-align: center; + white-space: nowrap; +} + +.toast.show { + opacity: 1; + visibility: visible; + transform: translateX(-50%) translateY(0); +} \ No newline at end of file diff --git a/pagesA/images/ch.png b/pagesA/images/ch.png new file mode 100644 index 0000000..a1b862e Binary files /dev/null and b/pagesA/images/ch.png differ diff --git a/pagesA/pages/advisory/advisory.js b/pagesA/pages/advisory/advisory.js new file mode 100644 index 0000000..2858aba --- /dev/null +++ b/pagesA/pages/advisory/advisory.js @@ -0,0 +1,159 @@ +Page({ + data: { + // 专家信息(新增在线状态) + expertInfo: { + avatar: 'https://api.dicebear.com/7.x/avataaars/png?seed=expert_pro&size=140', + name: '张振农', + specialty: '作物栽培 · 土壤改良', + experience: 15, + online: true // 在线状态 + }, + // 聊天申请列表数据 + applyList: [], + // 分页相关 + page: 1, + pageSize: 10, + hasMore: true, + total: 0, + }, + + onLoad() { + this.loadApplyList(1); + }, + + // 加载申请列表(增强模拟数据) + loadApplyList(page) { + const { pageSize } = this.data; + wx.showLoading({ title: '加载中...', mask: true }); + + setTimeout(() => { + const mockData = this.generateMockData(page, pageSize); + + if (page === 1) { + this.setData({ + applyList: mockData.list, + total: mockData.total, + hasMore: mockData.hasMore, + page: page + }); + } else { + this.setData({ + applyList: this.data.applyList.concat(mockData.list), + total: mockData.total, + hasMore: mockData.hasMore, + page: page + }); + } + wx.hideLoading(); + }, 600); + }, + + // 生成更丰富的模拟数据(含标签) + generateMockData(page, pageSize) { + const total = 23; + const start = (page - 1) * pageSize; + const end = start + pageSize; + const hasMore = end < total; + const list = []; + + const seeds = ['farmer1', 'sheep', 'cattle', 'wheat', 'tractor', 'green', 'sun', 'rain', 'soil', 'seed']; + const firstNames = ['李', '王', '张', '刘', '赵', '陈', '杨', '周', '吴', '黄']; + const farmTypes = ['水稻种植', '牛羊养殖', '果树栽培', '蔬菜大棚', '有机农场', '蜂蜜养殖', '食用菌', '药材种植']; + const tagPool = [ + ['玉米', '虫害'], + ['羊羔', '腹泻'], + ['施肥', '建议'], + ['土壤', '检测'], + ['大棚', '温度'], + ['猪病', '防治'], + ['果树', '修剪'], + ['蜂蜜', '取蜜'] + ]; + + for (let i = start; i < Math.min(end, total); i++) { + const id = `apply_${i + 1}`; + const userId = `user_${(i % 10) + 1}`; + const seedIndex = i % seeds.length; + const nameIndex = i % firstNames.length; + const typeIndex = (i * 3) % farmTypes.length; + const unread = i % 4 === 0 ? 2 : (i % 7 === 0 ? 1 : 0); + const statuses = ['pending', 'accepted', 'completed']; + const status = statuses[i % 3]; + + // 随机标签 + const tags = tagPool[(i * 2) % tagPool.length]; + + const time = new Date(Date.now() - (i * 7200000) - Math.floor(Math.random() * 5000000)); + const timeStr = `${time.getMonth()+1}.${time.getDate()} ${time.getHours()}:${time.getMinutes().toString().padStart(2,'0')}`; + + // 更真实的预览消息 + let lastMessage = ''; + if (i % 5 === 0) lastMessage = '专家您好,我家玉米出现黄叶,能帮看看吗?'; + else if (i % 3 === 0) lastMessage = '咨询一下羊羔腹泻的问题,急!'; + else if (i % 4 === 0) lastMessage = '请问什么时候方便通话?'; + else lastMessage = '请求添加您为咨询顾问'; + + list.push({ + id: id, + user: { + id: userId, + name: firstNames[nameIndex] + (i % 2 === 0 ? '建国' : '秀英') + (i + 1), + avatar: `https://api.dicebear.com/7.x/avataaars/png?seed=${seeds[seedIndex]}_${i}&size=96`, + farmType: farmTypes[typeIndex], + }, + applyTime: timeStr, + lastMessage: lastMessage, + unreadCount: unread, + status: status, + tags: tags, + }); + } + + return { + list, + total, + hasMore, + }; + }, + + // 处理点击申请项 + handleApply(e) { + const { id, user } = e.currentTarget.dataset; + wx.showActionSheet({ + itemList: ['接受并回复', '标记为已读', '稍后处理'], + success: (res) => { + if (res.tapIndex === 0) { + wx.showToast({ title: '已接受申请', icon: 'success' }); + // 模拟更新状态 + const newList = this.data.applyList.map(item => + item.id === id ? {...item, status: 'accepted'} : item + ); + this.setData({ applyList: newList }); + } else if (res.tapIndex === 1) { + const newList = this.data.applyList.map(item => + item.id === id ? {...item, unreadCount: 0} : item + ); + this.setData({ applyList: newList }); + wx.showToast({ title: '已标记已读', icon: 'none' }); + } else { + wx.showToast({ title: '已稍后处理', icon: 'none' }); + } + } + }); + }, + + + + loadMore() { + const { hasMore, page } = this.data; + if (hasMore) { + this.loadApplyList(page + 1); + } + }, + + onPullDownRefresh() { + this.setData({ page: 1, hasMore: true }); + this.loadApplyList(1); + wx.stopPullDownRefresh(); + } +}); \ No newline at end of file diff --git a/pagesA/pages/advisory/advisory.json b/pagesA/pages/advisory/advisory.json new file mode 100644 index 0000000..1461427 --- /dev/null +++ b/pagesA/pages/advisory/advisory.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText":"咨询列表", + "usingComponents": {} +} \ No newline at end of file diff --git a/pagesA/pages/advisory/advisory.wxml b/pagesA/pages/advisory/advisory.wxml new file mode 100644 index 0000000..2674ac4 --- /dev/null +++ b/pagesA/pages/advisory/advisory.wxml @@ -0,0 +1,62 @@ + + + + + + + + + + {{expertInfo.name}} + {{expertInfo.online ? '在线' : '离线'}} + + {{expertInfo.specialty}} + + 从业 {{expertInfo.experience}} 年 + + + + + + + + 咨询申请 + {{applyList.length}} + + + + + + + + + + + + {{item.applyTime}} + + + {{item.lastMessage || '请求咨询...'}} + {{item.unreadCount > 99 ? '99+' : item.unreadCount}} + + + + + + + + 暂无新的咨询申请 + 稍后刷新试试 + + + + + + 正在加载更多... + + 没有更多了 + + + \ No newline at end of file diff --git a/pagesA/pages/advisory/advisory.wxss b/pagesA/pages/advisory/advisory.wxss new file mode 100644 index 0000000..982b2dd --- /dev/null +++ b/pagesA/pages/advisory/advisory.wxss @@ -0,0 +1,360 @@ +.container-box { + display: flex; + flex-direction: column; + height: 100vh; + overflow: hidden; +} + +/* 专家卡片*/ +.expert-card { + background-image: linear-gradient(to top, #48c6ef 0%, #6f86d6 100%); + padding: 36rpx 32rpx; + display: flex; + align-items: center; + color: white; + box-shadow: 0 8rpx 24rpx rgba(0, 30, 10, 0.25); + flex-shrink: 0; + position: relative; +} + +.avatar-wrapper { + position: relative; + margin-right: 28rpx; + flex-shrink: 0; +} + +.avatar { + width: 140rpx; + height: 140rpx; + border-radius: 70rpx; + border: 4rpx solid rgba(255, 255, 255, 0.25); + background-color: #e6f0ea; + box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.15); + transition: transform 0.2s; +} + +.avatar:active { + transform: scale(0.98); +} + +.online-status { + position: absolute; + bottom: 6rpx; + right: 6rpx; + width: 28rpx; + height: 28rpx; + border-radius: 14rpx; + border: 4rpx solid #1a4b2e; + background-color: #a0a0a0; + transition: background-color 0.2s; +} + +.online-status.online { + background-color: #4caf50; + box-shadow: 0 0 0 2rpx rgba(76, 175, 80, 0.3); +} + +.online-status.offline { + background-color: #9e9e9e; +} + +.info { + flex: 1; + display: flex; + flex-direction: column; + min-width: 0; +} + +.name-row { + display: flex; + align-items: center; + margin-bottom: 12rpx; + flex-wrap: wrap; + gap: 16rpx; +} + +.name { + font-size: 44rpx; + font-weight: 600; + line-height: 1.2; + letter-spacing: 1rpx; + text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.2); +} + +.online-text { + font-size: 26rpx; + background-color: rgba(255, 255, 255, 0.2); + padding: 3rpx 20rpx; + border-radius: 30rpx; + backdrop-filter: blur(4px); + border: 1rpx solid rgba(255, 255, 255, 0.15); + font-weight: 400; + color: #ffecb3; +} + +.specialty { + font-size: 26rpx; + opacity: 0.95; + margin-bottom: 16rpx; + display: flex; + align-items: center; + background-color: rgba(255, 255, 255, 0.1); + padding: 8rpx 20rpx; + border-radius: 40rpx; + width: fit-content; + backdrop-filter: blur(4px); + border: 1rpx solid rgba(255, 255, 255, 0.1); +} + +.experience-tag { + display: flex; + align-items: center; + background-color: rgba(255, 255, 255, 0.1); + padding: 8rpx 22rpx 8rpx 18rpx; + border-radius: 60rpx; + width: fit-content; +} + + +.tag-text { + font-size: 26rpx; + font-weight: 400; +} + +/* 列表头部 */ +.list-header { + padding: 28rpx 32rpx 20rpx; + display: flex; + justify-content: space-between; + align-items: center; + background-color: transparent; + flex-shrink: 0; +} + +.list-title-wrap { + display: flex; + align-items: baseline; + gap: 12rpx; +} + +.list-title { + font-size: 34rpx; + font-weight: 600; + color: #1f2d3d; + letter-spacing: 0.5rpx; +} + +.list-count { + font-size: 28rpx; + color: #5f6b7a; + background-color: #e9ecf0; + padding: 4rpx 16rpx; + border-radius: 30rpx; + font-weight: 500; +} + + +/* 滚动区域 */ +.apply-scroll { + flex: 1; + overflow-y: auto; + padding: 0 32rpx; + background-color: transparent; + box-sizing: border-box; +} + +.apply-list { + padding: 8rpx 0 30rpx; +} + +/* 申请项卡片 */ +.apply-item { + background-color: #ffffff; + border-radius: 32rpx; + padding: 32rpx 28rpx; + margin-bottom: 20rpx; + display: flex; + align-items: flex-start; + box-shadow: 0 8rpx 24rpx rgba(0, 20, 10, 0.04); + transition: all 0.25s ease; + border: 1rpx solid #edf2f7; + position: relative; + backdrop-filter: blur(2px); +} + +.apply-item:active { + background-color: #fafdff; + transform: translateY(-4rpx); + box-shadow: 0 16rpx 32rpx rgba(30, 60, 40, 0.08); + border-color: #cbd5e0; +} + +.user-avatar { + width: 96rpx; + height: 96rpx; + border-radius: 10rpx; + background-color: #dde5ed; + margin-right: 28rpx; + flex-shrink: 0; + border: 2rpx solid #e2e8f0; + transition: border-color 0.2s; +} + +.apply-item:active .user-avatar { + border-color: #2b6c4e; +} + +.apply-content { + flex: 1; + min-width: 0; +} + +.apply-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 16rpx; +} + +.user-info { + display: flex; + align-items: center; + gap: 16rpx; + flex-wrap: wrap; + flex: 1; + min-width: 0; +} + +.user-name { + font-size: 34rpx; + font-weight: 600; + color: #1e293b; + max-width: 240rpx; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + + +.apply-time { + font-size: 24rpx; + color: #94a3b8; + flex-shrink: 0; + margin-left: 16rpx; + background-color: #f8fafc; + padding: 4rpx 16rpx; + border-radius: 30rpx; +} + +.message-area { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 22rpx; +} + +.message-preview { + font-size: 28rpx; + color: #475569; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + flex: 1; + min-width: 0; + margin-right: 16rpx; + line-height: 1.4; +} + +.unread-badge { + background: linear-gradient(145deg, #ff5f6d, #ff7b89); + color: white; + font-size: 22rpx; + font-weight: 600; + min-width: 40rpx; + height: 40rpx; + line-height: 40rpx; + text-align: center; + border-radius: 40rpx; + padding: 0 12rpx; + flex-shrink: 0; + box-shadow: 0 4rpx 8rpx rgba(255, 95, 109, 0.25); + border: 2rpx solid rgba(255, 255, 255, 0.5); +} + + +/* 空状态 */ +.empty-state { + text-align: center; + padding: 80rpx 0; + color: #94a3b8; + display: flex; + flex-direction: column; + align-items: center; +} + + + +.empty-text { + font-size: 32rpx; + font-weight: 500; + color: #64748b; + margin-bottom: 8rpx; +} + +.empty-subtext { + font-size: 26rpx; + color: #a0afbe; +} + +/* 加载更多 */ +.loading-more { + text-align: center; + padding: 30rpx 0 40rpx; + color: #5f7d9c; + font-size: 26rpx; + display: flex; + align-items: center; + justify-content: center; + gap: 16rpx; +} + +.loading-spinner { + width: 32rpx; + height: 32rpx; + border: 4rpx solid #d1d9e6; + border-top-color: #2b6c4e; + border-radius: 50%; + animation: spin 0.8s linear infinite; +} + +@keyframes spin { + to { + transform: rotate(360deg); + } +} + +.no-more { + text-align: center; + padding: 30rpx 0; + color: #9aa9b9; + font-size: 26rpx; + position: relative; +} + +.no-more::before, +.no-more::after { + content: ''; + position: absolute; + top: 50%; + width: 60rpx; + height: 1rpx; + background-color: #dce3ec; +} + +.no-more::before { + left: 60rpx; +} + +.no-more::after { + right: 60rpx; +} \ No newline at end of file diff --git a/pagesA/pages/precept/precept.js b/pagesA/pages/precept/precept.js new file mode 100644 index 0000000..025df01 --- /dev/null +++ b/pagesA/pages/precept/precept.js @@ -0,0 +1,66 @@ +import http from '../../../utils/api' +Page({ + data: { + diagnosisList: [] + }, + + onLoad: function () { + + }, + + onShow:function(){ + this.getwzd() + }, + + + // 问诊单 + getwzd() { + http.wzd({ + data: {}, + success: res => { + console.log(1111, res); + this.setData({ + diagnosisList: res.rows + }) + } + }) + }, + + + + // 格式化日期显示 + formatDate: function (dateString) { + const date = new Date(dateString); + const now = new Date(); + const diff = now - date; + const diffDays = Math.floor(diff / (1000 * 60 * 60 * 24)); + const diffHours = Math.floor(diff / (1000 * 60 * 60)); + const diffMinutes = Math.floor(diff / (1000 * 60)); + + if (diffMinutes < 60) { + return `${diffMinutes}分钟前`; + } else if (diffHours < 24) { + return `${diffHours}小时前`; + } else if (diffDays === 1) { + return '昨天'; + } else if (diffDays === 2) { + return '前天'; + } else if (diffDays < 7) { + return `${diffDays}天前`; + } else { + const month = date.getMonth() + 1; + const day = date.getDate(); + return `${month}月${day}日`; + } + }, + + + // 查看详情 + viewDetail: function (e) { + const data = e.currentTarget.dataset.value + wx.navigateTo({ + url: `/pagesA/pages/askingSyDetails/askingSyDetails?data=${encodeURIComponent(JSON.stringify(data))}`, + }); + }, + +}); \ No newline at end of file diff --git a/pagesA/pages/precept/precept.json b/pagesA/pages/precept/precept.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pagesA/pages/precept/precept.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pagesA/pages/precept/precept.wxml b/pagesA/pages/precept/precept.wxml new file mode 100644 index 0000000..4ec1cae --- /dev/null +++ b/pagesA/pages/precept/precept.wxml @@ -0,0 +1,95 @@ + + + + + + 远程诊疗 + 专业兽医在线解答 + + + + + + + + + + + + + + 暂无问诊记录 + 开始您的第一次问诊吧 + + + + + + + + + + + + {{item.farmerName || '用户'}} + + + {{item.status}} + + + + + + + + + 牲畜信息 + + + + + + + {{item.animalType}} + + + {{item.animalAge}} + + + {{item.animalGender}} + + + + + + + + {{item.description}} + + + + + + + + {{item.createdTime}} + + + + + + 制定方案 + + + + + + + + + 已显示全部记录 + + + + + \ No newline at end of file diff --git a/pagesA/pages/precept/precept.wxss b/pagesA/pages/precept/precept.wxss new file mode 100644 index 0000000..9dcdd49 --- /dev/null +++ b/pagesA/pages/precept/precept.wxss @@ -0,0 +1,428 @@ +/* 全局样式 */ +.wzbox{ + min-height: 100vh; + position: relative; + background: linear-gradient(180deg, #F8FBFF 0%, #F0F7FF 100%); + } + + /* 头部样式优化 */ + .header { + padding: 20rpx 40rpx 20rpx; + background: linear-gradient(135deg, #6D9EFF 0%, #4A7CFF 100%); + border-radius: 0 0 36rpx 36rpx; + box-shadow: 0 4rpx 20rpx rgba(74, 144, 226, 0.15); + position: relative; + overflow: hidden; + } + + .header-content { + position: relative; + z-index: 2; + } + + .title-section { + display: flex; + flex-direction: column; + gap: 8rpx; + } + + .title { + font-size: 44rpx; + font-weight: 700; + color: #FFFFFF; + letter-spacing: 0.5rpx; + text-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); + } + + .subtitle { + font-size: 28rpx; + color: rgba(255, 255, 255, 0.9); + font-weight: 400; + } + + /* 头部装饰元素 */ + .header-decoration { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + overflow: hidden; + z-index: 1; + } + + .decoration-circle { + position: absolute; + border-radius: 50%; + background: rgba(255, 255, 255, 0.08); + } + + .circle-1 { + width: 200rpx; + height: 200rpx; + top: -80rpx; + right: -40rpx; + } + + .circle-2 { + width: 120rpx; + height: 120rpx; + bottom: -40rpx; + left: -20rpx; + } + + /* 问诊记录列表 */ + .record-list { + height: calc(100vh - 200rpx); + padding: 0 32rpx 20rpx; + box-sizing: border-box; + } + + .records-container { + padding-top: 24rpx; + } + + /* 列表头部 */ + .section-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 24rpx; + padding: 0 4rpx; + } + + .section-title { + font-size: 32rpx; + font-weight: 700; + color: #1A1A1A; + position: relative; + padding-left: 16rpx; + } + + .section-title::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + width: 4rpx; + height: 20rpx; + background: linear-gradient(180deg, #6D9EFF 0%, #4A7CFF 100%); + border-radius: 2rpx; + } + + .section-count { + font-size: 26rpx; + color: #666; + background: #F0F7FF; + padding: 6rpx 16rpx; + border-radius: 16rpx; + font-weight: 500; + } + + /* 问诊记录卡片 */ + .record-card { + background: #FFFFFF; + border-radius: 24rpx; + margin-bottom: 24rpx; + box-shadow: 0 6rpx 24rpx rgba(74, 144, 226, 0.08); + position: relative; + overflow: hidden; + transition: all 0.3s cubic-bezier(0.2, 0, 0.2, 1); + border: 1rpx solid #F0F7FF; + } + + .record-card:active { + transform: translateY(-2rpx); + box-shadow: 0 10rpx 30rpx rgba(74, 144, 226, 0.15); + } + + /* 卡片头部 */ + .card-header { + display: flex; + justify-content: space-between; + align-items: center; + padding: 24rpx 28rpx; + border-bottom: 1rpx solid #F5F9FF; + } + + .user-section { + display: flex; + align-items: center; + gap: 16rpx; + flex: 1; + } + + .user-avatar { + width: 60rpx; + height: 60rpx; + border-radius: 50%; + border: 2rpx solid rgba(255, 255, 255, 0.8); + box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08); + } + + .user-name { + font-size: 28rpx; + color: #1A1A1A; + font-weight: 600; + } + + /* 状态标签 */ + .status-tag { + padding: 8rpx 20rpx; + border-radius: 20rpx; + font-size: 22rpx; + font-weight: 600; + min-width: 80rpx; + text-align: center; + flex-shrink: 0; + } + + .status-replied { + background: linear-gradient(135deg, rgba(76, 217, 100, 0.12) 0%, rgba(46, 204, 113, 0.12) 100%); + color: #2ECC71; + border: 1rpx solid rgba(46, 204, 113, 0.2); + } + + .status-pending { + background: linear-gradient(135deg, rgba(255, 149, 0, 0.12) 0%, rgba(255, 127, 0, 0.12) 100%); + color: #FF9500; + border: 1rpx solid rgba(255, 149, 0, 0.2); + } + + /* 牲畜信息 */ + .livestock-section { + padding: 20rpx 28rpx; + } + + /* 牲畜信息标题优化 */ + .livestock-title-wrapper { + display: flex; + align-items: center; + justify-content: center; + margin-bottom: 20rpx; + position: relative; + } + + .livestock-title-line { + flex: 1; + height: 2rpx; + background: linear-gradient(90deg, transparent, #4A7CFF 50%, transparent); + opacity: 0.3; + } + + .livestock-title-content { + display: flex; + align-items: center; + gap: 12rpx; + padding: 0 20rpx; + position: relative; + } + + .livestock-title-text { + font-size: 30rpx; + font-weight: 700; + color: #333; + background: linear-gradient(135deg, #4A7CFF 0%, #8CB4FF 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; + text-shadow: 0 2rpx 4rpx rgba(74, 124, 255, 0.1); + letter-spacing: 1rpx; + } + + + @keyframes cowPulse { + 0%, 100% { + transform: scale(1) rotate(0deg); + } + 50% { + transform: scale(1.1) rotate(5deg); + } + } + + .livestock-tags { + display: flex; + gap: 16rpx; + flex-wrap: wrap; + } + + .livestock-tag { + padding: 5rpx 20rpx; + border-radius: 20rpx; + font-size: 26rpx; + font-weight: 600; + display: flex; + align-items: center; + justify-content: center; + box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); + } + + .type-tag { + background: linear-gradient(135deg, #6D9EFF 0%, #4A7CFF 100%); + color: #FFFFFF; + border: 2rpx solid rgba(255, 255, 255, 0.3); + } + + .age-tag { + background: linear-gradient(135deg, #FFB347 0%, #FFA033 100%); + color: #FFFFFF; + border: 2rpx solid rgba(255, 255, 255, 0.3); + } + + .gender-tag { + background: linear-gradient(135deg, #42E695 0%, #3BB2B8 100%); + color: #FFFFFF; + border: 2rpx solid rgba(255, 255, 255, 0.3); + } + + .tag-text { + font-size: 26rpx; + font-weight: 600; + color: #FFFFFF; + } + + /* 症状描述 */ + .symptom-section { + padding: 24rpx 28rpx 28rpx; + } + + .symptom-content { + background: #F9FAFF; + padding: 20rpx 24rpx; + border-radius: 16rpx; + border: 1rpx solid #E6ECFF; + position: relative; + } + + .symptom-content::before { + content: '症状描述'; + position: absolute; + top: -12rpx; + left: 24rpx; + background: #FFFFFF; + padding: 0 12rpx; + font-size: 24rpx; + font-weight: 600; + color: #4A7CFF; + z-index: 1; + } + + .symptom-text { + font-size: 28rpx; + color: #333; + line-height: 1.6; + font-weight: 400; + } + + /* 卡片底部 */ + .card-footer { + display: flex; + justify-content: space-between; + align-items: center; + padding: 20rpx 28rpx; + border-top: 1rpx solid #F5F9FF; + } + + .time-info { + display: flex; + align-items: center; + gap: 8rpx; + } + + .time-text { + font-size: 24rpx; + color: #999; + font-weight: 400; + } + + .reply-info { + display: flex; + align-items: center; + gap: 8rpx; + padding: 8rpx 16rpx; + background: #F0F7FF; + border-radius: 16rpx; + border: 1rpx solid #E5EFFF; + } + + .reply-count { + font-size: 24rpx; + font-weight: 500; + color: #4A7CFF; + } + + /* 空状态优化 */ + .empty-state { + display: flex; + flex-direction: column; + align-items: center; + padding-top: 120rpx; + text-align: center; + } + + .empty-icon { + width: 400rpx; + margin-bottom: 32rpx; + opacity: 0.5; + } + + .empty-text { + font-size: 32rpx; + color: #666; + margin-bottom: 12rpx; + font-weight: 600; + } + + .empty-tip { + font-size: 26rpx; + color: #999; + margin-bottom: 40rpx; + line-height: 1.4; + } + + /* 列表底部 */ + .list-footer { + text-align: center; + padding: 40rpx 0; + color: #999; + font-size: 24rpx; + } + + .footer-text { + opacity: 0.6; + letter-spacing: 1rpx; + } + + + /* 卡片入场动画 */ + @keyframes cardSlideIn { + from { + opacity: 0; + transform: translateY(30rpx); + } + to { + opacity: 1; + transform: translateY(0); + } + } + + .record-card { + animation: cardSlideIn 0.4s ease-out forwards; + opacity: 0; + } + + .record-card:nth-child(1) { animation-delay: 0.1s; } + .record-card:nth-child(2) { animation-delay: 0.15s; } + .record-card:nth-child(3) { animation-delay: 0.2s; } + .record-card:nth-child(4) { animation-delay: 0.25s; } + .record-card:nth-child(5) { animation-delay: 0.3s; } + + /* 响应式适配 */ + @media screen and (min-width: 768px) { + .record-card { + max-width: 600rpx; + margin-left: auto; + margin-right: auto; + } + } \ No newline at end of file diff --git a/pagesA/pages/releaseSuffer/releaseSuffer.js b/pagesA/pages/releaseSuffer/releaseSuffer.js new file mode 100644 index 0000000..583bf39 --- /dev/null +++ b/pagesA/pages/releaseSuffer/releaseSuffer.js @@ -0,0 +1,191 @@ +import http from '../../../utils/api'; +const baseUrl = require('../../../utils/baseUrl'); + +Page({ + data: { + baseUrl: baseUrl, + // 表单数据 + formData: { + title: '', + summary: '', + categoryName: '', + tags: '', // 改为字符串格式,如 "传染病,疫苗" + content: '' + }, + // 分类列表 - 直接从接口返回的 rows 赋值 + categoryList: [], + categoryIndex: -1, + // 标签列表 - 直接从接口返回的 rows 赋值 + tagList: [], + // 已选中的标签对象数组 + selectedTags: [], + // 提交状态 + submitting: false + }, + + onLoad(options) { + this.getCategoryList(); + this.getTagList(); + }, + + // 输入处理 + onInput(e) { + const { field } = e.currentTarget.dataset; + const { value } = e.detail; + this.setData({ + [`formData.${field}`]: value + }); + }, + + // 获取文章分类 - 直接使用 res.rows + getCategoryList() { + http.articleZd({ + data: { + dictType: 'vet_experience_category' + }, + success: (res) => { + // 直接使用 res.rows 赋值 + if (res.rows && Array.isArray(res.rows)) { + this.setData({ categoryList: res.rows }); + } else { + console.error('分类数据格式错误', res); + wx.showToast({ title: '分类加载失败', icon: 'none' }); + } + }, + fail: (err) => { + console.error('分类接口异常', err); + wx.showToast({ title: '网络错误', icon: 'none' }); + } + }); + }, + + // 获取文章标签 - 直接使用 res.rows + getTagList() { + http.videoZd({ + data: { + dictType: 'vet_experience_tag' + }, + success: (res) => { + // 直接使用 res.rows 赋值 + if (res.rows && Array.isArray(res.rows)) { + this.setData({ tagList: res.rows }); + } else { + console.error('标签数据格式错误', res); + wx.showToast({ title: '标签加载失败', icon: 'none' }); + } + }, + fail: (err) => { + console.error('标签接口异常', err); + wx.showToast({ title: '网络错误', icon: 'none' }); + } + }); + }, + + // 分类选择 + onCategoryChange(e) { + const index = parseInt(e.detail.value, 10); + const selectedCategory = this.data.categoryList[index]; + this.setData({ + categoryIndex: index, + [`formData.categoryName`]: selectedCategory.dictLabel + }); + }, + + // 标签点击切换 + toggleTag(e) { + const tagItem = e.currentTarget.dataset.item; + let selectedTags = [...this.data.selectedTags]; + const index = selectedTags.findIndex(t => t.dictValue === tagItem.dictValue); + + if (index > -1) { + selectedTags.splice(index, 1); + } else { + selectedTags.push(tagItem); + } + + // 生成逗号分隔的标签字符串,如 "传染病,疫苗" + const tagString = selectedTags.map(item => item.dictLabel).join(','); + + this.setData({ + selectedTags: selectedTags, + [`formData.tags`]: tagString + }); + }, + + // 表单提交 + formSubmit(e) { + const { title, categoryName, content } = this.data.formData; + + // 表单验证 + if (!title || title.trim() === '') { + this.showError('请填写文章标题'); + return; + } + if (!categoryName) { + this.showError('请选择文章分类'); + return; + } + if (this.data.selectedTags.length === 0) { + this.showError('请至少选择一个标签'); + return; + } + if (!content || content.trim() === '') { + this.showError('请填写文章内容'); + return; + } + + this.setData({ submitting: true }); + + // 构建提交数据 - tags 已经是字符串格式 + const postData = { + title: this.data.formData.title, + summary: this.data.formData.summary || '', + categoryName: this.data.formData.categoryName, + tags: this.data.formData.tags, // 已经是 "传染病,疫苗" 格式 + content: this.data.formData.content + }; + + console.log('提交数据:', postData); // 调试用 + + http.shareAdd({ + data: postData, + success: (res) => { + if(res.code == 200){ + wx.showToast({ + title: '发布成功', + icon: 'success', + duration: 2000, + success: () => { + setTimeout(() => { + wx.navigateBack(); + }, 1500); + } + }) + }else{ + console.error('发布失败', err); + this.showError('发布失败,请重试'); + this.setData({ submitting: false }); + } + }, + fail: (err) => { + console.error('发布失败', err); + this.showError('发布失败,请重试'); + this.setData({ submitting: false }); + }, + complete: () => { + setTimeout(() => { + this.setData({ submitting: false }); + }, 3000); + } + }); + }, + + // 错误提示 + showError(msg) { + wx.showToast({ + title: msg, + icon: 'none', + duration: 2000 + }); + } +}); \ No newline at end of file diff --git a/pagesA/pages/releaseSuffer/releaseSuffer.json b/pagesA/pages/releaseSuffer/releaseSuffer.json new file mode 100644 index 0000000..7b8bc36 --- /dev/null +++ b/pagesA/pages/releaseSuffer/releaseSuffer.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText":"发布文章", + "usingComponents": {} +} \ No newline at end of file diff --git a/pagesA/pages/releaseSuffer/releaseSuffer.wxml b/pagesA/pages/releaseSuffer/releaseSuffer.wxml new file mode 100644 index 0000000..b558f51 --- /dev/null +++ b/pagesA/pages/releaseSuffer/releaseSuffer.wxml @@ -0,0 +1,109 @@ + +
+ + + + 📝 + 文章标题 + 必填 + + + + + + + + + + + + 📋 + 文章摘要 + 选填 + + + +