1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

小程序登录逻辑跑通;登陆密码MD5存储;小程序首页添加调试输出

This commit is contained in:
2022-11-24 02:06:50 +08:00
parent d28fa0dd00
commit 08bab25a48
9 changed files with 161 additions and 61 deletions

View File

@@ -22,6 +22,7 @@
<script>
import Taro from '@tarojs/taro'
import md5 from 'blueimp-md5'
import './login.css'
@@ -42,40 +43,45 @@ export default {
duration: 2000
})
} else {
let passwordHash = md5(this.password);
Taro.request({
url: `${this.baseUrl}/user/login`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
username: this.username,
password: this.password,
password: passwordHash,
},
success: function (d) {
let data = d.data;
if (data.code == 200) {
if (data.status == "success") {
Taro.setStorageSync("userInfo", data.userInfo);
console.log("userInfo", Taro.getStorageSync("userInfo"))
Taro.showToast({
title: "登录成功",
icon: 'success',
success: function () {
Taro.redirectTo({
url: '/pages/index/index'
})
}
})
} else {
Taro.showToast({
title: data.msg,
icon: 'error'
})
}
let result = d.data;
if (result.success) {
Taro.setStorageSync("userInfo", result.data.userInfo);
console.log("userInfo", Taro.getStorageSync("userInfo"))
Taro.showToast({
title: "登录成功",
icon: 'success',
success: function () {
Taro.redirectTo({
url: '/pages/index/index'
})
}
})
} else {
Taro.showToast({
title: data.msg,
title: result.msg,
icon: 'error',
duration: 2000
})
}
},
fail: function () {
Taro.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
}
})
}