登录,设置密码,修改密码,我的,首页,会议列表(接口逻辑已写,差加密文件的完善,代联调)
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
// pages/mine/mine.js
|
||||
import UserApi from '../../assets/js/http/userApi'
|
||||
import {JSEncrypt} from '../../assets/js/jsencrypt/jsencrypt'
|
||||
var countdown = 60; // 倒计时秒数
|
||||
Page({
|
||||
data: {
|
||||
phone: '',
|
||||
captcha: '',
|
||||
count: 60,
|
||||
rsaPublicKey: '',
|
||||
showGetCaptcha: true
|
||||
},
|
||||
|
||||
bindInputPhone(e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
// 获取验证码
|
||||
getVerCode() {
|
||||
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
|
||||
}).then(res => {
|
||||
// 获取成功,倒计时 start
|
||||
if (res.success) {
|
||||
this.countDown()
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '获取验证码失败',
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
// 倒计时
|
||||
countDown(){
|
||||
if (countdown === 0) {
|
||||
this.setData({
|
||||
showGetCaptcha: true
|
||||
})
|
||||
countdown = 60;
|
||||
return;
|
||||
} else {
|
||||
this.setData({
|
||||
showGetCaptcha: false
|
||||
})
|
||||
countdown--;
|
||||
this.setData({
|
||||
count: countdown
|
||||
})
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.countDown()
|
||||
}, 1000)
|
||||
// 倒计时 end
|
||||
},
|
||||
// 登录
|
||||
formSubmit(e) {
|
||||
console.log('form发生了submit事件,携带数据为:', e.detail.value)
|
||||
if (e.detail.value.phone && e.detail.value.captcha) {
|
||||
wx.showLoading({
|
||||
title: '正在登录...',
|
||||
icon: 'loading'
|
||||
})
|
||||
// 新建JSEncrypt对象
|
||||
let encrypt = new JSEncrypt()
|
||||
encrypt.setPublicKey(this.data.rsaPublicKey) // 公钥加密
|
||||
let params = {
|
||||
username: encrypt.encrypt(e.detail.value.phone), // 手机号加密
|
||||
captcha: e.detail.value.captcha,
|
||||
rsaPublicKey: this.data.rsaPublicKey
|
||||
}
|
||||
// 请求短信登录start
|
||||
UserApi.codeLogin(params).then(res => {
|
||||
if (res.success) {
|
||||
wx.hideLoading()
|
||||
} else {
|
||||
wx.hideLoading()
|
||||
wx.showToast({
|
||||
title: '登录失败',
|
||||
icon: 'error',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
})
|
||||
// 登录失败
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '请输入正确的验证码',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: '../setPassword/setPassword',
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
UserApi.getRSAPublicKey().then(res => {
|
||||
if (res.success) {
|
||||
this.setData({
|
||||
rsaPublicKey: res.result
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user