123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // 邮箱登录
- const CryptoJS = require('crypto-js')
- const createOption = require('../util/option.js')
- module.exports = async (query, request) => {
- const data = {
- username: query.email,
- password: query.md5_password || CryptoJS.MD5(query.password).toString(),
- rememberLogin: 'true',
- }
- let result = await request(`/api/login`, data, {
- ...createOption(query),
- uaType: 'pc',
- })
- if (result.body.code === 502) {
- return {
- status: 200,
- body: {
- msg: '账号或密码错误',
- code: 502,
- message: '账号或密码错误',
- },
- }
- }
- 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
- }
|