Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦想橡皮擦
uni-starter
提交
d7189d46
U
uni-starter
项目概览
梦想橡皮擦
/
uni-starter
与 Fork 源项目一致
Fork自
DCloud / uni-starter
通知
1
Star
0
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看板
提交
d7189d46
编写于
4月 12, 2021
作者:
L
linju
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
123
上级
4912b726
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
308 addition
and
97 deletion
+308
-97
common/appInit.js
common/appInit.js
+1
-1
js_sdk/request.js
js_sdk/request.js
+36
-0
main.js
main.js
+3
-0
pages.json
pages.json
+21
-22
pages/list/list.vue
pages/list/list.vue
+1
-1
pages/test/test.vue
pages/test/test.vue
+27
-0
uniCloud-aliyun/database/uni-id-users.schema.json
uniCloud-aliyun/database/uni-id-users.schema.json
+1
-1
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package-lock.json
...d/uniCloud/cloudfunctions/common/uni-id/package-lock.json
+25
-8
uni_modules/uni-quick-login/components/uni-quick-login/uni-quick-login.vue
...uick-login/components/uni-quick-login/uni-quick-login.vue
+19
-40
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/index.js
...-quick-login/uniCloud/cloudfunctions/user-center/index.js
+7
-1
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package-lock.json
...gin/uniCloud/cloudfunctions/user-center/package-lock.json
+3
-23
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/index.js
...les/uni-quick-login/uniCloud/cloudfunctions/user/index.js
+82
-0
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package-lock.json
...uick-login/uniCloud/cloudfunctions/user/package-lock.json
+58
-0
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package.json
...uni-quick-login/uniCloud/cloudfunctions/user/package.json
+16
-0
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/user.param.json
...-quick-login/uniCloud/cloudfunctions/user/user.param.json
+8
-0
未找到文件。
common/appInit.js
浏览文件 @
d7189d46
...
...
@@ -5,7 +5,7 @@ export default function (){
initAppVersion
();
// 检查更新
checkUpdate
();
//
checkUpdate();
}
/**
...
...
js_sdk/request.js
0 → 100644
浏览文件 @
d7189d46
/*
1.优雅访问指定路由地址
2.load自动显示与关闭
3.统一路由拦截
3.1 读取云端接口权限配置,先验证本地token再访问
3.2 处理因token过期等问题自动更新本地token,或token无效跳转至登陆页面
*/
const
debug
=
true
;
//开启后,会alert错误信息
export
default
function
request
(
name
,
params
,
callback
,{
showLoading
=
false
,
loadText
=
''
,
fail
=
()
=>
{}}
=
{}){
console
.
log
(
'
request
'
);
showLoading
||
loadText
?
uni
.
showLoading
({
title
:
loadText
}):
''
;
let
routers
=
name
.
split
(
'
/
'
);
var
action
=
false
if
(
routers
.
length
>
1
){
name
=
routers
[
0
]
action
=
routers
[
1
]
}
console
.
log
({
name
,
data
:
{
action
,
params
}})
return
uniCloud
.
callFunction
({
name
,
data
:
{
action
,
params
},
success
(
e
){
console
.
log
(
e
);
if
(
showLoading
||
loadText
)
uni
.
hideLoading
()
const
res
=
e
.
result
if
(
res
.
code
===
0
)
{
return
callback
(
res
.
data
,
e
.
result
,
e
)
}
debug
?
uni
.
showModal
({
content
:
JSON
.
stringify
(
e
)})
:
''
;
},
fail
(
err
){
console
.
log
(
err
);
debug
?
uni
.
showModal
({
content
:
JSON
.
stringify
(
err
)})
:
''
;
fail
(
err
)
}
})
}
\ No newline at end of file
main.js
浏览文件 @
d7189d46
...
...
@@ -2,7 +2,10 @@ import Vue from 'vue'
import
App
from
'
./App
'
import
store
from
'
./store/index.js
'
;
import
request
from
'
./js_sdk/request.js
'
;
Vue
.
config
.
productionTip
=
false
Vue
.
prototype
.
request
=
request
App
.
mpType
=
'
app
'
...
...
pages.json
浏览文件 @
d7189d46
...
...
@@ -180,34 +180,33 @@
}
}
],
,{
"path"
:
"pages/test/test"
,
"style"
:
{
"navigationBarTitleText"
:
""
,
"enablePullDownRefresh"
:
false
}
}
],
"globalStyle"
:
{
"navigationBarTextStyle"
:
"black"
,
"navigationBarTitleText"
:
"base-app"
,
"navigationBarBackgroundColor"
:
"#FFFFFF"
,
"backgroundColor"
:
"#F8F8F8"
},
//
"condition"
:
{
//
"list"
:
[{
//
"path"
:
"uni_modules/uni-login-page/pages/index/index"
,
//
"style"
:
{
//
"navigationBarTitleText"
:
""
,
//
"app-plus"
:
{
//
"animationType"
:
"none"
,
//
"popGesture"
:
"none"
,
//
"titleNView"
:
{
//
"buttons"
:
[{
//
"text"
:
"帮助"
,
//
"type"
:
"none"
,
//
"fontSize"
:
"16px"
,
//
"width"
:
"60px"
//
}]
//
}
//
}
//
}
//
}],
//
"current"
:
0
//
},
"condition"
:
{
"list"
:
[
{
"path"
:
"uni_modules/uni-login-page/pages/index/index"
},
{
"path"
:
"pages/test/test"
}
],
"current"
:
0
},
"tabBar"
:
{
"color"
:
"#7A7E83"
,
"selectedColor"
:
"#007AFF"
,
...
...
pages/list/list.vue
浏览文件 @
d7189d46
...
...
@@ -16,7 +16,7 @@
searchText
:
''
,
canSearch
:
true
};
},
},
onShow
(
options
)
{
this
.
searchText
=
getApp
().
globalData
.
searchText
;
},
...
...
pages/test/test.vue
0 → 100644
浏览文件 @
d7189d46
<
template
>
<view>
test
</view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
}
},
onLoad
()
{
this
.
request
(
'
user-center/login_by_
'
,{},
e
=>
{
console
.
log
(
e
);
})
},
methods
:
{
}
}
</
script
>
<
style
>
</
style
>
uniCloud-aliyun/database/uni-id-users.schema.json
浏览文件 @
d7189d46
{
"bsonType"
:
"object"
,
"permission"
:
{
"read"
:
true
,
"read"
:
"'read' in auth.permission"
,
"create"
:
false
,
"update"
:
"doc._id == auth.uid"
,
"delete"
:
false
...
...
uni_modules/uni-id/uniCloud/cloudfunctions/common/uni-id/package-lock.json
浏览文件 @
d7189d46
{
"name"
:
"uni-id"
,
"version"
:
"3.0.8"
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
"uni-config-center"
:
{
"version"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
"name"
:
"uni-id"
,
"version"
:
"3.0.8"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{
""
:
{
"version"
:
"3.0.8"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
},
"../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
:
{
"version"
:
"0.0.1"
,
"license"
:
"Apache-2.0"
},
"node_modules/uni-config-center"
:
{
"resolved"
:
"../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"link"
:
true
}
},
"dependencies"
:
{
"uni-config-center"
:
{
"version"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
uni_modules/uni-quick-login/components/uni-quick-login/uni-quick-login.vue
浏览文件 @
d7189d46
...
...
@@ -97,7 +97,7 @@
login
(
type
)
{
let
oauthService
=
this
.
oauthServices
.
find
((
service
)
=>
service
.
id
==
type
)
// #ifdef APP-PLUS
uni
.
showLoading
({
mask
:
true
});
//
uni.showLoading({mask: true});
//请勿直接使用前端获取的unionid或openid直接用于登陆,前端的数据都是不可靠的
if
(
type
==
'
weixin
'
){
...
...
@@ -131,46 +131,25 @@
})
// #endif
},
quickLogin
(
params
,
type
){
console
.
log
({
params
,
type
});
uniCloud
.
callFunction
({
//联网验证登陆
"
name
"
:
"
user-center
"
,
"
data
"
:
{
"
action
"
:
"
login_by_
"
+
type
,
params
},
success
:
async
(
e
)
=>
{
uni
.
hideLoading
()
console
.
log
(
e
.
result
);
// uni.showModal({
// content: JSON.stringify(e.result),
// showCancel: false
// });
if
(
e
.
result
.
code
===
0
){
uni
.
setStorageSync
(
'
uni_id_uid
'
,
e
.
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
e
.
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
e
.
result
.
tokenExpired
)
// console.log('66666=',e.result.uid,e.result.token,e.result.tokenExpired);
delete
e
.
result
.
userInfo
.
token
this
.
setUserInfo
(
e
.
result
.
userInfo
)
if
(
type
==
'
univerify
'
){
uni
.
closeAuthView
()
}
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
navigateBack
()
quickLogin
(
params
,
type
){
//联网验证登陆
console
.
log
(
params
,
type
);
this
.
request
(
'
user-center/login_by_
'
+
type
,
params
,(
data
,
result
)
=>
{
console
.
log
(
result
);
if
(
result
.
code
===
0
){
uni
.
setStorageSync
(
'
uni_id_uid
'
,
result
.
uid
)
uni
.
setStorageSync
(
'
uni_id_token
'
,
result
.
token
)
uni
.
setStorageSync
(
'
uni_id_token_expired
'
,
result
.
tokenExpired
)
delete
result
.
userInfo
.
token
this
.
setUserInfo
(
result
.
userInfo
)
if
(
type
==
'
univerify
'
){
uni
.
closeAuthView
()
}
},
fail
:
(
err
)
=>
{
console
.
log
(
err
);
if
(
err
.
errCode
===
30002
){
}
},
complete
:
()
=>
{
uni
.
hideLoading
()
uni
.
showToast
({
title
:
'
登陆成功
'
,
icon
:
'
none
'
});
uni
.
navigateBack
()
}
})
},
...
...
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/index.js
浏览文件 @
d7189d46
'
use strict
'
;
cons
t
uniID
=
require
(
'
uni-id
'
)
le
t
uniID
=
require
(
'
uni-id
'
)
const
uniCaptcha
=
require
(
'
uni-captcha
'
)
const
db
=
uniCloud
.
database
()
const
dbCmd
=
db
.
command
exports
.
main
=
async
(
event
,
context
)
=>
{
/**
* UNI_WYQ:这里的uniID换成新的,保证多人访问不会冲突
*/
uniID
=
uniID
.
createInstance
({
context
})
//event为客户端上传的参数
console
.
log
(
'
event :
'
+
event
)
let
params
=
event
.
params
||
{}
...
...
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user-center/package-lock.json
浏览文件 @
d7189d46
{
"name"
:
"user-center"
,
"version"
:
"1.0.0"
,
"lockfileVersion"
:
1
,
"requires"
:
true
,
"dependencies"
:
{
"uni-captcha"
:
{
"version"
:
"file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
},
"uni-config-center"
:
{
"version"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"uni-id"
:
{
"version"
:
"file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
,
"requires"
:
{
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"dependencies"
:
{
"uni-config-center"
:
{
"version"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
}
"name"
:
"user-center"
,
"version"
:
"1.0.0"
,
"lockfileVersion"
:
1
}
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/index.js
0 → 100644
浏览文件 @
d7189d46
'
use strict
'
;
const
uniID
=
require
(
'
uni-id
'
)
const
uniCaptcha
=
require
(
'
uni-captcha
'
)
const
db
=
uniCloud
.
database
()
const
dbCmd
=
db
.
command
let
params
,
context
,
res
;
class
User
{
async
quickLogin
(){
let
{
access_token
,
openid
,
type
}
=
params
switch
(
type
){
case
'
weixin
'
:
let
userinfo_res
=
await
uniCloud
.
httpclient
.
request
(
'
https://api.weixin.qq.com/sns/userinfo
'
,
{
method
:
'
GET
'
,
dataType
:
"
json
"
,
data
:{
access_token
,
openid
}
});
return
userinfo_res
.
data
//根据access_token,openid得到userinfo
//检查是否已经注册...
break
;
case
'
univerify
'
:
return
uniID
.
loginByUniverify
({
access_token
,
openid
})
break
;
case
'
apple
'
:
return
await
uniID
.
loginByApple
(
params
)
break
;
default
:
return
{
"
code
"
:
100
,
"
msg
"
:
"
暂不提供
"
+
type
+
"
登陆的云端接口演示
"
}
break
;
}
}
async
sendSmsCode
(){
// 简单限制一下客户端调用频率
const
ipLimit
=
await
db
.
collection
(
'
uni-verify
'
).
where
({
ip
:
context
.
CLIENTIP
,
created_at
:
dbCmd
.
gt
(
Date
.
now
()
-
60000
)
}).
get
()
if
(
ipLimit
.
data
.
length
>
0
)
{
return
{
code
:
429
,
msg
:
'
请求过于频繁
'
}
}
const
templateId
=
'
11753
'
// 替换为自己申请的模板id
if
(
!
templateId
)
{
return
{
code
:
500
,
msg
:
'
sendSmsCode需要传入自己的templateId,参考https://uniapp.dcloud.net.cn/uniCloud/uni-id?id=sendsmscode
'
}
}
const
randomStr
=
'
00000
'
+
Math
.
floor
(
Math
.
random
()
*
1000000
)
const
code
=
randomStr
.
substring
(
randomStr
.
length
-
6
)
return
await
uniID
.
sendSmsCode
({
mobile
:
params
.
mobile
,
code
,
type
:
params
.
type
,
templateId
})
}
}
const
userClass
=
new
User
();
exports
.
main
=
async
(
event
,
ctx
)
=>
{
[{
params
},
context
]
=
[
event
,
ctx
]
//1.判断需要token的action是否有token
/*let noCheckAction = ['register', 'loginByWeixin', 'checkToken','login', 'logout', 'sendSmsCode','loginBySms', 'inviteLogin', 'loginByUniverify','loginByApple', 'createCaptcha', 'verifyCaptcha','refreshCaptcha']
if(!noCheckAction.includes(event.action)) {
if (!event.uniIdToken) {
return {"code":403,"msg":"缺少token"}
}
let payload = {}
payload = await uniID.checkToken(event.uniIdToken)
if (payload.code && payload.code > 0) {
return payload
}
params.uid = payload.uid
}*/
try
{
return
await
userClass
[
event
.
action
]()
||
res
;
}
catch
(
err
){
return
{
"
code
"
:
404
,
"
msg
"
:
err
}
}
}
\ No newline at end of file
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package-lock.json
0 → 100644
浏览文件 @
d7189d46
{
"name"
:
"user"
,
"version"
:
"1.0.0"
,
"lockfileVersion"
:
2
,
"requires"
:
true
,
"packages"
:
{
""
:
{
"version"
:
"1.0.0"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"uni-captcha"
:
"file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"uni-id"
:
"file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
}
},
"../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
:
{
"version"
:
"0.1.0"
,
"license"
:
"Apache-2.0"
},
"../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
:
{
"version"
:
"0.0.1"
,
"license"
:
"Apache-2.0"
},
"../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
:
{
"version"
:
"3.0.8"
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
},
"node_modules/uni-captcha"
:
{
"resolved"
:
"../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"link"
:
true
},
"node_modules/uni-config-center"
:
{
"resolved"
:
"../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"link"
:
true
},
"node_modules/uni-id"
:
{
"resolved"
:
"../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
,
"link"
:
true
}
},
"dependencies"
:
{
"uni-captcha"
:
{
"version"
:
"file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
},
"uni-config-center"
:
{
"version"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
},
"uni-id"
:
{
"version"
:
"file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
,
"requires"
:
{
"uni-config-center"
:
"file:../../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
}
}
}
}
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/package.json
0 → 100644
浏览文件 @
d7189d46
{
"name"
:
"user"
,
"version"
:
"1.0.0"
,
"description"
:
""
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"uni-captcha"
:
"file:../../../../uni-captcha/uniCloud/cloudfunctions/common/uni-captcha"
,
"uni-config-center"
:
"file:../../../../uni-config-center/uniCloud/cloudfunctions/common/uni-config-center"
,
"uni-id"
:
"file:../../../../uni-id/uniCloud/cloudfunctions/common/uni-id"
}
}
uni_modules/uni-quick-login/uniCloud/cloudfunctions/user/user.param.json
0 → 100644
浏览文件 @
d7189d46
//
本文件中的json内容将在云函数【运行】时作为参数传给云函数。
//
配置教程参考:https://uniapp.dcloud.net.cn/uniCloud/quickstart?id=runparam
{
"action"
:
"sendSmsCode"
,
"params"
:
{
"phone"
:
"17769516081"
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录