提交 0db87f78 编写于 作者: DCloud_JSON's avatar DCloud_JSON

2修复仅选择一种快捷登录时的错误,未完成待续...

上级 8253a864
......@@ -19,28 +19,6 @@
// #endif
// #ifdef APP-PLUS
//一键登录 功能预登录
plus.oauth.getServices(oauthServices => {
// console.log(oauthServices);
oauthServices.forEach(({
_id
}, item) => {
if (_id == 'provider') {
uni.preLogin({
provider: item,
complete: e => {
console.log(e);
}
})
}
})
uni.preloadPage({
url: "/pages/ucenter/login-page/index/index"
});
}, err => {
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
//idfa有需要的用户在应用首次启动时自己获取存储到storage中
//https://ask.dcloud.net.cn/article/36107
/*if(~plus.storage.getItem('idfa')){
......
......@@ -455,7 +455,7 @@ uni-starter
### 注意事项
1. 真机运行需要制作自定义基座,制作后选择运行到自定义基座
2. 苹果登录的图标,需要满足苹果应用市场的审核规范请勿随便修改;如需修改请先阅读:[Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple/overview/buttons/)
2. 苹果登录的图标,需要满足苹果应用市场的审核规范请勿随便修改;如需修改请先阅读:[Sign in with Apple Button](https://appleid.apple.com/signinwithapple/button)
3. 应用登录功能,默认不勾选同意隐私权限是响应安卓应用市场的规范;请勿修改该逻辑。
### FAQ:常见问题
......
......@@ -7,17 +7,64 @@ import callCheckVersion from '@/uni_modules/uni-upgrade-center-app/utils/call-ch
import interceptorChooseImage from '@/uni_modules/json-interceptor-chooseImage/js_sdk/main.js';
// #endif
const db = uniCloud.database()
export default function() {
// #ifndef H5
export default async function() {
let loginConfig = uniStarterConfig.router.login
//清除有配置但设备环境不支持的登陆项
// #ifdef APP-PLUS
await new Promise((callBack)=>{
plus.oauth.getServices(oauthServices => {
loginConfig = loginConfig.filter(item=>{
if(["univerify", "weixin", "apple"].includes(item)){
let index = oauthServices.findIndex(e=>e.id==item)
if(index==-1){
return false
}else{
return oauthServices[index].nativeClient
}
}else{
return true
}
})
if(loginConfig.includes('univerify')){ //一键登录 功能预登录
uni.preLogin({
provider:'univerify',
complete: e => {
console.log(e);
}
})
}
callBack()
}, err => {
console.error('获取服务供应商失败:' + JSON.stringify(err));
})
})
// #endif
// #ifndef APP-PLUS
loginConfig = loginConfig.filter(item=>{
return ![
'univerify',
'apple',
// #ifdef H5
'weixin'
// #endif
].includes(item)
})
// #endif
uniStarterConfig.router.login = loginConfig
// uniStarterConfig挂载到getApp().globalData.config
// #ifdef MP-WEIXIN
setTimeout(()=>{
// #endif
// uniStarterConfig挂载到getApp().
const app = getApp({allowDefault: true})
app.globalData.config = uniStarterConfig;
// #ifndef H5
},30)
getApp({allowDefault: true}).globalData.config = uniStarterConfig;
// #ifdef MP-WEIXIN
},100)
// #endif
// 初始化appVersion(仅app生效)
initAppVersion();
......@@ -257,12 +304,15 @@ export default function() {
&&
pages[pages.length - 1].route.split('/')[2]!='login-page'
) {
console.log(9527777,login);
//一键登录(univerify)、账号(username)、验证码登录(短信smsCode)
if (login[0] == 'univerify') {
if(e.url == url) { e.url += '?' } //添加参数之前判断是否带了`?`号如果没有就补上,因为当开发场景本身有参数的情况下是已经带了`?`号
e.url += "univerify_first=true"
} else if (login[0] == 'username') {
if (login[0] == 'username') {
e.url = "/pages/ucenter/login-page/pwd-login/pwd-login"
}else{
if(e.url == url) { e.url += '?' } //添加参数之前判断是否带了`?`号如果没有就补上,因为当开发场景本身有参数的情况下是已经带了`?`号
e.url += "type="+login[0]
}
}else{
//拦截强制登录页面
......
......@@ -4,10 +4,10 @@
<checkbox style="transform: scale(0.7);" />
<text>同意</text>
</checkbox-group>
<template v-for="(agreement,index) in agreements">
<view class="item" v-for="(agreement,index) in agreements" :key="index">
<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
<text class="hint" v-if="hasAnd(agreements,index)"></text>
</template>
</view>
</view>
</template>
......@@ -56,6 +56,9 @@
display: flex;
flex-direction: row;
}
.item{
flex-direction: row;
}
.agreement{
color:#04498c;
}
......
......@@ -123,7 +123,7 @@
})
})
// #endif
//添加已配置且可用的第三方快捷登陆项
//添加可用的第三方快捷登陆项
servicesList = servicesList.concat(this.oauthServices.map( ({id})=>{
return {...this.config[id],id}
}))
......@@ -169,7 +169,8 @@
uni.navigateBack();
} else {
uni.navigateTo({
url: path
url: path,
animationType:'slide-in-left'
})
}
},
......
......@@ -57,14 +57,20 @@
],
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ]
},
"ios" : {},
"ios" : {
"capabilities" : {
"entitlements" : {
"com.apple.developer.associated-domains" : [ "applinks:static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com" ]
}
}
},
"sdkConfigs" : {
"oauth" : {
"apple" : {},
"weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0",
"appsecret" : "",
"UniversalLinks" : ""
"UniversalLinks" : "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com/uni-universallinks/__UNI__03B096E"
},
"univerify" : {}
},
......@@ -72,7 +78,7 @@
"share" : {
"weixin" : {
"appid" : "wxffdd8fa6ec4ef2a0",
"UniversalLinks" : ""
"UniversalLinks" : "https://static-76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e.bspapp.com/uni-universallinks/__UNI__03B096E"
}
},
"geolocation" : {},
......@@ -108,5 +114,6 @@
},
"h5" : {
"template" : ""
}
},
"_spaceID" : "76ce2c5e-31c7-4d81-8fcf-ed1541ecbc6e"
}
......@@ -185,7 +185,7 @@
"path": "pages/ucenter/settings/settings"
}
],
"current": 1
"current": 0
},
"tabBar": {
"color": "#7A7E83",
......
......@@ -2,15 +2,21 @@
<view class="content">
<!-- 顶部文字 -->
<text class="title">登录后即可展示自己</text>
<!-- 登录框 -->
<input v-if="first_type=='smsCode'" type="number" class="input-box" :inputBorder="false" v-model="phone" maxlength="11"
placeholder="请输入手机号" />
<image @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image>
<uni-agreements @setAgree="agree = $event"></uni-agreements>
<button v-if="first_type=='smsCode'" class="get-code" :disabled="!isPhone" :type="isPhone?'primary':'default'"
@click="sendShortMsg">获取短信验证码</button>
<text v-if="first_type=='smsCode'" class="tip">未注册的手机号验证通过后将自动注册</text>
<!-- 登录按钮弹窗 -->
<!-- 登录框 -->
<view v-if="['apple','weixin'].includes(type)" class="quickLogin">
<image @click="quickLogin" :src="imgSrc" mode="widthFix" class="quickLoginBtn"></image>
<uni-agreements @setAgree="agree = $event"></uni-agreements>
</view>
<template v-else>
<input type="number" class="input-box" :inputBorder="false" v-model="phone" maxlength="11"
placeholder="请输入手机号" />
<uni-agreements @setAgree="agree = $event"></uni-agreements>
<button class="get-code" :disabled="!isPhone" :type="isPhone?'primary':'default'"
@click="sendShortMsg">获取短信验证码</button>
<text class="tip">未注册的手机号验证通过后将自动注册</text>
</template>
<!-- 快捷登录按钮弹窗 -->
<uni-quick-login :agree="agree" ref="uniQuickLogin"></uni-quick-login>
</view>
</template>
......@@ -20,24 +26,28 @@
export default {
data() {
return {
first_type:"",
type:"",
phone: "",
agree: false
}
},
computed: {
computed: {
loginConfig() {
return getApp().globalData.config.router.login
},
isPhone() {
return /^1\d{10}$/.test(this.phone);
},
imgSrc(){
return '/static/login-index/'+this.first_type+'.jpg'
return '/static/login-index/'+this.type+'.png'
}
},
onLoad(e) {
this.first_type = e.first_type
this.type = e.type
//是否优先启动一键登录。即:页面一加载就启动一键登录
//#ifdef APP-PLUS
if (this.first_type == "univerify") {
if (this.type == "univerify") {
const pages = getCurrentPages();
currentWebview = pages[pages.length - 1].$getAppWebview();
currentWebview.setStyle({
......@@ -48,7 +58,8 @@
},
onReady() {
//#ifdef APP-PLUS
if (univerify_first) {
if (this.type == "univerify") {
this.type == loginConfig[1]
// console.log('开始一键登录');
setTimeout(() => {
this.$refs.uniQuickLogin.login_before('univerify')
......@@ -69,7 +80,7 @@
},
methods: {
quickLogin(){
this.$refs.uniQuickLogin.login_before(this.first_type)
this.$refs.uniQuickLogin.login_before(this.type)
},
sendShortMsg() {
if (!this.agree) {
......@@ -99,8 +110,14 @@
<style lang="scss">
@import url("../common/login-page.css");
.quickLogin{
width: 650rpx;
height: 350px;
align-items: center;
justify-content: center;
}
.quickLoginBtn{
width: 500rpx;
margin: 100rpx;
margin-bottom:20px;
width: 450rpx;
}
</style>
</style>
\ No newline at end of file
......@@ -31,7 +31,7 @@ module.exports = {
根据数组的第0项,决定登录方式的第一优先级。
*/
// "login": ["username","smsCode","univerify", "weixin", "apple"],
"login": ["weixin","username"],
"login": ["username","weixin","apple","smsCode"],
},
//关于应用
"about": {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册