潘超林 2 місяців тому
батько
коміт
ca200854e2
4 змінених файлів з 31 додано та 21 видалено
  1. 5 5
      app.config.js
  2. 8 6
      pages/index/index.vue
  3. 12 6
      pages/index/pay-zfb.vue
  4. 6 4
      pages/index/pay.vue

+ 5 - 5
app.config.js

@@ -3,8 +3,8 @@
  */
 export const requestConfig = {
 	/**接口请求地址 */
-	BaseUrl: 'http://192.168.3.97:9001/api/',
-	// BaseUrl: 'https://app.sxdirectpurchase.com/api/',
+	// BaseUrl: 'http://192.168.3.97:9001/api/',
+	BaseUrl: 'https://app.sxdirectpurchase.com/api/',
 	/**微信信息*/
 	/**授权回调地址 */
 	// 授权后重定向的回调链接地址, 请使用 urlEncode 对链接进行处理
@@ -25,10 +25,10 @@ export const requestConfig = {
 
 	//获取授权类型
 	zfb_scope: "auth_user",
-	
+
 	//正式
-	zfb_request_url:"https://openauth.alipay.com/oauth2/publicAppAuthorize.htm",
-	
+	zfb_request_url: "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm",
+
 	//测试
 	// zfb_request_url: "https://openauth-sandbox.dl.alipaydev.com/oauth2/publicAppAuthorize.htm",
 

+ 8 - 6
pages/index/index.vue

@@ -37,14 +37,16 @@
 		},
 		onLoad(options) {
 			this.shopId = options.shopId;
-			let userInfo = localStorage.getItem('userInfo');
-			this.userInfo = JSON.parse(userInfo)
-			if (this.userInfo) {
-				this.radiovalue = 1
-				this.login()
+			let alipayuserinfo = localStorage.getItem("aliPayUserInfo")
+			let wechatuserinfo = localStorage.getItem("weChatUserInfo")
+			console.log(wechatuserinfo);
+			this.radiovalue = 1
+			if (alipayuserinfo) {
+				this.zfbLink()
+			} else if (wechatuserinfo) {
+				this.wxLink()
 			}
 
-
 		},
 		methods: {
 			login() {

+ 12 - 6
pages/index/pay-zfb.vue

@@ -81,14 +81,14 @@
 				shopInfo: {},
 				zfbInfo: {},
 				shopId: "",
-				localUserInfo: {}   
+				localUserInfo: {}
 
 			};
 		},
 		onLoad(options) {
 			this.zfbInfo = options
 			this.shopId = options.shopId
-			let info = localStorage.getItem('userInfo');
+			let info = localStorage.getItem('aliPayUserInfo');
 			this.localUserInfo = JSON.parse(info)
 			if (this.localUserInfo) {
 				this.vidTokenExist()
@@ -110,7 +110,7 @@
 					this.getShopInfo();
 				} else {
 					uni.$u.toast('登录已过期,请重新登录!');
-					localStorage.removeItem('userInfo');
+					localStorage.removeItem('aliPayUserInfo');
 					setTimeout(() => {
 						uni.redirectTo({
 							url: '/pages/index/index?shopId=' + this.shopId
@@ -125,7 +125,7 @@
 				);
 				if (res.data.code == 200) {
 					this.userInfo = res.data.data;
-					localStorage.setItem('userInfo', JSON.stringify(this.userInfo))
+					localStorage.setItem('aliPayUserInfo', JSON.stringify(this.userInfo))
 					if (this.userInfo.bindPhoneStatus == 0) {
 						this.showPhone = true
 					} else {
@@ -172,8 +172,10 @@
 							`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(pay.data.data.result)}`
 						// window.close(); // 关闭当前页面
 						// ap.popWindow()
+
 					} else {
-						uni.$u.toast('支付失败!');
+						uni.hideLoading();
+						uni.$u.toast(pay.data.msg);
 					}
 				} else {
 					uni.$u.toast('创建线下支付订单失败!');
@@ -216,7 +218,11 @@
 					uni.$u.toast('请输入验证码');
 				}
 				const res = await axios.post(
-					`${requestConfig.BaseUrl}user/app/v1/user/bindPhone?phone=${this.phone}&code=${this.yzm}&alipayUserId=${this.userInfo.alipayUserId}`
+					`${requestConfig.BaseUrl}user/app/v1/user/bindPhone?
+					phone=${this.phone}
+					&code=${this.yzm}
+					&alipayUserId=${this.userInfo.alipayUserId}
+					`
 				);
 				if (res.data.code == 200) {
 					uni.$u.toast('绑定手机号成功');

+ 6 - 4
pages/index/pay.vue

@@ -90,7 +90,7 @@
 		},
 		onLoad(options) {
 			this.shopId = options.shopId
-			let info = localStorage.getItem('userInfo');
+			let info = localStorage.getItem('weChatUserInfo');
 			this.localUserInfo = JSON.parse(info)
 			if (this.localUserInfo) {
 				this.vidTokenExist()
@@ -112,7 +112,7 @@
 					this.getShopInfo();
 				} else {
 					uni.$u.toast('登录已过期,请重新登录!');
-					localStorage.removeItem('userInfo');
+					localStorage.removeItem('weChatUserInfo');
 					setTimeout(() => {
 						uni.redirectTo({
 							url: '/pages/index/index?shopId=' + this.shopId
@@ -254,7 +254,7 @@
 					}
 				} else if (res.data.code == 403) {
 					uni.$u.toast('登录已过期,请重新登录!');
-					localStorage.removeItem('userInfo');
+					localStorage.removeItem('weChatUserInfo');
 					setTimeout(() => {
 						uni.redirectTo({
 							url: '/pages/index/index'
@@ -273,7 +273,9 @@
 				);
 				if (res.data.code == 200) {
 					this.userInfo = res.data.data;
-					localStorage.setItem('userInfo', JSON.stringify(this.userInfo))
+					
+					localStorage.setItem('weChatUserInfo', JSON.stringify(this.userInfo))
+					
 					if (this.userInfo.bindPhoneStatus == 0) {
 						this.showPhone = true
 					} else {