Procházet zdrojové kódy

调整授权相关

liujd před 6 roky
rodič
revize
904035f679

+ 8 - 8
mobile-code/src/App.vue

@@ -1,7 +1,7 @@
 <script>
 import { mapMutations, mapActions, mapGetters } from 'vuex'
 import { setTimeout } from 'timers'
-import { getCheckLogin, getUser, wxLoginFn } from '@/utils/auth'
+import { getUser, wxLoginFn } from '@/utils/auth'
 export default {
 	// 全端,数据共享,还可以解决页面初始化模板访问不到值得问题
 	// 有坑 分包里的页面访问不到
@@ -18,13 +18,13 @@ export default {
 		uni.setStorageSync('token', 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImp0aSI6IjFfMTI1MzY2MzAifQ.eyJpc3MiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJhdWQiOiJodHRwOlwvXC9tLmhoYi5jb20iLCJqdGkiOiIxXzEyNTM2NjMwIiwiaWF0IjoxNTc0NDIzMDc4LCJuYmYiOjE1NzQ0MjMwNzgsImV4cCI6MTU3NDQyNjY3OCwidXNlcklkIjoxMjUzNjYzMH0.v_T9NuFRpzuI7GtwuuuNlVg6EylImaCUwqo2A6NRTE4')
 		uni.setStorageSync('account', '12358')
 		// 登录
-		if (this.$constant.source == 'business') {
-			getCheckLogin().then(res => {
-				if (res) {
-					getUser()
-				}
-			})
-		}
+		// if (this.$constant.source == 'business') {
+		this.$util.getCheckLogin().then(res => {
+			if (res) {
+				getUser()
+			}
+		})
+		// }
 	},
 	onShow() {
 		// this.isLogin()

+ 2 - 2
mobile-code/src/pages/home/components/login-popup.vue

@@ -62,7 +62,7 @@ import AppStep from '@/components/app-step'
 import BottomPopup from '@/components/plugin/bottom-popup'
 import AppClose from '@/components/module/app-close'
 // api
-import { getCheckLogin, getUser } from '@/utils/auth'
+import { getUser } from '@/utils/auth'
 import { getWxPhone } from '@/api/mini'
 export default {
 	name: 'login-popup-module',
@@ -95,7 +95,7 @@ export default {
 			this.$emit('hide')
 		},
 		registerFn() {
-			getCheckLogin()
+			this.$util.getCheckLogin()
 		},
 		getWxMobile(e) {
 			console.log(e)

+ 2 - 2
mobile-code/src/pages/home/user.vue

@@ -117,7 +117,7 @@ import TuiListCell from '@/components/plugin/list-cell'
 import LoginPopup from '@/pages/home/components/login-popup'
 import AppTrademark from '@/components/module/app-trademark'
 // api
-import { getShopUser, getCheckLogin } from '@/utils/auth'
+import { getShopUser } from '@/utils/auth'
 import { getWxInfo, getWxPhone } from '@/api/mini'
 export default {
 	name: 'user',
@@ -148,7 +148,7 @@ export default {
 		},
 		showPopup() {
 			// this.popupShow = true
-			getCheckLogin()
+			this.$util.getCheckLogin()
 		},
 		hidePopup() {
 			this.popupShow = false

+ 1 - 2
mobile-code/src/pages/pay/index.vue

@@ -54,7 +54,6 @@ import AppTabs from '@/components/plugin/tabs'
 import PayInputModule from './components/pay-input'
 import AppDeliveryModule from '@/components/app-delivery'
 // import { getMiniAppUrl } from '@/utils/common'
-import { getCheckLogin } from '@/utils/auth'
 import wexinPay from '@/utils/pay/wxPay'
 import ModalModule from '@/components/plugin/modal'
 // api
@@ -117,7 +116,7 @@ export default {
 	},
 	methods: {
 		init() {
-			// getCheckLogin().then(res => {})
+			// this.$util.getCheckLogin().then(res => {})
 			getShopUser()
 		},
 		_pay() {

+ 1 - 29
mobile-code/src/utils/auth.js

@@ -71,37 +71,9 @@ export async function getSelfInfo(update) {
 
 	return userInfo
 }
-// /**
-//  * 清除vuex的用户信息,目前包含(selfInfo, user)
-//  * @parmas 暂无,可扩展
-//  */
-// export async function resetAllUser() {
-// 	await store.dispatch('delSelfInfo')
-// 	await store.dispatch('delUser')
-// 	return true
-// }
-
-// // 获取用户认证信息
-// export async function getRoleReal() {
-// 	let roleReal = store.getters.getRoleReal
-// 	if (roleReal) {
-// 	  return roleReal
-// 	}
-// 	const params = {}
-// 	await getRoleRealApi(params).then((res) => {
-// 		roleReal = res.data.roleRealInfo
-// 		store.commit('FETCH_ROLE_REAL', {
-// 		  roleReal
-// 		})
-// 	}).catch(() => {
-// 		return false
-// 	})
-
-// 	return roleReal
-// }
 
 /**
- * 微信登陆
+ * 微信小程序登陆
  * @parmas update为true时会重新触发请求,重置vuex的数据
  */
 export async function wxLoginFn(update) {

+ 2 - 1
mobile-code/src/utils/util.js

@@ -1,5 +1,6 @@
 import CONSTANT from '@/constant'
 import { mobileReg } from '@/utils/tools/validate'
+import { getMiniAppUrl } from '@/utils/common'
 // 是否为空
 const isEmpty = (val) => {
 	if (val instanceof Array) {
@@ -70,7 +71,7 @@ const checkName = (str) => {
  * @parmas query 拼接得参数对象
  * @parmas isFrist 为true时开头为&
  */
-export const getCheckLogin = () => {
+export async function getCheckLogin() {
 	let status = false
 	let token = uni.getStorageSync('token')
 	if (token) {