import HttpRequest from "../system/request"; import { decryptRouteMap } from "../system/routeMap"; /** * 获取用户信息 * @returns {Promise} 用户信息 */ export const getUserInfo = async () => { const res = await HttpRequest.get('/userInfo'); if (res.status == 1) { let userInfo = res.data; if (userInfo.other != null && userInfo.other != undefined) { userInfo.other = decryptRouteMap(userInfo.other); userInfo['currency1'] = userInfo.other['a']; userInfo['currency2'] = userInfo.other['b']; userInfo['currency3'] = userInfo.other['c']; userInfo['uid'] = userInfo.other['uid']; userInfo['pid'] = userInfo.other['pid']; delete userInfo.other; } console.log("userInfo", userInfo); return userInfo; } return null; } /** * 申请注销账号 * @returns {Promise} 是否成功 */ export const deleteAccount = async () => { const res = await HttpRequest.post('/deleteAccount'); return res; } /** * 手机号登录 * @param {String} phone 手机号 * @param {String} code 验证码 * @param {String} pid 推广码 * @returns {Promise} 是否成功 */ export const mobileLogin = async (phone, code, pid = 0) => { const res = await HttpRequest.post('/mobileLogin', { mobile: phone, code: code, pid: pid }); return res; } /** * 修改用户信息 * @param {String} nickname 昵称 * @param {String} avatar 头像 * @param {String} imagebase 图片base64 * @param {Number} gender 性别(1-男,2-女,3-保密,0-未设置) * @returns {Promise} 是否成功 */ export const updateUserInfo = async (nickname, avatar, imagebase, gender = 3) => { const res = await HttpRequest.post('/update_userinfo', { nickname, headimg: avatar, imagebase, gender }); return res.status == 1; } /** * 获取用户优惠卷 * @param {Number} status 状态(0-未使用 1-已使用 2-已过期) * @param {Number} page 页码 * @param {Number} pageSize 每页条数 * @returns {Promise} 优惠卷列表 */ export const getUserCoupon = async (status, page, pageSize=10) => { const res = await HttpRequest.get('/get_coupon_list', { type: 1, status: status, page, limit: pageSize, }); return res; }