完成一键登录和支付功能

This commit is contained in:
future
2026-06-28 14:49:21 +08:00
parent 74876e0923
commit 09e587cb65
94 changed files with 10283 additions and 2665 deletions
@@ -0,0 +1,6 @@
{
"provider": "univerify",
"appid": "__UNI__52E2F0D",
"apiKey": "IKsoDGSM9l8pIws9gXtyp4",
"apiSecret": ""
}
@@ -0,0 +1,59 @@
exports.main = async (event, context) => {
let { access_token, openid, appid } = event
if (event.body) {
try {
const body = typeof event.body === 'string' ? JSON.parse(event.body) : event.body
access_token = body.access_token || body.accessToken || access_token
openid = body.openid || openid
appid = body.appid || appid
} catch (e) {
console.error('解析body失败:', e)
}
}
if (!access_token) {
return {
success: false,
message: 'access_token不能为空'
}
}
try {
const params = {
provider: 'univerify',
access_token: access_token,
openid: openid
}
if (appid) {
params.appid = appid
}
console.log('调用getPhoneNumber参数:', JSON.stringify(params))
const res = await uniCloud.getPhoneNumber(params)
console.log('getPhoneNumber返回:', JSON.stringify(res))
if (res && res.phoneNumber) {
return {
success: true,
phone: res.phoneNumber
}
} else {
return {
success: false,
message: '获取手机号失败',
error: res
}
}
} catch (error) {
console.error('获取手机号异常:', error)
return {
success: false,
message: '获取手机号异常',
error: error.message || error
}
}
}
@@ -0,0 +1,12 @@
{
"name": "getPhoneByUniverify",
"version": "1.0.0",
"description": "通过univerify获取手机号",
"main": "index.js",
"extensions": {
"uni-cloud-verify": {}
},
"cloudfunction-config": {
"path": "/getPhoneByUniverify"
}
}
@@ -0,0 +1,12 @@
// 本文件用于,使用JQL语法操作项目关联的uniCloud空间的数据库,方便开发调试和远程数据库管理
// 编写clientDB的js API(也支持常规js语法,比如var),可以对云数据库进行增删改查操作。不支持uniCloud-db组件写法
// 可以全部运行,也可以选中部分代码运行。点击工具栏上的运行按钮或者按下【F5】键运行代码
// 如果文档中存在多条JQL语句,只有最后一条语句生效
// 如果混写了普通js,最后一条语句需是数据库操作语句
// 此处代码运行不受DB Schema的权限控制,移植代码到实际业务中注意在schema中配好permission
// 不支持clientDB的action
// 数据库查询有最大返回条数限制,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-database.html#limit
// 详细JQL语法,请参考:https://uniapp.dcloud.net.cn/uniCloud/jql.html
// 下面示例查询uni-id-users表的所有数据
db.collection('uni-id-users').get();