Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一个会的不多的人
uni-starter
提交
0db87f78
U
uni-starter
项目概览
一个会的不多的人
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-starter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0db87f78
编写于
7月 06, 2021
作者:
DCloud_JSON
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2修复仅选择一种快捷登录时的错误,未完成待续...
上级
8253a864
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
119 addition
and
63 deletion
+119
-63
App.vue
App.vue
+0
-22
README.md
README.md
+1
-1
common/appInit.js
common/appInit.js
+61
-11
components/uni-agreements/uni-agreements.vue
components/uni-agreements/uni-agreements.vue
+5
-2
components/uni-quick-login/uni-quick-login.vue
components/uni-quick-login/uni-quick-login.vue
+3
-2
manifest.json
manifest.json
+11
-4
pages.json
pages.json
+1
-1
pages/ucenter/login-page/index/index.vue
pages/ucenter/login-page/index/index.vue
+36
-19
static/login-index/apple.jpg
static/login-index/apple.jpg
+0
-0
static/login-index/weixin.jpg
static/login-index/weixin.jpg
+0
-0
uni-starter.config.js
uni-starter.config.js
+1
-1
未找到文件。
App.vue
浏览文件 @
0db87f78
...
...
@@ -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')){
...
...
README.md
浏览文件 @
0db87f78
...
...
@@ -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:常见问题
...
...
common/appInit.js
浏览文件 @
0db87f78
...
...
@@ -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
{
//拦截强制登录页面
...
...
components/uni-agreements/uni-agreements.vue
浏览文件 @
0db87f78
...
...
@@ -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
;
}
...
...
components/uni-quick-login/uni-quick-login.vue
浏览文件 @
0db87f78
...
...
@@ -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
'
})
}
},
...
...
manifest.json
浏览文件 @
0db87f78
...
...
@@ -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"
}
pages.json
浏览文件 @
0db87f78
...
...
@@ -185,7 +185,7 @@
"path"
:
"pages/ucenter/settings/settings"
}
],
"current"
:
1
"current"
:
0
},
"tabBar"
:
{
"color"
:
"#7A7E83"
,
...
...
pages/ucenter/login-page/index/index.vue
浏览文件 @
0db87f78
...
...
@@ -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
+
'
.jp
g
'
return
'
/static/login-index/
'
+
this
.
type
+
'
.pn
g
'
}
},
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
:
500r
px
;
margin
:
10
0rpx
;
margin-bottom
:
20
px
;
width
:
45
0rpx
;
}
</
style
>
</
style
>
\ No newline at end of file
static/login-index/apple.jpg
已删除
100644 → 0
浏览文件 @
8253a864
7.5 KB
static/login-index/weixin.jpg
已删除
100644 → 0
浏览文件 @
8253a864
7.5 KB
uni-starter.config.js
浏览文件 @
0db87f78
...
...
@@ -31,7 +31,7 @@ module.exports = {
根据数组的第0项,决定登录方式的第一优先级。
*/
// "login": ["username","smsCode","univerify", "weixin", "apple"],
"
login
"
:
[
"
weixin
"
,
"
usernam
e
"
],
"
login
"
:
[
"
username
"
,
"
weixin
"
,
"
apple
"
,
"
smsCod
e
"
],
},
//关于应用
"
about
"
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录