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

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

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