Parcourir la source

commit -m 修改用户授权登录

zhengjinyi il y a 4 ans
Parent
commit
7ca7fb005e

+ 4 - 5
App.vue

@@ -66,7 +66,7 @@
 			// }
 		},
 		methods:{
-			...mapMutations(['login','logout']),
+			...mapMutations(['login','logout','isWxAuthorize']),
 			async getWxAuthorize(){
 				const wechatCode = await authorize.getCode('weixin');// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 				const getUserInfo = await authorize.getUserInfo('weixin');
@@ -90,12 +90,11 @@
 			refresh(){
 				let TIME = (20*60)*1000;
 				setInterval(()=>{
-					authorize.checkLogin().then(res => {
+					if(this.isWxAuthorize){
 						this.getWxAuthorize()
-					})
-					.catch(err => {
+					}else{
 						console.log(new Date +'用户未授权微信信息')
-					})
+					}	
 				},TIME)
 			},
 			diffTime(t){

+ 26 - 5
common/config/authorize.js

@@ -72,7 +72,7 @@ const getCode = provider => {
         uni.login({
             provider: provider,
             success: function(loginRes) {
-				console.log(loginRes)
+				console.log('loginRes',loginRes)
                 if (loginRes && loginRes.code) { 
 					resolve(loginRes.code) 
 				} else {
@@ -83,7 +83,7 @@ const getCode = provider => {
 				}
             },
 			fail:function(error){ 
-				console.log(err)
+				console.log('获取code失败',)
 				reject("获取code失败")
 			}
         });
@@ -122,6 +122,7 @@ const getUserInfo = (provider)=>{
 				}
 			}
 			,fail: (error) => {
+				console.log('获取用户信息失败')
 				reject(0); //如果用户拒绝过授权 直接走fail
 			}
 		});
@@ -132,16 +133,35 @@ const checkLogin = () => {
 	return new Promise((resolve, reject) => {
 		uni.checkSession({
 			success() {
-				resolve(1)
 				console.log('登录成功')
+				resolve(1)
 			},
-			fail(err) {
+			fail(error) {
+				console.log('获取用户信息失败',error)
 				reject(0)
 			}
 		})
 	})
 }
 
+// util.js
+const getUserProfile = () =>{
+	wx.getUserProfile({
+		desc: '用于完善个人资料',
+		success: function(res) {
+			var userInfo = res.userInfo
+			// console.log('userInfo==>', userInfo)
+			wx.setStorageSync('storage_info', 1);//本地标记
+			//下面将userInfo存入服务器中的用户个人资料
+			//...
+		  },
+		fail() {
+			console.log("用户拒绝授权")
+		}
+	})
+}
+  
+
 export default {
 	getProvider,
 	getSetting,
@@ -149,5 +169,6 @@ export default {
 	getCode,
 	login,
 	getUserInfo,
-	checkLogin
+	checkLogin,
+	getUserProfile
 }

+ 4 - 6
h5/pages/activity/activity_mid.vue

@@ -117,7 +117,7 @@
 			uni.setNavigationBarTitle({title:'年中大促'});
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo'])
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		methods:{
 			getWinHeight() {
@@ -239,14 +239,12 @@
 				this.$api.navigateTo(`/pages/goods/product?id=${item.productID}&path=activity`)
 			},
 			navigator(){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					this.$store.commit('setLoginType',9)
 					this.$api.navigateTo('/pages/login/login?type=0')
-				})
-				.catch(err => {
+				}else{
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},	
 			toFixedFn(text){//处理小数点后两位数
 				return Number(text).toFixed(2);

+ 5 - 6
pages/goods/cart.vue

@@ -214,7 +214,7 @@
 			this.setScrollHeight();
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo'])
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		filters:{
 			NumFormat(value) {//处理金额
@@ -236,13 +236,12 @@
 				})	
 			},
 			initLogin(){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					this.$api.redirectTo('/pages/login/login?type=4')
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=0')
-				})
+				}	
 			},
 			clickPopupShow(pros,type){
 				this.popupShow = true;

+ 6 - 8
pages/goods/good-floor.vue

@@ -49,15 +49,16 @@
 				typeSort:'',
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','identity','isWxAuthorize'])
+		},
 		onLoad(option) {
 			if(option.type =='share'){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			this.pageId = option.linkId
 			this.$api.getComStorage('userInfo').then((resolve) =>{
@@ -72,9 +73,6 @@
 				this.skeletonShow = false
 			},2000)
 		},
-		computed: {
-			...mapState(['hasLogin','userInfo','identity'])
-		},
 		methods:{
 			GetInstrumentPageData(){//获取楼层数据
 				this.CommonService.GetInstrumentPageData({pageId:this.pageId,userId:this.userID,source:2}).then(response =>{

+ 7 - 8
pages/goods/goods-classify.vue

@@ -235,23 +235,22 @@
 				searchCheckedId:null
 			}	
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','identity','isWxAuthorize'])
+		},
 		onLoad(option) {
 			console.log(option)
 			if(option.type =='share'){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			this.SetScrollHeight()
 			this.InitOption(option)
 		},
-		computed: {
-			...mapState(['hasLogin','userInfo','identity'])
-		},
+		
 		filters: {
 			NumFormat:function(text) {//处理金额
 				return Number(text).toFixed(2);

+ 6 - 8
pages/goods/instrument-details.vue

@@ -194,6 +194,9 @@
 				popupShow:false//参数弹窗
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','isWxAuthorize'])
+		},
 		onLoad(option) {
 			this.equipmentId = option.id;//获取商品ID
 			this.isShareType = option.type
@@ -203,18 +206,13 @@
 				this.backPage = option.page
 			}
 			if(this.isShareType =='share'){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 		},
-		computed: {
-			...mapState(['hasLogin','isWxAuthorize'])
-		},
 		methods:{
 			initData(){// 初始化商品详情查询
 				this.ProductService.GetEquipmentDetails({equipmentId:this.equipmentId}).then(response =>{	

+ 19 - 24
pages/goods/product.vue

@@ -357,6 +357,9 @@
 				isNoneSupplier:false
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','isWxAuthorize','identity'])
+		},
 		onLoad(option) {
 			this.productID = option.id;//获取商品ID
 			this.isShareType = option.type
@@ -366,19 +369,14 @@
 				this.backPage = option.page
 			}
 			if(this.isShareType =='share'){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			this.getWinHeight()
 		},
-		computed: {
-			...mapState(['hasLogin','isWxAuthorize','identity'])
-		},
 		methods:{
 			initData(){// 初始化商品详情查询
 				this.ProductService.queryProductDetils({userId:this.userID,productID:this.productID,identity:this.identity}).then(response =>{	
@@ -484,30 +482,28 @@
 				console.log(e.detail.query)
 			},
 			buyProductCart(){//底部购物车按钮点击
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					if(this.hasLogin){
 						this.$api.navigateTo('/pages/goods/cart')
 					}else{					
 						this.$api.navigateTo('/pages/login/login?type=1')
 					}
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},
 			btnGetConfirm(type){//加入购物车&&立即购买点击
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					if(this.hasLogin){
 						this.showSpec(type);
-					}else{
+					}else{					
 						this.$api.navigateTo('/pages/login/login?type=1')
 					}
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},	
 			changeCountAdd(){//popup弹窗数量增加按钮
 				if(this.buyRetailPriceStep == 2){
@@ -602,15 +598,14 @@
 				})
 			},
 			navToLogin(){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					this.$store.commit('setLoginType',8)
 					this.$store.commit('setLoginProductId',this.productID)
 					this.$api.navigateTo(`/pages/login/login?id=${this.productID}`)
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},
 			setHeaderBtnPosi(){
 				// 获得胶囊按钮位置信息

+ 12 - 12
pages/login/bindOperator.vue

@@ -97,20 +97,20 @@
 				isUserInfo:false
 			}
 		},
+		computed: {
+			...mapState(['isWxAuthorize'])
+		},
 		onLoad(option) {
 			console.log(option)
 			uni.setStorageSync('bind_id', option.userID);
 			this.getVerificationCode()
-			authorize.checkLogin().then(res => {
+			if(this.isWxAuthorize){
 				this.getWxAuthorize()
-			})
-			.catch(err => {
-				this.$api.navigateTo('/pages/authorization/authorization')
+			}else{
+				console.log(new Date +'用户未授权微信信息')
+				this.$api.navigateTo('/pages/authorization/authorization?type=0')
 				this.isUserInfo = true
-			})
-		},
-		computed: {
-			...mapState(['isWxAuthorize'])
+			}	
 		},
 		methods:{
 			...mapMutations(['login','logout']),
@@ -167,12 +167,12 @@
 					this.$util.msg('验证码格式不正确',2000)
 					return
 				}
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					this.bindingWechatLogin()
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization')
-				})
+				}	
 			},
 			getVerificationCode(){//图形验证
 				this.PublicService.GetImgVerifyCode().then(res => {

+ 4 - 5
pages/login/binding.vue

@@ -243,13 +243,12 @@
 			}
 		},
 		onShow() {
-			authorize.checkLogin().then(res => {
+			if(this.isWxAuthorize){
 				this.getWxAuthorize()
-			})
-			.catch(err => {
-				this.isRegisterShow= true
+			}else{
+				console.log(new Date +'用户未授权微信信息')
 				this.$api.navigateTo('/pages/authorization/authorization')
-			})
+			}	
 		}
 	}
 </script>

+ 8 - 10
pages/login/login.vue

@@ -63,13 +63,12 @@
 					this.$util.msg('请输入密码',2000)
 					return
 				}
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					this.AorganizationLogin()
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=0')
-				})
+				}	
 			},
 			AorganizationLogin(){
 				this.UserService.AorganizationLogin(this.params)
@@ -96,13 +95,12 @@
 				this.isShowEye = !this.isShowEye;
 			},
 			async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginQuick()
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=0')
-				})
+				}	
 			}
 		},
 		onShow() {

+ 4 - 5
pages/login/register-supplier.vue

@@ -645,13 +645,12 @@
 			}
 		},
 		onShow() {
-			authorize.checkLogin()
-			.then(res => {
+			if(this.isWxAuthorize){
 				wxLogin.wxLoginQuick()
-			})
-			.catch(err => {
+			}else{
+				console.log(new Date +'用户未授权微信信息')
 				this.$api.navigateTo('/pages/authorization/authorization?type=0')
-			})
+			}	
 		}
 	}
 </script>

+ 4 - 5
pages/login/register.vue

@@ -230,13 +230,12 @@
 				}
 			},
 			async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginQuick()
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=0')
-				})
+				}	
 			}
 		},
 		onShow() {

+ 5 - 6
pages/tabBar/cart/cart.vue

@@ -202,7 +202,7 @@
 			this.setScrollHeight();
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo'])
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		filters:{
 			NumFormat(value) {//处理金额
@@ -224,13 +224,12 @@
 				})	
 			},
 			initLogin(){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					this.$api.redirectTo('/pages/login/login?type=4')
-				})
-				.catch(err =>{
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=0')
-				})
+				}	
 			},
 			clickPopupShow(pros,type){
 				this.popupShow = true;

+ 6 - 42
pages/tabBar/home/index.vue

@@ -80,45 +80,11 @@
 			
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo','identity','isActivity'])
+			...mapState(['hasLogin','userInfo','identity','isActivity','isWxAuthorize'])
 		},
 		methods: {
 			...mapMutations(['login','logout']),
-			GetWxAuthorize(){
-				authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
-					authorize.getUserInfo('weixin').then(getUserInfo =>{
-						this.UserService.UserLoginAuthApplets({ 
-							code:wechatcode,
-							encryptedData:getUserInfo.encryptedData,
-							iv:getUserInfo.iv ,
-						})
-						.then(response =>{
-							this.isLogin = true;
-							this.userID = response.data.userId;						
-							this.userIdentity = response.data.userIdentity;						
-							this.clubStatus = response.data.clubStatus;						
-							this.$store.commit('updateStatus',response.data)
-							this.login(response.data);
-							uni.setStorageSync('token',response.data.token)
-							uni.setStorageSync('unionId',response.data.unionId)
-							if(response.data.userIdentity ==1){
-								this.$api.redirectTo('/seller/pages/index/index')
-							}else if(response.data.userIdentity === 3){
-								this.$api.redirectTo('/supplier/pages/index/index')
-							}
-							this.getHomeInformation()
-						})
-						.catch(error =>{
-							this.isLogin = false;
-							this.logout()
-							uni.setStorageSync('unionId',error.data.unionId)
-							this.$store.commit('updateStatus',error.data)
-							this.getHomeInformation()
-						})
-					})
-				})						
-			},
-			async getWxAuthorize(){
+			async GetWxAuthorize(){
 				const wechatCode = await authorize.getCode('weixin');// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 				const getUserInfo = await authorize.getUserInfo('weixin');
 				this.UserService.UserLoginAuthApplets({ 
@@ -203,19 +169,17 @@
 				uni.setStorageSync('lockTime',Date.now())
 				uni.setStorageSync('isActivityStatus',true)	
 			},
-			async InitAuthorize(){ //是否已授权 0:为取消授权 1:为已授权 2:为未操作
-				authorize.checkLogin()
-				.then(res => {
+			InitAuthorize(){ //是否已授权 
+				if(this.isWxAuthorize){
 					this.GetWxAuthorize()
-				})
-				.catch(err => {
+				}else{
 					this.$api.getComStorage('userInfo').then((resolve) =>{
 						this.userID = resolve.userId ? resolve.userId :0;
 						this.getHomeInformation()
 					}).catch(error =>{
 						this.getHomeInformation()
 					})
-				})
+				}
 			}
 		},
 		onPageScroll(e){//实时获取到滚动的值

+ 9 - 11
pages/tabBar/user/user.vue

@@ -204,7 +204,7 @@
 			
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo'])
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		methods:{
 			getUserInfo(){
@@ -277,28 +277,26 @@
 				})
 			},
 			navigator(url){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					if(this.hasLogin){
 						this.$api.navigateTo(url)
 					}else{
 						this.$api.navigateTo('/pages/login/login?type=0')
 					}
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},	
 			navigatorNex(url,type){
-				authorize.checkLogin()
-				.then(res => {
+				if(this.isWxAuthorize){
 					if(!this.hasLogin){
 						this.$api.navigateTo(url)
 					}
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo(`/pages/authorization/authorization?type=${type}`)
-				})
+				}	
 			},		
 			showBadge(n){
 				let num ='';

+ 6 - 4
search/pages/search/search-instrument.vue

@@ -68,14 +68,16 @@
 				total:0
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
+		},
 		onLoad(option){
 			if(option.type =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			if(option.keyWord){
 				this.listQuery.keyword = option.keyWord

+ 6 - 4
search/pages/search/search-supplier.vue

@@ -107,14 +107,16 @@
 				total:0
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
+		},
 		onLoad(option){
 			if(option.type =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			if(option.keyWord){
 				console.log(option.keyWord)

+ 6 - 4
search/pages/search/search.vue

@@ -209,15 +209,17 @@
 				total:0
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
+		},
 		onLoad(option) {
 			console.log(option)
 			if(option.type =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			this.$api.getStorage().then((resolve) =>{
 				this.userID = resolve.userId ? resolve.userId : 0;

+ 10 - 8
second/pages/product/product-details.vue

@@ -211,6 +211,9 @@
 				winHeight:''
 			}
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
+		},
 		onLoad(option) {
 			this.productID = option.id;//获取商品ID
 			this.isShareType = option.type
@@ -220,12 +223,11 @@
 				this.backPage = option.page
 			}
 			if(this.isShareType =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 		},
 		computed: {
@@ -283,14 +285,14 @@
 
 			},
 			navToLogin(){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					this.$store.commit('setLoginType',8)
 					this.$store.commit('setLoginProductId',this.productID)
 					this.$api.navigateTo(`/pages/login/login?id=${this.productID}`)
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},
 			setHeaderBtnPosi(){
 				// 获得胶囊按钮位置信息

+ 6 - 7
second/pages/product/product-list.vue

@@ -147,19 +147,18 @@
 			 this.gettabList();
 			 this.isFocus = true;
 		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
+		},
 		onLoad(option) {
 			if(option.type =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}
 			}
 		},
-		computed: {
-			...mapState(['hasLogin','userInfo'])
-		},
 		methods:{
 			scrolltolower() {
 				if(this.hasNextPage && this.pullFlag) {

+ 7 - 8
seller/pages/login/login.vue

@@ -95,12 +95,12 @@
 					this.$util.msg('请输入密码',2000)
 					return
 				}
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					this.SellerLogin()
-				})
-				.catch(err => {
+				}else{
+					console.log(new Date +'用户未授权微信信息')
 					this.$api.navigateTo('/pages/authorization/authorization?type=1')
-				})
+				}	
 			},
 			SellerLogin(){
 				this.SellerService.SellerLogin(this.params)
@@ -135,13 +135,12 @@
 			},
 		},
 		onShow() {
-			authorize.checkLogin().then(res => {
+			if(this.isWxAuthorize){
 				this.getWxAuthorize()
-			})
-			.catch(err => {
+			}else{
 				this.$api.navigateTo('/pages/authorization/authorization')
 				this.isSeller= true
-			})
+			}	
 		}
 	}
 </script>

+ 12 - 10
supplier/pages/login/share-info.vue

@@ -7,6 +7,7 @@
 	</view>
 </template>
 <script>
+	import { mapState,mapMutations } from 'vuex'
 	import authorize from '@/common/config/authorize.js' 
 	export default{
 		data() {
@@ -21,6 +22,9 @@
 				authority:'',//用户权限
 			}
 		},
+		computed: {
+			...mapState(['isWxAuthorize'])
+		},
 		onLoad(option) {
 			// scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
 			console.log(option);
@@ -35,15 +39,14 @@
 					this.source = 3
 				}
 			}
-			authorize.checkLogin().then(res => {
+			if(this.isWxAuthorize){
+				this.infoMiniShipments();
+			}else{
 				this.$api.navigateTo('/pages/authorization/authorization?type=4')
 				setTimeout(()=>{
 					this.isRequest = true
 				},2000)
-			})
-			.catch(err => {
-				this.infoMiniShipments();
-			})
+			}	
 		},
 		methods:{
 			infoMiniShipments(){
@@ -87,13 +90,12 @@
 			}
 		},
 		onShow() {
-			authorize.checkLogin().then(res => {
+			if(this.isWxAuthorize){
 				this.isRequest = false;
 				this.infoMiniShipments();
-			})
-			.catch(err => {
-				console.log('用户未授权')
-			})
+			}else{
+				console.log(new Date +'用户未授权微信信息')
+			}	
 		}
 	}
 </script>

+ 6 - 4
supplier/pages/user/my-shop.vue

@@ -272,14 +272,16 @@
 				total:0
 			}
 		},
+		computed: {
+			...mapState(['isWxAuthorize'])
+		},
 		onLoad(option) {
 			if(option.type =='share'){
-				authorize.checkLogin().then(res => {
+				if(this.isWxAuthorize){
 					wxLogin.wxLoginAuthorize()
-				})
-				.catch(err => {
+				}else{
 					console.log(new Date +'用户未授权微信信息')
-				})
+				}	
 			}
 			this.listQuery.id = this.supplierId = option.shopId
 			this.$api.getStorage().then((resolve) =>{