4.23
This commit is contained in:
@@ -2,7 +2,7 @@ import App from './App'
|
||||
import Inputli from './components/form/input-li.vue';
|
||||
import Selectli from './components/form/select-li.vue';
|
||||
import Dateli from './components/form/date-li.vue';
|
||||
import { getToken } from './api/create.js'
|
||||
import { getToken,getUser } from './api/create.js'
|
||||
import { formatDate, calculator } from './com/index.js'
|
||||
|
||||
// #ifndef VUE3
|
||||
@@ -33,23 +33,38 @@ const navTo = (url, skip = 'navigateTo') =>{
|
||||
url
|
||||
});
|
||||
}
|
||||
const login = () =>{
|
||||
return new Promise((reslove,reject)=>{
|
||||
const login = () => {
|
||||
// uni.showLoading({
|
||||
// mask: true,
|
||||
// title: '登录中...'
|
||||
// })
|
||||
return new Promise((reslove, reject) => {
|
||||
uni.getAuthCode({
|
||||
success:(user)=>{
|
||||
console.log(user)
|
||||
getToken(user.authCode).then((res)=>{
|
||||
if(res){
|
||||
reslove(res.data)
|
||||
console.log(res.data)
|
||||
success: (user) => {
|
||||
getToken(user.authCode).then((res) => {
|
||||
if (res.errcode == 0) {
|
||||
uni.setStorageSync('token', res.result.token)
|
||||
getUser().then(data => {
|
||||
console.log(data)
|
||||
uni.setStorageSync('user',data)
|
||||
uni.hideLoading()
|
||||
// uni.showToast({
|
||||
// title: '登录成功',
|
||||
// icon: 'success'
|
||||
// })
|
||||
})
|
||||
reslove(res)
|
||||
}
|
||||
}).catch(err =>{
|
||||
reject(err)
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: '登录失败,服务器出错了',
|
||||
icon: 'error'
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
// 提示框 点击确定进入resolve 取消进入reject
|
||||
const showModel = (content) =>{
|
||||
@@ -72,7 +87,7 @@ const showModel = (content) =>{
|
||||
})
|
||||
}
|
||||
|
||||
Vue.prototype.$navTo = navTo // 页面跳转
|
||||
Vue.prototype.$navTo = navTo //
|
||||
Vue.prototype.$msg = msg
|
||||
Vue.prototype.$setNavigationBar = setNavigationBar
|
||||
Vue.prototype.$login = login
|
||||
|
||||
Reference in New Issue
Block a user