diff --git a/pages/home/home.js b/pages/home/home.js index e15bac2..0cb937e 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -9,53 +9,54 @@ Page({ // 通知公告数据 currentNotice: 0, noticeList: [], - forum:[] + forum: [], + suffer: [], + // 添加用户数据 + user: {}, + county: '' }, - // 查询用户信息 - getUserInfo(){ - http.UserInfo({ - data:{}, - success:res=>{ - this.setData({ - user:res.data.area - }) - } - }) + getUserInfo() { + http.UserInfo({ + data: {}, + success: res => { + this.setData({ + user: res.data.area + }) + } + }) }, // 在线问答列表 - getforumList(){ + getforumList() { http.forumList({ - data:{}, - success:res=>{ + data: {}, + success: res => { const zxwd = [] zxwd.push(res.rows[0]) this.setData({ - forum:zxwd + forum: zxwd }) } }) }, // 经验分享列表 - getexperience(){ - http.experience({ - data:{}, - success:res=>{ - console.log(111,res); - const zyfx = [] - zyfx.push(res.rows[0]) - this.setData({ - suffer:zyfx - }) - } - }) + getexperience() { + http.experience({ + data: {}, + success: res => { + console.log(111, res); + const zyfx = [] + zyfx.push(res.rows[0]) + this.setData({ + suffer: zyfx + }) + } + }) }, - - // 轮播 getCarousel() { http.carousel({ @@ -68,18 +69,34 @@ Page({ }) }, - // 灾害 + // 灾害/通知公告 getDisaster() { http.disaster({ data: {}, success: res => { + // 处理通知数据,添加时间戳 + const notices = res.rows.map(item => { + return { + ...item, + // // 判断是否是24小时内的通知 + // isNew: this.isNewNotification(item.createdTime) + } + }) this.setData({ - noticeList: res.rows + noticeList: notices }) } }) }, + // // 判断通知是否在24小时内 + // isNewNotification(createdTime) { + // if (!createdTime) return false + // const noticeTime = new Date(createdTime.replace(/-/g, '/')).getTime() + // const now = new Date().getTime() + // const twentyFourHours = 24 * 60 * 60 * 1000 + // return now - noticeTime < twentyFourHours + // }, // 区域划分跳转 bindXzqh() { @@ -137,11 +154,11 @@ Page({ }) }, - //问答列表 - bindwdlist(){ - wx.navigateTo({ - url: '/pagesB/pages/forumlist/forumlist', - }) + // 问答列表 + bindwdlist() { + wx.navigateTo({ + url: '/pagesB/pages/forumlist/forumlist', + }) }, // 问答详情 @@ -154,22 +171,33 @@ Page({ }, // 经验分享列表 - viewexperience(){ + viewexperience() { wx.navigateTo({ url: '/pagesB/pages/experienceList/experienceList', }) }, // 经验分享详情 - bindfx(e){ + bindfx(e) { const id = e.currentTarget.dataset.id - wx.navigateTo({ - url: `/pagesB/pages/experienceDetails/experienceDetails?id=${id}`, - }) + wx.navigateTo({ + url: `/pagesB/pages/experienceDetails/experienceDetails?id=${id}`, + }) + }, + + // 查看所有通知 + viewAllNotices() { + wx.navigateTo({ + url: '/pagesB/pages/noticeList/noticeList', + }) }, + // 查看所有问题 + viewAllQuestions() { + this.bindwdlist() + }, - //获取当前位置信息 + // 获取当前位置信息 getLocation() { let that = this; // 腾讯获取的密钥 @@ -202,25 +230,44 @@ Page({ }, onShow() { - + // 页面显示时重置轮播图(解决某些手机上的轮播问题) + this.resetSwiper() }, - + // 重置轮播图(解决轮播不自动播放的问题) + resetSwiper() { + setTimeout(() => { + if (this.data.swiperList.length > 0) { + this.setData({ + currentSwiper: this.data.currentSwiper + }) + } + }, 300) + }, // 轮播图变化事件 onSwiperChange(e) { const current = e.detail.current; - const swiperList = this.data.swiperList.map((item, index) => ({ - ...item, - })); - this.setData({ - currentSwiper: current, - swiperList + currentSwiper: current }); }, + // 轮播图指示器点击 + onIndicatorTap(e) { + const index = e.currentTarget.dataset.index; + this.setData({ + currentSwiper: index + }); + }, + // 通知轮播变化事件 + onNoticeSwiperChange(e) { + const current = e.detail.current; + this.setData({ + currentNotice: current + }); + }, // 轮播图点击 onSwiperTap(e) { @@ -231,11 +278,9 @@ Page({ icon: 'none', duration: 1000 }); - }, - - // 通知点击 - 使用catchtap防止事件冒泡 + // 通知点击 onNoticeTap(e) { const id = e.currentTarget.dataset.id; console.log('通知点击:', id); @@ -244,15 +289,15 @@ Page({ const notice = this.data.noticeList.find(item => item.id === id); if (notice) { wx.showModal({ - title: notice.typeName, - content: notice.content, + title: notice.warningLevel || '通知详情', + content: notice.title, showCancel: true, cancelText: '关闭', confirmText: '查看详情', success: (res) => { if (res.confirm) { wx.navigateTo({ - url: '/pages/notice/detail?id=' + id + url: '/pagesB/pages/noticeDetail/noticeDetail?id=' + id }); } } @@ -260,18 +305,12 @@ Page({ } }, - // 更多通知 - gotoNotices() { - wx.navigateTo({ - url: '' - }); - }, - - onReady() { - //当前网络状态 + // 当前网络状态 wx.getNetworkType({ - success: function (res) { // 返回网络类型, 有效值:// wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) + success: function (res) { + // 返回网络类型, 有效值: + // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) console.log(res); var networkType = res.networkType if (networkType !== 'unknown') { @@ -285,11 +324,18 @@ Page({ }) }, - // 下拉刷新 onPullDownRefresh() { wx.showNavigationBarLoading() - setTimeout(function () { + + // 重新加载所有数据 + Promise.all([ + new Promise(resolve => this.getUserInfo(resolve)), + new Promise(resolve => this.getDisaster(resolve)), + new Promise(resolve => this.getCarousel(resolve)), + new Promise(resolve => this.getforumList(resolve)), + new Promise(resolve => this.getexperience(resolve)) + ]).then(() => { wx.showToast({ title: '刷新成功', icon: 'none', @@ -297,11 +343,14 @@ Page({ }) wx.hideNavigationBarLoading() wx.stopPullDownRefresh() - }, 1000) + }).catch(() => { + wx.hideNavigationBarLoading() + wx.stopPullDownRefresh() + }) }, // 页面滚动 onPageScroll(e) { - + // 可以根据需要添加滚动效果 } }); \ No newline at end of file diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 84db7a7..96d85d5 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -22,9 +22,19 @@ - + - + @@ -87,20 +97,43 @@ + + + 📢 + 通知公告 + + + 更多 > + + - + - {{item.warningLevel}} + + {{item.warningLevel}} + NEW + {{item.createdTime}} - {{item.title}} + + {{item.title}} + + + diff --git a/pages/home/home.wxss b/pages/home/home.wxss index 499d7fd..f136757 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -6,7 +6,6 @@ padding-top: env(safe-area-inset-top); } - /* 主要内容区域 */ .box { width: 93%; @@ -29,7 +28,6 @@ border-radius: 50%; } - .orientation{ display: flex; align-items: center; @@ -59,7 +57,7 @@ color: #fff; } -/* 轮播图区域 */ +/* 轮播图区域 - 已修复 */ .swiper-container { position: relative; border-radius: 20rpx; @@ -175,13 +173,12 @@ } .indicator-dot.active { - width: 30rpx; + width: 40rpx; background: #96DBD4; border-radius: 6rpx; } /* 卡片类型 */ - .kap { animation: kapIn 0.5s ease-out 0.5s both; } @@ -196,8 +193,6 @@ } } - - .card { width: 100%; display: grid; @@ -299,7 +294,7 @@ background-color: #FD8140; } -/* 通知公告区域 */ +/* 通知公告区域 */ .notice-section { background: #FFFFFF; border-radius: 20rpx; @@ -307,39 +302,99 @@ margin: 20rpx 0; box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.05); animation: fadeIn 0.6s ease-out 0.6s both; + position: relative; + overflow: hidden; } @keyframes fadeIn { from { opacity: 0; + transform: translateY(30rpx); } to { opacity: 1; + transform: translateY(0); } } +/* 通知标题区域 */ +.notice-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 20rpx; + padding-bottom: 20rpx; + border-bottom: 1px solid rgba(150, 219, 212, 0.2); +} + +.notice-title { + display: flex; + align-items: center; + gap: 12rpx; +} + +.notice-icon { + font-size: 32rpx; +} + +.notice-title-text { + font-size: 32rpx; + font-weight: 600; + color: #333; + position: relative; + padding-left: 16rpx; +} + +.notice-title-text::before { + content: ''; + position: absolute; + left: 0; + top: 50%; + transform: translateY(-50%); + width: 6rpx; + height: 28rpx; + background: linear-gradient(135deg, #FF9800, #F44336); + border-radius: 3rpx; +} + +.notice-more { + font-size: 24rpx; + color: #96DBD4; + padding: 8rpx 16rpx; + background: rgba(150, 219, 212, 0.1); + border-radius: 20rpx; + transition: all 0.3s ease; +} + +.notice-more:active { + background: rgba(150, 219, 212, 0.2); + transform: scale(0.95); +} + +/* 通知内容区域 */ .notice-content { position: relative; } .notice-swiper { - height: 150rpx; + height: 160rpx; } .notice-item { - padding: 20rpx 0; transition: all 0.3s ease; display: flex; flex-direction: column; + justify-content: center; position: relative; + cursor: pointer; } .notice-item.highlight { - background: rgba(76, 175, 80, 0.05); - border-radius: 12rpx; + background: rgba(150, 219, 212, 0.08); + border-radius: 16rpx; padding: 20rpx; - margin: -10rpx -10rpx 0; + margin: 0 -10rpx; } .notice-item-header { @@ -349,47 +404,90 @@ margin-bottom: 16rpx; } +.notice-type-container { + display: flex; + align-items: center; + gap: 10rpx; +} + .notice-type { - padding: 4rpx 16rpx; + padding: 6rpx 16rpx; border-radius: 20rpx; font-size: 22rpx; font-weight: 500; + display: inline-flex; + align-items: center; + justify-content: center; + min-width: 80rpx; } +/* 优化通知类型样式 */ .notice-type.urgent { - background: rgba(244, 67, 54, 0.1); - color: #F44336; + background: linear-gradient(135deg, #FF5252, #FF1744); + color: white; + box-shadow: 0 4rpx 12rpx rgba(244, 67, 54, 0.2); } .notice-type.important { - background: rgba(255, 152, 0, 0.1); - color: #FF9800; + background: linear-gradient(135deg, #FF9800, #FF9100); + color: white; + box-shadow: 0 4rpx 12rpx rgba(255, 152, 0, 0.2); } .notice-type.normal { - background: rgba(33, 150, 243, 0.1); - color: #2196F3; + background: linear-gradient(135deg, #96DBD4, #60C0B9); + color: white; + box-shadow: 0 4rpx 12rpx rgba(33, 150, 243, 0.2); +} + +.notice-badge { + background: #FF4081; + color: white; + font-size: 18rpx; + padding: 2rpx 8rpx; + border-radius: 10rpx; + margin-left: 4rpx; } .notice-time { font-size: 22rpx; - color: #999999; + color: #888; + font-family: 'Arial', sans-serif; +} + +.notice-text-container { + display: flex; + justify-content: space-between; + align-items: center; } .notice-text { font-size: 28rpx; - color: #333333; + color: #333; line-height: 1.5; flex: 1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; + font-weight: 500; + padding-right: 20rpx; +} + +.notice-arrow { + font-size: 24rpx; + color: #96DBD4; + opacity: 0.7; + transition: all 0.3s ease; } +.notice-item.highlight .notice-arrow { + opacity: 1; + transform: translateX(4rpx); +} -/* 用户提问板块 - 优化样式 */ +/* 用户提问板块 */ .user-question-section { background: #FFFFFF; border-radius: 24rpx; @@ -447,7 +545,6 @@ border-radius: 4rpx; } - .title-text1_1 { font-size: 38rpx; font-weight: bold; @@ -457,7 +554,6 @@ padding-left: 20rpx; } - .title-text1_1::before { content: ''; position: absolute; @@ -476,8 +572,6 @@ padding-left: 20rpx; } - - .view-all { display: flex; align-items: center; @@ -494,7 +588,6 @@ transform: scale(0.98); } - .view-all1_1{ display: flex; align-items: center; @@ -511,9 +604,6 @@ transform: scale(0.98); } - - - /* 问题元信息 */ .question-meta { display: flex; @@ -540,7 +630,6 @@ overflow: hidden; } - /* 用户信息 */ .question-info { display: flex; @@ -577,7 +666,6 @@ margin-bottom: 6rpx; } - .time-info { font-size: 22rpx; color: #999; @@ -586,7 +674,6 @@ border-radius: 16rpx; } - .post-footer { display: flex; align-items: center; diff --git a/pagesA/images/duig.png b/pagesA/images/duig.png new file mode 100644 index 0000000..41de07f Binary files /dev/null and b/pagesA/images/duig.png differ diff --git a/pagesA/images/name.png b/pagesA/images/name.png new file mode 100644 index 0000000..265e3d1 Binary files /dev/null and b/pagesA/images/name.png differ diff --git a/pagesA/images/sfz.png b/pagesA/images/sfz.png new file mode 100644 index 0000000..c946203 Binary files /dev/null and b/pagesA/images/sfz.png differ diff --git a/pagesA/pages/askingSy/askingSy.js b/pagesA/pages/askingSy/askingSy.js index 41b2732..4b40826 100644 --- a/pagesA/pages/askingSy/askingSy.js +++ b/pagesA/pages/askingSy/askingSy.js @@ -4,35 +4,39 @@ Page({ diagnosisList: [] }, - onLoad: function() { - this.getwzd() + onLoad: function () { + + }, + + onShow:function(){ + this.getwzd() }, - + // 问诊单 - getwzd(){ - http.wzd({ - data:{}, - success:res=>{ - console.log(1111,res); - this.setData({ - diagnosisList:res.rows - }) - } - }) + getwzd() { + http.wzd({ + data: {}, + success: res => { + console.log(1111, res); + this.setData({ + diagnosisList: res.rows + }) + } + }) }, // 格式化日期显示 - formatDate: function(dateString) { + 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) { @@ -51,30 +55,18 @@ Page({ }, // 新增问诊单 - showCreateModal: function() { + showCreateModal: function () { wx.navigateTo({ url: '/pagesA/pages/askingSyAdd/askingSyAdd', }); }, // 查看详情 - viewDetail: function(e) { - console.log(1111,e); - const status = e.currentTarget.dataset.value.status + viewDetail: function (e) { const data = e.currentTarget.dataset.value - console.log(data); - - if(status=='已回复'){ - wx.navigateTo({ - url: `/pagesA/pages/askingSyDetails/askingSyDetails?data=${encodeURIComponent(JSON.stringify(data))}`, - }); - }else{ - wx.showToast({ - title: `无回复内容`, - icon: 'none', - duration: 1000 - }); - } + wx.navigateTo({ + url: `/pagesA/pages/askingSyDetails/askingSyDetails?data=${encodeURIComponent(JSON.stringify(data))}`, + }); }, diff --git a/pagesA/pages/askingSyAdd/askingSyAdd.js b/pagesA/pages/askingSyAdd/askingSyAdd.js index a4f7f7d..09ae4f2 100644 --- a/pagesA/pages/askingSyAdd/askingSyAdd.js +++ b/pagesA/pages/askingSyAdd/askingSyAdd.js @@ -1,5 +1,6 @@ import http from '../../../utils/api' const baseUrl = require('../../../utils/baseUrl') + Page({ /** * 页面的初始数据 @@ -16,7 +17,9 @@ Page({ isSubmitting: false, isFormValid: false, tempImages: [], // 新增:临时存储本地图片路径 - isUploading: false // 新增:防止重复上传 + isUploading: false, // 新增:防止重复上传 + showLoadingMask: false, // 新增:显示加载遮罩层 + loadingText: '提交中...' // 新增:加载提示文字 }, /** @@ -234,8 +237,11 @@ Page({ return; } + // 显示加载遮罩层 this.setData({ - isSubmitting: true + isSubmitting: true, + showLoadingMask: true, + loadingText: '提交中...' }); // 准备提交数据 @@ -248,29 +254,77 @@ Page({ data: submitData, success: (res) => { console.log('提交成功', res); - this.setData({ - isSubmitting: false - }); + if(res.code==200){ - // 提交成功后的处理 - wx.showToast({ - title: '提交成功', - icon: 'success', - duration: 1500, - success: () => { - setTimeout(() => { - // 返回上一页 - // wx.navigateBack(); - }, 1500); - } - }); - }else{ - wx.showToast({ - title: '提交失败,请重试', - icon: 'none' + // 提交成功后的处理 + this.setData({ + loadingText: '提交成功' }); + + setTimeout(() => { + this.setData({ + isSubmitting: false, + showLoadingMask: false + }); + + wx.showToast({ + title: '提交成功', + icon: 'success', + duration: 1500, + success: () => { + // 返回上一页 + wx.navigateBack(); + } + }); + }, 1000); + } else { + this.setData({ + loadingText: '提交失败' + }); + + setTimeout(() => { + this.setData({ + isSubmitting: false, + showLoadingMask: false + }); + + wx.showToast({ + title: res.msg || '提交失败,请重试', + icon: 'none', + duration: 2000 + }); + }, 1000); } }, + fail: (err) => { + this.setData({ + loadingText: '网络错误' + }); + + setTimeout(() => { + this.setData({ + isSubmitting: false, + showLoadingMask: false + }); + + wx.showToast({ + title: '网络异常,请检查网络后重试', + icon: 'none', + duration: 2000 + }); + }, 1000); + } + }); + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + // 页面卸载时重置状态 + this.setData({ + isSubmitting: false, + showLoadingMask: false }); } }); \ No newline at end of file diff --git a/pagesA/pages/askingSyAdd/askingSyAdd.wxml b/pagesA/pages/askingSyAdd/askingSyAdd.wxml index 4ce9bda..98db029 100644 --- a/pagesA/pages/askingSyAdd/askingSyAdd.wxml +++ b/pagesA/pages/askingSyAdd/askingSyAdd.wxml @@ -1,114 +1,122 @@ - - -
+ + + - - - - - 牲畜类型 - - 必填 + + + + + 牲畜类型 - + 必填 + + - - - - - 牲畜信息 - - 必填 + + + + + 牲畜信息 + 必填 + - - - - - 年龄 - - - - + + + + + 年龄 + + + + - - - - 性别 + + + + 性别 + + + + - - - - - - - + + + - - - - - 症状描述 - - 必填 + + + + + 症状描述 - -