neteasecloudmusicapi/module/login_cellphone.js
2024-08-10 22:12:53 +08:00

38 lines
915 B
JavaScript

// 手机登录
const CryptoJS = require('crypto-js')
const createOption = require('../util/option.js')
module.exports = async (query, request) => {
const data = {
phone: query.phone,
countrycode: query.countrycode || '86',
captcha: query.captcha,
[query.captcha ? 'captcha' : 'password']: query.captcha
? query.captcha
: query.md5_password || CryptoJS.MD5(query.password).toString(),
rememberLogin: 'true',
}
let result = await request(`/api/login/cellphone`, data, {
...createOption(query, 'weapi'),
uaType: 'pc',
})
if (result.body.code === 200) {
result = {
status: 200,
body: {
...JSON.parse(
JSON.stringify(result.body).replace(
/avatarImgId_str/g,
'avatarImgIdStr',
),
),
cookie: result.cookie.join(';'),
},
cookie: result.cookie,
}
}
return result
}