const cloud = require('wx-server-sdk');
cloud.init();
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext();
try {
const result = await cloud.openapi.security.getPhoneNumber({
code: event.code
});
return {
openid: wxContext.OPENID,
phoneData: result.phoneInfo,
};
} catch (error) {
console.error('获取手机号码失败,错误信息:', error);
return {
code: -1,
message: '获取手机号失败',
error: error
};
}
};
报啥错也不说