瀏覽代碼

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
修改

1004749546@qq.com 4 年之前
父節點
當前提交
28fff0d0ab
共有 4 個文件被更改,包括 5 次插入1 次删除
  1. 2 1
      api/login.js
  2. 1 0
      libs/axios.js
  3. 1 0
      pages/index/index.vue
  4. 1 0
      pages/login/login.vue

+ 2 - 1
api/login.js

@@ -18,7 +18,8 @@ export const logout = params => {
 
 // 验证是否登录过
 export const checkLogin = () => {
-  let token = getApp().globalData.token
+  let token = uni.getStorageSync('token')
+  console.log(token,'token')
   if (token&&token!='') {
     return axios.request({
       url: `checkToken`,

+ 1 - 0
libs/axios.js

@@ -3,6 +3,7 @@ const baseUrl = getApp().globalData.baseUrl
 const request = (opts, hasToken) => {
 	const authorization = getApp().globalData.token
 	console.log(opts, 'opts')
+	console.log(authorization,'authorization')
 	//  hasToken是否传入token,为true则不传token
 	const header = {
 			'Content-Type': 'application/json;charset=UTF-8'

+ 1 - 0
pages/index/index.vue

@@ -108,6 +108,7 @@
 			this.mapCtx = uni.createMapContext('map')
 		},
 		onShow() {
+			console.log(1111)
 			this.checkLogin()
 		},
 		onLoad() {

+ 1 - 0
pages/login/login.vue

@@ -51,6 +51,7 @@
 								console.log(res, 'login data')
 								if (res.status == '200') {
 									console.log(res.data, 'login data')
+									uni.setStorageSync('token',res.data)
 									_this.$u.vuex('vuex_token',res.data)
 									if (_this.path === '/pages/index/main' || _this.lanuch) {
 										uni.reLaunch({