zhengjinyi hace 5 años
padre
commit
80fc62827a
Se han modificado 4 ficheros con 8 adiciones y 28 borrados
  1. 2 22
      App.vue
  2. 1 1
      README.md
  3. 4 4
      common/config/wxLogin.js
  4. 1 1
      store/index.js

+ 2 - 22
App.vue

@@ -5,7 +5,7 @@
 	import Vue from 'vue'
 	import { mapState,mapMutations} from 'vuex';
 	import authorize from '@/common/config/authorize.js'
-	import { userInfoLogin } from "@/api/use.js"
+	import wxLogin from "@/common/config/wxLogin.js"
 	export default {
 		onLaunch: function() {
 			let self = this
@@ -57,30 +57,10 @@
 			this.refresh()
 		},
 		methods:{
-			...mapMutations(['login','logout']),
-			getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
-				authorize.getCode('weixin').then(wechatcode =>{
-					// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
-					authorize.getUserInfo('weixin').then(wxResponse =>{
-						userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
-							this.login(response.data)
-							uni.setStorageSync('token',response.data.token)
-							uni.removeStorageSync('sessionid')
-							uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
-							this.$store.commit('updateStatus',response.data)
-						}).catch(error =>{
-							this.logout()
-							uni.removeStorageSync('sessionid')
-							uni.setStorageSync('sessionid','JSESSIONID='+error.data)
-							this.$store.commit('updateStatus',error.data)
-						})
-					})
-				})
-			},
 			refresh(){
 				let TIME = (20*60)*1000;
 				setInterval(()=>{
-					this.getCheekeyCode()
+					wxLogin.wxLoginAuthorize()
 				},TIME)
 			}
 		},

+ 1 - 1
README.md

@@ -5,7 +5,7 @@ caimei-applets-caimei --采美商城小程序
 软件架构
 	-HBuild-X  微信开发者工具
 前端框架API
-	-uni-app  Vue.js
+	-uni-app  Vue.js  微信Api
 目录结构
 			
 运行项目

+ 4 - 4
common/config/wxLogin.js

@@ -12,11 +12,11 @@ const wxLoginAuthorize = function(){
 				uni.setStorageSync('token',response.data.token)
 				uni.removeStorageSync('sessionid')
 				uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
-			}).catch(response =>{
+			}).catch(error =>{
 				uni.removeStorageSync('sessionid')
-				uni.setStorageSync('sessionid','JSESSIONID='+response.data)
-				store.commit('logout',response.data)
-				store.commit('updateStatus',response.data)
+				uni.setStorageSync('sessionid','JSESSIONID='+error.data)
+				store.commit('logout',error.data)
+				store.commit('updateStatus',error.data)
 				store.commit('wxLogin',wxResponse.userInfo);
 			})
 		})

+ 1 - 1
store/index.js

@@ -68,7 +68,7 @@ const store = new Vuex.Store({
 			}
 		},
 		setChangeVar(state,variable){
-			//单一的改变某一个变量
+			//获取设备信息是否为IphoneX
 			state.isIphoneX = variable;
 		}
 	},