- 修复 uni-popup-dialog/uni-data-picker keypress.js 中 $once 在 H5 端报错(改用生命周期钩子清理监听) - main.js 补 $delete globalProperties polyfill(z-paging 自动高度逻辑依赖) - App.vue onLaunch 补设备信息初始化,修复 X-Device-Id 恒为 unknown - 68 处 ::v-deep、/deep/ 旧深度选择器替换为 :deep()(含 login-page.scss) - zetank-personalpage 组件 .sync 修饰符改为 v-model:xxx(Vue3 已移除 .sync) - vite.config.js HBuilderX 路径支持 HBUILDERX_HOME 环境变量覆盖 - 根 package.json 清理 image-grid 插件遗留元数据 - 收录此前未提交的 uView Vue3 兜底补丁(common/uview-init.js 及各组件 props.js)
299 lines
8.1 KiB
Vue
299 lines
8.1 KiB
Vue
<!-- 免密登录页 -->
|
|
<template>
|
|
<view class="uni-content">
|
|
<!-- 顶部文字 -->
|
|
<text class="title">请选择登录方式</text>
|
|
<!-- 快捷登录框 当url带参数时有效 -->
|
|
<template v-if="['apple','weixin', 'weixinMobile', 'huawei', 'huaweiMobile'].includes(type)">
|
|
<text class="tip">将根据第三方账号服务平台的授权范围获取你的信息</text>
|
|
<view class="quickLogin">
|
|
<image v-if="type !== 'weixinMobile' && type !== 'huaweiMobile'" @click="quickLogin" :src="imgSrc"
|
|
mode="widthFix" class="quickLoginBtn"></image>
|
|
<view v-else style="position: relative">
|
|
<button v-if="type ==='weixinMobile'" type="primary" open-type="getPhoneNumber"
|
|
@getphonenumber="quickLogin" class="uni-btn">微信授权手机号登录</button>
|
|
<button v-if="type === 'huaweiMobile'" open-type="getPhoneNumber" @getphonenumber="quickLogin"
|
|
class="quickLoginBtn" style="padding: 0; display: flex">
|
|
<image :src="imgSrc" mode="widthFix"></image>
|
|
</button>
|
|
<view v-if="this.needAgreements && !this.agree" class="mobile-login-agreement-layer"
|
|
@click="showAgreementModal"></view>
|
|
</view>
|
|
<uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements>
|
|
</view>
|
|
</template>
|
|
<template v-else>
|
|
<text class="tip">未注册的账号验证通过后将自动注册</text>
|
|
<view class="phone-box">
|
|
<view @click="chooseArea" class="area">+86</view>
|
|
<uni-easyinput trim="both" :focus="focusPhone" @blur="focusPhone = false" class="input-box"
|
|
type="number" :inputBorder="false" v-model="phone" maxlength="11" placeholder="请输入手机号" />
|
|
</view>
|
|
<uni-id-pages-agreements scope="register" ref="agreements"></uni-id-pages-agreements>
|
|
<button class="uni-btn" type="primary" @click="toSmsPage">获取验证码</button>
|
|
</template>
|
|
<!-- 固定定位的快捷登录按钮 -->
|
|
<uniIdPagesFabLoginVue ref="uniFabLogin"></uniIdPagesFabLoginVue>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
let currentWebview; //当前窗口对象
|
|
import config from '@/pages3/uni_modules/uni-id-pages/config.js'
|
|
import mixin from '@/pages3/uni_modules/uni-id-pages/common/login-page.mixin.js';
|
|
import uniIdPagesFabLoginVue from '../../components/uni-id-pages-fab-login/uni-id-pages-fab-login.vue';
|
|
export default {
|
|
mixins: [mixin],
|
|
components:{uniIdPagesFabLoginVue},
|
|
data() {
|
|
return {
|
|
type: "", //快捷登录方式
|
|
phone: "", //手机号码
|
|
focusPhone: false,
|
|
logo: "https://qnycdn.mymoyu.top/static/uni-id-pages/static/logo.png"
|
|
}
|
|
},
|
|
computed: {
|
|
async loginTypes() { //读取配置的登录优先级
|
|
return config.loginTypes
|
|
},
|
|
isPhone() { //手机号码校验正则
|
|
return /^1\d{10}$/.test(this.phone);
|
|
},
|
|
imgSrc() { //大快捷登录按钮图
|
|
const images = {
|
|
weixin: 'https://qnycdn.mymoyu.top/static/uni-id-pages/static/login/weixin.png',
|
|
apple: 'https://qnycdn.mymoyu.top/static/uni-id-pages/static/login/apple.png',
|
|
huawei: 'https://qnycdn.mymoyu.top/static/uni-id-pages/static/login/huawei.png',
|
|
huaweiMobile: 'https://qnycdn.mymoyu.top/static/uni-id-pages/static/login/huawei-mobile.png',
|
|
}
|
|
return images[this.type]
|
|
}
|
|
},
|
|
async onLoad(e) {
|
|
//获取通过url传递的参数type设置当前登录方式,如果没传递直接默认以配置的登录
|
|
let type = e.type || config.loginTypes[0]
|
|
this.type = type
|
|
|
|
// console.log("this.type: -----------",this.type);
|
|
if (type != 'univerify') {
|
|
this.focusPhone = true
|
|
}
|
|
this.$nextTick(() => {
|
|
//关闭重复显示的登录快捷方式
|
|
if (['weixin', 'apple', 'huawei', 'huaweiMobile'].includes(type)) {
|
|
this.$refs.uniFabLogin['servicesList'] = this.$refs.uniFabLogin['servicesList'] && this.$refs
|
|
.uniFabLogin['servicesList'].filter(item =>
|
|
item.id != type)
|
|
}
|
|
})
|
|
uni.$on('uni-id-pages-setLoginType', type => {
|
|
this.type = type
|
|
})
|
|
},
|
|
onShow() {
|
|
// #ifdef H5
|
|
document.onkeydown = event => {
|
|
var e = event || window.event;
|
|
if (e && e.keyCode == 13) { //回车键的键值为13
|
|
this.toSmsPage()
|
|
}
|
|
};
|
|
// #endif
|
|
},
|
|
onUnload() {
|
|
uni.$off('uni-id-pages-setLoginType')
|
|
},
|
|
onReady() {
|
|
// 是否优先启动一键登录。即:页面一加载就启动一键登录
|
|
//#ifdef APP-PLUS
|
|
if (config.loginTypes.includes('univerify') && this.type == "univerify") {
|
|
uni.preLogin({
|
|
provider: 'univerify',
|
|
success: () => {
|
|
const pages = getCurrentPages();
|
|
currentWebview = pages[pages.length - 1].$getAppWebview();
|
|
currentWebview.setStyle({
|
|
"top": "2000px" // 隐藏当前页面窗体
|
|
})
|
|
// this.type == this.loginTypes[1]
|
|
// console.log('开始一键登录');
|
|
this.$refs.uniFabLogin.login_before('univerify')
|
|
},
|
|
fail: (err) => {
|
|
console.log(err);
|
|
if (config.loginTypes.length > 1) {
|
|
this.$refs.uniFabLogin.login_before(config.loginTypes[1])
|
|
} else {
|
|
uni.showModal({
|
|
content: err.message,
|
|
showCancel: false
|
|
});
|
|
}
|
|
}
|
|
})
|
|
}
|
|
//#endif
|
|
},
|
|
methods: {
|
|
showCurrentWebview() {
|
|
// 恢复当前页面窗体的显示 一键登录,默认不显示当前窗口
|
|
currentWebview.setStyle({
|
|
"top": 0
|
|
})
|
|
},
|
|
showAgreementModal() {
|
|
this.$refs.agreements.popup()
|
|
},
|
|
quickLogin(e) {
|
|
let options = {
|
|
|
|
}
|
|
console.log(e)
|
|
if (e.detail?.code) {
|
|
options.phoneNumberCode = e.detail.code
|
|
}
|
|
|
|
if ((this.type === 'weixinMobile' || this.type === 'huaweiMobile') && !e.detail?.code) return
|
|
// console.log(this.$refs.uniFabLogin,'this.$refs.uniFabLogin');
|
|
this.$nextTick(()=>{
|
|
console.log(this.$refs.uniFabLogin,'this.$refs.uniFabLogin');
|
|
this.$refs.uniFabLogin.login_before(this.type, true, options)
|
|
})
|
|
// this.$refs.uniFabLogin.login_before(this.type, true, options)
|
|
},
|
|
toSmsPage() {
|
|
if (!this.isPhone) {
|
|
this.focusPhone = true
|
|
return uni.showToast({
|
|
title: "手机号码格式不正确",
|
|
icon: 'none',
|
|
duration: 3000
|
|
});
|
|
}
|
|
if (this.needAgreements && !this.agree) {
|
|
return this.$refs.agreements.popup(this.toSmsPage)
|
|
}
|
|
// 发送验证吗
|
|
uni.navigateTo({
|
|
url: '/pages3/uni_modules/uni-id-pages/pages/login/login-smscode?phoneNumber=' + this.phone
|
|
});
|
|
},
|
|
//去密码登录页
|
|
toPwdLogin() {
|
|
uni.navigateTo({
|
|
url: './login-withpwd.vue'
|
|
})
|
|
},
|
|
chooseArea() {
|
|
uni.showToast({
|
|
title: '暂不支持其他国家',
|
|
icon: 'none',
|
|
duration: 3000
|
|
});
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
@import "@/pages3/uni_modules/uni-id-pages/common/login-page.scss";
|
|
|
|
@media screen and (min-width: 690px) {
|
|
.uni-content {
|
|
height: 350px;
|
|
}
|
|
}
|
|
|
|
.mobile-login-agreement-layer {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.uni-content,
|
|
.quickLogin {
|
|
/* #ifndef APP-NVUE */
|
|
display: flex;
|
|
flex-direction: column;
|
|
/* #endif */
|
|
}
|
|
|
|
.phone-box {
|
|
position: relative;
|
|
/* #ifndef APP-NVUE */
|
|
display: flex;
|
|
/* #endif */
|
|
}
|
|
|
|
.area {
|
|
position: absolute;
|
|
left: 10px;
|
|
z-index: 9;
|
|
top: 12px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.area::after {
|
|
content: "";
|
|
border: 3px solid transparent;
|
|
border-top-color: #000;
|
|
top: 12px;
|
|
left: 3px;
|
|
position: relative;
|
|
}
|
|
|
|
/* #ifdef MP */
|
|
/* 解决小程序端开启虚拟节点virtualHost引起class = input-box丢失的问题 */
|
|
.phone-box :deep(.uni-easyinput__content) {
|
|
/* #ifndef APP-NVUE */
|
|
box-sizing: border-box;
|
|
/* #endif */
|
|
flex: 1;
|
|
padding-left: 45px;
|
|
margin-bottom: 10px;
|
|
border-radius: 0;
|
|
}
|
|
/* #endif */
|
|
|
|
.input-box {
|
|
/* #ifndef APP-NVUE */
|
|
box-sizing: border-box;
|
|
/* #endif */
|
|
flex: 1;
|
|
padding-left: 45px;
|
|
margin-bottom: 10px;
|
|
border-radius: 0;
|
|
}
|
|
|
|
.quickLogin {
|
|
height: 350px;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.quickLoginBtn {
|
|
margin: 20px 0;
|
|
width: 450rpx;
|
|
background-color: transparent;
|
|
border: none;
|
|
box-shadow: none;
|
|
/* #ifndef APP-NVUE */
|
|
max-width: 230px;
|
|
/* #endif */
|
|
height: 82rpx;
|
|
}
|
|
|
|
.tip {
|
|
margin-top: -15px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
@media screen and (min-width: 690px) {
|
|
.quickLogin {
|
|
height: auto;
|
|
}
|
|
}
|
|
</style> |