Browse Source

实名认证,修改上传头像名称,反馈建议,退出登录

master
ZhaoYang 1 week ago
parent
commit
7d667253a7
  1. 7
      app.json
  2. 1
      pages/home/home.js
  3. 30
      pages/home/home.wxml
  4. BIN
      pages/images/gywm.png
  5. BIN
      pages/images/logout.png
  6. BIN
      pages/images/sz.png
  7. BIN
      pages/images/xx.png
  8. BIN
      pages/images/xx1.png
  9. 7
      pages/market/market.wxml
  10. 9
      pages/market/market.wxss
  11. 66
      pages/news/news.js
  12. 4
      pages/news/news.json
  13. 2
      pages/news/news.wxml
  14. 1
      pages/news/news.wxss
  15. 343
      pages/personal/personal.js
  16. 45
      pages/personal/personal.wxml
  17. 214
      pages/personal/personal.wxss
  18. 123
      pagesA/pages/attestation/attestation.js
  19. 24
      pagesA/pages/attestation/attestation.wxml
  20. 111
      pagesA/pages/attestation/attestation.wxss
  21. 18
      utils/api.js
  22. 4
      utils/baseUrl.js

7
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": "市场",

1
pages/home/home.js

@ -21,6 +21,7 @@ Page({
http.UserInfo({
data: {},
success: res => {
console.log(11111,res);
this.setData({
user: res.data.area
})

30
pages/home/home.wxml

@ -24,17 +24,7 @@
<!-- 轮播图区域-->
<view class="swiper-container">
<swiper class="custom-swiper"
indicator-dots="{{false}}"
indicator-color="rgba(255,255,255,0.4)"
indicator-active-color="#4CAF50"
autoplay="{{true}}"
interval="5000"
duration="500"
circular="{{true}}"
current="{{currentSwiper}}"
bindchange="onSwiperChange"
style="height: 360rpx;">
<swiper class="custom-swiper" indicator-dots="{{false}}" indicator-color="rgba(255,255,255,0.4)" indicator-active-color="#4CAF50" autoplay="{{true}}" interval="5000" duration="500" circular="{{true}}" current="{{currentSwiper}}" bindchange="onSwiperChange" style="height: 360rpx;">
<block wx:for="{{swiperList}}" wx:key="id">
<swiper-item>
<view class="swiper-item {{item.isActive ? 'active' : ''}}" data-value="{{item}}" catchtap="onSwiperTap">
@ -107,14 +97,7 @@
</view>
</view>
<view class="notice-content">
<swiper class="notice-swiper"
vertical="{{true}}"
autoplay="{{true}}"
interval="4000"
duration="800"
circular="{{true}}"
style="height: 160rpx;"
bindchange="onNoticeSwiperChange">
<swiper class="notice-swiper" vertical="{{true}}" autoplay="{{true}}" interval="4000" duration="800" circular="{{true}}" style="height: 160rpx;" bindchange="onNoticeSwiperChange">
<block wx:for="{{noticeList}}" wx:key="id">
<swiper-item>
<view class="notice-item {{index === currentNotice ? 'highlight' : ''}}" data-id="{{item.id}}" catchtap="onNoticeTap">
@ -221,6 +204,15 @@
{{item.publishTime}}
</view>
</view>
<!-- 底部信息 -->
<view class="post-footer">
<view class="post-meta">
<view class="meta-item">
<image class="meta-icon" src="/pagesB/images/lll.png" mode="aspectFit"></image>
<text class="meta-count">{{item.viewCount || 0}}</text>
</view>
</view>
</view>
</view>
</view>

BIN
pages/images/gywm.png

Before

Width: 200  |  Height: 200  |  Size: 3.8 KiB

BIN
pages/images/logout.png

After

Width: 200  |  Height: 200  |  Size: 4.4 KiB

BIN
pages/images/sz.png

Before

Width: 200  |  Height: 200  |  Size: 6.5 KiB

BIN
pages/images/xx.png

Before

Width: 200  |  Height: 200  |  Size: 5.2 KiB

BIN
pages/images/xx1.png

Before

Width: 200  |  Height: 200  |  Size: 5.4 KiB

7
pages/market/market.wxml

@ -78,7 +78,7 @@
</view>
<view class="card-status">
<view class="status-dot {{salesStatus}}"></view>
<text class="status-text">{{salesStatus === 'active' ? '更新中' : '已更新'}}</text>
<text class="status-text">已更新</text>
</view>
</view>
@ -152,7 +152,7 @@
</view>
<view class="card-status">
<view class="status-dot {{feedStatus}}"></view>
<text class="status-text">{{feedStatus === 'active' ? '更新中' : '已更新'}}</text>
<text class="status-text">已更新</text>
</view>
</view>
@ -205,9 +205,6 @@
<text class="section-text">市场趋势</text>
<text class="section-desc">通知公告与行业分析</text>
<view class="section-indicator"></view>
<view class="unread-badge" wx:if="{{unreadCount > 0}}">
<text class="badge-text">{{unreadCount}}条未读</text>
</view>
</view>
<view

9
pages/market/market.wxss

@ -206,15 +206,6 @@
margin-left: 12rpx;
}
.unread-badge {
background: #ef4444;
color: white;
font-size: 20rpx;
padding: 4rpx 12rpx;
border-radius: 12rpx;
margin-left: 12rpx;
font-weight: 500;
}
/* 卡片通用样式优化 */
.market-card {

66
pages/news/news.js

@ -1,66 +0,0 @@
// pages/news/news.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

4
pages/news/news.json

@ -1,4 +0,0 @@
{
"navigationBarTitleText":"消息",
"usingComponents": {}
}

2
pages/news/news.wxml

@ -1,2 +0,0 @@
<!--pages/news/news.wxml-->
<text>pages/news/news.wxml</text>

1
pages/news/news.wxss

@ -1 +0,0 @@
/* pages/news/news.wxss */

343
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
},
onLoad() {
this.loadUserInfo();
// 上传状态
isUploadingAvatar: false,
isUpdatingNickname: false
},
// 跳转实名认证
bindrz(){
wx.navigateTo({
url: '/pagesA/pages/attestation/attestation',
})
onLoad() {
this.getUserInfo()
},
onShow() {
this.getUserInfo()
},
// 加载用户信息
loadUserInfo() {
// 从缓存获取用户信息
const userInfo = wx.getStorageSync('userInfo');
const avatarUrl = wx.getStorageSync('avatarUrl');
if (userInfo) {
// 获取用户信息
getUserInfo() {
http.UserInfo({
data: {},
success: (res) => {
if (res.data && res.data.user) {
wx.setStorageSync('userInfo', res.data)
this.setData({
userInfo,
avatarUrl
});
} else {
// 首次使用,生成默认用户信息
const defaultUserInfo = {
nickName: '微信用户',
isVerified: false
};
wx.setStorageSync('userInfo', defaultUserInfo);
this.setData({ userInfo: defaultUserInfo });
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 : ''
})
}
}
})
},
// 更新用户信息到服务器
updateUserInfo() {
const formData = this.data.formData
// 过滤掉空值
const dataToUpdate = {}
if (formData.avatar) dataToUpdate.avatar = formData.avatar
if (formData.nickName) dataToUpdate.nickName = formData.nickName
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
}
// 显示加载
wx.showLoading({
title: '更新中...',
mask: true
});
const { avatarUrl } = e.detail
if (!avatarUrl) {
this.showToast('选择头像失败')
return
}
// 模拟上传过程
setTimeout(() => {
this.setData({ avatarUrl });
this.setData({ isUploadingAvatar: true })
// 保存到缓存
wx.setStorageSync('avatarUrl', avatarUrl);
wx.showLoading({
title: '上传中...',
mask: true
})
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: '/pages/auth/realname'
});
url: '/pagesA/pages/attestation/attestation'
})
}
},
// 显示反馈弹窗
@ -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.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'
};
}
});
}
})

45
pages/personal/personal.wxml

@ -4,19 +4,20 @@
<view class="user-card">
<!-- 头像 -->
<button class="avatar-btn" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
<image class="avatar" src="{{avatarUrl || '/pages/images/tx.png'}}" mode="aspectFill"></image>
<image class="avatar" src="{{baseUrl + userInfo.user.avatar || '/pages/images/tx.png'}}" mode="aspectFill"></image>
<view class="avatar-edit-tip">点击修改</view>
</button>
<!-- 用户信息 -->
<view class="user-info">
<view class="nickname-section" bindtap="editNickname">
<text class="nickname">{{userInfo.nickName || '微信用户'}}</text>
<text class="nickname">{{userInfo.user.nickName || '微信用户'}}</text>
<image src="/pages/images/bj.png"></image>
</view>
<view class="user-meta">
<view class="auth-tag {{userInfo.isVerified ? 'verified' : ''}}" bindtap="goToAuth">
<text>{{userInfo.isVerified ? '已认证' : '未认证'}}</text>
<text>{{userInfo.authStatus ? '已认证' : '未认证'}}</text>
</view>
</view>
</view>
@ -57,8 +58,8 @@
<image class="item-icon" src="/pages/images/smrz.png"></image>
<text class="item-title">实名认证</text>
</view>
<view class="item-status {{userInfo.isVerified ? 'verified' : ''}}" bind:tap="bindrz">
{{userInfo.isVerified ? '已认证' : '去认证'}}
<view class="item-status {{userInfo.isVerified ? 'verified' : ''}}">
{{userInfo.authStatus ? '已认证' : '去认证'}}
</view>
</view>
@ -70,26 +71,17 @@
</view>
</view>
<!-- 关于我们 -->
<view class="function-item" bindtap="goToAbout">
<!-- 退出登录 -->
<view class="function-item" bindtap="showLogoutConfirm">
<view class="item-left">
<image class="item-icon" src="/pages/images/gywm.png"></image>
<text class="item-title">关于我们</text>
<image class="item-icon" src="/pages/images/logout.png"></image>
<text class="item-title logout-title">退出登录</text>
</view>
</view>
<!-- 设置 -->
<view class="function-item" bindtap="goToSettings">
<view class="item-left">
<image class="item-icon" src="/pages/images/sz.png"></image>
<text class="item-title">设置</text>
</view>
</view>
</view>
</view>
<!-- 反馈建议弹窗 -->
<view class="feedback-modal {{showFeedbackModal ? 'show' : ''}}">
<view class="modal-mask" bindtap="hideFeedback"></view>
@ -97,7 +89,7 @@
<view class="modal-header">
<text class="modal-title">反馈建议</text>
<view class="modal-close" bindtap="hideFeedback">
<image src="/pagesA/images/cuo.png"></image>
<image src="/pagesA/images/ch.png"></image>
</view>
</view>
@ -135,6 +127,21 @@
</view>
</view>
<!-- 退出登录确认弹窗 -->
<view class="logout-modal {{showLogoutModal ? 'show' : ''}}">
<view class="modal-mask" bindtap="hideLogoutModal"></view>
<view class="modal-content">
<view class="logout-modal-body">
<text class="logout-title">确认退出登录?</text>
<text class="logout-desc">退出后需要重新登录才能使用完整功能</text>
</view>
<view class="logout-modal-footer">
<button class="logout-cancel-btn" bindtap="hideLogoutModal">取消</button>
<button class="logout-confirm-btn" bindtap="doLogout">退出登录</button>
</view>
</view>
</view>
<!-- 提示信息 -->
<view class="toast {{showToast ? 'show' : ''}}">
<text>{{toastText}}</text>

214
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 {

123
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,42 +354,100 @@ Page({
});
try {
// 模拟API请求
await new Promise(resolve => setTimeout(resolve, 1500));
// 调用实名认证接口
const result = await this.callRealNameApi(name, idNumber);
wx.hideLoading();
if (result.success) {
// 处理身份证号脱敏显示
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()
});
this.setData({
isSubmitting: false,
currentStep: 3,
lineProgress2: 100
});
} else {
// 接口返回失败
this.handleApiError(result);
}
} catch (error) {
wx.hideLoading();
this.setData({ isSubmitting: false });
this.setData({
isSubmitting: false,
currentStep: 1,
lineProgress2: 0
});
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);
},
// 显示成功弹窗
showSuccessModal(maskedId) {
@ -381,7 +462,7 @@ Page({
this.setData({ showSuccessModal: false });
},
// 前往首页
// 返回
goToHome() {
this.closeSuccessModal();
wx.switchTab({

24
pagesA/pages/attestation/attestation.wxml

@ -258,4 +258,28 @@
</view>
</view>
</view>
<!-- 错误弹窗(新增) -->
<view class="modal-overlay {{showErrorModal ? 'show' : ''}}" bindtap="closeErrorModal">
<view class="modal-container error-modal" catchtap="stopPropagation">
<view class="modal-header">
<view class="modal-title error-title">{{errorTitle}}</view>
<button class="modal-close" bindtap="closeErrorModal">
<image class="close-icon" src="/pagesA/images/ch.png" mode="aspectFit"></image>
</button>
</view>
<view class="modal-content error-content">
<view class="error-message">
{{errorMessage}}
</view>
</view>
<view class="modal-footer">
<button class="modal-confirm error-confirm" bindtap="closeErrorModal">
确定
</button>
</view>
</view>
</view>
</view>

111
pagesA/pages/attestation/attestation.wxss

@ -826,7 +826,7 @@ page {
.close-icon {
width: 26rpx;
height: 26rpx;
opacity: 0.6;
filter: brightness(0);
}
.modal-content {
@ -1283,3 +1283,112 @@ page {
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);
}

18
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
}

4
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
Loading…
Cancel
Save