使用社交账号(微信小程序)登录

This commit is contained in:
sfmind
2022-05-05 19:09:04 +08:00
parent c533f5e5e8
commit c8e00ad04c
10 changed files with 160 additions and 163 deletions

View File

@ -2,7 +2,7 @@ import Vue from 'vue'
import Vuex from 'vuex'
import { logout } from '@/api/auth'
import { getUserInfo } from '@/api/user'
import { passwordLogin, smsLogin } from '@/api/auth'
import { passwordLogin, smsLogin, socialLogin } from '@/api/auth'
const TokenKey = 'App-Token'
@ -56,15 +56,18 @@ const store = new Vuex.Store({
actions: {
//账号登录
Login({ state, commit }, { type, data }) {
console.log(type, data)
if (type === 0) {
return passwordLogin(data).then(res => {
commit('SET_TOKEN', res.data)
})
} else {
} else if (type === 1) {
return smsLogin(data).then(res => {
commit('SET_TOKEN', res.data)
})
} else {
return socialLogin(data).then(res => {
commit('SET_TOKEN', res.data)
})
}
},
// 退出登录