Files
video_app/uniCloud-aliyun/cloudfunctions/login/index.js

19 lines
861 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
const res = await uniCloud.getPhoneNumber({
appid: '__UNI__E0B05B1', // 替换成自己开通一键登录的应用的DCloud appid使用callFunction方式调用时可以不传会自动取当前客户端的appid如果使用云函数URL化的方式访问必须传此参数
provider: 'univerify',
apiKey: '999f511095b875f4e1ac9eb495e4d208', // 在开发者中心开通服务并获取apiKey
apiSecret: 'd81d7c58aa11848c687c0970f615c5dc', // 在开发者中心开通服务并获取apiSecret
access_token: event.access_token,
openid: event.openid
});
console.log(res); // res里的数据格式 { code: 0, success: true, phoneNumber: '186*****078' }
// 执行入库等操作,正常情况下不要把完整手机号返回给前端
return res;
};