修改登录逻辑,新增获取手机号的权限
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { login } from "../../service/user"
|
||||
import { alertError, loadingFunc, wxLogin } from "../../utils/index"
|
||||
import { alertError, alertInfo, loadingFunc, wxLogin } from "../../utils/index"
|
||||
import { OK } from "../../utils/request"
|
||||
// pages/login/index.js
|
||||
Page({
|
||||
@@ -25,15 +25,15 @@ Page({
|
||||
|
||||
},
|
||||
onClose() {
|
||||
wx.exitMiniProgram()
|
||||
// wx.exitMiniProgram()
|
||||
},
|
||||
onConfirm() {
|
||||
this.handleLogin()
|
||||
},
|
||||
async handleLogin() {
|
||||
// onConfirm() {
|
||||
// this.handleLogin()
|
||||
// },
|
||||
async handleLogin(phoneCode) {
|
||||
loadingFunc(async () => {
|
||||
const wxLoginCode = await wxLogin()
|
||||
const { code, message, data } = await login({ code: wxLoginCode })
|
||||
const { code, message, data } = await login({ code: wxLoginCode, phoneCode })
|
||||
if (code !== OK) {
|
||||
alertError(message)
|
||||
return
|
||||
@@ -41,6 +41,27 @@ Page({
|
||||
console.log('data', data)
|
||||
})
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
const { errno, code: phoneCode } = e.detail;
|
||||
console.log('errno', errno, 'phoneCode', phoneCode)
|
||||
switch(errno) {
|
||||
case 103:
|
||||
alertInfo("已拒绝");
|
||||
setTimeout(() => {
|
||||
wx.exitMiniProgram()
|
||||
}, 100)
|
||||
return;
|
||||
break;
|
||||
case 1400001:
|
||||
alertInfo("服务达到上限")
|
||||
setTimeout(() => {
|
||||
wx.exitMiniProgram()
|
||||
}, 100)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
this.handleLogin(phoneCode)
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
|
Reference in New Issue
Block a user