【修改】注册联调

This commit is contained in:
fengachen
2021-12-17 20:34:27 +08:00
parent 2b9c882ad2
commit b32c9edb24
3 changed files with 89 additions and 36 deletions
+3 -1
View File
@@ -72,7 +72,9 @@ const UserApi = {
// 获取用户的信息
getUserInfo: (params) => http.get(`${URL_CONFIG}sys/user/queryById`, params),
// 注册
registerUser: (params) => http.post(`${URL_CONFIG}sys/user/register`, params),
registerUser: (params) => http.post(`${URL_CONFIG}home/registerSelf`, params),
// 手机号唯一校验
checkPhoneOnly: (params) => http.get(`${URL_CONFIG}/sys/duplicate/check`, params),
}
export default UserApi
+85 -34
View File
@@ -70,21 +70,21 @@ Page({
return
}
// 手机号
if (this.data.currentInfo.phone === '' || this.data.currentInfo.phone === null || this.data.currentInfo.phone === undefined) {
wx.showToast({
title: '请输入手机号',
icon: 'none',
duration: 800
})
return
} else if (this.data.currentInfo.phone && !phoneReg(this.data.currentInfo.phone)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none',
duration: 800
})
return
}
// if (this.data.currentInfo.phone === '' || this.data.currentInfo.phone === null || this.data.currentInfo.phone === undefined) {
// wx.showToast({
// title: '请输入手机号',
// icon: 'none',
// duration: 800
// })
// return
// } else if (this.data.currentInfo.phone && !phoneReg(this.data.currentInfo.phone)) {
// wx.showToast({
// title: '请输入正确的手机号',
// icon: 'none',
// duration: 800
// })
// return
// }
// 性别
if (this.data.currentInfo.gender === '' || this.data.currentInfo.gender === null || this.data.currentInfo.gender === undefined) {
@@ -123,16 +123,27 @@ Page({
})
return
}
let formData = Object.assign({},this.data.prePageData,this.data.currentInfo,this.data.selectedCompany)
formData.post = e.detail.value.post.trim()
formData.remarks = e.detail.value.remarks.trim()
let formData = {}
let currentPageInfo = Object.assign({},this.data.currentInfo,this.data.selectedCompany)
// this.data.prePageData,
currentPageInfo.post = e.detail.value.post.trim()
currentPageInfo.remarks = e.detail.value.remarks.trim()
// 上一步的的数据加密
formData.rsaPublicKey = this.data.rsaPublicKey
formData.phone = encrypt(this.data.rsaPublicKey,formData.phone),
formData.password = encrypt(this.data.rsaPublicKey,formData.password),
formData.confirmPassword = encrypt(this.data.rsaPublicKey,formData.confirmPassword),
formData.verifyCode =this.data.prePageData.verifyCode
formData.phone = encrypt(this.data.rsaPublicKey,this.data.prePageData.phone),
formData.password = encrypt(this.data.rsaPublicKey,this.data.prePageData.password),
formData.verifyPassword = encrypt(this.data.rsaPublicKey,this.data.prePageData.verifyPassword),
formData.payContactsManagement = currentPageInfo
// formData.payContactsManagement
console.log('表单提交的数据',formData);
UserApi.registerUser(formData).then(res => {
console.log(res);
wx.showToast({
title: res.result,
icon:none,
duration:800
})
wx.navigateTo({
url: '../login/login',
success(){
@@ -176,7 +187,7 @@ Page({
return
}
// 再次校准验证码
if (this.data.prePageData.captcha === '' || this.data.prePageData.captcha === null || this.data.prePageData.captcha === undefined) {
if (this.data.prePageData.verifyCode === '' || this.data.prePageData.verifyCode === null || this.data.prePageData.verifyCode === undefined) {
wx.showToast({
title: '请输入验证码',
icon: 'none',
@@ -202,14 +213,14 @@ Page({
}
// 再次校准确认密码
if (this.data.prePageData.confirmPassword === '' || this.data.prePageData.confirmPassword === null || this.data.prePageData.confirmPassword === undefined) {
if (this.data.prePageData.verifyPassword === '' || this.data.prePageData.verifyPassword === null || this.data.prePageData.verifyPassword === undefined) {
wx.showToast({
title: '请输入确认密码',
icon: 'none',
duration: 800
})
return
} else if (this.data.prePageData.phone && this.data.prePageData.password !== this.data.prePageData.confirmPassword) {
} else if (this.data.prePageData.password && this.data.prePageData.password !== this.data.prePageData.verifyPassword) {
wx.showToast({
title: '密码与确认密码不一致',
icon: 'none',
@@ -255,12 +266,23 @@ Page({
})
},
// 获取验证码
getVerCode() {
async getVerCode() {
console.log(this.data.phone);
// let flag = await this.checkPhoneOnly(this.data.value)
if(!this.data.phone){
// wx.showToast({
// title: '手机号已存在',
// icon: 'none',
// duration: 2000
// })
return
}
countdown = 60
if (/^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.phone)) {
UserApi.sendCode({
phone: this.data.phone,
codeType: 1
codeType: 3
}).then(res => {
// 获取成功,倒计时 start
if (res.success) {
@@ -315,7 +337,7 @@ Page({
// 倒计时 end
},
// 校验手机号
validatePhone(e) {
async validatePhone(e) {
let value = e.detail.value
this.setData({
phone: value,
@@ -333,9 +355,24 @@ Page({
})
return
} else if (phoneReg(value)) {
this.setData({
'prePageData.phone': value
})
let flag = await this.checkPhoneOnly(value)
console.log(flag);
if(flag){
this.setData({
'prePageData.phone': value,
'phone':value
})
}else{
wx.showToast({
title: '手机号已存在',
icon: 'none',
duration: 800
})
this.setData({
'phone': ''
})
}
} else {
wx.showToast({
title: errmsg,
@@ -345,11 +382,25 @@ Page({
}
},
// 判断手机号是否存在
checkPhoneOnly(value){
return new Promise(resolve => {
// 校验手机号是否存在
const param = {
confusionCode: 'pay_contacts_management_phone',
fieldVal: value,
encrypt: 1
}
UserApi.checkPhoneOnly(param).then(res => {
resolve(res.success)
})
})
},
// 校验验证码
validateVerCode(e) {
let value = e.detail.value
this.setData({
'prePageData.captcha': value
'prePageData.verifyCode': value
})
let {
message,
@@ -365,7 +416,7 @@ Page({
} else {
this.setData({
captcha: value,
'prePageData.captcha': value
'prePageData.verifyCode': value
})
}
@@ -543,7 +594,7 @@ Page({
console.log(e);
let value = e.detail.value
this.setData({
'prePageData.confirmPassword': value
'prePageData.verifyPassword': value
})
let {
message,
@@ -559,7 +610,7 @@ Page({
} else if (e.detail.value === this.data.password) {
this.setData({
confirmPassword: value,
'prePageData.confirmPassword': value
'prePageData.verifyPassword': value
})
} else {
wx.showToast({
+1 -1
View File
@@ -91,7 +91,7 @@
<view class="item" wx:if="{{currentTab === 2}}">
<view class="label validate">手机号</view>
<view class="value">
<input name="phone2" bindblur="validatePhoneCurent" data-type="phone" data-message='请输入手机号' data-errmsg='请输入正确的手机号' type="number" maxlength="11" value="{{currentInfo.phone}}" placeholder="请输入手机号" />
<input name="phone" bindblur="validatePhoneCurent" disabled data-type="phone" data-message='请输入手机号' data-errmsg='请输入正确的手机号' type="number" maxlength="11" value="{{prePageData.phone}}" placeholder="请输入手机号" />
</view>
</view>