diff --git a/pages/mine/edit-info.vue b/pages/mine/edit-info.vue
index 083d142..1f5ac74 100644
--- a/pages/mine/edit-info.vue
+++ b/pages/mine/edit-info.vue
@@ -3,24 +3,24 @@
-
+
+
- {{userInfo.name}}
+
-
+
+
- {{userInfo.idcard}}
+
-
+
+
- {{userInfo.contact_mobile}}
+
@@ -31,13 +31,12 @@
-
+
- {{userInfo.birthday}}
-
+ {{userInfo.birthday}}
-
+
@@ -55,40 +54,39 @@
-
- {{userInfo.to_province_name}}-{{userInfo.to_city_name}}-{{userInfo.to_area_name}}
-
-
-
-
- {{userInfo.reside_province_name}}-{{userInfo.reside_city_name}}-{{userInfo.reside_area_name}}
+ {{userInfo.to_province_name}}{{userInfo.to_city_name}}{{userInfo.to_area_name}}
-
+
+
- {{userInfo.detail}}
+ {{userInfo.reside_province_name}}{{userInfo.reside_city_name}}{{userInfo.reside_area_name}}
-
-
- {{userInfo.join_time}}
-
+
+
+
+
-
+
-
+
- {{userInfo.retire_time}}
-
+ {{userInfo.join_time}}
-
+
+
+
+
+ {{userInfo.retire_time}}
+
+
@@ -104,10 +102,10 @@
-
+
+
- {{userInfo.purpose}}
+
@@ -119,36 +117,23 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -170,6 +155,10 @@
},
data() {
return {
+ birth: false,
+ joinTime: false,
+ retireTime: false,
+ value1: Number(new Date()),
userInfo: {
code: "", //登录code
org_id: "", //机构ID 默认1
@@ -226,11 +215,11 @@
},
isPickerVisible: false, // 控制选择器显示状态
selectedAddress: '', // 存储选择的地址
- pageType: 'edit'
+ pageType: 'edit',
}
},
onLoad(options) {
- console.log(options,'');
+ console.log(options, '');
if (options.type && options.type == 'register') {
this.userInfo.org_id = 1
this.userInfo.code = options.code
@@ -247,7 +236,25 @@
}
},
+ onReady() {
+
+ // 微信小程序需要用此写法
+ this.$refs.datetimePicker.setFormatter(this.formatter)
+ },
+
methods: {
+ formatter(type, value) {
+ if (type === 'year') {
+ return `${value}年`
+ }
+ if (type === 'month') {
+ return `${value}月`
+ }
+ if (type === 'day') {
+ return `${value}日`
+ }
+ return value
+ },
getPreInfo() {
uni.showLoading({
title: '加载中...'
@@ -356,9 +363,36 @@
}
})
},
+ formatDate(timestamp) {
+ const date = new Date(timestamp);
+
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以要加1
+ const day = String(date.getDate()).padStart(2, '0');
+
+ return `${year}-${month}-${day}`;
+ },
// 修改生日
handleBirth() {
- this.$refs.birth.show()
+ this.birth = true
+ },
+ birthConfirm(e) {
+ this.birth = false
+ this.userInfo.birthday = this.formatDate(e.value)
+ },
+ handlejoinTime() {
+ this.joinTime = true
+ },
+ joinTimeConfirm(e) {
+ this.joinTime = false
+ this.userInfo.join_time = this.formatDate(e.value)
+ },
+ handleretireTime() {
+ this.retireTime = true
+ },
+ retireTimeConfirm(e) {
+ this.retireTime = false
+ this.userInfo.retire_time = this.formatDate(e.value)
},
// 修改情感
handleEmotion() {
@@ -456,9 +490,9 @@
})
return
}
- if (!that.userInfo.contact_mobile) {
+ if (!that.isValidIDCard(that.userInfo.idcard)) {
uni.showToast({
- title: '请输入手机号',
+ title: '身份证格式错误',
icon: 'none'
})
return
@@ -470,6 +504,13 @@
})
return
}
+ if (!that.isValidPhoneNumber(that.userInfo.contact_mobile)) {
+ uni.showToast({
+ title: '手机号格式错误',
+ icon: 'none'
+ })
+ return
+ }
if (!that.userInfo.sex) {
uni.showToast({
title: '请选择性别',
@@ -560,37 +601,47 @@
that.userInfo.name = rsaEncrypt(that.userInfo.name);
that.userInfo.idcard = rsaEncrypt(that.userInfo.idcard);
that.userInfo.contact_mobile = rsaEncrypt(that.userInfo.contact_mobile);
- infoEdit(that.userInfo).then(res => {
- uni.hideLoading()
- if (res.code == 0) {
- uni.showLoading({
- title: '提交成功',
- icon: 'none'
- })
- if (that.pageType == 'edit') {
+ if (that.pageType == 'edit') {
+ infoEdit(that.userInfo).then(res => {
+ uni.hideLoading()
+ if (res.code == 0) {
+ uni.showToast({
+ title: '提交成功',
+ icon: 'none'
+ })
setTimeout(() => {
uni.navigateBack({
delta: 1
})
}, 400)
} else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
+ }
+ })
+ } else {
+ register(that.userInfo).then(res => {
+ uni.hideLoading()
+ if (res.code == 0) {
+ uni.showToast({
+ title: '提交成功',
+ icon: 'none'
+ })
setTimeout(() => {
uni.reLaunch({
url: '/pages/home/home'
})
}, 400)
+ } else {
+ uni.showToast({
+ title: res.msg,
+ icon: 'none'
+ })
}
-
- } else {
- uni.showLoading({
- title: res.msg,
- icon: 'none'
- })
- }
- })
-
-
-
+ })
+ }
}
}
diff --git a/utils/lib/code.js b/utils/lib/code.js
index 329548a..f30744b 100644
--- a/utils/lib/code.js
+++ b/utils/lib/code.js
@@ -18,7 +18,8 @@ function codes() {
uni.reLaunch({
url: '/pages/home/home'
})
- } else {
+ }
+ else {
uni.reLaunch({
url: '/pages/mine/edit-info?type=register' + '&code=' + res.code
})