gcz 4 rokov pred
rodič
commit
6b95743718
1 zmenil súbory, kde vykonal 66 pridanie a 66 odobranie
  1. 66 66
      pages/center/index.vue

+ 66 - 66
pages/center/index.vue

@@ -22,7 +22,7 @@
 		<view class="u-m-t-20">
 			<u-cell-group>
 				<u-cell-item icon="star" title="手机号登录" @click="openPage('/pages/center/phoneLogin/phoneLogin')"></u-cell-item>
-				<u-cell-item icon="star" title="微信支付" @click="handlewxpay"></u-cell-item>
+				<!-- <u-cell-item icon="star" title="微信支付" @click="handlewxpay"></u-cell-item> -->
 			</u-cell-group>
 		</view>
 		
@@ -70,71 +70,71 @@
 					window.location.replace(this.config.loginUrl)
 				}
 			},
-			getCode () {
-				var local = window.location.href // 获取页面url
-				let locationLocaturl = window.location.search;
-				this.code = getUrlParams(locationLocaturl,"code"); // 截取code
-				if (this.code == null || this.code === '') { // 如果没有code,则去请求
-					window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
-				} else {
-					this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
-				}
-			},
-			handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
-				let _this = this
-				this.$u.api.getWXInfo(code).then((res) => {
-					if (res.code === 200 ) {
-						this.$u.vuex('vuex_wxinfo',res.data);
-						// 继续支付
-					}
-				}).catch((err) => {
-					this.$refs.uToast.show({
-						title: err.msg,
-						type: 'error',
-					});
-				})
-			},			
-			handlewxpay(){				
-				if(!this.$store.state.vuex_wxinfo.openId){ // 如果微信openId,则需用code去后台获取
-					this.$refs.uToast.show({
-						title: '请登录后重试!',
-						type: 'info',
-						// url: '/pages/user/index'
-					});
-					this.getCode();
-				} else {
-					// 别的业务逻辑
-					this.getWXPay();
-				}
-			},
-			async getWXPay(id){
-				let params = {
-					orderId:id||new Date().getTime(),
-					openid:this.$store.state.vuex_wxinfo.openId,
-					tradeType:"test"
-				};
-				await this.$wxApi.config(); 
-				this.$pay.wxPay(params).then(res =>{
-					console.log('wxPay',res.code);
-					if(res.code == 0){
-						// 成功
-						// uni.reLaunch({
-						// 	url: '/pages/buySuccess/buySuccess?orderId=' + params.orderId
-						// })
-					}else if(res.code == 1){
-						// 取消
-						// uni.redirectTo({
-						// 	url: '/pages/userCenter/myOrder/myOrder'
-						// })
-					}else if(res.code == 2){
-						this.$refs.uToast.show({
-							title: '支付失败,请检查!',
-							type: 'error',
-							// url: '/pages/user/index'
-						});
-					}
-				});
-			},
+			// getCode () {
+			// 	var local = window.location.href // 获取页面url
+			// 	let locationLocaturl = window.location.search;
+			// 	this.code = getUrlParams(locationLocaturl,"code"); // 截取code
+			// 	if (this.code == null || this.code === '') { // 如果没有code,则去请求
+			// 		window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${this.config.wxAppid}&redirect_uri=${encodeURIComponent(local)}&response_type=code&scope=snsapi_userinfo&#wechat_redirect`
+			// 	} else {
+			// 		this.handleGetWXInfo(this.code) //把code传给后台获取用户信息
+			// 	}
+			// },
+			// handleGetWXInfo (code) { // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
+			// 	let _this = this
+			// 	this.$u.api.getWXInfo(code).then((res) => {
+			// 		if (res.code === 200 ) {
+			// 			this.$u.vuex('vuex_wxinfo',res.data);
+			// 			// 继续支付
+			// 		}
+			// 	}).catch((err) => {
+			// 		this.$refs.uToast.show({
+			// 			title: err.msg,
+			// 			type: 'error',
+			// 		});
+			// 	})
+			// },			
+			// handlewxpay(){				
+			// 	if(!this.$store.state.vuex_wxinfo.openId){ // 如果微信openId,则需用code去后台获取
+			// 		this.$refs.uToast.show({
+			// 			title: '请登录后重试!',
+			// 			type: 'info',
+			// 			// url: '/pages/user/index'
+			// 		});
+			// 		this.getCode();
+			// 	} else {
+			// 		// 别的业务逻辑
+			// 		this.getWXPay();
+			// 	}
+			// },
+			// async getWXPay(id){
+			// 	let params = {
+			// 		orderId:id||new Date().getTime(),
+			// 		openid:this.$store.state.vuex_wxinfo.openId,
+			// 		tradeType:"test"
+			// 	};
+			// 	await this.$wxApi.config(); 
+			// 	this.$pay.wxPay(params).then(res =>{
+			// 		console.log('wxPay',res.code);
+			// 		if(res.code == 0){
+			// 			// 成功
+			// 			// uni.reLaunch({
+			// 			// 	url: '/pages/buySuccess/buySuccess?orderId=' + params.orderId
+			// 			// })
+			// 		}else if(res.code == 1){
+			// 			// 取消
+			// 			// uni.redirectTo({
+			// 			// 	url: '/pages/userCenter/myOrder/myOrder'
+			// 			// })
+			// 		}else if(res.code == 2){
+			// 			this.$refs.uToast.show({
+			// 				title: '支付失败,请检查!',
+			// 				type: 'error',
+			// 				// url: '/pages/user/index'
+			// 			});
+			// 		}
+			// 	});
+			// },
 
 		}
 	}