فهرست منبع

微信小程序登录逻辑梳理_v10

John-Hong 2 سال پیش
والد
کامیت
75bc716d19

+ 7 - 3
nginx_parking.conf

@@ -28,9 +28,13 @@ server {
     #     proxy_pass https://qa-apim.kerryplus.com/c/api/payment/v1;
     #     proxy_pass https://qa-apim.kerryplus.com/c/api/payment/v1;
     # }
     # }
 
 
-    # location /profileApi {
-    #     proxy_pass https://qa-apim.kerryplus.com/c/api;
-    # }
+    location /profileApi {
+        proxy_pass https://qa-apim.kerryplus.com/c/api;
+    }
+    
+    location /profileApiProd {
+        proxy_pass https://apim.kerryplus.com/c/api;
+    }
 
 
     location /sns {
     location /sns {
         proxy_pass https://api.weixin.qq.com/sns;
         proxy_pass https://api.weixin.qq.com/sns;

+ 2 - 2
src/App.vue

@@ -249,7 +249,7 @@ export default {
         this.$router.replace({
         this.$router.replace({
           path: '/home',
           path: '/home',
           query: {
           query: {
-            pageId: uni.getStorageSync('pageId'),
+            pageId: uni.getStorageSync('pageid'),
             token: uni.getStorageSync('token'),
             token: uni.getStorageSync('token'),
           },
           },
         });
         });
@@ -277,7 +277,7 @@ export default {
                 path: '/openWx',
                 path: '/openWx',
                 query: query,
                 query: query,
               });
               });
-              return
+              return;
             }
             }
             this.isInit = true;
             this.isInit = true;
             // 当所有的数据都初始化之后再次执行
             // 当所有的数据都初始化之后再次执行

+ 3 - 2
src/pages/login/openWx.vue

@@ -22,13 +22,14 @@ export default {
       const local = window.location.origin;
       const local = window.location.origin;
       // return
       // return
       if (code == null || code === '') {
       if (code == null || code === '') {
+        const componentAppid = 'wxd830fe4d1e04988e'
         window.location.href =
         window.location.href =
           'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
           'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
           //   window.APPID +
           //   window.APPID +
           `wx907c27f16841a919` +
           `wx907c27f16841a919` +
           '&redirect_uri=' +
           '&redirect_uri=' +
-          encodeURIComponent(local) +
-          '&response_type=code&scope=snsapi_base&state=1#wechat_redirect';
+          encodeURIComponent('https://dev-tparking.kerryonvip.com') +
+          `&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
       } else {
       } else {
         this.getOpenId(code); //把code传给后台获取用户信息
         this.getOpenId(code); //把code传给后台获取用户信息
       }
       }

+ 9 - 25
src/pages/parkingFee/parkingFeeDetail.vue

@@ -1816,40 +1816,24 @@ export default {
     },
     },
     // 嘉里第三方支付接口
     // 嘉里第三方支付接口
     kerryPayment(session = '011cad54-735f-4e92-8f1b-f22bdfe073cd', payParams) {
     kerryPayment(session = '011cad54-735f-4e92-8f1b-f22bdfe073cd', payParams) {
-      // window.toWXSendMsg({
-      //   type: 'openWxPay',
-      //   options: {
-      //     session
-      //   },
-      // });
-      // return
-      console.log(1782, 1782, 1782, session, payParams);
-      let appId = 'wx907c27f16841a919'
-      // const openId = MemberCacheTool.getOpenId(app);
-      // const appId = uni.getAccountInfoSync().miniProgram.appId;
-      // const appId = 'wx192b7d2e8dcbefd0';
-      // const appId = 'wx907c27f16841a919';
-      // const appId = 'wxd830fe4d1e04988e';
-      // const appId = 'wx92c3e55fbef6b2af';
-      if ( platform === 'miniprogram' ) {
-        appId = 'wx92c3e55fbef6b2af'
+      const platform = getPlatform();
+      let appId = 'wxd830fe4d1e04988e';
+      let openId = uni.getStorageSync('openid') || this.openid;
+      if (platform === 'miniprogram') {
+        appId = 'wxd830fe4d1e04988e';
       }
       }
       const params = {
       const params = {
         region: 'cn',
         region: 'cn',
         payChannel: 'MINI_PROGRAM',
         payChannel: 'MINI_PROGRAM',
         payOption: 'WECHATPAY',
         payOption: 'WECHATPAY',
         appId: appId,
         appId: appId,
-        // openId: openId,
-        openId: this.openId,
+        // openId: 'oudWQ5SCDElfn-IQH6eBR5JesOz4', // 下的appid: wxd830fe4d1e04988e
+        openId,
       };
       };
+      console.log(1854, params);
       this.$md(params);
       this.$md(params);
-      // let path =
-      //   this.$kipPaymentUrl + 'services/session/' + session + '/transactions';
-      // https://qa-payment.kerryplus.com/services/session/7c6a199a-fbcb-48b0-a9c1-b325c2c9bf88/transactions
-      // let path = 'kipPaymentUrl/services/session/' + session + '/transactions';
-      let path = `${window.injectConfig.profileApi}/payment/v1/services/session/${session}/transactions`;
+      let path = `/profileApi/payment/v1/services/session/${session}/transactions`;
       this.$request({
       this.$request({
-        // url: 'https://qa-payment.kerryplus.com/' + `services/session/${session}/transactions`,
         url: path,
         url: path,
         data: params,
         data: params,
         method: 'POST',
         method: 'POST',

+ 1 - 1
src/utils/api-crm-member.js

@@ -97,7 +97,7 @@ export function crmQueryMemberInfo (params) {
 // 获取会员详细信息用于会员注册后完善信息操作,在obj.extend属性中,外层是基础会员信息
 // 获取会员详细信息用于会员注册后完善信息操作,在obj.extend属性中,外层是基础会员信息
 export function kipGetUserDetail (params) {
 export function kipGetUserDetail (params) {
   // https://apim.kerryplus.com/c/api/profile/v1/customer/crm/current
   // https://apim.kerryplus.com/c/api/profile/v1/customer/crm/current
-  const url = window.injectConfig.profileApi + `/profile/v1/customer/crm/current`;
+  const url = + `/profileApi/profile/v1/customer/crm/current`;
   return request.get(url, params, {...DEFAULT_CONFIG});
   return request.get(url, params, {...DEFAULT_CONFIG});
 }
 }
 
 

+ 35 - 35
src/utils/authorizeH5.js

@@ -1,7 +1,7 @@
 // h5授权
 // h5授权
 export function authorizeH5(mallid, groupId, urls, callback) {
 export function authorizeH5(mallid, groupId, urls, callback) {
 	const value = uni.getStorageSync('member');
 	const value = uni.getStorageSync('member');
-  console.log('授权后的会员号', value)
+	console.log('授权后的会员号', value)
 	if (value) {
 	if (value) {
 		callback()
 		callback()
 	} else {
 	} else {
@@ -27,9 +27,9 @@ export function authorizeH5(mallid, groupId, urls, callback) {
 					})
 					})
 				}
 				}
 			},
 			},
-      fail: (err) => {
-        console.log('------err', err)
-      }
+			fail: (err) => {
+				console.log('------err', err)
+			}
 		});
 		});
 	}
 	}
 }
 }
@@ -51,7 +51,7 @@ export function getCode(mallid, groupId, urls, callback, appid, componentAppid)
 			`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&component_appid=${componentAppid}#wechat_redirect`;
 			`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&component_appid=${componentAppid}#wechat_redirect`;
 		window.location.href = url;
 		window.location.href = url;
 	} else {
 	} else {
-    console.log('-------------code授权成功')
+		console.log('-------------code授权成功')
 		// 发送code
 		// 发送code
 		this.$postCode(mallid, groupId, urls, callback, code)
 		this.$postCode(mallid, groupId, urls, callback, code)
 	}
 	}
@@ -68,13 +68,13 @@ function getUrlCode(name) {
 // 发送code 获取会员信息
 // 发送code 获取会员信息
 export function postCode(mallid, groupId, urls, callback, code) {
 export function postCode(mallid, groupId, urls, callback, code) {
 	// // const app = getApp()
 	// // const app = getApp()
- const app = {}
+	const app = {}
 	var datas = {
 	var datas = {
 		mallid: mallid,
 		mallid: mallid,
 		groupId: groupId,
 		groupId: groupId,
 		scope: 'snsapi_userinfo',
 		scope: 'snsapi_userinfo',
 		code,
 		code,
-    source: '2'
+		source: '2'
 	}
 	}
 	this.$md(datas)
 	this.$md(datas)
 	uni.request({
 	uni.request({
@@ -84,23 +84,23 @@ export function postCode(mallid, groupId, urls, callback, code) {
 		header: JSON.parse(uni.getStorageSync('handleUser')),
 		header: JSON.parse(uni.getStorageSync('handleUser')),
 		success: (res) => {
 		success: (res) => {
 			if (res.data.code == 0) {
 			if (res.data.code == 0) {
-        console.log('-----------code0获取会员信息', res.data.data)
+				console.log('-----------code0获取会员信息', res.data.data)
 				//res里面包含用户信息  openid等
 				//res里面包含用户信息  openid等
 				app.globalData.member = res.data.data.member
 				app.globalData.member = res.data.data.member
 				app.globalData.wxMember = res.data.data.wxMember
 				app.globalData.wxMember = res.data.data.wxMember
 				app.globalData.userInfo = res.data.data.userinfo || {}
 				app.globalData.userInfo = res.data.data.userinfo || {}
-        uni.setStorage({
-        	key: 'wxMember',
-        	data: JSON.stringify(res.data.data.wxMember),
-        	success: function() {
-        		console.log('userinfo-success');
-        	}
-        });
+				uni.setStorage({
+					key: 'wxMember',
+					data: JSON.stringify(res.data.data.wxMember),
+					success: function () {
+						console.log('userinfo-success');
+					}
+				});
 				// 存储会员信息
 				// 存储会员信息
 				uni.setStorage({
 				uni.setStorage({
 					key: 'member',
 					key: 'member',
 					data: JSON.stringify(res.data.data.member),
 					data: JSON.stringify(res.data.data.member),
-					success: function() {
+					success: function () {
 						console.log('userinfo-success');
 						console.log('userinfo-success');
 					}
 					}
 				});
 				});
@@ -117,7 +117,7 @@ export function postCode(mallid, groupId, urls, callback, code) {
 				uni.setStorage({
 				uni.setStorage({
 					key: 'userinfo',
 					key: 'userinfo',
 					data: JSON.stringify(res.data.data.userinfo),
 					data: JSON.stringify(res.data.data.userinfo),
-					success: function() {
+					success: function () {
 						console.log('userinfo-success');
 						console.log('userinfo-success');
 					}
 					}
 				});
 				});
@@ -125,14 +125,14 @@ export function postCode(mallid, groupId, urls, callback, code) {
 					const value = uni.getStorageSync('userinfo');
 					const value = uni.getStorageSync('userinfo');
 					if (value) {
 					if (value) {
 						var openId = JSON.parse(value).openid
 						var openId = JSON.parse(value).openid
-            app.globalData.openId = openId
-            uni.setStorageSync('openId', openId)
+						app.globalData.openId = openId
+						uni.setStorageSync('openId', openId)
 						console.log('openId', openId)
 						console.log('openId', openId)
 					}
 					}
 				} catch (e) {
 				} catch (e) {
 					// error
 					// error
 				}
 				}
-        console.log('授权后的会员号0')
+				console.log('授权后的会员号0')
 				callback()
 				callback()
 			} else if (res.data.code == 1005) {
 			} else if (res.data.code == 1005) {
 				console.log('-----------code1005获取会员信息', res.data.data)
 				console.log('-----------code1005获取会员信息', res.data.data)
@@ -140,7 +140,7 @@ export function postCode(mallid, groupId, urls, callback, code) {
 				uni.setStorage({
 				uni.setStorage({
 					key: 'userinfo',
 					key: 'userinfo',
 					data: JSON.stringify(res.data.data.userinfo),
 					data: JSON.stringify(res.data.data.userinfo),
-					success: function() {
+					success: function () {
 						console.log('userinfo-success');
 						console.log('userinfo-success');
 					}
 					}
 				});
 				});
@@ -148,25 +148,25 @@ export function postCode(mallid, groupId, urls, callback, code) {
 					const value = uni.getStorageSync('userinfo');
 					const value = uni.getStorageSync('userinfo');
 					if (value) {
 					if (value) {
 						var openId = JSON.parse(value).openid //openid
 						var openId = JSON.parse(value).openid //openid
-            app.globalData.openId = openId
-            uni.setStorageSync('openId', openId)
+						app.globalData.openId = openId
+						uni.setStorageSync('openId', openId)
 					}
 					}
 				} catch (e) {
 				} catch (e) {
 					// error
 					// error
 				}
 				}
-        console.log('---------注册登录')
-        // 仅限于集字页面的判断
-        console.log('仅限于集字页面的查看分享人手机号判断执行的回调...', this.$getLocationValue(urls, 'sharePhone'))
-        if (this.$getLocationValue(urls, 'sharePhone')) {
-          console.log('-----------有分享sharePhone', urls)
-          callback()
-        } else {
-          // 注册登录
-          window.location.href = this.$baseURLH5 + 'index.html#/pages/loginPubilc/loginH5?url='+encodeURIComponent(JSON.stringify(urls))
-        }
-        // window.location.href = this.$baseURLH5 + 'index.html#/pages/loginPubilc/loginH5?url='+encodeURIComponent(JSON.stringify(urls))
+				console.log('---------注册登录')
+				// 仅限于集字页面的判断
+				console.log('仅限于集字页面的查看分享人手机号判断执行的回调...', this.$getLocationValue(urls, 'sharePhone'))
+				if (this.$getLocationValue(urls, 'sharePhone')) {
+					console.log('-----------有分享sharePhone', urls)
+					callback()
+				} else {
+					// 注册登录
+					window.location.href = this.$baseURLH5 + 'index.html#/pages/loginPubilc/loginH5?url=' + encodeURIComponent(JSON.stringify(urls))
+				}
+				// window.location.href = this.$baseURLH5 + 'index.html#/pages/loginPubilc/loginH5?url='+encodeURIComponent(JSON.stringify(urls))
 			} else if (res.data.code == 1006) {
 			} else if (res.data.code == 1006) {
-        console.log('-----------code1006获取会员信息', res.data.data)
+				console.log('-----------code1006获取会员信息', res.data.data)
 				// 有会员查活动
 				// 有会员查活动
 				try {
 				try {
 					const member = uni.getStorageSync('member');
 					const member = uni.getStorageSync('member');

+ 2 - 2
src/utils/member-cache-tool.js

@@ -70,7 +70,7 @@ export default {
 			// app.globalData.kipMember = kipMember
 			// app.globalData.kipMember = kipMember
 			// app.globalData.openId = kipMember.openId;
 			// app.globalData.openId = kipMember.openId;
 			uni.setStorageSync('kipMember', kipMember)
 			uni.setStorageSync('kipMember', kipMember)
-			uni.setStorageSync("openId", kipMember.openId);
+			uni.setStorageSync("openid", kipMember.openId);
 			// Monitor.setConfig({
 			// Monitor.setConfig({
 			// 	c1: kipMember.id
 			// 	c1: kipMember.id
 			// })
 			// })
@@ -138,7 +138,7 @@ export default {
 		if (app) {
 		if (app) {
 			app.globalData.openId = openId
 			app.globalData.openId = openId
 		}
 		}
-		uni.setStorageSync("openId", openId)
+		uni.setStorageSync("openid", openId)
 	},
 	},
 	getOpenId () {
 	getOpenId () {
 		// let openId = app.globalData.openId;
 		// let openId = app.globalData.openId;

+ 3 - 2
src/utils/request-kip.js

@@ -56,7 +56,8 @@ function getUrl(path) {
   // 如果是dev、qa、prod环境
   // 如果是dev、qa、prod环境
   if (window.ininjectConfig) {
   if (window.ininjectConfig) {
     if (path.indexOf('/profileApi') > -1) {
     if (path.indexOf('/profileApi') > -1) {
-      return `${window.ininjectConfig.profileApi}${path}`
+      // return `${window.ininjectConfig.profileApi}${path}`
+      return `/profileApi${path}`
     }
     }
     if (/weixinApi/g.test(path)) {
     if (/weixinApi/g.test(path)) {
       return path;
       return path;
@@ -128,7 +129,7 @@ export default {
       config
       config
     }
     }
     return new Promise((resolve, reject) => {
     return new Promise((resolve, reject) => {
-      const url = getUrl(/\/sns/.test(path) ? path : `${window.injectConfig.profileApi}${path}`);
+      const url = getUrl(/\/sns/.test(path) ? path : `/profileApi${path}`);
       // console.log(130, url);
       // console.log(130, url);
       const { header } = handleConfig(config)
       const { header } = handleConfig(config)
       log.info(`===>request-kip url: ${url}`)
       log.info(`===>request-kip url: ${url}`)