diff --git a/app.json b/app.json index 38723fa..b5de33e 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,6 @@ "pages": [ "pages/home/home", "pages/login/login", - "pages/news/news", "pages/map/map", "pages/personal/personal", "pages/market/market" @@ -55,12 +54,6 @@ "iconPath": "pages/images/home.png", "selectedIconPath": "pages/images/home1.png" }, - { - "pagePath": "pages/news/news", - "text": "消息", - "iconPath": "pages/images/xx.png", - "selectedIconPath": "pages/images/xx1.png" - }, { "pagePath": "pages/market/market", "text": "市场", diff --git a/pages/home/home.js b/pages/home/home.js index 0cb937e..86fd314 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -21,6 +21,7 @@ Page({ http.UserInfo({ data: {}, success: res => { + console.log(11111,res); this.setData({ user: res.data.area }) diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 96d85d5..794242c 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -24,17 +24,7 @@ - + @@ -107,14 +97,7 @@ - + @@ -221,6 +204,15 @@ {{item.publishTime}} + + + + + + {{item.viewCount || 0}} + + + diff --git a/pages/images/gywm.png b/pages/images/gywm.png deleted file mode 100644 index 7a2cbfd..0000000 Binary files a/pages/images/gywm.png and /dev/null differ diff --git a/pages/images/logout.png b/pages/images/logout.png new file mode 100644 index 0000000..c84488c Binary files /dev/null and b/pages/images/logout.png differ diff --git a/pages/images/sz.png b/pages/images/sz.png deleted file mode 100644 index 3e72d5d..0000000 Binary files a/pages/images/sz.png and /dev/null differ diff --git a/pages/images/xx.png b/pages/images/xx.png deleted file mode 100644 index e453a8f..0000000 Binary files a/pages/images/xx.png and /dev/null differ diff --git a/pages/images/xx1.png b/pages/images/xx1.png deleted file mode 100644 index 23322fe..0000000 Binary files a/pages/images/xx1.png and /dev/null differ diff --git a/pages/market/market.wxml b/pages/market/market.wxml index add24fb..b54b78b 100644 --- a/pages/market/market.wxml +++ b/pages/market/market.wxml @@ -78,7 +78,7 @@ - {{salesStatus === 'active' ? '更新中' : '已更新'}} + 已更新 @@ -152,7 +152,7 @@ - {{feedStatus === 'active' ? '更新中' : '已更新'}} + 已更新 @@ -205,9 +205,6 @@ 市场趋势 通知公告与行业分析 - - {{unreadCount}}条未读 - -pages/news/news.wxml \ No newline at end of file diff --git a/pages/news/news.wxss b/pages/news/news.wxss deleted file mode 100644 index c142781..0000000 --- a/pages/news/news.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/news/news.wxss */ \ No newline at end of file diff --git a/pages/personal/personal.js b/pages/personal/personal.js index bd3d95e..daf0cd5 100644 --- a/pages/personal/personal.js +++ b/pages/personal/personal.js @@ -1,16 +1,19 @@ +import http from '../../utils/api' +const baseUrl = require('../../utils/baseUrl') + Page({ data: { // 用户信息 avatarUrl: '', userInfo: { - nickName: '', - userId: '', - isVerified: false - }, + user: {} + }, + baseUrl: baseUrl, // 弹窗状态 showFeedbackModal: false, showNicknameModal: false, + showLogoutModal: false, showToast: false, // 反馈相关 @@ -20,143 +23,226 @@ Page({ // 编辑相关 newNickname: '', + // 提示信息 - toastText: '' + toastText: '', + + // 表单数据 + formData: { + avatar: null, + nickName: null + }, + + // 上传状态 + isUploadingAvatar: false, + isUpdatingNickname: false }, onLoad() { - this.loadUserInfo(); + this.getUserInfo() }, - // 跳转实名认证 - bindrz(){ - wx.navigateTo({ - url: '/pagesA/pages/attestation/attestation', - }) + onShow() { + this.getUserInfo() }, - onShow() { - + // 获取用户信息 + getUserInfo() { + http.UserInfo({ + data: {}, + success: (res) => { + if (res.data && res.data.user) { + wx.setStorageSync('userInfo', res.data) + this.setData({ + userInfo: res.data, + avatarUrl: res.data.user?.avatar ? baseUrl + res.data.user.avatar : '' + }) + } + }, + fail: (err) => { + console.error('获取用户信息失败:', err) + // 使用缓存的用户信息 + const cachedUserInfo = wx.getStorageSync('userInfo') + if (cachedUserInfo) { + this.setData({ + userInfo: cachedUserInfo, + avatarUrl: cachedUserInfo.user?.avatar ? baseUrl + cachedUserInfo.user.avatar : '' + }) + } + } + }) }, - // 加载用户信息 - loadUserInfo() { - // 从缓存获取用户信息 - const userInfo = wx.getStorageSync('userInfo'); - const avatarUrl = wx.getStorageSync('avatarUrl'); + // 更新用户信息到服务器 + updateUserInfo() { + const formData = this.data.formData + // 过滤掉空值 + const dataToUpdate = {} + if (formData.avatar) dataToUpdate.avatar = formData.avatar + if (formData.nickName) dataToUpdate.nickName = formData.nickName - if (userInfo) { - this.setData({ - userInfo, - avatarUrl - }); - } else { - // 首次使用,生成默认用户信息 - const defaultUserInfo = { - nickName: '微信用户', - isVerified: false - }; - - wx.setStorageSync('userInfo', defaultUserInfo); - this.setData({ userInfo: defaultUserInfo }); - } + if (Object.keys(dataToUpdate).length === 0) return + + http.revise({ + data: dataToUpdate, + success: (res) => { + console.log('更新成功:', res) + // 清空表单数据 + this.setData({ + 'formData.avatar': null, + 'formData.nickName': null + }) + // 立即刷新用户信息 + this.getUserInfo() + }, + fail: (err) => { + console.error('更新失败:', err) + this.showToast('更新失败,请重试') + } + }) }, - // 选择头像 onChooseAvatar(e) { - const { avatarUrl } = e.detail; + if (this.data.isUploadingAvatar) { + this.showToast('正在上传中...') + return + } + + const { avatarUrl } = e.detail + if (!avatarUrl) { + this.showToast('选择头像失败') + return + } + + this.setData({ isUploadingAvatar: true }) - // 显示加载 wx.showLoading({ - title: '更新中...', + title: '上传中...', mask: true - }); + }) - // 模拟上传过程 - setTimeout(() => { - this.setData({ avatarUrl }); - - // 保存到缓存 - wx.setStorageSync('avatarUrl', avatarUrl); - - wx.hideLoading(); - this.showToast('头像更新成功'); - }, 800); + // 上传头像到服务器 + wx.uploadFile({ + url: baseUrl + '/common/upload', + header: { + 'Authorization': 'Bearer ' + wx.getStorageSync('token') + }, + filePath: avatarUrl, + name: 'file', + success: (uploadRes) => { + wx.hideLoading() + + try { + const result = JSON.parse(uploadRes.data) + if (result && result.fileName) { + // 立即更新本地显示 + this.setData({ + avatarUrl: avatarUrl, + 'formData.avatar': result.fileName, + 'userInfo.user.avatar': result.fileName + }) + + // 更新到服务器 + this.updateUserInfo() + + this.showToast('头像更新成功') + } else { + throw new Error('上传失败') + } + } catch (error) { + console.error('解析上传结果失败:', error) + this.showToast('上传失败,请重试') + } + }, + fail: (err) => { + wx.hideLoading() + console.error('上传失败:', err) + this.showToast('上传失败,请检查网络') + }, + complete: () => { + this.setData({ isUploadingAvatar: false }) + } + }) }, - - // 编辑昵称 editNickname() { this.setData({ showNicknameModal: true, - newNickname: this.data.userInfo.nickName - }); + newNickname: this.data.userInfo.user?.nickName || '' + }) }, hideNicknameModal() { - this.setData({ showNicknameModal: false }); + this.setData({ showNicknameModal: false }) }, onNicknameInput(e) { - this.setData({ newNickname: e.detail.value }); + this.setData({ newNickname: e.detail.value }) }, saveNickname() { - const newNickname = this.data.newNickname.trim(); + const newNickname = this.data.newNickname.trim() if (!newNickname) { - this.showToast('昵称不能为空'); - return; + this.showToast('昵称不能为空') + return } - if (newNickname.length > 20) { - this.showToast('昵称不能超过20个字符'); - return; + if (newNickname.length > 10) { + this.showToast('昵称不能超过10个字符') + return } - // 更新用户信息 - const updatedUserInfo = { - ...this.data.userInfo, - nickName: newNickname - }; + // 如果昵称没有变化,直接关闭弹窗 + if (newNickname === this.data.userInfo.user?.nickName) { + this.hideNicknameModal() + return + } + this.setData({ isUpdatingNickname: true }) + + // 立即更新本地显示 this.setData({ - userInfo: updatedUserInfo, - showNicknameModal: false - }); + 'userInfo.user.nickName': newNickname, + 'formData.nickName': newNickname + }) - // 保存到缓存 - wx.setStorageSync('userInfo', updatedUserInfo); + // 更新到服务器 + this.updateUserInfo() - this.showToast('昵称修改成功'); + this.setData({ + showNicknameModal: false, + isUpdatingNickname: false + }) + + this.showToast('昵称修改成功') }, // 查看问诊消息 goToConsultation() { wx.navigateTo({ url: '' - }); + }) }, // 查看问答消息 goToQA() { wx.navigateTo({ url: '' - }); + }) }, // 实名认证 goToAuth() { - if (this.data.userInfo.isVerified) { - this.showToast('您已完成实名认证'); - return; + if (this.data.userInfo.authStatus) { + this.showToast('您已完成实名认证') + } else { + wx.navigateTo({ + url: '/pagesA/pages/attestation/attestation' + }) } - - wx.navigateTo({ - url: '/pages/auth/realname' - }); }, // 显示反馈弹窗 @@ -166,77 +252,79 @@ Page({ feedbackContent: '', canSubmit: false, isSubmitting: false - }); + }) }, hideFeedback() { - this.setData({ showFeedbackModal: false }); + this.setData({ showFeedbackModal: false }) }, // 反馈内容输入 onFeedbackInput(e) { - const content = e.detail.value; - const canSubmit = content.trim().length > 0; + const content = e.detail.value + const canSubmit = content.trim().length > 0 this.setData({ feedbackContent: content, canSubmit - }); + }) }, // 提交反馈 submitFeedback() { - if (!this.data.canSubmit || this.data.isSubmitting) return; + if (!this.data.canSubmit || this.data.isSubmitting) return - const content = this.data.feedbackContent.trim(); + const content = this.data.feedbackContent.trim() if (content.length < 5) { - this.showToast('请填写详细的反馈内容'); - return; + this.showToast('请填写详细的反馈内容') + return } - this.setData({ isSubmitting: true }); + this.setData({ isSubmitting: true }) - // 模拟提交到服务器 + // 提交 setTimeout(() => { - console.log('提交反馈:', content); + console.log('提交反馈:', content) + http.feedback({ + data:{ + content:content + }, + success:res=>{ + console.log(111111,res); + if(res.code==200){ + this.showToast('感谢您的反馈!') + }else{ + this.showToast('反馈失败!') + } + this.setData({ + isSubmitting: false, + showFeedbackModal: false + }) + } + }) - this.setData({ - isSubmitting: false, - showFeedbackModal: false - }); - - this.showToast('感谢您的反馈!'); - - // 这里应该是实际的API调用 - // wx.request({ - // url: 'https://your-api.com/feedback', - // method: 'POST', - // data: { content }, - // success: (res) => { - // this.showToast('提交成功'); - // }, - // complete: () => { - // this.setData({ - // isSubmitting: false, - // showFeedbackModal: false - // }); - // } - // }); - }, 1500); + + }, 1500) }, - // 关于我们 - goToAbout() { - wx.navigateTo({ - url: '/pages/about/index' - }); + // 退出登录相关 + showLogoutConfirm() { + this.setData({ showLogoutModal: true }) }, - // 设置 - goToSettings() { - wx.navigateTo({ - url: '/pages/settings/index' - }); + hideLogoutModal() { + this.setData({ showLogoutModal: false }) + }, + + doLogout() { + // 清除本地存储 + wx.clearStorageSync() + + // 跳转到登录页 + wx.reLaunch({ + url: '/pages/login/login' + }) + this.showToast('已退出登录') }, // 显示提示 @@ -244,22 +332,21 @@ Page({ this.setData({ toastText: text, showToast: true - }); + }) setTimeout(() => { - this.setData({ showToast: false }); - }, 2000); + this.setData({ showToast: false }) + }, 2000) }, // 下拉刷新 onPullDownRefresh() { - this.loadUserInfo(); - this.checkUnreadMessages(); + this.getUserInfo() setTimeout(() => { - wx.stopPullDownRefresh(); - this.showToast('刷新成功'); - }, 1000); + wx.stopPullDownRefresh() + this.showToast('刷新成功') + }, 1000) }, // 分享 @@ -267,6 +354,6 @@ Page({ return { title: '健康守护 - 您的个人健康中心', path: '/pages/personal-center/index' - }; + } } -}); \ No newline at end of file +}) \ No newline at end of file diff --git a/pages/personal/personal.wxml b/pages/personal/personal.wxml index 3c7a4d1..a72916b 100644 --- a/pages/personal/personal.wxml +++ b/pages/personal/personal.wxml @@ -4,19 +4,20 @@ @@ -57,8 +58,8 @@ 实名认证 - - {{userInfo.isVerified ? '已认证' : '去认证'}} + + {{userInfo.authStatus ? '已认证' : '去认证'}} @@ -69,27 +70,18 @@ 反馈建议 - - - + + + - - 关于我们 + + 退出登录 - - - - - 设置 - - - - @@ -97,7 +89,7 @@ 反馈建议 - + @@ -135,6 +127,21 @@ + + + + + + 确认退出登录? + 退出后需要重新登录才能使用完整功能 + + + + + + + + {{toastText}} diff --git a/pages/personal/personal.wxss b/pages/personal/personal.wxss index c8f84b1..45087a5 100644 --- a/pages/personal/personal.wxss +++ b/pages/personal/personal.wxss @@ -1,9 +1,9 @@ -.personal-center{ +.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; @@ -23,12 +23,6 @@ transform: translateY(20rpx); } -.fade-in-delay-3 { - animation: fadeIn 0.6s 0.6s ease forwards; - opacity: 0; - transform: translateY(20rpx); -} - @keyframes fadeIn { to { opacity: 1; @@ -58,14 +52,15 @@ .avatar-btn { position: relative; - width: 120rpx; - height: 120rpx; + width: 140rpx; + height: 140rpx; margin-right: 30rpx; flex-shrink: 0; padding: 0; background: transparent; border: none; border-radius: 50%; + overflow: visible; } .avatar-btn::after { @@ -78,8 +73,32 @@ 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; @@ -89,6 +108,13 @@ 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 { @@ -102,12 +128,16 @@ 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 { @@ -117,14 +147,12 @@ gap: 16rpx; } - - .auth-tag { display: flex; align-items: center; - padding: 6rpx 12rpx; + padding: 6rpx 16rpx; background: #fef3c7; - border-radius: 16rpx; + border-radius: 20rpx; transition: all 0.3s ease; } @@ -134,23 +162,21 @@ .auth-tag:active { transform: scale(0.95); -} - -.auth-tag image { - width: 20rpx; - height: 20rpx; - margin-right: 6rpx; + opacity: 0.8; } .auth-tag text { - font-size: 22rpx; + font-size: 24rpx; color: #92400e; + font-weight: 500; } .auth-tag.verified text { color: #065f46; } + + /* 卡片样式 */ .section-card { background: white; @@ -188,8 +214,6 @@ border-radius: 3rpx; } - - /* 消息行 */ .message-row { display: flex; @@ -207,6 +231,7 @@ .message-item:active { transform: scale(0.95); + opacity: 0.8; } .message-icon-wrapper { @@ -220,6 +245,11 @@ background: #f8fafc; border-radius: 50%; border: 1rpx solid #e2e8f0; + transition: all 0.3s ease; +} + +.message-item:active .message-icon-wrapper { + background: #e2e8f0; } .message-icon { @@ -227,7 +257,6 @@ height: 60rpx; } - .message-label { font-size: 26rpx; color: #475569; @@ -270,10 +299,9 @@ } .item-icon { - width: 32rpx; - height: 32rpx; + width: 40rpx; + height: 40rpx; margin-right: 20rpx; - opacity: 0.8; } .item-title { @@ -282,6 +310,9 @@ font-weight: 500; } +.logout-title { + color: #ef4444; +} .item-status { font-size: 26rpx; @@ -293,14 +324,6 @@ color: #10b981; } - -.function-item:active .arrow { - opacity: 0.8; - transform: translateX(4rpx); -} - - - /* 反馈弹窗 */ .feedback-modal { position: fixed; @@ -363,9 +386,12 @@ } .modal-close { + width: 40rpx; + height: 40rpx; display: flex; align-items: center; justify-content: center; + border-radius: 50%; transition: all 0.3s ease; } @@ -377,7 +403,7 @@ .modal-close image { width: 36rpx; height: 36rpx; - opacity: 0.5; + filter: brightness(0%); } /* 反馈输入框 */ @@ -434,7 +460,7 @@ .submit-btn { width: 100%; - height: 88rpx; + padding: 5rpx 0; background: #e2e8f0; border-radius: 44rpx; font-size: 32rpx; @@ -538,7 +564,7 @@ .cancel-btn, .confirm-btn { flex: 1; - height: 80rpx; + padding: 5rpx 0; border-radius: 40rpx; font-size: 28rpx; font-weight: 500; @@ -551,6 +577,10 @@ color: #64748b; } +.cancel-btn::after{ + border: none; +} + .cancel-btn:active { background: #e2e8f0; } @@ -566,23 +596,121 @@ 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; +} + +.logout-modal.show { + opacity: 1; + visibility: visible; +} + +.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.9); + background: rgba(30, 41, 59, 0.95); backdrop-filter: blur(20rpx); color: white; - padding: 20rpx 40rpx; - border-radius: 12rpx; + 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 { diff --git a/pagesA/pages/attestation/attestation.js b/pagesA/pages/attestation/attestation.js index 9730423..8610fcb 100644 --- a/pagesA/pages/attestation/attestation.js +++ b/pagesA/pages/attestation/attestation.js @@ -1,5 +1,6 @@ +// pages/auth/real-name-auth.js import http from '../../../utils/api' -const baseUrl = require('../../../utils/baseUrl') + Page({ data: { // 表单数据 @@ -14,7 +15,7 @@ Page({ nameError: '', idNumberError: '', - // 提示显示控制 - 修复:初始为false + // 提示显示控制 showNameHint: false, showIdNumberHint: false, @@ -41,7 +42,12 @@ Page({ // 成功弹窗数据 showSuccessModal: false, - maskedIdNumber: '' + maskedIdNumber: '', + + // 错误弹窗数据 + showErrorModal: false, + errorTitle: '', + errorMessage: '' }, onLoad() { @@ -51,7 +57,7 @@ Page({ }, 600); }, - // 姓名输入处理 - 修复:简化逻辑 + // 姓名输入处理 onNameInput(e) { const value = e.detail.value.trim(); let error = ''; @@ -109,7 +115,7 @@ Page({ }); }, - // 身份证号输入处理 - 修复:简化逻辑 + // 身份证号输入处理 onIdNumberInput(e) { const value = e.detail.value.trim().toUpperCase(); let error = ''; @@ -270,6 +276,23 @@ Page({ this.setData({ showModal: false }); }, + // 显示错误弹窗 + showErrorModal(title, message) { + this.setData({ + errorTitle: title || '认证失败', + errorMessage: message || '请检查信息后重试', + showErrorModal: true + }); + }, + + // 关闭错误弹窗 + closeErrorModal() { + this.setData({ + showErrorModal: false, + isSubmitting: false // 关闭错误弹窗时重置提交状态 + }); + }, + // 阻止事件冒泡 stopPropagation(e) { // 阻止冒泡 @@ -331,41 +354,99 @@ Page({ }); try { - // 模拟API请求 - await new Promise(resolve => setTimeout(resolve, 1500)); + // 调用实名认证接口 + const result = await this.callRealNameApi(name, idNumber); wx.hideLoading(); - // 处理身份证号脱敏显示 - const maskedId = idNumber.substring(0, 4) + '**********' + idNumber.substring(14); - - // 显示成功弹窗 - this.showSuccessModal(maskedId); - - // 保存认证信息 - wx.setStorageSync('realNameAuth', { - name: name, - idNumber: idNumber, - certified: true, - certifiedTime: new Date().getTime() - }); + if (result.success) { + // 处理身份证号脱敏显示 + const maskedId = idNumber.substring(0, 4) + '**********' + idNumber.substring(14); + + // 显示成功弹窗 + this.showSuccessModal(maskedId); + + this.setData({ + isSubmitting: false, + currentStep: 3, + lineProgress2: 100 + }); + } else { + // 接口返回失败 + this.handleApiError(result); + } + } catch (error) { + wx.hideLoading(); this.setData({ isSubmitting: false, - currentStep: 3, - lineProgress2: 100 + currentStep: 1, + lineProgress2: 0 }); - } catch (error) { - wx.hideLoading(); - this.setData({ isSubmitting: false }); - - wx.showToast({ - title: '认证失败,请重试', - icon: 'error', - duration: 2000 + this.showErrorModal('网络错误', '认证请求失败,请检查网络连接后重试'); + console.error('实名认证错误:', error); + } + }, + + // 调用实名认证API + async callRealNameApi(realName, idCard) { + return new Promise((resolve, reject) => { + http.realName({ + data: { + realName: realName, // 姓名字段 + idCard: idCard // 身份证号字段 + }, + success: (res) => { + console.log('API响应:', res); + + // 根据实际API响应结构调整 + if (res.code === 200 || res.code === 0) { + resolve({ + success: true, + data: res.data || {} + }); + } else { + resolve({ + success: false, + code: res.code, + message: res.msg || '认证失败' + }); + } + }, + fail: (err) => { + reject(err); + } }); + }); + }, + + // 处理API错误 + handleApiError(result) { + console.log('API错误:', result); + + this.setData({ + isSubmitting: false, + currentStep: 1, + lineProgress2: 0 + }); + + // 根据错误码显示不同提示 + let title = '认证失败'; + let message = result.message || '请检查信息后重试'; + + // 根据不同的错误码定制提示信息 + if (result.code === 500) { + message = result.message || '服务器内部错误,请稍后重试'; + } else if (result.code === 400) { + message = result.message || '请求参数错误,请检查填写的信息'; + } else if (result.code === 401) { + message = result.message || '身份验证失败,请重新登录'; + } else if (result.code === 403) { + message = result.message || '认证信息不正确,请核对姓名和身份证号'; } + + this.showErrorModal(title, message); }, // 显示成功弹窗 @@ -381,7 +462,7 @@ Page({ this.setData({ showSuccessModal: false }); }, - // 前往首页 + // 返回 goToHome() { this.closeSuccessModal(); wx.switchTab({ diff --git a/pagesA/pages/attestation/attestation.wxml b/pagesA/pages/attestation/attestation.wxml index 574a145..a69aba6 100644 --- a/pagesA/pages/attestation/attestation.wxml +++ b/pagesA/pages/attestation/attestation.wxml @@ -258,4 +258,28 @@ + + + + + + {{errorTitle}} + + + + + + {{errorMessage}} + + + + + + + + \ No newline at end of file diff --git a/pagesA/pages/attestation/attestation.wxss b/pagesA/pages/attestation/attestation.wxss index e6c7a46..b8a23e7 100644 --- a/pagesA/pages/attestation/attestation.wxss +++ b/pagesA/pages/attestation/attestation.wxss @@ -826,7 +826,7 @@ page { .close-icon { width: 26rpx; height: 26rpx; - opacity: 0.6; + filter: brightness(0); } .modal-content { @@ -1282,4 +1282,113 @@ page { @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } +} + + +/* 错误弹窗样式 */ +.error-modal .modal-container { + background: #fff; + border-radius: 20rpx; + overflow: hidden; + animation: modalSlideUp 0.3s ease; +} + +.error-modal .modal-header { + padding: 40rpx 40rpx 20rpx; + text-align: center; + border-bottom: 2rpx solid #f0f0f0; +} + +.error-modal .error-title { + color: #ff4444; + font-size: 36rpx; + font-weight: 600; + text-align: center; + width: 100%; +} + +.error-modal .modal-content { + padding: 40rpx; + text-align: center; +} + + + +.error-modal .error-message { + color: #666; + font-size: 28rpx; + line-height: 1.6; + text-align: center; + padding: 0 20rpx; +} + +.error-modal .modal-footer { + padding: 30rpx 40rpx 40rpx; +} + +.error-modal .error-confirm { + background: linear-gradient(135deg, #ff4444, #ff6666); + color: white; + border: none; + border-radius: 50rpx; + height: 80rpx; + line-height: 80rpx; + font-size: 30rpx; + font-weight: 500; + width: 100%; + transition: all 0.3s ease; +} + +.error-modal .error-confirm:active { + opacity: 0.9; + transform: scale(0.98); +} + +/* 弹窗动画 */ +@keyframes modalSlideUp { + from { + opacity: 0; + transform: translateY(100rpx); + } + to { + opacity: 1; + transform: translateY(0); + } +} + +/* 修复原有的模态框样式 */ +.modal-overlay { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background: rgba(0, 0, 0, 0.5); + display: flex; + align-items: center; + justify-content: center; + opacity: 0; + visibility: hidden; + transition: all 0.3s ease; + z-index: 9999; + padding: 40rpx; +} + +.modal-overlay.show { + opacity: 1; + visibility: visible; +} + +.modal-container { + width: 600rpx; + max-width: 90vw; + background: #fff; + border-radius: 20rpx; + overflow: hidden; + transform: translateY(20rpx); + transition: transform 0.3s ease; +} + +.modal-overlay.show .modal-container { + transform: translateY(0); } \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index 77cb2e5..7a36637 100644 --- a/utils/api.js +++ b/utils/api.js @@ -197,6 +197,22 @@ function experiencezd(params) { http('/vet/article/options', 'get', params) } +// 实名认证 +function realName(params) { + http('/muhu/user/auth/submit', 'post', params) +} + +// 上传修改头像 +function revise(params) { + http('/muhu/user', 'put', params) +} + +// 个人中心反馈建议 +function feedback(params) { + http('/muhu/feedback', 'post', params) +} + + @@ -205,5 +221,5 @@ export default { // 暴露接口 search,trend,feed,sales,wzd,wzdxq,wzdAdd,expertsList,recommendationList,policyeZd, recommendationXq,queryList,tipList,article,articleDetails,articleZd,policyelucidation, areaChildren,userCode,UserInfo,videoList,videoZd,videoDetails,forumList,forumAdd,forumDetails, - forumReply,commentReply,experience,experiencezd,experienceDetails + forumReply,commentReply,experience,experiencezd,experienceDetails,realName,revise,feedback } diff --git a/utils/baseUrl.js b/utils/baseUrl.js index 79483b5..3de0bb9 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 = 'https://wx.chenhaitech.com/ymtx-prod-api' +var baseUrl = 'http://192.168.101.109:8080' // var baseUrl = 'http://192.168.101.105:8082' // var baseUrl = 'http://192.168.101.111:8081' module.exports = baseUrl