Browse Source

修改接口名称

ming 3 years ago
parent
commit
edb2e32c83
3 changed files with 6 additions and 9 deletions
  1. 1 1
      pages/index/welcome.vue
  2. 2 5
      services/common.js
  3. 3 3
      store/index.js

+ 1 - 1
pages/index/welcome.vue

@@ -17,7 +17,7 @@ import { useStore } from 'vuex'
 const store = useStore()
 
 onLoad(() => {
-	store.dispatch('loginByCode').finally(() => {
+	store.dispatch('loginByOpenId').finally(() => {
 		uni.switchTab({
 			url: '/pages/index/index'
 		})

+ 2 - 5
services/common.js

@@ -1,11 +1,8 @@
 import http from '@/utils/http'
 
-// #ifdef MP-WEIXIN
+// const appId = uni.getAccountInfoSync().miniProgram.appId
 
-// #endif
-const appId = uni.getAccountInfoSync().miniProgram.appId
-
-export function loginByCode(data) {
+export function loginByOpenId(data) {
 	return new Promise((resolve, reject) => {
 		uni.login({
 		  provider: 'weixin',

+ 3 - 3
store/index.js

@@ -1,5 +1,5 @@
 import { createStore } from 'vuex'
-import { login, wxLogin, loginByCode, logout } from '../services/common'
+import { login, wxLogin, loginByOpenId, logout } from '../services/common'
 
 const store = createStore({
   state: {
@@ -29,8 +29,8 @@ const store = createStore({
 				commit('setUserInfo', res.userInfo)
 			})
 		},
-		loginByCode({ commit }) {
-			return loginByCode().then(res => {
+		loginByOpenId({ commit }) {
+			return loginByOpenId().then(res => {
 				commit('setToken', res.token)
 				commit('setUserInfo', res.userInfo)
 			})