我的页面

This commit is contained in:
姚亚男
2021-10-11 16:49:22 +08:00
parent e4e2740c0b
commit 224833685d
28 changed files with 216 additions and 5738 deletions
+27 -15
View File
@@ -1,6 +1,6 @@
// pages/mine/mine.js
import UserApi from '../../assets/js/http/userApi'
import {JSEncrypt} from '../../assets/js/jsencrypt/jsencrypt'
import { encrypt } from '../../assets/js/jsencrypt/rsa'
var countdown = 60; // 倒计时秒数
Page({
data: {
@@ -65,26 +65,37 @@ Page({
},
// 登录
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), // 手机号加密
username: encrypt(this.data.rsaPublicKey,e.detail.value.phone), // 手机号加密
captcha: e.detail.value.captcha,
rsaPublicKey: this.data.rsaPublicKey
}
// 请求短信登录start
UserApi.codeLogin(params).then(res => {
if (res.success) {
wx.hideLoading()
// 存token和userInfo
wx.setStorage({
key: 'X-Access-Token',
data: res.result.token
})
wx.setStorage({
key: 'userInfo',
data: res.result.userInfo
})
if(res.message === "updatePassword") {
// 跳转设置密码页
wx.navigateTo({
url: '../setPassword/setPassword',
})
}else{
// 跳转设置密码页
wx.switchTab({
url: '../home/home',
})
}
} else {
wx.hideLoading()
wx.showToast({
title: '登录失败',
icon: 'error',
@@ -99,9 +110,6 @@ Page({
icon: 'none',
duration: 2000
})
wx.navigateTo({
url: '../setPassword/setPassword',
})
}
},
@@ -128,6 +136,10 @@ Page({
this.setData({
rsaPublicKey: res.result
})
wx.setStorage({
key: 'rsaPublicKey',
data: res.result
})
}
})
},