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.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 @@
-
-
-
-
+
+
+
+
+ {{loadingText}}
+
+
\ No newline at end of file
diff --git a/pagesA/pages/askingSyAdd/askingSyAdd.wxss b/pagesA/pages/askingSyAdd/askingSyAdd.wxss
index 5e619eb..c4d4bcd 100644
--- a/pagesA/pages/askingSyAdd/askingSyAdd.wxss
+++ b/pagesA/pages/askingSyAdd/askingSyAdd.wxss
@@ -318,6 +318,47 @@
box-shadow: none;
}
+/* 加载遮罩层 */
+.loading-mask {
+ 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;
+ z-index: 9999;
+}
+
+.loading-content {
+ background: #FFFFFF;
+ border-radius: 24rpx;
+ padding: 60rpx 80rpx;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ animation: scaleIn 0.3s ease-out;
+}
+
+.loading-spinner {
+ width: 80rpx;
+ height: 80rpx;
+ border: 6rpx solid #F0F7FF;
+ border-top: 6rpx solid #4A90E2;
+ border-radius: 50%;
+ animation: spin 1s linear infinite;
+ margin-bottom: 32rpx;
+}
+
+.loading-text {
+ font-size: 28rpx;
+ color: #333;
+ font-weight: 500;
+}
+
/* 动画效果 */
@keyframes fadeIn {
from {
@@ -330,6 +371,22 @@
}
}
+@keyframes scaleIn {
+ from {
+ opacity: 0;
+ transform: scale(0.9);
+ }
+ to {
+ opacity: 1;
+ transform: scale(1);
+ }
+}
+
+@keyframes spin {
+ 0% { transform: rotate(0deg); }
+ 100% { transform: rotate(360deg); }
+}
+
.form-section {
animation: fadeIn 0.4s ease-out forwards;
opacity: 0;
diff --git a/pagesA/pages/attestation/attestation.js b/pagesA/pages/attestation/attestation.js
index 9dfe01f..9730423 100644
--- a/pagesA/pages/attestation/attestation.js
+++ b/pagesA/pages/attestation/attestation.js
@@ -1,25 +1,26 @@
-// pages/real-name-auth/real-name-auth.js
+import http from '../../../utils/api'
+const baseUrl = require('../../../utils/baseUrl')
Page({
data: {
// 表单数据
name: '',
- phone: '',
- smsCode: '',
+ idNumber: '',
// 焦点状态
nameFocus: false,
- phoneFocus: false,
- codeFocus: false,
+ idNumberFocus: false,
// 错误提示
nameError: '',
- phoneError: '',
- smsCodeError: '',
+ idNumberError: '',
- // 验证码相关
- canSendCode: false,
- countdown: 0,
- countdownTimer: null,
+ // 提示显示控制 - 修复:初始为false
+ showNameHint: false,
+ showIdNumberHint: false,
+
+ // 验证状态
+ isNameValid: false,
+ isIdNumberValid: false,
// 协议状态
agreed: false,
@@ -28,211 +29,262 @@ Page({
canSubmit: false,
isSubmitting: false,
- // 弹窗
- showSuccessModal: false
+ // 进度条
+ currentStep: 1,
+ lineProgress1: 0,
+ lineProgress2: 0,
+
+ // 弹窗数据
+ showModal: false,
+ modalTitle: '',
+ modalContent: '',
+
+ // 成功弹窗数据
+ showSuccessModal: false,
+ maskedIdNumber: ''
},
onLoad() {
- this.checkForm();
+ // 页面加载时启动进度条动画
+ setTimeout(() => {
+ this.setData({ lineProgress1: 50 });
+ }, 600);
},
- onUnload() {
- // 清除定时器
- if (this.data.countdownTimer) {
- clearInterval(this.data.countdownTimer);
- }
- },
-
- // 姓名输入处理
+ // 姓名输入处理 - 修复:简化逻辑
onNameInput(e) {
- const name = e.detail.value.trim();
- let nameError = '';
+ const value = e.detail.value.trim();
+ let error = '';
+ let showHint = true;
+ let isValid = false;
- if (name && !/^[\u4e00-\u9fa5]{2,10}$/.test(name)) {
- nameError = '姓名应为2-10个汉字';
+ if (value) {
+ if (!/^[\u4e00-\u9fa5]{2,10}$/.test(value)) {
+ error = '姓名应为2-10个汉字';
+ } else {
+ isValid = true;
+ // 验证通过时保持提示显示,但无错误
+ }
+ } else {
+ // 内容为空时显示正常提示
+ error = '';
}
this.setData({
- name: name,
- nameError: nameError
+ name: value,
+ nameError: error,
+ showNameHint: showHint,
+ isNameValid: isValid
}, () => {
this.checkForm();
- this.checkCanSendCode();
});
},
onNameFocus() {
- this.setData({ nameFocus: true });
+ this.setData({
+ nameFocus: true,
+ showNameHint: true // 获得焦点时显示提示
+ });
},
onNameBlur() {
- this.setData({ nameFocus: false });
+ const { name } = this.data;
+
+ this.setData({
+ nameFocus: false,
+ // 失去焦点时,如果内容为空或验证失败,保持提示显示
+ showNameHint: !!(name && !this.data.isNameValid)
+ });
},
- // 手机号输入处理
- onPhoneInput(e) {
- const phone = e.detail.value.trim();
- let phoneError = '';
-
- if (phone && !/^1[3-9]\d{9}$/.test(phone)) {
- phoneError = '请输入正确的手机号码';
- }
-
+ // 清除姓名
+ clearName() {
this.setData({
- phone: phone,
- phoneError: phoneError
+ name: '',
+ nameError: '',
+ showNameHint: false,
+ isNameValid: false
}, () => {
this.checkForm();
- this.checkCanSendCode();
});
},
- onPhoneFocus() {
- this.setData({ phoneFocus: true });
- },
-
- onPhoneBlur() {
- this.setData({ phoneFocus: false });
- },
-
- // 验证码输入处理
- onSmsCodeInput(e) {
- const smsCode = e.detail.value.trim();
- let smsCodeError = '';
+ // 身份证号输入处理 - 修复:简化逻辑
+ onIdNumberInput(e) {
+ const value = e.detail.value.trim().toUpperCase();
+ let error = '';
+ let showHint = true;
+ let isValid = false;
- if (smsCode && !/^\d{6}$/.test(smsCode)) {
- smsCodeError = '请输入6位数字验证码';
+ if (value) {
+ if (value.length < 18) {
+ error = '还需输入' + (18 - value.length) + '位';
+ } else if (value.length === 18) {
+ if (this.validateIdNumber(value)) {
+ isValid = true;
+ // 验证通过时保持提示显示,但无错误
+ } else {
+ error = '身份证号格式不正确';
+ }
+ }
+ } else {
+ // 内容为空时显示正常提示
+ error = '';
}
this.setData({
- smsCode: smsCode,
- smsCodeError: smsCodeError
+ idNumber: value,
+ idNumberError: error,
+ showIdNumberHint: showHint,
+ isIdNumberValid: isValid
}, () => {
this.checkForm();
});
},
- onCodeFocus() {
- this.setData({ codeFocus: true });
+ onIdNumberFocus() {
+ this.setData({
+ idNumberFocus: true,
+ showIdNumberHint: true // 获得焦点时显示提示
+ });
},
- onCodeBlur() {
- this.setData({ codeFocus: false });
+ onIdNumberBlur() {
+ const { idNumber } = this.data;
+ let error = '';
+ let isValid = false;
+
+ // 最终验证
+ if (idNumber) {
+ if (idNumber.length < 18) {
+ error = '还需输入' + (18 - idNumber.length) + '位';
+ } else if (idNumber.length === 18) {
+ if (this.validateIdNumber(idNumber)) {
+ isValid = true;
+ } else {
+ error = '身份证号格式不正确';
+ }
+ }
+ }
+
+ this.setData({
+ idNumberFocus: false,
+ idNumberError: error,
+ isIdNumberValid: isValid,
+ // 失去焦点时,如果内容为空或验证失败,保持提示显示
+ showIdNumberHint: !!(idNumber && !isValid)
+ });
},
- // 检查是否可以发送验证码
- checkCanSendCode() {
- const { name, phone, nameError, phoneError } = this.data;
- const canSendCode = name && phone && !nameError && !phoneError;
- this.setData({ canSendCode });
+ // 清除身份证号
+ clearIdNumber() {
+ this.setData({
+ idNumber: '',
+ idNumberError: '',
+ showIdNumberHint: false,
+ isIdNumberValid: false
+ }, () => {
+ this.checkForm();
+ });
},
- // 发送验证码
- async sendSmsCode() {
- const { name, phone, countdown } = this.data;
+ // 身份证验证函数
+ validateIdNumber(idNumber) {
+ // 基础格式验证
+ if (!/^\d{17}[\dXx]$/.test(idNumber)) {
+ return false;
+ }
- if (countdown > 0) return;
+ // 地区码验证(简化的验证,实际应该更严谨)
+ const areaCode = idNumber.substring(0, 2);
+ const validAreaCodes = ['11', '12', '13', '14', '15', '21', '22', '23',
+ '31', '32', '33', '34', '35', '36', '37', '41',
+ '42', '43', '44', '45', '46', '50', '51', '52',
+ '53', '54', '61', '62', '63', '64', '65'];
- // 验证手机号格式
- if (!/^1[3-9]\d{9}$/.test(phone)) {
- this.setData({ phoneError: '请输入正确的手机号码' });
- return;
+ if (!validAreaCodes.includes(areaCode)) {
+ return false;
}
- // 显示加载
- wx.showLoading({
- title: '发送中...',
- mask: true
- });
-
- try {
- // 模拟发送验证码请求
- await new Promise(resolve => setTimeout(resolve, 1500));
-
- wx.hideLoading();
-
- // 发送成功
- wx.showToast({
- title: '验证码已发送',
- icon: 'success',
- duration: 2000
- });
-
- // 开始倒计时
- this.startCountdown();
-
- } catch (error) {
- wx.hideLoading();
- wx.showToast({
- title: '发送失败,请重试',
- icon: 'error',
- duration: 2000
- });
+ // 出生日期验证
+ const year = parseInt(idNumber.substring(6, 10));
+ const month = parseInt(idNumber.substring(10, 12));
+ const day = parseInt(idNumber.substring(12, 14));
+
+ const currentYear = new Date().getFullYear();
+ if (year < 1900 || year > currentYear) return false;
+ if (month < 1 || month > 12) return false;
+ if (day < 1 || day > 31) return false;
+
+ // 校验码验证
+ const checkCode = idNumber.charAt(17).toUpperCase();
+ const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
+ const checkCodes = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'];
+
+ let sum = 0;
+ for (let i = 0; i < 17; i++) {
+ sum += parseInt(idNumber.charAt(i)) * weights[i];
}
- },
-
- // 开始倒计时
- startCountdown() {
- this.setData({ countdown: 60 });
- const timer = setInterval(() => {
- let { countdown } = this.data;
- countdown--;
-
- if (countdown <= 0) {
- clearInterval(timer);
- this.setData({
- countdown: 0,
- countdownTimer: null
- });
- } else {
- this.setData({
- countdown: countdown,
- countdownTimer: timer
- });
- }
- }, 1000);
+ const mod = sum % 11;
+ return checkCode === checkCodes[mod];
},
// 协议处理
toggleAgreement() {
+ const newAgreed = !this.data.agreed;
this.setData({
- agreed: !this.data.agreed
+ agreed: newAgreed
}, () => {
this.checkForm();
});
},
- viewAgreement() {
- wx.navigateTo({
- url: '/pages/web-view/web-view?url=' + encodeURIComponent('https://your-domain.com/agreement')
- });
+ // 显示协议弹窗
+ showAgreementModal() {
+ const title = '用户服务协议';
+ const content = `欢迎您使用"与牧同行"服务!\n\n在使用我们的服务前,请您仔细阅读并同意以下协议:\n\n1. 服务条款\n您在使用与牧同行提供的各项服务时,应当遵守相关法律法规,不得从事任何非法行为。\n\n2. 用户责任\n您需要保证所提供信息的真实性、准确性和完整性。\n\n3. 服务变更\n我们保留随时修改、暂停或终止服务的权利。\n\n4. 免责声明\n在法律法规允许的最大范围内,我们对因使用服务而产生的任何间接损失不承担责任。\n\n5. 法律适用\n本协议的订立、执行和解释及争议的解决均适用中华人民共和国法律。\n\n请您确保已阅读并理解以上条款。`;
+
+ this.showModal(title, content);
},
- viewPrivacy() {
- wx.navigateTo({
- url: '/pages/web-view/web-view?url=' + encodeURIComponent('https://your-domain.com/privacy')
+ // 显示隐私弹窗
+ showPrivacyModal() {
+ const title = '隐私保护协议';
+ const content = `我们非常重视您的隐私保护,请您仔细阅读以下隐私政策:\n\n1. 信息收集\n我们仅收集为您提供服务所必需的信息,包括姓名、身份证号等实名信息。\n\n2. 信息使用\n您的信息仅用于身份验证和服务提供,不会用于其他商业用途。\n\n3. 信息保护\n我们采用先进的安全技术保护您的信息,防止未经授权的访问、使用或泄露。\n\n4. 信息共享\n除非获得您的明确同意,我们不会向第三方共享您的个人信息。\n\n5. 您的权利\n您可以随时查看、更正或删除您的个人信息。\n\n6. 政策更新\n我们可能会不时更新本隐私政策,更新后的政策将在本页面公布。\n\n我们承诺严格遵守相关法律法规,保护您的个人信息安全。`;
+
+ this.showModal(title, content);
+ },
+
+ // 显示弹窗
+ showModal(title, content) {
+ this.setData({
+ modalTitle: title,
+ modalContent: content,
+ showModal: true
});
},
+ // 关闭弹窗
+ closeModal() {
+ this.setData({ showModal: false });
+ },
+
+ // 阻止事件冒泡
+ stopPropagation(e) {
+ // 阻止冒泡
+ },
+
// 检查表单
checkForm() {
const {
- name,
- phone,
- smsCode,
- nameError,
- phoneError,
- smsCodeError,
+ isNameValid,
+ isIdNumberValid,
agreed
} = this.data;
- const isValid = name &&
- phone &&
- smsCode &&
- !nameError &&
- !phoneError &&
- !smsCodeError &&
+ const isValid = isNameValid &&
+ isIdNumberValid &&
agreed;
this.setData({
@@ -244,56 +296,70 @@ Page({
async submitAuth() {
if (!this.data.canSubmit || this.data.isSubmitting) return;
- this.setData({ isSubmitting: true });
-
- // 验证数据
- const { name, phone, smsCode } = this.data;
-
// 最终验证
+ const { name, idNumber } = this.data;
+
if (!/^[\u4e00-\u9fa5]{2,10}$/.test(name)) {
this.setData({
nameError: '姓名应为2-10个汉字',
- isSubmitting: false
+ showNameHint: true,
+ canSubmit: false
});
return;
}
- if (!/^1[3-9]\d{9}$/.test(phone)) {
+ if (!this.validateIdNumber(idNumber)) {
this.setData({
- phoneError: '请输入正确的手机号码',
- isSubmitting: false
+ idNumberError: '身份证号格式不正确',
+ showIdNumberHint: true,
+ canSubmit: false
});
return;
}
+
+ this.setData({
+ isSubmitting: true,
+ currentStep: 2,
+ lineProgress1: 100,
+ lineProgress2: 50
+ });
- if (!/^\d{6}$/.test(smsCode)) {
- this.setData({
- smsCodeError: '请输入6位数字验证码',
- isSubmitting: false
- });
- return;
- }
+ // 显示加载动画
+ wx.showLoading({
+ title: '正在验证...',
+ mask: true
+ });
try {
// 模拟API请求
- await new Promise(resolve => setTimeout(resolve, 2000));
+ await new Promise(resolve => setTimeout(resolve, 1500));
- // 提交成功
- this.setData({
- isSubmitting: false,
- showSuccessModal: true
- });
+ wx.hideLoading();
+
+ // 处理身份证号脱敏显示
+ const maskedId = idNumber.substring(0, 4) + '**********' + idNumber.substring(14);
+
+ // 显示成功弹窗
+ this.showSuccessModal(maskedId);
- // 保存认证信息到本地
+ // 保存认证信息
wx.setStorageSync('realNameAuth', {
name: name,
- phone: phone,
+ idNumber: idNumber,
certified: true,
certifiedTime: new Date().getTime()
});
+ this.setData({
+ isSubmitting: false,
+ currentStep: 3,
+ lineProgress2: 100
+ });
+
} catch (error) {
+ wx.hideLoading();
this.setData({ isSubmitting: false });
+
wx.showToast({
title: '认证失败,请重试',
icon: 'error',
@@ -302,7 +368,15 @@ Page({
}
},
- // 成功弹窗处理
+ // 显示成功弹窗
+ showSuccessModal(maskedId) {
+ this.setData({
+ maskedIdNumber: maskedId,
+ showSuccessModal: true
+ });
+ },
+
+ // 关闭成功弹窗
closeSuccessModal() {
this.setData({ showSuccessModal: false });
},
@@ -311,7 +385,7 @@ Page({
goToHome() {
this.closeSuccessModal();
wx.switchTab({
- url: '/pages/index/index'
+ url: '/pages/personal/personal'
});
}
});
\ No newline at end of file
diff --git a/pagesA/pages/attestation/attestation.wxml b/pagesA/pages/attestation/attestation.wxml
index b86f3a7..574a145 100644
--- a/pagesA/pages/attestation/attestation.wxml
+++ b/pagesA/pages/attestation/attestation.wxml
@@ -1,185 +1,261 @@
-
-
-
-
-
-
+
+
+
+
+
-
-