Parcourir la source

用户未登录使用流程梳理V2

john.hong il y a 2 ans
Parent
commit
4f7ffb6822

+ 1 - 1
src/App.vue

@@ -94,7 +94,7 @@ export default {
             callback: () => {
               this.$store.commit('SET_IS_INIT', true);
               // 无感积分逻辑
-              this.wxEasyPointsCommitStatusInit();
+              // this.wxEasyPointsCommitStatusInit();
             },
           });
         } catch (err) {

+ 28 - 10
src/pages/parkingFee/mixins/parkingFee.js

@@ -119,19 +119,34 @@ export default {
       await initWxJsSdkConfig(['checkJsApi', 'scanQRCode']);
     }
     const member = uni.getStorageSync('member');
-    console.log(4141, member);
+    // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
     if (!member && !uni.getStorageSync('isLogin') && window?.toWXSendMsg) {
       wxToLoginCallback('parkingFee', (options) => {
-        uni.setStorageSync('isLogin', 'isLogin');
-        // console.log(126, options);
-        // if (options?.noLoginParkingFeeWebView === 'fail') {
-        //   this.loadData();
-        // } else {
-        //   this.$router.back(-1);
-        // }
+        if(!this.openid) {
+          this.$store.commit('SET_IS_INIT', false);
+          // 请求 projectId
+          window.toWXSendMsg({
+            type: 'getProjectId',
+            options: {},
+          });
+          window.subscribe('projectId', (newOptions) => {
+            this.$store.dispatch('baseInit', {
+              options: newOptions,
+              callback: () => {
+                this.$nextTick(( ) => {
+                  this.getParkInfo();
+                  this.$store.commit('SET_IS_INIT', true);
+                })
+              },
+            });
+          });
+        } else {
+          this.getParkInfo();
+        }
       });
+      // return
     }
-
+    console.log(136, this.openid);
     if (this.openid) {
       this.getParkInfo();
       this.showSq = false;
@@ -181,7 +196,10 @@ export default {
         title: '加载中',
       });
       try {
-        const res = await parkingLots('8aaa82ea804d07cd0180516ff03b0008'); // TODO: 临时写死
+        console.log('加载车场信息', this.$store.state.lbsId);
+        // const res = await parkingLots('8aaa82ea804d07cd0180516ff03b0008'); // TODO: 临时写死
+        const res = await parkingLots(this.$store.state.lbsId); // TODO: 临时写死
+        console.log(res);
         let reg = /[;;]/g;
         this.description = res.description.replace(reg, '\r\n').replace(/\r\n/g, '<br/>');
         const carList = uni.getStorageSync('carList');

+ 4 - 13
src/pages/parkingFee/mixins/parkingFeeList.js

@@ -42,21 +42,12 @@ export default {
     canloading = true;
     pageNum = 0;
     const member = uni.getStorageSync('member');
-    // console.log('用户不走未登录', !uni.getStorageSync('loadData'));
-    if (member) {
-      this.loadData();
-    } else if(!uni.getStorageSync('loadData')){
+    this.loadData();
+    if(!uni.getStorageSync('loadData') && !member){
+      uni.setStorageSync('loadData', 'loadData')
       wxToLoginCallback('parkingFeeList', (options) => {
-        // console.log(229, options);
-        uni.setStorageSync('loadData', 'loadData')
-        if (options?.noLoginParkingFeeWebView === 'fail') {
-          this.loadData();
-        } else {
-          this.$router.back(-1);
-        }
+        this.loadData();
       });
-    } else {
-      this.loadData();
     }
   },
   filters: {

+ 5 - 2
src/pages/parkingFee/mixins/vehicleManagement.js

@@ -81,9 +81,10 @@ export default {
       });
     }, 300);
     // await this.$onLaunched
-    this.isBeijing = isCruMarketByKey('北京');
+    // this.isBeijing = isCruMarketByKey('北京');
     const member = uni.getStorageSync('member');
-    if (JSON.stringify(this.member) !== '{}') {
+    console.log('member', member);
+    if (member && JSON.stringify(this.member) !== '{}') {
       this.getKipMemberVehicles();
     } else {
       wxToLoginCallback('vehicleManagement', (options) => {
@@ -94,7 +95,9 @@ export default {
             message: '您还未登录,请登录',
             icon: 'none',
             onClose: () => {
+              console.log(97, '后退页面');
               this.$router.back();
+              return
             },
           });
         } else {

+ 1 - 1
src/store/index.js

@@ -250,7 +250,7 @@ const store = new Vuex.Store({
          commit('SET_MALL_ID', '8a888aed7d0295e5017d029ff1f40000');
          }*/
         commit('SET_LBS_ID', lbsId);
-        commit('SET_OPENID', openid);
+        commit('SET_OPENID', openid || uni.getStorageSync('openid'));
         if (isLogin) {
           commit('SET_ACCESS_TOKEN', accessToken);
           commit('SET_KIP_USER_ID', kipUserId);

+ 6 - 1
src/utils/index.js

@@ -1,5 +1,6 @@
 import qs from 'qs';
 import { lbsDictionary } from '@/common/js/BaseDictionary';
+import uni from './uniHooks'
 
 export function getMobileOperatingSystem() {
   // #ifdef H5
@@ -132,8 +133,10 @@ export function getGroupIdAndMallIdByLsbId(lbsId) {
 
 // 微信小程序端登录之后的回调
 export function wxToLoginCallback(path, callback) {
+  const oldPath = uni.getStorageSync('oldPath');
   // 如果是在微信小程序内部运行的话
-  if (getIsMin()) {
+  if (getIsMin() && oldPath !== path) {
+    uni.setStorageSync('oldPath', path);
     // 前往登录
     window.toWXSendMsg({
       type: 'toLogin',
@@ -144,8 +147,10 @@ export function wxToLoginCallback(path, callback) {
     window.subscribe('callback', (options) => {
       console.log('登录页面的回调', JSON.stringify(options));
       if (options.isReload) {
+        console.log('刷新页面');
         window.location.reload();
       } else {
+        console.log('刷新页面:callback');
         callback && callback(options);
       }
     });

+ 2 - 2
vue.config.js

@@ -115,11 +115,11 @@ module.exports = {
       },
       '/msApi': {
         // target: 'http://172.20.50.208:8080',
-        // target: 'https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service', //代理地址,这里设置的地址会代替axios中设置的baseURL
+        target: 'https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service', //代理地址,这里设置的地址会代替axios中设置的baseURL
         // target: 'http://172.21.203.140:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL   2023-2-9
         // target: 'http://172.21.203.20:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL
         // target: 'http://172.21.200.89:8080', //代理地址,这里设置的地址会代替axios中设置的baseURL
-        target: 'http://172.21.201.227:8080', // 代理地址,这里设置的地址会代替axios中设置的baseURL
+        // target: 'http://172.21.201.227:8080', // 代理地址,这里设置的地址会代替axios中设置的baseURL
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
         //ws: true, // proxy websockets
         //pathRewrite方法重写url