开始做登录
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import { login } from "../../service/user"
|
||||
import { alertError, loadingFunc, wxLogin } from "../../utils/index"
|
||||
import { OK } from "../../utils/request"
|
||||
// pages/login/index.js
|
||||
Page({
|
||||
|
||||
@@ -21,7 +24,23 @@ Page({
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
onClose() {
|
||||
wx.exitMiniProgram()
|
||||
},
|
||||
onConfirm() {
|
||||
this.handleLogin()
|
||||
},
|
||||
async handleLogin() {
|
||||
loadingFunc(async () => {
|
||||
const wxLoginCode = await wxLogin()
|
||||
const { code, message, data } = await login({ code: wxLoginCode })
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
}
|
||||
console.log('data', data)
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
|
Reference in New Issue
Block a user