Jelajahi Sumber

修改微信授权流程

zhengjinyi 5 tahun lalu
induk
melakukan
ca68abef3f

+ 0 - 8
api/seller.js

@@ -29,14 +29,6 @@ export function sellerWxLogin(params) {
  */
 export function sellerLogin(params) {
 	return new Promise(function(resolve,reject) {
-		if( params.mobile == ''){
-			uni.showToast({title: '请输入账户名',duration: 2000,mask:true, icon:'none'})
-			return
-		}
-		if( params.password == ''){
-			uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
-			return
-		}
 		request.post('/seller/login',params, true,res => {
 			resolve(res)
 		})

+ 0 - 8
api/use.js

@@ -159,14 +159,6 @@ export function organizationUpdate(params) {
  */
 export function organizationLogin(params) {
 	return new Promise(function(resolve,reject) {
-		if( params.mobileOrEmail == ''){
-			uni.showToast({title: '请输入账户名',duration: 2000,mask:true, icon:'none'})
-			return
-		}
-		if( params.password == ''){
-			uni.showToast({title: '请输入密码',duration: 2000,mask:true,icon:'none'})
-			return
-		}
 		request.post('/user/login',params,true, res => {
 			resolve(res)
 		})

+ 3 - 1
common/config/caimeiApi.js

@@ -121,12 +121,14 @@ const caimeiApi = {
 		});
 	},
 	getStorage:function(){// 获取本地userInfo
-	
 		return new Promise(function(resolve,reject) {
 			uni.getStorage({
 				key: 'userInfo',
 				success: function (res){
 					resolve(res.data);
+				},
+				fail: function(res){
+					reject(false)
 				}
 			})
 		});

+ 2 - 0
common/config/wxLogin.js

@@ -8,6 +8,7 @@ const wxLoginAuthorize = function(){
 			userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
 				store.commit('updateStatus',response.data)
 				store.commit('login',response.data);
+				store.commit('wxLogin',wxResponse.userInfo);
 				uni.setStorageSync('token',response.data.token)
 				uni.removeStorageSync('sessionid')
 				uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
@@ -16,6 +17,7 @@ const wxLoginAuthorize = function(){
 				uni.setStorageSync('sessionid','JSESSIONID='+response.data)
 				store.commit('logout',response.data)
 				store.commit('updateStatus',response.data)
+				store.commit('wxLogin',wxResponse.userInfo);
 			})
 		})
 	})

+ 10 - 1
market/pages/club/allClub-list.vue

@@ -30,7 +30,7 @@
 							<view class="list-tel">
 								<text class="txt">{{item.name}}</text>
 								<text class="txt sm">
-									<text class="txt-le">{{item.linkMan1 ? desensitizationName(item.linkMan1) : ''}}</text>
+									<text class="txt-le">{{checkData(item.linkMan1)  ? desensitizationName(item.linkMan1) : ''}}</text>
 									{{item.contractMobile1 ? hidePhone(item.contractMobile1) : ''}}
 								</text>
 							</view>
@@ -180,6 +180,15 @@
 				let phone = this.$reg.hidePhone(val) 
 				return phone
 			},
+			checkData (value){
+				let data;
+				if(value == null || value ==""){
+					data = ''
+				}else{
+					data = value
+				}
+				return data
+			},
 			desensitizationName(val){
 				let name = this.$reg.desensitizationName(val)
 				return name

+ 34 - 19
market/pages/login/login.vue

@@ -27,7 +27,7 @@
 </template>
 
 <script>
-	import { mapMutations } from 'vuex';
+	import { mapState,mapMutations } from 'vuex';
 	import errorAlert from '@/components/module/modelAlert/errorAlert.vue'
 	import authorize from '@/common/config/authorize.js' 
 	import { sellerLogin } from '@/api/seller.js' 
@@ -48,7 +48,7 @@
 				isIphoneX:this.$store.state.isIphoneX,
 				CustomBar:this.CustomBar,// 顶部导航栏高度
 				isShowEye:false,
-				isSeller:false,
+				isSeller:true,
 				iseErrorAlert:false,
 				iconEyes:'icon-yanjing_yincang_o',
 				iconEyen:'icon-yanjing_xianshi_o',
@@ -56,17 +56,27 @@
 				password:'',	   //协销登录密码	
 			}
 		},
-		onLoad(option) {
-			this.getOption = JSON.stringify(option)
+		onLoad() {
+			authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+				if(wxResponse == 1){
+					this.getWxAuthorize()
+				}else{
+					this.$api.navigateTo('/pages/authorization/authorization?type=1')
+					this.isSeller= true
+				}
+			})	
+		},
+		computed: {
+			...mapState(['isWxAuthorize'])
 		},
 		methods:{
 			...mapMutations(['login','logout']),
-			getCheekeyCode(){
+			getWxAuthorize(){
 				authorize.getCode('weixin').then(wechatcode =>{
 					// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 					authorize.getUserInfo('weixin').then(wxResponse =>{
 						userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
-							if(response.code != -6){
+							if(response.code != -6){//判断是否为微信绑定了供应商的账户
 								if(response.data.userIdentity !=1){
 									this.logout()
 									uni.removeStorageSync('sessionid')
@@ -94,18 +104,30 @@
 				})	
 			},	
 			confirmLogin(){
-				let params ={
-						mobile:this.accountNumber,
-						password:this.password
+				if( this.accountNumber == ''){
+					this.$util.msg('请输入账户名',2000)
+					return
 				}
-				sellerLogin(params).then(response =>{
+				if( this.password == ''){
+					this.$util.msg('请输入密码',2000)
+					return
+				}
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						this.SellerLogin()
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization?type=1')
+					}
+				})	
+			},
+			SellerLogin(){
+				sellerLogin({mobile:this.accountNumber,password:this.password}).then(response =>{
 					if(response.code == '0' ){
 						this.$store.commit('updateStatus',response.data)
 						this.login(response.data);
 						uni.setStorageSync('token',response.data.token)
 						uni.removeStorageSync('sessionid')
 						uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
-						// this.$api.navigateTo('/market/pages/user/user')
 						this.$api.navigateTo('/market/pages/index/index')
 					}else{
 						this.$util.msg(response.msg,2000);
@@ -128,14 +150,7 @@
 			},
 		},
 		onShow() {
-			//查看此微信用户是否已经授权过
-			authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
-				if(res == 1){
-					this.getCheekeyCode()
-				}else{
-					this.$api.navigateTo('/pages/authorization/authorization?type=2')
-				}
-			})		
+			
 		}
 	}
 </script>

+ 60 - 49
pages/authorization/authorization.vue

@@ -4,13 +4,21 @@
 			<image class="logo" src="../../static/login-logo@3x.png" mode=""></image>
 			<text class="logo-text">生美/医美采购服务平台</text>
 		</view>
-		<button class="login-btn" type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo">微信授权</button>
+		<view class="login-content">
+			<text>您暂未授权采美采购小程序获取您的信息,将无法正常使用小程序的功能。如需正常使用,请点击“授权”按钮,并允许头像、昵称等信息的授权</text>
+		</view>
+		<view class="login-form">
+			<button class="login-btn use" type="primary" size="small" open-type="getUserInfo" lang="zh_CN" @getuserinfo="getuserinfo">微信授权</button>
+			<view class="login-btn back" @tap="undGetuserinfo">取消</view>
+		</view>
 	</view>
 </template>
 
 <script>
 	import {mapState,mapMutations } from 'vuex';
 	import authorize from '@/common/config/authorize.js' 
+	import wxLogin from "@/common/config/wxLogin.js"
+	
 	export default{
 		data() {
 			return{
@@ -21,7 +29,6 @@
 			this.authorizeType = option.type
 		},
 		methods:{
-			...mapMutations(['wxLogin']),
 			//授权登录 
 			getuserinfo: function (e) {
 				console.log(e)
@@ -31,25 +38,23 @@
 					this.$util.msg('授权失败',2000)
 			    }
 			 },
+			undGetuserinfo(){
+				switch(this.authorizeType){
+					case '0':
+						this.$api.switchTabTo('/pages/tabBar/home/home')
+						break;
+						default:
+						uni.navigateBack({delta: 1});
+				}
+			},
 			wxGetUserInfo(){
 				authorize.getCode('weixin').then(wechatcode =>{
 					wx.getUserInfo({
 						success: res => {
-							//根据页面参数跳转相应的页面
-							switch(this.authorizeType){
-								case '0':
-									this.$api.switchTabTo('/pages/tabBar/user/user')	
-									break;
-								case '1':
-									this.$api.switchTabTo('/pages/tabBar/home/home')	
-									break;
-								case '2':
-									this.$api.navigateTo('/market/pages/login/login')
-									break;
-								case '3':
-									this.$api.navigateTo('/pages/login/bindOperator')	
-									break;
-							}
+							wxLogin.wxLoginAuthorize()
+							setTimeout(()=>{
+								uni.navigateBack({delta: 1});
+							},2000)
 						}
 					});	
 				})
@@ -76,46 +81,52 @@
 			height: auto;
 			padding:200rpx 0 0 0;
 			.logo{
-				width: 250rpx;
-				height: 210rpx;
+				width: 200rpx;
+				height: 170rpx;
 				display: block;
 			}
 			.logo-text{
-				font-size: $font-size-44;
-				line-height: 44rpx;
-				color: $color-system;
-				margin-top: 44rpx;
-			}
-		}
-		.login-input{
-			width: 654rpx;
-			height: 40rpx;
-			padding: 24rpx;
-			margin: 0 auto;
-			margin-bottom: 60rpx;
-			background: #F7F7F7;
-			border-radius: 14rpx;
-			.input{
-				width: 100%;
-				height: 100%;
-				background: #F7F7F7;
-				font-size: $font-size-28;
+				font-size: $font-size-40;
 				line-height: 40rpx;
-				color: #333333;
-				border-radius: 14rpx;
+				color:$color-system;
+				margin-top: 40rpx;
 			}
 		}
-		.login-btn{
+		.login-content{
+			width: 620rpx;
+			margin: 95rpx auto;
+			line-height: 36rpx;
+			font-size: $font-size-24;
+			color: #666666;
+			text-align: justify;
+		}
+		.login-form{
 			width: 702rpx;
-			height: 88rpx;
-			border-radius: 14rpx;
-			font-size: $font-size-28;
-			line-height: 88rpx;
-			color: #FFFFFF;
-			text-align: center;
-			background: linear-gradient(135deg,rgba(8,162,103,1) 0%,rgba(5,183,115,1) 100%);
+			height: auto;
+			display: flex;
+			flex-direction: column;
+			align-items: center;
 			margin: 0 auto;
-			margin-top: 400rpx;
+			.login-btn{
+				width: 654rpx;
+				height: 80rpx;
+				border-radius: 14rpx;
+				font-size: $font-size-32;
+				line-height: 80rpx;
+				color: #FFFFFF;
+				text-align: center;
+				background: linear-gradient(135deg,rgba(4,190,2,1) 0%,rgba(4,183,2,1) 100%);
+				display: flex;
+				flex-direction: column;
+				align-items: center;
+				&.back{
+					height: 76rpx;
+					background: #FFFFFF;
+					border: 1px solid #08A267;
+					color: #08A267;
+					margin-top: 30rpx;
+				}
+			}
 		}
 	}
 </style>

+ 44 - 14
pages/goods/product.vue

@@ -212,6 +212,7 @@
 <script>
 	import { mapState,mapMutations } from 'vuex'
 	import headerPoduct from '@/components/module/headerNavbar/header-poduct' 		 //自定义导航
+	import authorize from '@/common/config/authorize.js'
 	import uniStars from '@/components/uni-stars/uni-stars.vue'
 	import parser from "@/components/jyf-Parser/index" //富文本处理
 	import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
@@ -290,11 +291,18 @@
 				this.backPage = option.page
 			}
 			if(this.isShareType =='share'){
-				wxLogin.wxLoginAuthorize()
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					console.log(wxResponse)
+					if(wxResponse == 1){
+						wxLogin.wxLoginAuthorize()
+					}else{
+						console.log(new Date +'用户未授权微信信息')
+					}
+				})	
 			}
 		},
 		computed: {
-			...mapState(['hasLogin','userInfo'])
+			...mapState(['hasLogin','isWxAuthorize'])
 		},
 		methods:{
 			initData(){// 初始化商品详情查询
@@ -383,18 +391,30 @@
 
 			},
 			buyProductCart(){//底部购物车按钮点击
-				if(this.hasLogin){
-					this.$api.switchTabTo('/pages/tabBar/cart/cart')
-				}else{
-					this.$api.navigateTo('/pages/login/login-accont?type=1')
-				}
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						if(this.hasLogin){
+							this.$api.switchTabTo('/pages/tabBar/cart/cart')
+						}else{					
+							this.$api.navigateTo('/pages/login/login-accont?type=1')
+						}
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization')
+					}
+				})	
 			},
 			btnGetConfirm(type){//加入购物车&&立即购买点击
-				if(this.hasLogin){
-					this.showSpec(type);
-				}else{
-					this.$api.navigateTo('/pages/login/login-accont?type=1')
-				}
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						if(this.hasLogin){
+							this.showSpec(type);
+						}else{
+							this.$api.navigateTo('/pages/login/login-accont?type=1')
+						}
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization')
+					}	
+				})
 			},	
 			changeCountAdd(){//popup弹窗数量增加按钮
 				this.number++
@@ -478,7 +498,13 @@
 				})
 			},
 			navToLogin(){
-				this.$api.navigateTo(`/pages/login/login-accont?type=detilType&id=${this.productID}`)
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						this.$api.navigateTo(`/pages/login/login-accont?type=detilType&id=${this.productID}`)
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization')
+					}
+				})	
 			},
 			setHeaderBtnPosi(){
 				// 获得胶囊按钮位置信息
@@ -533,6 +559,7 @@
 		},
 		onShow() {
 			this.$api.getStorage().then((resolve) => {
+				console.log('2222222222')
 				this.userID = resolve.userID ? resolve.userID : '';	
 				this.userIdentity = resolve.userIdentity ? resolve.userIdentity : 3
 				if (isPreviewImg) {
@@ -541,7 +568,10 @@
 				} else {
 					this.initData();
 				}
-			})	
+			}).catch(resolve =>{
+				console.log('1111111111')
+				this.initData();
+			})
 		}
 	}
 </script>

+ 9 - 7
pages/login/bindOperator.vue

@@ -94,9 +94,12 @@
 			uni.setStorageSync('bind_id', option.userID);
 			this.getVerificationCode()
 		},
+		computed: {
+			...mapState(['isWxAuthorize'])
+		},
 		methods:{
 			...mapMutations(['login','logout']),
-			getCheekeyCode(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
+			getWxAuthorize(){// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 				authorize.getCode('weixin').then(wechatcode =>{
 					// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 					authorize.getUserInfo('weixin').then(res =>{
@@ -218,14 +221,13 @@
 			}
 		},
 		onShow() {
-			//查看此微信用户是否已经授权过
-			authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
-				if(res != 1){
-					this.$api.navigateTo('/pages/authorization/authorization?type=3')
+			authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+				if(wxResponse == 1){
+					this.getWxAuthorize()
 				}else{
-					this.getCheekeyCode()
+					this.$api.navigateTo('/pages/authorization/authorization')
 				}
-			})		
+			})	
 		}
 	}
 </script>

+ 30 - 10
pages/login/login-accont.vue

@@ -1,5 +1,5 @@
 <template>
-	<view class="container login">
+	<view class="container login" v-if="isWxAuthorize">
 		<view class="login-main">
 			<image class="logo" src="../../static/login-logo@3x.png" mode=""></image>
 			<text class="logo-text">生美/医美采购服务平台</text>
@@ -30,10 +30,10 @@
 </template>
 
 <script>
-	import { mapMutations } from 'vuex';
+	import { mapState,mapMutations } from 'vuex';
 	import authorize from '@/common/config/authorize.js' 
+	import wxLogin from "@/common/config/wxLogin.js"
 	import { organizationLogin } from '@/api/use.js' 
-	var self;
 	export default{
 		data() {
 			return{
@@ -55,17 +55,31 @@
 		},
 		onLoad(option) {
 			this.getOption = JSON.stringify(option)
-			
+		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		methods:{
 			...mapMutations(['login']),
 			confirmLogin(){
-				let params ={
-						mobileOrEmail:this.accountNumber,
-						password:this.password,
-						source:'www',
+				if( this.accountNumber == ''){
+					this.$util.msg('请输入账户名',2000)
+					return
+				}
+				if( this.password == ''){
+					this.$util.msg('请输入密码',2000)
+					return
 				}
-				organizationLogin(params).then(response =>{
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						this.OrganizationLogin()
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization?type=0')
+					}
+				})
+			},
+			OrganizationLogin(){
+				organizationLogin({mobileOrEmail:this.accountNumber,password:this.password,source:'www'}).then(response =>{
 					if(response.code == '0' ){
 						this.storeUpdataeStatus(response.data)
 						this.$api.navigateTo(`/pages/login/bindwechat?data=${JSON.stringify(this.getOption)}&codeType=${response.code}`)
@@ -98,7 +112,13 @@
 			},
 		},
 		onShow() {
-		
+			authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+				if(wxResponse == 1){
+					wxLogin.wxLoginAuthorize()
+				}else{
+					this.$api.navigateTo('/pages/authorization/authorization?type=0')
+				}	
+			})
 		}
 	}
 </script>

+ 0 - 3
pages/login/register.vue

@@ -178,9 +178,6 @@
 				<view class="register-from picker">
 					<view class="label">机构类型:</view>
 						<view class="row-input picker" @click="bindPickerChange">{{ organizationTypeText }}</view>
-<!-- 					<picker @change="bindPickerChange" :value="index" :range="organizationTypeList" range-key="name">
-						<view class="row-input" :class="[isOrganizationType == 0 ? 'none' : '']">{{organizationTypeList[typtIndex].name}}</view>
-					</picker> -->
 					<text class="iconfont icon-xiayibu"></text>
 				</view>
 			</view>

+ 11 - 4
pages/tabBar/cart/cart.vue

@@ -97,6 +97,7 @@
 	</view>
 </template>
 <script>
+	import authorize from '@/common/config/authorize.js'
 	import tuiSkeleton from "@/components/tui-skeleton/tui-skeleton"
 	import tuiLoadmore from "@/components/tui-components/loadmore/loadmore"
 	import tuiNomore from "@/components/tui-components/nomore/nomore"
@@ -160,7 +161,13 @@
 				})	
 			},
 			initLogin(){
-				this.$api.redirectTo('/pages/login/login-accont?type=4')
+				authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(wxResponse == 1){
+						this.$api.redirectTo('/pages/login/login-accont?type=4')
+					}else{
+						this.$api.navigateTo('/pages/authorization/authorization?type=0')
+					}
+				})	
 			},
 			setScrollHeight() {
 				// 窗口高度-footer高度
@@ -579,10 +586,10 @@
 			uni.stopPullDownRefresh()
 		},
 		onShow(){
-			if(!this.hasLogin){
-				this.initLogin()
-			}else{
+			if(this.hasLogin){
 				this.initData()
+			}else{
+				this.initLogin()
 			}
 		},
 	}

+ 20 - 24
pages/tabBar/home/home.vue

@@ -135,7 +135,7 @@
 	import uniStars from '@/components/uni-stars/uni-stars.vue'
 	import { userInfoLogin, queryHomeInfo } from "@/api/use.js"
 	import { queryPreferred } from "@/api/product.js"
-	import { mapMutations} from 'vuex';
+	import { mapState,mapMutations} from 'vuex';
 	export default {
 		components:{
 			tuiSkeleton,
@@ -145,6 +145,11 @@
 		},
 		data() {
 			return {
+				webviewStyles: {
+					progress: {
+						color: '#FF3333'
+					}
+				},
 				userID:'',
 				inputActive:'float',
 				hotSearchText:'你想要的这里都有',
@@ -175,16 +180,15 @@
 			}
 		},
 		onLoad() {
-			this.initData()
+			this.getHomeInformation()
+			this.getOrganizeProducts()
+		},
+		computed: {
+			...mapState(['hasLogin','userInfo','isWxAuthorize'])
 		},
 		methods: {
 			...mapMutations(['login','logout']),
-			async initData(){
-				this.skeletonShow = true;
-				let hotGoodsList = await this.$util.json('hotGoodsList'); 
-				this.hotGoodsList = hotGoodsList;
-			},	
-			getCheekeyCode(){
+			getWxAuthorize(){
 				authorize.getCode('weixin').then(wechatcode =>{// 根据微信的code获取用户登录状态:1已登录过 -1未登录过
 					authorize.getUserInfo('weixin').then(wxResponse =>{
 						userInfoLogin({code:wechatcode,encryptedData:wxResponse.encryptedData,iv:wxResponse.iv}).then(response =>{
@@ -197,9 +201,6 @@
 							uni.setStorageSync('sessionid','JSESSIONID='+response.data.sessionId)
 							if(response.data.userIdentity ==1){
 								this.$api.navigateTo('/market/pages/index/index')
-							}else{
-								this.getHomeInformation()
-								this.getOrganizeProducts()
 							}
 						}).catch(response =>{
 							this.isLogin = false;
@@ -207,8 +208,6 @@
 							uni.removeStorageSync('sessionid')
 							uni.setStorageSync('sessionid','JSESSIONID='+response.data)
 							this.$store.commit('updateStatus',response.data)
-							this.getHomeInformation()
-							this.getOrganizeProducts()
 						})
 					})
 				})
@@ -218,13 +217,17 @@
 					let data = res.data;
 					this.bannerImageList = data.bannerImageList
 					this.mallPageModules = data.mallPageModules
-					this.$store.commit('updateAllNum',data.shoppingCartCount)
 					this.firstModulesName= data.firstModulesName
 					this.secondModulesName= data.secondModulesName
 					this.firstModulesImage= data.firstModulesImage
 					this.secondModulesImage= data.secondModulesImage
 					this.thirdModulesName= data.thirdModulesName
 					this.skeletonShow = false;
+					if(this.isWxAuthorize){
+						this.$store.commit('updateAllNum',data.shoppingCartCount)
+					}else{
+						this.$store.commit('updateAllNum',0)
+					}
 				})
 			},
 			getOrganizeProducts(){//获取模块三商品
@@ -264,8 +267,8 @@
 				console.log(e.detail.query)
 			},
 			showTost(){
-				this.$util.msg("正在开发中,敬请期待~",2000)
-				// this.$api.navigateTo(`/market/pages/login/login`)
+				// this.$util.msg("正在开发中,敬请期待~",2000)
+				this.$api.navigateTo(`/market/pages/login/login`)
 				// uni.navigateToMiniProgram({
 				// 	appId: 'wx5a5cda32926f55ac',
 				// 	path: '/pages/tabBar/home/home',
@@ -317,17 +320,10 @@
 		},
 		onShow(){
 			this.modallayer = false;
-			//查看此微信用户是否已经授权过
 			authorize.getSetting().then(res =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
 				if(res == 1){
-					this.getCheekeyCode()
-				}else{
-					this.$api.redirectTo('/pages/authorization/authorization?type=1')
+					this.getWxAuthorize()
 				}
-			}).catch(res =>{
-				this.$util.modal('提示',res,'去授权','取消',true,() =>{
-					this.$api.redirectTo('/pages/authorization/authorization?type=1')
-				})
 			})			
 		}
 	}

+ 16 - 18
pages/tabBar/user/user.vue

@@ -1,6 +1,6 @@
 <template>
-	<view class="container user clearfix">
-		<view class="user-section" :class="[!isShowNoLogin  ? 'show' : 'none']">
+	<view class="container user clearfix" v-if="hasLogin">
+		<view class="user-section">
 			<view class="u-header">
 				<image src="https://img.caimei365.com/group1/M00/03/94/Cmis216Sk_SAPDwvAAcTspdl8h0610.png" mode=""></image>
 				<view class="u-header-main">
@@ -118,6 +118,7 @@
 </template>
 <script>
 	import uniBadge from '@/components/uni-badge/uni-badge.vue'
+	import authorize from '@/common/config/authorize.js'
 	import { mapState,mapMutations } from 'vuex'
 	import { personalInfo } from "@/api/use.js"
 	
@@ -139,7 +140,6 @@
 				waitShipmentsCount:0, //待收货角标
 				shipmentsCount:0,  //已发货角标
 				salesReturnCount:'',//退货/款角标
-				isShowNoLogin:false,
 				firstList:[
 					{name:'运营人员管理',path:'/pages/user/operator/list'},
 					{name:'机构资料',path:'/pages/login/information'},
@@ -158,7 +158,7 @@
 			...mapState(['hasLogin','userInfo'])
 		},
 		methods:{
-			initData(){
+			getUserInfo(){
 				personalInfo({userID:this.userID}).then(response =>{
 					this.$store.commit('updateAllNum',response.data.count)
 					let data =response.data
@@ -208,20 +208,24 @@
 				return num;
 			},
 			onPullDownRefresh() {//下拉刷新
-				this.initData()
+				this.getUserInfo()
 				uni.stopPullDownRefresh()
 			},
 			onShow(){
-				if(!this.hasLogin){
-					this.isShowNoLogin = true;
-					this.$api.redirectTo('/pages/login/login-accont?type=4')
-					this.$store.commit('updateAllNum',0)
-				}else{
+				if(this.hasLogin){
 					this.$api.getStorage().then((resolve) =>{
 						this.userID = resolve.userID
-						this.initData()
-						this.isShowNoLogin = false;
+						this.getUserInfo()
 					})
+				}else{
+					this.$store.commit('updateAllNum',0)
+					authorize.getSetting().then(wxResponse =>{// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+						if(wxResponse == 1){
+							this.$api.redirectTo('/pages/login/login-accont?type=0')
+						}else{
+							this.$api.navigateTo('/pages/authorization/authorization?type=0')
+						}
+					})	
 				}
 			}
 		}
@@ -239,12 +243,6 @@
 		position:relative;
 		background: rgba(247, 247, 247, 1);
 	}	
-	.user-section.none{
-		display: none;
-	}
-	.user-section.show{
-		display: block;
-	}
 	.u-header{
 		width: 100%;
 		height: 400rpx;

+ 3 - 2
store/index.js

@@ -6,6 +6,7 @@ import authorize from '../common/config/authorize.js'
 Vue.use(Vuex)
 const store = new Vuex.Store({
 	state: {
+		isWxAuthorize:false,
 		hasLogin: false,
 		userInfo: {},
 		wechatUserInfo:{},
@@ -16,12 +17,10 @@ const store = new Vuex.Store({
 		login(state, provider) {
 			state.hasLogin = true;
 			state.userInfo = provider;
-			// console.log(state.hasLogin)
 			uni.setStorage({//缓存用户登陆状态
 			    key: 'userInfo',  
 			    data: provider  
 			}) 
-			// console.log(state.userInfo);
 		},
 		logout(state) {
 			state.hasLogin = false;
@@ -34,6 +33,8 @@ const store = new Vuex.Store({
 			})
 		},
 		wxLogin(state,provider) {
+			state.isWxAuthorize = true
+			// console.log(state.isWxAuthorize)
 			state.wechatUserInfo = provider;
 			uni.setStorage({//缓存用户登陆状态
 			    key: 'wechatUserInfo',