Browse Source

企微bug

twt 8 months ago
parent
commit
db792c4221
4 changed files with 99 additions and 138 deletions
  1. 24 20
      pages/index/auto.vue
  2. 2 2
      pages/index/car.vue
  3. 11 3
      pages/index/custom.vue
  4. 62 113
      pages/index/index.vue

+ 24 - 20
pages/index/auto.vue

@@ -1,8 +1,8 @@
 <template>
 	<view class="content">
 	<!-- 	<view>11{{code}}</view> -->
-<!-- 	<view>{{agentId}}</view>
-	<view>{{code}}</view> -->
+  <!-- <view>agentId:{{agentId}}</view>
+	<view>code:{{code}}</view> -->
 	</view>
 </template>
 
@@ -24,6 +24,23 @@
 		  console.log(opt)
 		  this.agentId=opt.agentid
 		  this.corpID=opt.appid
+		  if(this.agentId){
+			  uni.setStorage({
+			  	key: 'corpID',
+			  	data: opt.appid,
+			  	 success: function () {	
+			  					
+			  	 }
+			  });
+			  uni.setStorage({
+			  	key: 'agentId',
+			  	data: opt.agentid,
+			  	 success: function () {	
+			  				
+			  	 }
+			  });
+		  }
+		  
 		  uni.showLoading({
 		   	title: '加载中'
 		  }); 
@@ -38,33 +55,20 @@
 			  	key: 'code',
 			  	data: opt.code,
 			  	 success: function () {	
-					uni.navigateTo({
+					 uni.navigateTo({
 					 	url:'index'
 					 }) 
 			  	 }
 			  });
-			  uni.setStorage({
-			  	key: 'corpID',
-			  	data: 'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
-			  	 success: function () {	
-			  					
-			  	 }
-			  });
-			  uni.setStorage({
-			  	key: 'agentId',
-			  	data: '1000051',
-			  	 success: function () {	
-			  					
-			  	 }
-			  });
+			 
 		  }else{
 			  this.$http('enterpriseWechat/auth/oAuth2', {
-			       corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+			       corpID:opt.appid,
 			  	   redirectUri:'http://qw.66km.com.cn/pages/index/auto',
-			  	   agentId:'1000051'
+			  	   agentId:opt.agentid
 			  }, 'GET').then(res => {
 			  	//console.log(res.data)
-			  	 location.href=  res.data
+			  	location.href=  res.data
 			  	
 			  }).catch(err=>{
 			  		

+ 2 - 2
pages/index/car.vue

@@ -288,9 +288,9 @@
 			   		var state= this.isDateGreater(item.carDetailInfo.InsuranceExpireDate)
 			   		var day= this.daysUntilDate(item.carDetailInfo.InsuranceExpireDate)
 			   		if(state){
-			   			txt='您的爱车'+item.PlateNumber+'车险到期时间为'+item.carDetailInfo.InsuranceExpireDate+',还有'+day+'天即将到期,请及时续保~'
+			   			txt='您的爱车'+item.PlateNumber+'车险到期时间为'+item.carDetailInfo.InsuranceExpireDate.slice(0,10)+',还有'+day+'天即将到期,请及时续保~'
 			   		}else{
-			   			txt='您的爱车'+item.PlateNumber+'车险已于'+item.carDetailInfo.InsuranceExpireDate+'为了不影响车辆使用,请及时续保~'
+			   			txt='您的爱车'+item.PlateNumber+'车险已于'+item.carDetailInfo.InsuranceExpireDate.slice(0,10)+'为了不影响车辆使用,请及时续保~'
 			   		}		   
 			   }
 			   console.log(txt)

+ 11 - 3
pages/index/custom.vue

@@ -168,6 +168,8 @@
 				unionID:'',
 				keyongMoney:'',
 				moreShow:false,
+				userId:'',
+				corpID:'',
 			}
 		},
 		onLoad() {
@@ -187,8 +189,9 @@
 				}); 
 				var that=this;
 				this.userId=uni.getStorageSync('userId')
+				this.corpID=uni.getStorageSync('corpID')
 				this.$http('enterprise/wechat/extCustomerInfo', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:this.corpID,
 				   extUserId:this.userId,
 				   token:this.token
 				}, 'GET').then(res => {
@@ -210,14 +213,19 @@
 			   	title: '加载中'
 			  }); 
 			  this.userId=uni.getStorageSync('userId')
+			  this.corpID=uni.getStorageSync('corpID')
 			  this.$http('enterprise/wechat/extCustomerMobile', {
-			     corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+			     corpID:this.corpID,
 			     extUserId: this.userId,
 			     extUserMobile:this.extUserMobile
 			  }, 'POST').then(res => {
 				   uni.hideLoading();
 				  if(res.code!=1){
-					  
+					  	 uni.showToast({
+					  	 	title: res.msg,
+					  	 	icon: 'none',
+					  	 	duration: 3000
+					  	 });
 				  }else{
 					  uni.showToast({
 							title: res.data,

+ 62 - 113
pages/index/index.vue

@@ -42,6 +42,7 @@
 		<view @click="copy(userId)">复制userId</view>
 		<view>{{token}}</view>
 		<view @click="copy(token)">复制token</view> -->
+	<!-- 	<view>agentId:{{agentId}}</view> -->
 	</view>
 </template>
 
@@ -76,14 +77,16 @@
 			this.token=uni.getStorageSync('token')
 			this.corpID=uni.getStorageSync('corpID')
 			this.agentId=uni.getStorageSync('agentId')
+			/* this.corpID='wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g'
+			this.agentId='1000051'
 			this.userId='wmMGjbBgAA0JAbGD5Vu8BzEuYgZhvhOA'
 			this.token='26AF53EA2DC528681ABD7B3AC46072E96F0A964431A2453CF0F1DA1C28732A1EAF945459643F62A3A6FD87751E6880BB'
-			
+			 */
 		     //this.userId='wmMGjbBgAALroygkoaVBN4-W2O1daIkg'
 			 //this.token='065BAA93971FEB1A37A08D682FCDB41CC69E76FC36BB038790FB99C5CD71C28EAF945459643F62A3A6FD87751E6880BB'
 		    //this.userId='wmMGjbBgAAeKTdCmEN0CLKPNwJ4ACTxw'
 			//this.token='0A809B6077F4044EDECFC49762B59668E9508B2CA4C6C4791C8894B2B1A7338AAF945459643F62A3A6FD87751E6880BB'
-			 uni.setStorage({
+			/* uni.setStorage({
 				key: 'token',
 				data: that.token,
 				 success: function () {	
@@ -97,7 +100,7 @@
 				 success: function () {	
 					
 				 }
-			}); 
+			}); */
 			/* this.code='aSBU0ums_4Z3ofjrfgSlYppwI9Cku5qtIg45ECkJTYY'
 			
 			 
@@ -112,7 +115,7 @@
 				 //this.init()
 			}
 			 */
-			 //this.authUserInfo()
+			 this.authUserInfo()
 			//this.extUserDetail()
 		},
 		methods: {
@@ -138,11 +141,35 @@
 			extCustomerInfo(){
 				var that=this;
 				this.$http('enterprise/wechat/extCustomerInfo', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   //corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:that.corpID,
 				  // extUserId:'wmMGjbBgAA0JAbGD5Vu8BzEuYgZhvhOA',
 				    extUserId:this.userId,
 				   token:this.token
 				}, 'GET').then(res => {
+					console.log(res.code)
+					 uni.hideLoading();
+					if(res.code!=1){
+						uni.showModal({
+							title: '提示',
+							content: res.msg,
+							success: function (res) {
+								if (res.confirm) {
+									console.log('用户点击确定');
+								} else if (res.cancel) {
+									console.log('用户点击取消');
+								}
+							}
+						});
+
+						
+						 //uni.clearStorageSync()
+						 uni.showToast({
+						 	title: res.msg,
+						 	icon: 'none',
+						 	duration: 3000
+						 });
+					}
 				    this.customerInfo=res.data.customerInfo
 					uni.setStorage({
 						key: 'integral',
@@ -174,7 +201,7 @@
 				var that=this;
 				
 				this.$http('enterpriseWechat/auth/extUserDetail', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:that.corpID,
 				  // extUserId:'wmMGjbBgAA0JAbGD5Vu8BzEuYgZhvhOA'
 				  extUserId:this.userId
 				}, 'GET').then(res => {
@@ -187,12 +214,19 @@
 				var that=this;
 				this.extCustomerInfo()
 				this.$http('enterpriseWechat/auth/extUserDetail', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:that.corpID,
 				  // extUserId:'wmMGjbBgAA0JAbGD5Vu8BzEuYgZhvhOA'
 				  extUserId:this.userId
 				}, 'GET').then(res => {
 					uni.hideLoading();
 					this.userDetail=res.data
+					if(res.code!=1){
+						 uni.showToast({
+						 	title: res.msg,
+						 	icon: 'none',
+						 	duration: 3000
+						 });
+					}
 					
 				})
 			},
@@ -202,18 +236,26 @@
 				 	title: '加载中'
 				}); 
 				this.$http('enterpriseWechat/auth/authUserInfo', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:that.corpID,
 				   code: this.code
 				}, 'GET').then(res => {
+					if(res.code!=1){
+						 uni.showToast({
+						 	title: res.msg,
+						 	icon: 'none',
+						 	duration: 3000
+						 });
+					}else{
+						this.token=res.data.token
+						uni.setStorage({
+							key: 'token',
+							data: that.token,
+							 success: function () {	
+								 that.init()
+							 }
+						});
+					}
 					
-					this.token=res.data.token
-					uni.setStorage({
-						key: 'token',
-						data: that.token,
-						 success: function () {	
-							 that.init()
-						 }
-					});
 					
 					//that.extUserDetail()
 					//that.extCustomerInfo()
@@ -235,12 +277,12 @@
 				} */
 				var that=this
 				this.$http('enterpriseWechat/auth/getAgentConfig', {
-				   corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
+				   corpID:that.corpID,
 				   url:'http://qw.66km.com.cn/'
 				}, 'GET').then(res => {
 					console.log(11)
 					that.$wx.agentConfig({
-					    corpid: 'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g', // 必填,企业微信的corpid,必须与当前登录的企业一致
+					    corpid:that.corpID,// 必填,企业微信的corpid,必须与当前登录的企业一致
 					    agentid:that.agentId, // 必填,企业微信的应用id (e.g. 1000247)
 					    timestamp: res.data.timestamp, // 必填,生成签名的时间戳
 					    nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
@@ -259,7 +301,7 @@
 					    fail: function(err) {
 							   console.log(err)
 							   uni.showToast({
-								title: 'agentConfig失败11',
+								title: 'agentConfig失败',
 								icon: 'none',
 								duration: 3000
 							   });
@@ -313,100 +355,7 @@
 					   }
 				   });
 			},
-		   init2(){
-			   var that=this;
-			    console.log(this.$wx.config)
-				if(this.code){
-					if(that.$wx.config){
-										   
-					}else{
-						   uni.showToast({
-							title: 'agentConfig失败',
-							icon: 'none',
-							duration: 3000
-						   });
-					}
-				}else{
-					uni.navigateTo({
-						url:'auto'
-					})
-				}
-			    uni.showLoading({
-			     	title: '加载中'
-			    }); 
-			   /* this.$http('enterpriseWechat/auth/oAuth2', {
-			     corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
-			   	 redirectUri:'http://qw.66km.com.cn/#/',
-				 agentId:'1000036'
-			   }, 'GET').then(res => {
-			   	   uni.hideLoading();
-			   	   console.log(res.data)
-			   }).catch(err=>{
-			   		uni.hideLoading();
-			   }) */
-			  
-			   this.$http('enterpriseWechat/auth/getAgentConfig', {
-			     corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
-				 url:'http://qw.66km.com.cn/'
-			   }, 'GET').then(res => {
-			   	   uni.hideLoading();
-				   console.log(this.$wx)
-				  
-				   this.$wx.config({
-				     debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
-				     appId: 'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g', // 必填,公众号的唯一标识
-				     timestamp: res.data.timestamp, // 必填,生成签名的时间戳
-				     nonceStr:  res.data.nonceStr, // 必填,生成签名的随机串
-				     signature: res.data.signature,// 必填,签名
-				     jsApiList: [getCurExternalContact] // 必填,需要使用的JS接口列表
-				   }); 
-				   that.$wx.ready(() => {
-					   if(that.$wx.agentConfig){
-					   					   
-					   }else{
-							   uni.showToast({
-								title: 'agentConfig失败',
-								icon: 'none',
-								duration: 3000
-							   });
-					   }
-					  // that.agentConfigFn()
-					  that.$wx.agentConfig({
-					      corpid: 'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g', // 必填,企业微信的corpid,必须与当前登录的企业一致
-					      agentid: '1000051', // 必填,企业微信的应用id (e.g. 1000247)
-					      timestamp: res.data.timestamp, // 必填,生成签名的时间戳
-					      nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
-					      signature: res.data.signature,// 必填,签名,见附录-JS-SDK使用权限签名算法
-					      jsApiList: ['getCurExternalContact'], //必填,传入需要使用的接口名称
-					      success: function(res) {
-								   console.log(res)
-								   uni.showToast({
-									title: 'agentConfig成功',
-									icon: 'none',
-									duration: 3000
-								   });
-					          // 回调
-					  			taht.getContext()
-					      },
-					      fail: function(res) {
-								   console.log(res)
-								   uni.showToast({
-									title: 'agentConfig失败',
-									icon: 'none',
-									duration: 3000
-								   });
-					          if(res.errMsg.indexOf('function not exist') > -1){
-					              alert('版本过低请升级')
-					          }
-					      }
-					  });
-				   })
-				 
-			   	
-			   }).catch(err=>{
-				    uni.hideLoading();
-			   })
-		   },
+		 
 		   agentConfigFn(){
 			   
 		   },