From 978acb877b16a5ef58b902f1a82657d39c8199e9 Mon Sep 17 00:00:00 2001 From: linju Date: Mon, 20 Feb 2023 14:29:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E9=9D=9E=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=E6=8A=A5`TypeErro?= =?UTF-8?q?r:=20uni.hideHomeButton=20is=20not=20a=20function`=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-id-pages/changelog.md | 2 + .../uni-id-pages/common/login-page.mixin.js | 40 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/uni_modules/uni-id-pages/changelog.md b/uni_modules/uni-id-pages/changelog.md index bb8c7db..69697f4 100644 --- a/uni_modules/uni-id-pages/changelog.md +++ b/uni_modules/uni-id-pages/changelog.md @@ -1,3 +1,5 @@ +## 1.1.3(2023-02-13) +- 修复 非微信小程序端报`TypeError: uni.hideHomeButton is not a function`的问题 ## 1.1.2(2023-02-10) - 新增 微信小程序端 首页需强制登录时,隐藏返回首页按钮 - uni-id-co 新增 外部联登后修改用户信息接口(updateUserInfoByExternal) [文档](https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#external-update-userinfo) diff --git a/uni_modules/uni-id-pages/common/login-page.mixin.js b/uni_modules/uni-id-pages/common/login-page.mixin.js index cff4071..35e5030 100644 --- a/uni_modules/uni-id-pages/common/login-page.mixin.js +++ b/uni_modules/uni-id-pages/common/login-page.mixin.js @@ -1,9 +1,8 @@ -import { - store, - mutations - } from '@/uni_modules/uni-id-pages/common/store.js' +import { + mutations +} from '@/uni_modules/uni-id-pages/common/store.js' import config from '@/uni_modules/uni-id-pages/config.js' -let mixin = { +const mixin = { data() { return { config, @@ -17,7 +16,7 @@ let mixin = { // #endif }, mounted() { - this.isMounted = true; + this.isMounted = true }, onLoad(e) { if (e.is_weixin_redirect) { @@ -25,12 +24,12 @@ let mixin = { mask: true }) - if( window.location.href.includes('#') ){ + if (window.location.href.includes('#')) { // 将url通过 ? 分割获取后面的参数字符串 再通过 & 将每一个参数单独分割出来 - let paramsArr = window.location.href.split('?')[1].split('&') - paramsArr.forEach(item=>{ - let arr = item.split('=') - if(arr[0] == 'code'){ + const paramsArr = window.location.href.split('?')[1].split('&') + paramsArr.forEach(item => { + const arr = item.split('=') + if (arr[0] == 'code') { e.code = arr[1] } }) @@ -38,19 +37,21 @@ let mixin = { this.$nextTick(n => { // console.log(this.$refs.uniFabLogin); this.$refs.uniFabLogin.login({ - code:e.code + code: e.code }, 'weixin') }) } if (e.uniIdRedirectUrl) { this.uniIdRedirectUrl = decodeURIComponent(e.uniIdRedirectUrl) - } - - if(getCurrentPages().length === 1){ - uni.hideHomeButton() - console.log('已隐藏:返回首页按钮'); - } + } + + // #ifdef MP-WEIXIN + if (getCurrentPages().length === 1) { + uni.hideHomeButton() + console.log('已隐藏:返回首页按钮'); + } + // #endif }, computed: { needAgreements() { @@ -90,4 +91,5 @@ let mixin = { } } } -export default mixin + +export default mixin -- GitLab