From e5c9a96353f4c721cc2eeb5bc6b7149e9c5f2363 Mon Sep 17 00:00:00 2001 From: qiaomu <3520484422@qq.com> Date: Mon, 18 Mar 2024 13:46:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E5=8F=B7=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 2 +- components/select/index.js | 5 +++-- pages/login/index.js | 35 ++++++++++++++++++++++++++++------- pages/login/index.wxml | 2 ++ pages/my/index.json | 7 ++++--- pages/my/index.wxml | 13 ++++++++++--- 6 files changed, 48 insertions(+), 16 deletions(-) diff --git a/app.json b/app.json index 4f4e555..870b1af 100644 --- a/app.json +++ b/app.json @@ -1,9 +1,9 @@ { "pages": [ "pages/login/index", + "pages/my/index", "pages/recharge/index", "pages/rechargeRecord/index", - "pages/my/index", "pages/questions/index", "pages/meterList/index", "pages/home/index", diff --git a/components/select/index.js b/components/select/index.js index df2bfd0..d6f0eaf 100644 --- a/components/select/index.js +++ b/components/select/index.js @@ -34,11 +34,12 @@ Component({ }) }, onChoose(e) { - console.log('e', e) const { data = {} } = e.currentTarget.dataset; + console.log('data', data) this.setData({ - visible + visible: false }) + this.triggerEvent("choose", data) } } }) \ No newline at end of file diff --git a/pages/login/index.js b/pages/login/index.js index 2ecdd38..4db4151 100644 --- a/pages/login/index.js +++ b/pages/login/index.js @@ -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) + }, /** * 生命周期函数--监听页面显示 */ diff --git a/pages/login/index.wxml b/pages/login/index.wxml index c13053e..4db36f3 100644 --- a/pages/login/index.wxml +++ b/pages/login/index.wxml @@ -7,6 +7,8 @@ show-cancel-button bind:close="onClose" bind:confirm="onConfirm" + confirm-button-open-type="getPhoneNumber" + bind:getphonenumber="getPhoneNumber" > 使用本系统,代表您已阅读并同意 《用电管理服务条款》《用电管理登录政策》《隐私政策》。 diff --git a/pages/my/index.json b/pages/my/index.json index 8a6d015..c959eb7 100644 --- a/pages/my/index.json +++ b/pages/my/index.json @@ -1,6 +1,7 @@ { "usingComponents": { - "navigator": "/components/navigator/index", - "cell": "/components/cell/index" - } + "van-cell": "@vant/weapp/cell/index", + "van-cell-group": "@vant/weapp/cell-group/index" + }, + "navigationBarTitleText": "我的" } \ No newline at end of file diff --git a/pages/my/index.wxml b/pages/my/index.wxml index 902bf6a..3dadaad 100644 --- a/pages/my/index.wxml +++ b/pages/my/index.wxml @@ -1,4 +1,11 @@ - - - \ No newline at end of file + + + + + + + + + \ No newline at end of file