slcing registrasi awal
This commit is contained in:
55
auth-code/modules/auth.js
Normal file
55
auth-code/modules/auth.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import * as api from "../api/api.js"
|
||||
|
||||
const Store = {
|
||||
state() {
|
||||
return {
|
||||
alert: {
|
||||
show: false,
|
||||
type: 'info',
|
||||
message: window.i18n.global.t('message.msgInfo')
|
||||
},
|
||||
authcode: "",
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
setAuthcode(state, data) {
|
||||
state.authcode = data
|
||||
},
|
||||
setAlert(state, data) {
|
||||
state.alert = data
|
||||
},
|
||||
setLoading(state, data) {
|
||||
state.loading = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async submit({state, commit}) {
|
||||
commit('setLoading', true)
|
||||
try {
|
||||
let fn = "linking"
|
||||
let params = {
|
||||
AuthCodeCode: state.authcode
|
||||
}
|
||||
let headers = {}
|
||||
|
||||
let resp = await api.callApi(fn, params, headers)
|
||||
if (resp.data.status != 'OK') {
|
||||
commit('setLoading', false);
|
||||
} else {
|
||||
commit('setLoading', false);
|
||||
|
||||
localStorage.setItem("token", resp.data.token)
|
||||
localStorage.setItem("user", JSON.stringify(resp.data.data))
|
||||
|
||||
window.location.replace("")
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
commit('setLoading', false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Store
|
||||
Reference in New Issue
Block a user