1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- /**
- * Created by JianJia.Zhou<jianjia.zhou> on 2022/8/14.
- */
- import { getAuthorize, getToken } from '../../utils/auth'
- const request = uni.$u.http
- export async function authorize() {
- return new Promise(resolve => {
- uni.showLoading({
- title: '数据加载中...',
- mask: true
- })
- uni.login({
- provider: uni.$u.platform,
- success: loginRes => {
- uni.hideLoading()
- return request.post(
- '/auth/wechat/minni/code',
- { code: loginRes.code }
- ).then(res => {
- resolve(res)
- })
- }
- })
- })
- }
- export async function login(account, password, code) {
- return new Promise((resolve, reject) => {
- return request.post(
- '/auth/login',
- { account, password, code }
- ).then(res => {
- resolve(res)
- }).catch(err => {
- reject(err)
- })
- })
- }
- export async function phoneQuickLogin(data) {
- return new Promise(resolve => {
- return request.post(
- '/auth/wechat/minni/phone',
- data
- ).then(res => {
- resolve(res)
- })
- })
- }
- export async function info() {
- return request.get(
- 'user/info'
- )
- }
- export function isLogin() {
- return !!getToken()
- }
- export function isAuthorize() {
- return !!getAuthorize()
- }
- export default {
- authorize,
- login,
- info,
- isLogin,
- isAuthorize,
- phoneQuickLogin
- }
|