修改登录逻辑,新增获取手机号的权限

This commit is contained in:
qiaomu 2024-03-18 13:46:38 +08:00
parent 633cff358d
commit e5c9a96353
6 changed files with 48 additions and 16 deletions

View File

@ -1,9 +1,9 @@
{ {
"pages": [ "pages": [
"pages/login/index", "pages/login/index",
"pages/my/index",
"pages/recharge/index", "pages/recharge/index",
"pages/rechargeRecord/index", "pages/rechargeRecord/index",
"pages/my/index",
"pages/questions/index", "pages/questions/index",
"pages/meterList/index", "pages/meterList/index",
"pages/home/index", "pages/home/index",

View File

@ -34,11 +34,12 @@ Component({
}) })
}, },
onChoose(e) { onChoose(e) {
console.log('e', e)
const { data = {} } = e.currentTarget.dataset; const { data = {} } = e.currentTarget.dataset;
console.log('data', data)
this.setData({ this.setData({
visible visible: false
}) })
this.triggerEvent("choose", data)
} }
} }
}) })

View File

@ -1,5 +1,5 @@
import { login } from "../../service/user" 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" import { OK } from "../../utils/request"
// pages/login/index.js // pages/login/index.js
Page({ Page({
@ -25,15 +25,15 @@ Page({
}, },
onClose() { onClose() {
wx.exitMiniProgram() // wx.exitMiniProgram()
}, },
onConfirm() { // onConfirm() {
this.handleLogin() // this.handleLogin()
}, // },
async handleLogin() { async handleLogin(phoneCode) {
loadingFunc(async () => { loadingFunc(async () => {
const wxLoginCode = await wxLogin() const wxLoginCode = await wxLogin()
const { code, message, data } = await login({ code: wxLoginCode }) const { code, message, data } = await login({ code: wxLoginCode, phoneCode })
if (code !== OK) { if (code !== OK) {
alertError(message) alertError(message)
return return
@ -41,6 +41,27 @@ Page({
console.log('data', data) 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)
},
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */

View File

@ -7,6 +7,8 @@
show-cancel-button show-cancel-button
bind:close="onClose" bind:close="onClose"
bind:confirm="onConfirm" bind:confirm="onConfirm"
confirm-button-open-type="getPhoneNumber"
bind:getphonenumber="getPhoneNumber"
> >
<view class="confirmWrapper"> <view class="confirmWrapper">
使用本系统,代表您已阅读并同意 <text class="agreementText">《用电管理服务条款》</text>、<text class="agreementText">《用电管理登录政策》</text><text class="agreementText">《隐私政策》</text>。 使用本系统,代表您已阅读并同意 <text class="agreementText">《用电管理服务条款》</text>、<text class="agreementText">《用电管理登录政策》</text><text class="agreementText">《隐私政策》</text>。

View File

@ -1,6 +1,7 @@
{ {
"usingComponents": { "usingComponents": {
"navigator": "/components/navigator/index", "van-cell": "@vant/weapp/cell/index",
"cell": "/components/cell/index" "van-cell-group": "@vant/weapp/cell-group/index"
} },
"navigationBarTitleText": "我的"
} }

View File

@ -1,4 +1,11 @@
<!--pages/my/index.wxml--> <!--pages/my/index.wxml-->
<navigator title="我的" />
<cell open-type="contact" title="联系客服" borderBottom="{{true}}" /> <!-- <cell open-type="contact" title="联系客服" borderBottom="{{true}}" />
<cell title="常见问题" bind:click="jumpToQuestions" /> <cell title="常见问题" bind:click="jumpToQuestions" /> -->
<van-cell-group title=" ">
<van-cell title="单元格" value="内容" is-link />
</van-cell-group>
<van-cell-group title=" ">
<van-cell title="单元格" value="内容" is-link />
</van-cell-group>