소스 검색

feat(SCRM-2416): C端|H5停车缴费登陆注册入口

John-Hong 2 년 전
부모
커밋
a06f4387a2

+ 200 - 3
src/App.vue

@@ -22,14 +22,26 @@
   </div>
 </template>
 <script>
+import { KIP_API_CODE } from '@/common/js/config';
 import Stomp from '@/lib/stompjs';
+import loginMinix from '@/mixins/login';
+import {
+  kipCheckToken,
+  kipGetNewAccessTokenByRefreshToken,
+} from '@/utils/api-kip';
 import CacheTool from '@/utils/cache-tool';
 import { Decrypt, Encrypt } from '@/utils/crypto';
-import { getIsMin } from '@/utils/index.js';
+import { getIsMin, getIsWxh5 } from '@/utils/index.js';
+import KipCacheTool from '@/utils/kip-cache-tool';
+import log from '@/utils/log';
 import SockJS from '@/utils/sockjs';
+import uni from '@/utils/uniHooks';
+import { getAppIdByGroupIdAndMallId } from '@/utils/index.js';
 import { Toast } from 'vant';
+import { pathToRegexp, parse, compile } from 'path-to-regexp';
 
 export default {
+  mixins: [loginMinix],
   data() {
     return {
       ws: null,
@@ -48,6 +60,9 @@ export default {
     cachedViews() {
       return this.$store.state.cachedViews.cachedViews;
     },
+    passLogin() {
+      return this.$store.state.passLogin;
+    },
     key() {
       return this.$route.path;
     },
@@ -72,7 +87,7 @@ export default {
   methods: {
     async init() {
       // 如果是微信小程序。初始化wss
-      if (getIsMin() || true) {
+      if (getIsMin()) {
         // this.Toastloading = Toast.loading({
         //   message: '加载中',
         //   duration: 0,
@@ -101,6 +116,11 @@ export default {
           console.log(err);
         }
       }
+      // 如果是微信公众号
+      if (getIsWxh5() || true) {
+        // 判断用户是否登录
+        this.micromessengerInit();
+      }
     },
     wss() {
       return new Promise((resolve, reject) => {
@@ -193,7 +213,7 @@ export default {
       const href = window.location.href;
       console.log('当前页面的url地址  ', href);
       if (/dev-|8080/.test(href)) {
-        window.env = 'dev';
+        window.env = 'qa';
         window.profileApi = 'profileApi';
         window.api = 'qaApi';
         return;
@@ -237,6 +257,183 @@ export default {
       // return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
       return `https://crm.kerryplus.com/xcrm-api`;
     },
+    micromessengerInit() {
+      this.isInit = true;
+      const [groupId, mallId] = window.location.pathname
+        .split('/')
+        .filter((elm) => elm);
+      this.$store.commit('SET_GROUP_ID', groupId);
+      this.$store.commit('SET_MALL_ID', mallId);
+      // 设置appid
+      const appid = getAppIdByGroupIdAndMallId({
+        groupId,
+        mallId,
+        type: 'appid',
+      });
+      uni.setStorageSync('appid', appid);
+      // 如果用户没有openid
+      const openid = uni.getStorageSync('openid');
+      // 设置openid
+      if (openid && openid !== 'undefined') {
+        this.$store.commit('SET_OPENID', openid);
+        // 用户选择不登录
+        if (!this.passLogin) {
+          // 判断用户是否需要登录
+          this.checkIsLogin(() => {
+            window.location.reload();
+          });
+        }
+      } else {
+        // 前往授权页面
+        if (this.$route.path.indexOf('openWx') < 0) {
+          this.$router.push({
+            path: 'openWx',
+          });
+        }
+      }
+      // 获取openid
+      // openid 在本地存在的话,走登录验证
+      // openid 不存在的话
+      // window.location.pathname
+      // this.$router.replace({
+      //   path: 'openWx',
+      //   query: query,
+      // });
+      // 初始化微信jsdk
+      // 初始化appid,根据 lbsId、groupId、mallId
+
+      /*console.log(109, { groupId, mallId });
+      const kipAccessToken = uni.getStorageSync('kipAccessToken');
+      // 设置 member、groupId 和 mallId
+      this.$store.commit(
+        'SET_GROUP_ID',
+        groupId || uni.getStorageSync('groupId')
+      );
+      this.$store.commit('SET_MALL_ID', mallId || uni.getStorageSync('mallId'));
+      // 如果用户没有登录的话,我们需要让用户完成授权拿到 openid
+      /!* const openid = uni.getStorageSync('openid');
+       // console.log(949494, openid);
+       // 设置openid
+       if (openid && openid !== 'undefined') {
+       this.$store.commit('SET_OPENID', openid);
+       } *!/
+      // 如果用户没有openid
+      const openid = uni.getStorageSync('openid');
+      // 如果 存在,清空缓存,然后先去openid
+      // console.log(949494, openid);
+      // 设置openid
+      if (openid && openid !== 'undefined') {
+        this.$store.commit('SET_OPENID', openid);
+      }
+      if (!openid) {
+        // 当进入其他页面时,需要先打开路由展示
+        this.isInit = true;
+        // 前往授权页面
+        this.$router.replace({
+          path: '/openWx',
+          query: query,
+        });
+        return;
+      }
+      /!* 如果用户选择不登录 *!/
+      const passLogin = uni.getStorageSync('passLogin');
+      if (passLogin && /true/.test(passLogin)) {
+        return;
+      }
+      if (!openid) {
+        // 当进入其他页面时,需要先打开路由展示
+        this.isInit = true;
+        // 前往授权页面
+        this.$router.replace({
+          path: 'openWx',
+          query: query,
+        });
+        return;
+      }
+      if (!kipAccessToken) {
+        // 如果用户不选择登录,则不走登录逻辑
+        this.isInit = true;
+        this.$router.replace({
+          path: '/login',
+          query: query,
+        });
+        return;
+      }
+      // 如果用已经登录
+      // 验证 kipAccessToken 是否过期,过期则刷新
+      const _this = this;
+      kipCheckToken(kipAccessToken)
+        .then((resp) => {
+          // console.log(120, resp);
+          if (resp && resp.statusCode == '401') {
+            log.info(
+              `access_token已过期,使用refresh_token刷新access_token,如果refresh_token过期则删除所有数据`
+            );
+            // token过期之后使用refresh_token刷新access_token,如果refresh_token过期则删除所有数据
+            const kipRefreshToken = KipCacheTool.getKipRefreshToken();
+            kipGetNewAccessTokenByRefreshToken(kipRefreshToken)
+              .then((result) => {
+                // const result = resp.data;
+                if (
+                  result &&
+                  result.code === '000000' &&
+                  result.data.access_token
+                ) {
+                  KipCacheTool.setKipToken(result.data.access_token);
+                  log.info(
+                    `refreshToken获取成功,这是新的token:`,
+                    result.data.access_token
+                  );
+                } else {
+                  if (
+                    result &&
+                    result.code !== KIP_API_CODE.REFRESH_TOKEN_EXPIRED
+                  ) {
+                    uni.showToast({
+                      title: result.message,
+                      duration: 2000,
+                      icon: 'none',
+                    });
+                  }
+                  console.warn('===>清除所有缓存1');
+                  log.info(`清除所有缓存1`);
+                  _this.cleanAll();
+                  this.$router.replace({
+                    path: '/login',
+                    query: query,
+                  });
+                }
+              })
+              .catch((err) => {
+                console.warn('===>清除所有缓存2');
+                log.info(`清除所有缓存2`);
+                _this.cleanAll();
+                this.$router.replace({
+                  path: '/login',
+                  query: query,
+                });
+              });
+          }
+        })
+        .catch((err) => {
+          console.error(err);
+          console.warn('===>清除所有缓存3');
+          log.info(`refresh_token获取失败,清除所有缓存3`, err);
+          _this.cleanAll();
+          this.$router.replace({
+            path: '/login',
+            query: query,
+          });
+        });
+      // 初始化微信
+      console.log('初始化');
+      // initWxJsSdkConfig(['chooseWXPay', 'scanQRCode', 'checkJsApi'],['wx-open-launch-weapp']);
+      // initWxJsSdkConfig(['chooseWXPay']);
+      this.$router.push({
+        path: '/home',
+        query: query,
+      });*/
+    },
   },
 };
 </script>

+ 2 - 0
src/common/js/BaseDictionary.js

@@ -1,6 +1,8 @@
 // lbs 对照表,不区分环境
 export const lbsDictionary = {
   '8a84854a7cfd947d017d0289266a0003': {
+    appid: 'wx907c27f16841a919',
+    secret: 'd9c81d6c47f7de322a2ff85847de6728',
     qa: {
       groupId: '8a8485497c9cafbc017c9cb90b9d0000',
       mallId: '8a84854a7cfd947d017d02861a9d0002',

+ 199 - 185
src/constants.js

@@ -1,63 +1,66 @@
 // 嘉里MALL:KO小程序
- //const APPID = 'wx2a1741f02f7bb650';
+//const APPID = 'wx2a1741f02f7bb650';
 // 嘉里link:CRM小程序
 // const APPID = 'wxd830fe4d1e04988e'
 // console.log('uni:::::', uni)
 // const APPID = 'wxd830fe4d1e04988e' // uni.getAccountInfoSync().miniProgram.appId;
-const APPID = 'wx907c27f16841a919' // uni.getAccountInfoSync().miniProgram.appId;
+import uni from '@/utils/uniHooks';
+
+// const APPID = 'wx907c27f16841a919' // uni.getAccountInfoSync().miniProgram.appId;
+const APPID = uni.getStorageSync('appid'); // uni.getAccountInfoSync().miniProgram.appId;
 // const APPID = 'wx2a1741f02f7bb650';
 
 const APPID_MAP = {
-	kerryMall:"wx2a1741f02f7bb650",
-	kerryLink:"wxd830fe4d1e04988e",
-}
+  kerryMall: 'wx2a1741f02f7bb650',
+  kerryLink: 'wxd830fe4d1e04988e',
+};
 
 const GENDER_ARR = [
-	{tag:'♂',label:'男', value: '1'},
-	{tag:'♀',label:'女', value: '2'},
-	{tag:'不选择',label:'不选择', value: '0'},
+  { tag: '♂', label: '男', value: '1' },
+  { tag: '♀', label: '女', value: '2' },
+  { tag: '不选择', label: '不选择', value: '0' },
 ];
 const BABY_STATUS_ARR = [
-	{value:'0',label:'不选择'},
-	{value:'1',label:'有'},
-	{value:'2',label:'无'},
+  { value: '0', label: '不选择' },
+  { value: '1', label: '有' },
+  { value: '2', label: '无' },
 ];
 const CERTIFICATE_TYPE_ARR = [
-	{value:'1',label:'身份证'},
-	{value:'2',label:'驾驶证'},
-	{value:'3',label:'护照'},
-	{value:'4',label:'其他证件'},
+  { value: '1', label: '身份证' },
+  { value: '2', label: '驾驶证' },
+  { value: '3', label: '护照' },
+  { value: '4', label: '其他证件' },
 ];
 const USER_LIST_ITEM_EDIT_OBJ = {
-	'realName':{label:'姓名',placeholder:'请填写姓名'},
-	'address':{label:'详细地址',placeholder:'请填写您的详细地址编辑'},
-	'email':{label:'邮箱',placeholder:'请填写您的邮箱'},
-	'companyName':{label:'公司',placeholder:'请填写您的公司'},
-	'certificateNum':{label:'证件号码',placeholder:'请填写您的证件号码'},
-}
+  realName: { label: '姓名', placeholder: '请填写姓名' },
+  address: { label: '详细地址', placeholder: '请填写您的详细地址编辑' },
+  email: { label: '邮箱', placeholder: '请填写您的邮箱' },
+  companyName: { label: '公司', placeholder: '请填写您的公司' },
+  certificateNum: { label: '证件号码', placeholder: '请填写您的证件号码' },
+};
 
 // const LOGO_DEFAULT = `https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/logo-default.png`;
 const LOGO_KO_DEFAULT = `https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/logo-default1.png`;
 
 const LICENSE_PLATE_TYPE_ARR = [
-	{value: 'ORDINARY_CAR_NO', label: '燃油车辆'},
-	{value: 'NEW_ENERGY_CAR_NO', label: '新能源'},
-	{value: 'SPECIAL_CAR_NO', label: '特殊车辆'},
-]
+  { value: 'ORDINARY_CAR_NO', label: '燃油车辆' },
+  { value: 'NEW_ENERGY_CAR_NO', label: '新能源' },
+  { value: 'SPECIAL_CAR_NO', label: '特殊车辆' },
+];
 
 // 注册来源
 const REG_SOURCE = {
-	'SCAN_POINTS': { value: 'integral', label: '扫码积分' },
-	'ACTIVITY': { value: 'activities', label: '活动' },
-	'PARKING': { value: 'parking', label: '停车场' },
-	'MINI_APP': { value: 'miniProgram', label: '小程序注册' },
-	'OFFICIAL_ACCOUNTS': { value: 'officialAccount', label: '公众号' },
-	'COUPONS': { value: 'coupon', label: '卡券' },
-	'QUESTION_LIST':{value: 'question', label: '问卷调查'},
-	'RECEPTION':{value: 'reception', label: '服务台'},
-	'MERCHANT':{value: 'merchant', label: '商户'},
-	'THIRD_PARTY':{value: 'thirdParty', label: '第三方'},
-}
+  SCAN_POINTS: { value: 'integral', label: '扫码积分' },
+  ACTIVITY: { value: 'activities', label: '活动' },
+  PARKING: { value: 'parking', label: '停车场' },
+  MINI_APP: { value: 'miniProgram', label: '小程序注册' },
+  OFFICIAL_ACCOUNTS: { value: 'officialAccount', label: '公众号' },
+  COUPONS: { value: 'coupon', label: '卡券' },
+  QUESTION_LIST: { value: 'question', label: '问卷调查' },
+  RECEPTION: { value: 'reception', label: '服务台' },
+  MERCHANT: { value: 'merchant', label: '商户' },
+  THIRD_PARTY: { value: 'thirdParty', label: '第三方' },
+};
 
 const LOGO_DEFAULT = `https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/logo-default.png`;
 const LOGO_DEFAULT1 = `https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/images/logo-default1.png`;
@@ -74,167 +77,178 @@ const SHENYANG_LOGO = `images/logo-shenyang.png`;
 const TIANJIN_LOGO = `images/logo-tianjin.png`;
 const SHENZHEN_LOGO = `images/logo-shenzhen.png`;
 const PROD_CONST = {
-	name: 'prod',
-	constants: {
-		BASE_URL: 'https://crm.kerryplus.com/xcrm-api/',
-		BASE_URL_H5: 'https://crm.kerryplus.com/aifengleh5/',
-		WS_BASE_URL: 'wss://crm.kerryplus.com/xcrm-api',
-		PIC_URL: 'https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/',
-		KIP_PAYMENT_URL: 'https://apim.kerryplus.com/c/api/payment/v1',
-		KIP_APPID: 'wx92c3e55fbef6b2af',
-		ETCP_APPID: 'wxc07f9d67923d676d',
-		KIP_API: 'https://apim.kerryplus.com/c/api',
-		PUDONG_LBS_ID: "8a88835c7cd96d31017cda3f77e80003",
-		JINGAN_LBS_ID: "8a88835c7cd96d31017cda2fd9910000",
-		BEIJING_LBS_ID: "8a8884e77cc9e70a017cca4003590008",
-		KERRY_ON_BRAND_ID: "8a8884e77cc9e70a017cca14d07e0002",
-		KERRY_HZ_BRAND_ID: "8a8884e77cc9e70a017cca1011970001",
-		HANGZHOU_LBS_ID: "8a8883557cca9463017ccb002b360001",
-		SHENYANG_BRAND_ID: "8a8884e77cc9e70a017cca1c77e80004",
-		SHENYANG_LBS_ID: "8a888aed7d0295e5017d029ff1f40000",
-		TIANJIN_BRAND_ID: "8a8884e77cc9e70a017cca188fae0003",
-		TIANJIN_LBS_ID: "8a8883557cca9463017ccb0ce0a00002",
-		SHENZHEN_BRAND_ID: "8a888a087cc59dc0017cc622f9ad0000",
-		SHENZHEN_LBS_ID: "8a88a9fd7f73ffcd017f968739870006",
-		TRACKING_API_URL: "https://prod-tracking-cip.kerryplus.com/sa?project=kerry_tracking",
-		REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
-		LOCATION_DISTANCE_RANGE: 1, // 附近商场的位置范围,单位:千米
-	}
-}
+  name: 'prod',
+  constants: {
+    BASE_URL: 'https://crm.kerryplus.com/xcrm-api/',
+    BASE_URL_H5: 'https://crm.kerryplus.com/aifengleh5/',
+    WS_BASE_URL: 'wss://crm.kerryplus.com/xcrm-api',
+    PIC_URL: 'https://cnsh-kerry-crm-prod.oss-cn-shanghai.aliyuncs.com/',
+    KIP_PAYMENT_URL: 'https://apim.kerryplus.com/c/api/payment/v1',
+    KIP_APPID: 'wx92c3e55fbef6b2af',
+    ETCP_APPID: 'wxc07f9d67923d676d',
+    KIP_API: 'https://apim.kerryplus.com/c/api',
+    PUDONG_LBS_ID: '8a88835c7cd96d31017cda3f77e80003',
+    JINGAN_LBS_ID: '8a88835c7cd96d31017cda2fd9910000',
+    BEIJING_LBS_ID: '8a8884e77cc9e70a017cca4003590008',
+    KERRY_ON_BRAND_ID: '8a8884e77cc9e70a017cca14d07e0002',
+    KERRY_HZ_BRAND_ID: '8a8884e77cc9e70a017cca1011970001',
+    HANGZHOU_LBS_ID: '8a8883557cca9463017ccb002b360001',
+    SHENYANG_BRAND_ID: '8a8884e77cc9e70a017cca1c77e80004',
+    SHENYANG_LBS_ID: '8a888aed7d0295e5017d029ff1f40000',
+    TIANJIN_BRAND_ID: '8a8884e77cc9e70a017cca188fae0003',
+    TIANJIN_LBS_ID: '8a8883557cca9463017ccb0ce0a00002',
+    SHENZHEN_BRAND_ID: '8a888a087cc59dc0017cc622f9ad0000',
+    SHENZHEN_LBS_ID: '8a88a9fd7f73ffcd017f968739870006',
+    TRACKING_API_URL:
+      'https://prod-tracking-cip.kerryplus.com/sa?project=kerry_tracking',
+    REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
+    LOCATION_DISTANCE_RANGE: 1, // 附近商场的位置范围,单位:千米
+  },
+};
 
 const QA_CONST = {
-	name: 'qa',
-	constants: {
-		BASE_URL: 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api/',
-		BASE_URL_H5: 'https://qa-crm-kpl.kerryprops.com.cn/aifengleh5/',
-		WS_BASE_URL: 'wss://qa-crm-kpl.kerryprops.com.cn/xcrm-api',
-		PIC_URL: 'https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com/',
-		KIP_PAYMENT_URL: 'https://qa-apim.kerryplus.com/c/api/payment/v1',
-		KIP_APPID: 'wx92c3e55fbef6b2af',
-		ETCP_APPID: 'wxc07f9d67923d676d',
-		KIP_API: 'https://qa-apim.kerryplus.com/c/api',
-		PUDONG_LBS_ID: "8a8481f57cca9442017ce02875b8004a",
-		JINGAN_LBS_ID: "8a8481f57cca9442017ce026ddd40049",
-		BEIJING_LBS_ID: "8a8485067ce4da2d017ce555e9b20000",
-		KERRY_ON_BRAND_ID: "8a8480487c96d58f017c9b7bab7d0020",
-		KERRY_HZ_BRAND_ID: "8a84853b7c91ac5b017c962dab55030e",
-		HANGZHOU_LBS_ID: "8a84853b7c91ac5b017c961a9b2a030d",
-		SHENYANG_BRAND_ID: "8a8485497c9cafbc017c9cb90b9d0000",
-		SHENYANG_LBS_ID: "8a84854a7cfd947d017d02861a9d0002",
-		TIANJIN_BRAND_ID: "8a84819f7c6e260e017c726b6c8f01c3",
-		TIANJIN_LBS_ID: "8a84819f7c6e260e017c72a446c201c4",
-		SHENZHEN_BRAND_ID: "8a84819f7c6e260e017c72669bbe01c2",
-		SHENZHEN_LBS_ID: "8a8486a37f48f7bd017f4e5bddd10000",
-		TRACKING_API_URL: "https://qa-tracking-cip.kerryplus.com/sa?project=kerry_tracking",
-		REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
-		LOCATION_DISTANCE_RANGE: 5000, // 附近商场的位置范围,单位:千米
-	}
-}
+  name: 'qa',
+  constants: {
+    BASE_URL: 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api/',
+    BASE_URL_H5: 'https://qa-crm-kpl.kerryprops.com.cn/aifengleh5/',
+    WS_BASE_URL: 'wss://qa-crm-kpl.kerryprops.com.cn/xcrm-api',
+    PIC_URL: 'https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com/',
+    KIP_PAYMENT_URL: 'https://qa-apim.kerryplus.com/c/api/payment/v1',
+    KIP_APPID: 'wx92c3e55fbef6b2af',
+    ETCP_APPID: 'wxc07f9d67923d676d',
+    KIP_API: 'https://qa-apim.kerryplus.com/c/api',
+    PUDONG_LBS_ID: '8a8481f57cca9442017ce02875b8004a',
+    JINGAN_LBS_ID: '8a8481f57cca9442017ce026ddd40049',
+    BEIJING_LBS_ID: '8a8485067ce4da2d017ce555e9b20000',
+    KERRY_ON_BRAND_ID: '8a8480487c96d58f017c9b7bab7d0020',
+    KERRY_HZ_BRAND_ID: '8a84853b7c91ac5b017c962dab55030e',
+    HANGZHOU_LBS_ID: '8a84853b7c91ac5b017c961a9b2a030d',
+    SHENYANG_BRAND_ID: '8a8485497c9cafbc017c9cb90b9d0000',
+    SHENYANG_LBS_ID: '8a84854a7cfd947d017d02861a9d0002',
+    TIANJIN_BRAND_ID: '8a84819f7c6e260e017c726b6c8f01c3',
+    TIANJIN_LBS_ID: '8a84819f7c6e260e017c72a446c201c4',
+    SHENZHEN_BRAND_ID: '8a84819f7c6e260e017c72669bbe01c2',
+    SHENZHEN_LBS_ID: '8a8486a37f48f7bd017f4e5bddd10000',
+    TRACKING_API_URL:
+      'https://qa-tracking-cip.kerryplus.com/sa?project=kerry_tracking',
+    REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
+    LOCATION_DISTANCE_RANGE: 5000, // 附近商场的位置范围,单位:千米
+  },
+};
 const DEV_CONST = {
-	name: 'dev',
-	constants: {
-		BASE_URL: 'https://dev-crm-kpl.kerryprops.com.cn/xcrm-api/',
-		BASE_URL_H5: 'https://dev-crm-kpl.kerryprops.com.cn/aifengleh5/',
-		WS_BASE_URL: 'wss://dev-crm-kpl.kerryprops.com.cn/xcrm-api',
-		PIC_URL: 'https://dev-crm-kpl.kerryprops.com.cn/upload',
-		KIP_PAYMENT_URL: 'https://qa-payment.kerryplus.com/',
-		KIP_APPID: 'wx92c3e55fbef6b2af',
-		ETCP_APPID: 'wxc07f9d67923d676d',
-		KIP_API: 'https://dev-gateway-kip.kerryonvip.com/api',
-		PUDONG_LBS_ID: "8aaa81cb7c836c6b017c83e46b110001",
-		JINGAN_LBS_ID: "8aaa81cb7c836c6b017c83e2c76f0000",
-		BEIJING_LBS_ID: "8aaa80b47c784020017c78b205ba0023",
-		KERRY_ON_BRAND_ID: "8aaa81947c6e1ca0017c7201e82d0001",
-		KERRY_HZ_BRAND_ID: "4028e3817c2b3f79017c2b48c54c0000",
-		HANGZHOU_LBS_ID: "8aaa80b47c784020017c78b00d060022",
-		SHENYANG_BRAND_ID: "8a8485497c9cafbc017c9cb90b9d0000",
-		SHENYANG_LBS_ID: "8a84854a7cfd947d017d02861a9d0002",
-		TIANJIN_BRAND_ID: "8a84819f7c6e260e017c726b6c8f01c3",
-		TIANJIN_LBS_ID: "8a84819f7c6e260e017c72a446c201c4",
-		SHENZHEN_BRAND_ID: "8a84819f7c6e260e017c72669bbe01c2",
-		SHENZHEN_LBS_ID: "8a8486a37f48f7bd017f4e5bddd10000",
-		TRACKING_API_URL: "https://dev-tracking-cip.kerryplus.com/sa?project=kerry_tracking",
-		REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
-		LOCATION_DISTANCE_RANGE: 5000, // 附近商场的位置范围,单位:千米
-	}
-}
+  name: 'dev',
+  constants: {
+    BASE_URL: 'https://dev-crm-kpl.kerryprops.com.cn/xcrm-api/',
+    BASE_URL_H5: 'https://dev-crm-kpl.kerryprops.com.cn/aifengleh5/',
+    WS_BASE_URL: 'wss://dev-crm-kpl.kerryprops.com.cn/xcrm-api',
+    PIC_URL: 'https://dev-crm-kpl.kerryprops.com.cn/upload',
+    KIP_PAYMENT_URL: 'https://qa-payment.kerryplus.com/',
+    KIP_APPID: 'wx92c3e55fbef6b2af',
+    ETCP_APPID: 'wxc07f9d67923d676d',
+    KIP_API: 'https://dev-gateway-kip.kerryonvip.com/api',
+    PUDONG_LBS_ID: '8aaa81cb7c836c6b017c83e46b110001',
+    JINGAN_LBS_ID: '8aaa81cb7c836c6b017c83e2c76f0000',
+    BEIJING_LBS_ID: '8aaa80b47c784020017c78b205ba0023',
+    KERRY_ON_BRAND_ID: '8aaa81947c6e1ca0017c7201e82d0001',
+    KERRY_HZ_BRAND_ID: '4028e3817c2b3f79017c2b48c54c0000',
+    HANGZHOU_LBS_ID: '8aaa80b47c784020017c78b00d060022',
+    SHENYANG_BRAND_ID: '8a8485497c9cafbc017c9cb90b9d0000',
+    SHENYANG_LBS_ID: '8a84854a7cfd947d017d02861a9d0002',
+    TIANJIN_BRAND_ID: '8a84819f7c6e260e017c726b6c8f01c3',
+    TIANJIN_LBS_ID: '8a84819f7c6e260e017c72a446c201c4',
+    SHENZHEN_BRAND_ID: '8a84819f7c6e260e017c72669bbe01c2',
+    SHENZHEN_LBS_ID: '8a8486a37f48f7bd017f4e5bddd10000',
+    TRACKING_API_URL:
+      'https://dev-tracking-cip.kerryplus.com/sa?project=kerry_tracking',
+    REQ_lOCATION_TIME_LIMIT: 5000, // 请求位置限制时间,单位:毫秒
+    LOCATION_DISTANCE_RANGE: 5000, // 附近商场的位置范围,单位:千米
+  },
+};
 
 const ENV_LIST = [PROD_CONST, QA_CONST, DEV_CONST];
 
 // 扫码积分
 const BRAND_LBS_CONFIG = {
-	// 北京嘉里中心
-	'1': {
-		groupId: 'KERRY_ON_BRAND_ID',
-		mallId: 'BEIJING_LBS_ID',
-	},
-	// 杭州嘉里中心
-	'2': {
-		groupId: 'KERRY_HZ_BRAND_ID',
-		mallId: 'HANGZHOU_LBS_ID',
-	},
-	// 浦东嘉里中心
-	'3': {
-		groupId: 'KERRY_ON_BRAND_ID',
-		mallId: 'PUDONG_LBS_ID',
-	},
-	// 静安嘉里中心
-	'4': {
-		groupId: 'KERRY_ON_BRAND_ID',
-		mallId: 'JINGAN_LBS_ID',
-	},
-	// 沈阳嘉里中心
-	'5': {
-		groupId: 'SHENYANG_BRAND_ID',
-		mallId: 'SHENYANG_LBS_ID',
-	},
-	// 天津嘉里中心
-	'6': {
-		groupId: 'TIANJIN_BRAND_ID',
-		mallId: 'TIANJIN_LBS_ID',
-	},
-	// 深圳嘉里中心
-	'7': {
-		groupId: 'SHENZHEN_BRAND_ID',
-		mallId: 'SHENZHEN_LBS_ID',
-	},
+  // 北京嘉里中心
+  1: {
+    groupId: 'KERRY_ON_BRAND_ID',
+    mallId: 'BEIJING_LBS_ID',
+  },
+  // 杭州嘉里中心
+  2: {
+    groupId: 'KERRY_HZ_BRAND_ID',
+    mallId: 'HANGZHOU_LBS_ID',
+  },
+  // 浦东嘉里中心
+  3: {
+    groupId: 'KERRY_ON_BRAND_ID',
+    mallId: 'PUDONG_LBS_ID',
+  },
+  // 静安嘉里中心
+  4: {
+    groupId: 'KERRY_ON_BRAND_ID',
+    mallId: 'JINGAN_LBS_ID',
+  },
+  // 沈阳嘉里中心
+  5: {
+    groupId: 'SHENYANG_BRAND_ID',
+    mallId: 'SHENYANG_LBS_ID',
+  },
+  // 天津嘉里中心
+  6: {
+    groupId: 'TIANJIN_BRAND_ID',
+    mallId: 'TIANJIN_LBS_ID',
+  },
+  // 深圳嘉里中心
+  7: {
+    groupId: 'SHENZHEN_BRAND_ID',
+    mallId: 'SHENZHEN_LBS_ID',
+  },
 };
 
-const SOURCE_KEY = ['channel', 'utm_channel', 'utm_method', 'utm_source', 'utm_function', 'utm_user', 'utm_lbs']
+const SOURCE_KEY = [
+  'channel',
+  'utm_channel',
+  'utm_method',
+  'utm_source',
+  'utm_function',
+  'utm_user',
+  'utm_lbs',
+];
 
 const SOURCE_FUN_PREFIX = {
-	activity: 'ev_',
-	ticket: 'co_',
-	invite: 'rf_'
-}
+  activity: 'ev_',
+  ticket: 'co_',
+  invite: 'rf_',
+};
 
-const MINI_APP_VERSION = '1.17.0'
+const MINI_APP_VERSION = '1.17.0';
 
 export {
-	APPID,
-	GENDER_ARR,
-	BABY_STATUS_ARR,
-	CERTIFICATE_TYPE_ARR,
-	USER_LIST_ITEM_EDIT_OBJ,
-	LICENSE_PLATE_TYPE_ARR,
-	KIP_APP_PATH,
-	ETCP_APP_PATH,
-	ETCP_APP_INVOICE_PATH,
-	REG_SOURCE,
-	LOGO_DEFAULT,
-	LOGO_DEFAULT1,
-	LOGO_KO_DEFAULT,
-	JINGAN_LOGO,
-	PUDONG_LOGO,
-	BEIJING_LOGO,
-	HANGZHOU_LOGO,
-	ENV_LIST,
-	BRAND_LBS_CONFIG,
-	APPID_MAP,
-	SOURCE_KEY,
-	SOURCE_FUN_PREFIX,
-	SHENYANG_LOGO,
-	TIANJIN_LOGO,
-	SHENZHEN_LOGO,
-	MINI_APP_VERSION,
-}
+  APPID,
+  GENDER_ARR,
+  BABY_STATUS_ARR,
+  CERTIFICATE_TYPE_ARR,
+  USER_LIST_ITEM_EDIT_OBJ,
+  LICENSE_PLATE_TYPE_ARR,
+  KIP_APP_PATH,
+  ETCP_APP_PATH,
+  ETCP_APP_INVOICE_PATH,
+  REG_SOURCE,
+  LOGO_DEFAULT,
+  LOGO_DEFAULT1,
+  LOGO_KO_DEFAULT,
+  JINGAN_LOGO,
+  PUDONG_LOGO,
+  BEIJING_LOGO,
+  HANGZHOU_LOGO,
+  ENV_LIST,
+  BRAND_LBS_CONFIG,
+  APPID_MAP,
+  SOURCE_KEY,
+  SOURCE_FUN_PREFIX,
+  SHENYANG_LOGO,
+  TIANJIN_LOGO,
+  SHENZHEN_LOGO,
+  MINI_APP_VERSION,
+};

+ 88 - 0
src/mixins/login.js

@@ -0,0 +1,88 @@
+import { KIP_API_CODE } from '@/common/js/config';
+import {
+  kipCheckToken,
+  kipGetNewAccessTokenByRefreshToken,
+} from '@/utils/api-kip';
+import KipCacheTool from '@/utils/kip-cache-tool';
+import log from '@/utils/log';
+import MemberCacheTool from '@/utils/member-cache-tool';
+import uni from '@/utils/uniHooks';
+import { Toast } from 'vant';
+
+export default {
+  methods: {
+    async checkIsLogin(callback) {
+      // 判断用户是否登录
+      // 如果登录
+      // 未登录,或者是首次登录
+      const kipAccessToken = uni.getStorageSync('kipAccessToken');
+      if (!kipAccessToken) {
+        // 如果用户不选择登录,则不走登录逻辑
+        this.isInit = true;
+        await this.$router.replace({
+          path: 'login',
+        });
+        return;
+      }
+      // 用户二次登录,本地存在 kipAccessToken 检查 token 是否需要登录
+      const [stopCallBack] = await this.checkKipToken(kipAccessToken);
+      if (stopCallBack) return stopCallBack();
+      if (callback) {
+        callback();
+      }
+    },
+    checkKipToken(kipAccessToken) {
+      return new Promise(async (resolve) => {
+        try {
+          const resp = await kipCheckToken(kipAccessToken);
+          if (resp && resp.statusCode === '401') {
+            log.info(
+              `access_token已过期,使用refresh_token刷新access_token,如果refresh_token过期则删除所有数据`
+            );
+            const kipRefreshToken = KipCacheTool.getKipRefreshToken();
+            const result = await kipGetNewAccessTokenByRefreshToken(
+              kipRefreshToken
+            );
+            if (
+              result &&
+              result.code === '000000' &&
+              result.data.access_token
+            ) {
+              KipCacheTool.setKipToken(result.data.access_token);
+              log.info(
+                `refreshToken获取成功,这是新的token:`,
+                result.data.access_token
+              );
+              resolve([]);
+              return;
+            }
+            if (result && result.code !== KIP_API_CODE.REFRESH_TOKEN_EXPIRED) {
+              Toast({
+                message: result.message,
+                duration: 2000,
+              });
+            }
+            resolve([this.toLogin]);
+            return;
+          }
+          resolve([]);
+        } catch (err) {
+          resolve([this.toLogin]);
+        }
+      });
+    },
+    toLogin() {
+      console.warn('===>清除所有缓存1');
+      log.info(`清除所有缓存1`);
+      this.cleanAll();
+      this.$router.replace({
+        path: 'login',
+      });
+    },
+    cleanAll() {
+      // 清除所有用户信息
+      KipCacheTool.cleanKipCache();
+      MemberCacheTool.cleanMemberCache(this);
+    },
+  },
+};

+ 3 - 4
src/pages/login/login.vue

@@ -55,12 +55,11 @@
         注册/登录
       </button>
     </div>
-
-    <!-- div class="mgt20">
+    <div class="mgt20">
       <button class="authorize_btn authorize_btn--phone" @click="passLogin">
         未登录使用
       </button>
-    </div> -->
+    </div>
 
     <div class="mgt34">
       <div style="margin: 0 30px">
@@ -254,7 +253,7 @@ export default {
     },
     passLogin() {
       this.$store.commit('SET_PASS_LOGIN', true);
-      this.$router.push({path: '/home'})
+      this.$router.replace({ path: 'home' });
     },
     // 获取验证码
     getCodeData: function () {

+ 34 - 22
src/pages/login/openWx.vue

@@ -5,15 +5,26 @@
   </div>
 </template>
 <script>
-import { getUrlParams } from '@/utils/index';
+import { KIP_API_CODE } from '@/common/js/config';
+import { getUrlParams, getAppIdByGroupIdAndMallId } from '@/utils/index';
+import KipCacheTool from '@/utils/kip-cache-tool';
+import log from '@/utils/log';
 import { WxJsOpenId } from '@/utils/login';
+import MemberCacheTool from '@/utils/member-cache-tool';
 import uni from '@/utils/uniHooks';
+import {
+  kipCheckToken,
+  kipGetNewAccessTokenByRefreshToken,
+} from '@/utils/api-kip';
+import { Toast } from 'vant';
+import loginMinix from '@/mixins/login';
 
 export default {
   created() {
     console.log(12121212);
     this.getCode();
   },
+  mixins: [loginMinix],
   mounted() {
     console.log(17171717171717);
     const kipAccessToken = uni.getStorageSync('kipAccessToken');
@@ -34,7 +45,7 @@ export default {
       // 如果用户不选择登录,则不走登录逻辑
       this.isInit = true;
       this.$router.replace({
-        path: '/login',
+        path: 'login',
         query: query,
       });
       return;
@@ -43,14 +54,20 @@ export default {
   methods: {
     getCode() {
       const { code = '' } = getUrlParams(); // 截取路径中的code,如果没有就去微信授权,如果已经获取到了就直接传code给后台获取openId
-      const local = window.location.origin;
-      // return
+      const local = window.location.href;
+      // return;
       if (code == null || code === '') {
         // const componentAppid = 'wxd830fe4d1e04988e'
+        const { appid } = getAppIdByGroupIdAndMallId({
+          groupId: this.$route.params.groupId,
+          mallId: this.$route.params.mallId,
+          type: 'appid',
+        });
         window.location.href =
           'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
           //   window.APPID +
-          `wx907c27f16841a919` +
+          // `wx907c27f16841a919` +
+          appid +
           '&redirect_uri=' +
           encodeURIComponent(local) +
           // `&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect`;
@@ -61,32 +78,27 @@ export default {
     },
     async getOpenId(code) {
       // 通过code获取 openId等用户信息,/api/user/wechat/login 为后台接口
-      let _this = this;
-
+      const { appid, secret } = getAppIdByGroupIdAndMallId({
+        groupId: this.$route.params.groupId,
+        mallId: this.$route.params.mallId,
+        type: 'all',
+      });
       // ?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
       const res = await WxJsOpenId({
-        appid: 'wx907c27f16841a919',
-        secret: 'd9c81d6c47f7de322a2ff85847de6728',
+        appid,
+        secret,
         code,
         grant_type: 'authorization_code',
       });
       if (res?.expires_in && res?.openid) {
         this.$store.commit('SET_OPENID', res.openid);
-        this.$router.replace({
-          path: '/home',
+        // 判断用户是否需要登录,
+        await this.checkIsLogin(() => {
+          this.$router.replace({
+            path: 'home',
+          });
         });
       }
-      //   this.$http
-      //     .post('/api/user/wechat/login', { code: code })
-      //     .then((res) => {
-      //       let datas = res.data;
-      //       if (datas.code === 0) {
-      //         console.log('成功');
-      //       }
-      //     })
-      //     .catch((error) => {
-      //       console.log(error);
-      //     });
     },
   },
 };

+ 2 - 2
src/pages/parkingFee/parkingFee.vue

@@ -1,6 +1,6 @@
 <template>
   <div style="background-color: #f4f7ff">
-    <LoginDom></LoginDom>
+    <!--    <LoginDom></LoginDom>-->
     <scroll-view class="wrap-box">
       <div class="parkingFee" ref="parkingFee">
         <div class="parkingFee-top bg">
@@ -417,7 +417,7 @@ export default {
         openid: openid,
         vipcode: this.member?.vipcode,
       };
-      // console.log(342, params);
+      console.log(342, params);
       this.$md(params);
       this.$request({
         url: this.$baseURL + 'api/1.0/park/parkInfo',

+ 11 - 6
src/pages/parkingFee/parkingFeeDetail.vue

@@ -479,9 +479,13 @@ export default {
     const platform = getPlatform();
     if (platform === 'micromessenger') {
       initWxJsSdkConfig(['chooseWXPay']);
-      if (window.wxJsSdkConfigInitPromise) {
-        await window.wxJsSdkConfigInitPromise;
-      }
+      // try {
+      //   if (window.wxJsSdkConfigInitPromise) {
+      //     await window.wxJsSdkConfigInitPromise;
+      //   }
+      // } catch (e) {
+      //   console.log(487, e);
+      // }
     }
     const option = this.$route.query;
     this.picUrl = this.$picUrl;
@@ -1736,14 +1740,15 @@ export default {
     // 嘉里第三方支付接口
     kerryPayment(session = '011cad54-735f-4e92-8f1b-f22bdfe073cd', payParams) {
       const platform = getPlatform();
-      let appId = 'wxd830fe4d1e04988e';
+      let appId = uni.getStorageSync('appid');
       let openId = uni.getStorageSync('openid') || this.openid;
       if (platform === 'miniprogram') {
         appId = 'wx92c3e55fbef6b2af';
       }
       const params = {
         region: 'cn',
-        payChannel: 'MINI_PROGRAM',
+        payChannel: 'OFFICIAL_ACCOUNT',
+        // payChannel: 'MOBILE_WEB',
         payOption: 'WECHATPAY',
         appId: appId,
         // openId: 'oudWQ5SCDElfn-IQH6eBR5JesOz4', // 下的appid: wxd830fe4d1e04988e
@@ -1752,7 +1757,7 @@ export default {
       // console.log(1854, params);
       this.$md(params);
       // let path = `/profileApi/payment/v1/services/session/${session}/transactions`;
-      let path = `/${window.profileApi}/payment/v1/services/session/${session}/transactions`;
+      let path = `https://qa-apim.kerryplus.com/c/api/payment/v1/services/session/${session}/transactions`;
       this.$request({
         url: path,
         data: params,

+ 9 - 0
src/routes/index.js

@@ -156,14 +156,23 @@ const wxRoutes = routes.map((item) => {
   };
 });
 
+const otherRoutes = routes.map((item) => {
+  return {
+    ...item,
+    path: `/:groupId/:mallId${item.path}`,
+  };
+});
+
 const router = new VueRouter({
   mode: 'history',
   routes: [
     ...routes,
     ...wxRoutes,
+    ...otherRoutes,
     { path: '*', component: import('@/pages/NotFoundComponent/index.vue') },
   ],
 });
+console.log(175, router);
 
 // router.beforeEach((to, from, next) => {
 //   // let pageId = '';

+ 28 - 3
src/utils/index.js

@@ -62,7 +62,8 @@ export function getPlatform() {
     return 'micromessenger';
   }
   // TODO: 发布前取消注释
-  return 'browser';
+  // return 'browser';
+  return 'micromessenger';
 }
 
 // 是否在微信小程序中运行
@@ -78,13 +79,37 @@ export function getIsWxh5() {
 }
 
 // 获取appid
-export function getAppid() {
+export function getAppIdByGroupIdAndMallId({ groupId, mallId, type }) {
   const platform = getPlatform();
   if (platform === 'miniprogram') {
-    // TODO: 后期在其他公众号上线H5应用,appid需要根据地址栏的 project 动态处理
     return 'wx92c3e55fbef6b2af';
   }
   if (platform === 'micromessenger') {
+    // 后期在其他公众号上线H5应用,appid需要根据地址栏的 project 动态处理, 已预留入口
+    console.log(89);
+    const env = window.env === 'qa' ? 'qa' : 'prod';
+    let appInfo = {};
+    Object.keys(lbsDictionary).forEach((lbsId) => {
+      const elm = lbsDictionary[lbsId];
+      console.log(92, env, elm[env].groupId, groupId, elm[env].mallId, mallId);
+      if (elm[env].groupId === groupId && elm[env].mallId === mallId) {
+        appInfo = {
+          appid: elm.appid,
+          secret: elm.secret,
+        };
+      }
+    });
+    console.log(101, appInfo);
+    if (JSON.stringify(appInfo) === '{}') {
+      // groupId, mallId 错误
+      return;
+    }
+    if (type === 'appid') {
+      return appInfo.appid;
+    }
+    if (type === 'all') {
+      return appInfo;
+    }
     return 'wx907c27f16841a919';
   }
   return '';

+ 68 - 30
src/utils/login.js

@@ -1,9 +1,9 @@
 // import { ApiResponse, get, post } from './request';
 // import { get,post } from '@/utils/request-kip.js'
 import wx from './js_sdk/weixin';
-import request from '@/utils/request-kip.js'
-const get = request.get
-const post = request.post
+import request from '@/utils/request-kip.js';
+const get = request.get;
+const post = request.post;
 import store from '@/store';
 import { getMobileOperatingSystem, getQueryParam, isInWeixinH5 } from '@/utils';
 // import { Token } from './config/tokenManager';
@@ -20,7 +20,10 @@ const OAUTH_PREFIX = '/oauth/v1';
  */
 export function login(params) {
   // request.post(url, params, {contentType: 'form', ...DEFAULT_CONFIG, noToken: true});
-  return request.post(`${OAUTH_PREFIX}/auth/phone-login`, params, { isAuthRequest: true, isHandleError: false });
+  return request.post(`${OAUTH_PREFIX}/auth/phone-login`, params, {
+    isAuthRequest: true,
+    isHandleError: false,
+  });
 }
 
 //
@@ -34,7 +37,10 @@ export function login(params) {
  : Promise<{ code: string, data: Token }>
  */
 export function loginWeixinH5(params) {
-  return request.post(`${OAUTH_PREFIX}/auth/subscription-phone-login`, params, { isAuthRequest: true, isHandleError: false });
+  return request.post(`${OAUTH_PREFIX}/auth/subscription-phone-login`, params, {
+    isAuthRequest: true,
+    isHandleError: false,
+  });
 }
 
 /*
@@ -47,7 +53,10 @@ export function loginWeixinH5(params) {
  : Promise<{ code: string, data: Token }>
  */
 export function loginByWxOnClick(params) {
-  return request.post(`${OAUTH_PREFIX}/auth/authorized-phone-login`, params, { isAuthRequest: true, isHandleError: false });
+  return request.post(`${OAUTH_PREFIX}/auth/authorized-phone-login`, params, {
+    isAuthRequest: true,
+    isHandleError: false,
+  });
 }
 
 /*
@@ -55,7 +64,11 @@ export function loginByWxOnClick(params) {
  : Promise<{ code: string, data: Token }>
  */
 export function getLoginTokenByWxCode(jsCode) {
-  return request.post(`${OAUTH_PREFIX}/auth/openid-login`, { jsCode, }, { isAuthRequest: true, isHandleError: false });
+  return request.post(
+    `${OAUTH_PREFIX}/auth/openid-login`,
+    { jsCode },
+    { isAuthRequest: true, isHandleError: false }
+  );
 }
 
 /*
@@ -64,7 +77,11 @@ export function getLoginTokenByWxCode(jsCode) {
  : Promise<{ code: string, data: Token }>
  */
 export function getLoginTokenByWxCodeH5(authCode) {
-  return request.post(`${OAUTH_PREFIX}/auth/subscription-code-login`, { authCode }, { isAuthRequest: true, isHandleError: false });
+  return request.post(
+    `${OAUTH_PREFIX}/auth/subscription-code-login`,
+    { authCode },
+    { isAuthRequest: true, isHandleError: false }
+  );
 }
 
 /*
@@ -73,7 +90,11 @@ export function getLoginTokenByWxCodeH5(authCode) {
  : Promise<ApiResponse<Token>>
  */
 export function updateToken(refresh_token) {
-  return request.post(`${OAUTH_PREFIX}/oauth/renewToken`, { refreshToken: refresh_token }, { isAuthRequest: true, isHandleError: false })
+  return request.post(
+    `${OAUTH_PREFIX}/oauth/renewToken`,
+    { refreshToken: refresh_token },
+    { isAuthRequest: true, isHandleError: false }
+  );
 }
 
 /*
@@ -83,11 +104,11 @@ export function updateToken(refresh_token) {
 export function logout() {
   let data = undefined;
   // #ifdef MP-WEIXIN
-  data = { 'removeBinding': 1 };
+  data = { removeBinding: 1 };
   // #endif
   // #ifdef H5
   if (isInWeixinH5()) {
-    data = { 'removeBinding': 1 };
+    data = { removeBinding: 1 };
   }
   // #endif
   return post(`${OAUTH_PREFIX}/auth/logout`, data, { isLogout: true });
@@ -123,7 +144,10 @@ export function WxJsOpenId(param) {
  }>
  */
 function WxJsSdkSignature(param) {
-  return request.post(`https://qa-apim.kerryplus.com/c/api/oauth/v1/wx/config/signature`, param);
+  return request.post(
+    `https://qa-apim.kerryplus.com/c/api/oauth/v1/wx/config/signature`,
+    param
+  );
 }
 
 /*
@@ -150,8 +174,8 @@ async function WxJsSdkConfig(jsApiList = [], url = '', openTagList = []) {
   const res = await WxJsSdkSignature({ url: url ? url : location.href }); // 这个接口需要登录!
   let debug = false;
   try {
-    debug = uni.getStorageSync("WX_JSSDK_DEBUG");
-  } catch { }
+    debug = uni.getStorageSync('WX_JSSDK_DEBUG');
+  } catch {}
   return new Promise((resolve, reject) => {
     wx.config({
       debug,
@@ -161,7 +185,7 @@ async function WxJsSdkConfig(jsApiList = [], url = '', openTagList = []) {
       nonceStr: res.data.nonceStr,
       signature: res.data.signature,
       jsApiList,
-      openTagList: openTagList ? openTagList : []
+      openTagList: openTagList ? openTagList : [],
     });
     wx.ready(function () {
       // 来自微信官方文档:
@@ -183,7 +207,6 @@ async function WxJsSdkConfig(jsApiList = [], url = '', openTagList = []) {
 // 将 wx.uploadImage 上传的图片转存到阿里云OSS
 // 后端调用的
 
-
 /*
  param: { appId: string, mediaId: string }
 
@@ -207,7 +230,12 @@ export function WxJsUploadMediaToOSS(param) {
 
  : Promise<{ message: string, ossUrls: string[] }>
  */
-export async function wxChooseImageAndUpload(count, sizeType, sourceType, loadingText) {
+export async function wxChooseImageAndUpload(
+  count,
+  sizeType,
+  sourceType,
+  loadingText
+) {
   return new Promise((resolve, reject) => {
     wx.chooseImage({
       count: count,
@@ -224,7 +252,7 @@ export async function wxChooseImageAndUpload(count, sizeType, sourceType, loadin
         }
         const localIds = res.localIds;
         // eslint-disable-next-line no-console
-        console.log("----00---", res.localIds);
+        console.log('----00---', res.localIds);
         const serverIds = [];
         const ossUrls = [];
         let i = 0;
@@ -237,11 +265,14 @@ export async function wxChooseImageAndUpload(count, sizeType, sourceType, loadin
             success: async (resUpload) => {
               serverIds.push(resUpload.serverId);
               // eslint-disable-next-line no-console
-              console.log("----01---", serverIds.join(';'));
-              const resOssUpload = await WxJsUploadMediaToOSS({ appId: store.state.appId, mediaId: resUpload.serverId });
+              console.log('----01---', serverIds.join(';'));
+              const resOssUpload = await WxJsUploadMediaToOSS({
+                appId: store.state.appId,
+                mediaId: resUpload.serverId,
+              });
               ossUrls.unshift(resOssUpload.videoUrl);
               // eslint-disable-next-line no-console
-              console.log("----02---", serverIds.join(';'), ossUrls);
+              console.log('----02---', serverIds.join(';'), ossUrls);
               //如果还有照片,继续上传
               i++;
               if (i < length) {
@@ -252,18 +283,18 @@ export async function wxChooseImageAndUpload(count, sizeType, sourceType, loadin
             },
             fail: (resFail) => {
               // eslint-disable-next-line no-console
-              console.log("----03---", resFail);
+              console.log('----03---', resFail);
               reject(resFail);
-            }
+            },
           });
         };
         upload();
       },
       fail: (resFail) => {
         // eslint-disable-next-line no-console
-        console.log("----04---", resFail);
+        console.log('----04---', resFail);
         reject(resFail);
-      }
+      },
     });
   });
 }
@@ -287,13 +318,20 @@ export function getOpenIdInH5() {
     return;
   }
 
-  const redirect_uri = location.origin + LANDING_PAGE
-    + "?appId=" + store.state.appId
-    + "&redirect_uri=" + encodeURIComponent(fullPath);
+  const redirect_uri =
+    location.origin +
+    LANDING_PAGE +
+    '?appId=' +
+    store.state.appId +
+    '&redirect_uri=' +
+    encodeURIComponent(fullPath);
   const state = 'abc123';
 
-  const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${store.state.appId}` +
-    `&redirect_uri=${encodeURIComponent(redirect_uri)}&response_type=code&scope=snsapi_userinfo` +
+  const url =
+    `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${store.state.appId}` +
+    `&redirect_uri=${encodeURIComponent(
+      redirect_uri
+    )}&response_type=code&scope=snsapi_userinfo` +
     `&state=${state}#wechat_redirect`;
 
   location.href = url;

+ 245 - 239
src/utils/member-cache-tool.js

@@ -1,239 +1,245 @@
-import log from './log.js'
-import Monitor from '@/utils/monitor.js'
-import uni from './uniHooks'
-export default {
-	cleanMemberCache(app) {
-		this.cleanCurMemberCache(app)
-		this.cleanKipMemberCache(app)
-		uni.removeStorageSync('memberArray')
-	},
-	cleanCurMemberCache(app) {
-		// return ''
-		try {
-			app.$store.state.member = null
-			app.$store.state.wxMember = null
-			app.$store.state.userInfo = null;
-		} catch (err) {
-			console.log(17, err);
-		}
-		uni.removeStorageSync('member')
-		uni.removeStorageSync('wxMember')
-		uni.removeStorageSync("userInfo");
-	},
-	cleanKipMemberCache(app) {
-		// return ''
-		try {
-			app.$store.state.kipMember = null;
-			app.$store.state.openId = null;
-		} catch (err) {
-			console.log(29, err);
-		}
-		uni.removeStorageSync("kipMember");
-		uni.removeStorageSync("openId");
-	},
-	setMemberCache(app, { member, wxMember }) {
-		if (wxMember) {
-			member.openId = wxMember.openid
-			member.unionid = wxMember.unionid;
-		} else {
-			wxMember = member;
-		}
-		const userInfo = memberToWxUserInfo(member)
-
-		const memberObj = {
-			member,
-			wxMember,
-			userInfo,
-		}
-
-		setMemberArrayCache(app, member.groupId, memberObj);
-	},
-	setCurMemberCacheByGroupId(app, curGroupId) {
-		if (!curGroupId) {
-			console.error("[setCurMemberCache] curGroupId不存在")
-			return;
-		}
-		const memberArray = uni.getStorageSync("memberArray");
-		if (!memberArray) {
-			console.warn("[setCurMemberCache] memberArray不存在")
-			return null;
-		}
-		if (memberArray && curGroupId) {
-			const curMemberObj = memberArray[curGroupId];
-			if (curMemberObj) {
-				changeCurMemberCache(app, curMemberObj)
-				return curMemberObj;
-			} else {
-				console.info("[setCurMemberCache] 清空当前会员信息")
-				this.cleanCurMemberCache(app)
-			}
-		}
-		return null;
-	},
-	setKipMember(app, kipMember) {
-		if (kipMember) {
-			// app.globalData.kipMember = kipMember
-			// app.globalData.openId = kipMember.openId;
-			uni.setStorageSync('kipMember', kipMember)
-			uni.setStorageSync("openid", kipMember.openId);
-			// Monitor.setConfig({
-			// 	c1: kipMember.id
-			// })
-		}
-	},
-	getKipMember() {
-		const kipMember = uni.getStorageSync('kipMember')
-		if (isNotEmpty(kipMember)) {
-			return kipMember;
-		}
-		return null;
-	},
-	handleKipMemberToCrmMember(kipMemberInfo) {
-		if (!kipMemberInfo) return null;
-		// lastLoginTime: null
-		let crmMember = {
-			kipUserId: kipMemberInfo.id
-		}
-		if (kipMemberInfo.avatar) {
-			crmMember.headimgUrl = kipMemberInfo.avatar
-		}
-		if (kipMemberInfo.birthDate) {
-			crmMember.birthday = kipMemberInfo.birthDate
-		}
-		if (kipMemberInfo.gender || kipMemberInfo.gender == '0') {
-			if (kipMemberInfo.gender == '0') {
-				crmMember.sex = 'U'
-			} else if (kipMemberInfo.gender == '1') {
-				crmMember.sex = 'M'
-			} else if (kipMemberInfo.gender == '2') {
-				crmMember.sex = 'F'
-			}
-		}
-		if (kipMemberInfo.nickName) {
-			crmMember.nickname = kipMemberInfo.nickName
-		}
-		if (kipMemberInfo.openId) {
-			crmMember.openid = kipMemberInfo.openId
-		}
-		if (kipMemberInfo.phoneNumber) {
-			crmMember.mobile = kipMemberInfo.phoneNumber
-		}
-		if (kipMemberInfo.realName) {
-			crmMember.realName = kipMemberInfo.realName
-		}
-		crmMember.source = "1";
-		return crmMember;
-	},
-	getMemberCacheByGroupId(groupId) {
-		if (!groupId) {
-			console.warn('[getMemberCacheByGroupId] groupId 不能为空')
-			return null;
-		}
-		const memberArray = uni.getStorageSync("memberArray");
-		if (!memberArray) {
-			console.warn('[getMemberCacheByGroupId] memberArray 为空')
-			return null;
-		}
-		return memberArray[groupId];
-	},
-	setOpenId(app, openId) {
-		if (!openId) {
-			return;
-		}
-		if (app) {
-			app.globalData.openId = openId
-		}
-		uni.setStorageSync("openid", openId)
-	},
-	getOpenId() {
-		// let openId = app.globalData.openId;
-		let openId = '00000'
-		log.info(`===>获取到globalData中的openId: ${openId}`)
-		// if (!openId) {
-		// 	// openId = app.globalData.member?.openId
-		// 	let openId = '00000'
-		// 	log.info(`===>获取到globalData.member中的openId: ${openId}`)
-		// }
-		if (!openId) {
-			openId = uni.getStorageSync("openid");
-			log.info(`===>获取到storage中的openId: ${openId}`)
-		}
-		// if (!openId) {
-		// 	openId = uni.getStorageSync("member")?.openId;
-		// 	log.info(`===>获取到storage.member中的openId: ${openId}`)
-		// }
-		return openId;
-	}
-}
-
-// 改变当前会员信息
-function changeCurMemberCache(app, { member, wxMember, userInfo }) {
-	if (app) {
-		app.globalData.member = member;
-		app.globalData.wxMember = wxMember;
-		app.globalData.userInfo = userInfo;
-	}
-	uni.setStorageSync("member", member);
-	uni.setStorageSync("wxMember", wxMember);
-	uni.setStorageSync("userInfo", userInfo);
-	Monitor.setConfig({
-		setUsername: () => member.vipcode
-	})
-}
-
-// 将会员信息存入数组
-function setMemberArrayCache(app, groupId, memberObj) {
-	if (!groupId || !memberObj) {
-		return null;
-	}
-	let memberArray = uni.getStorageSync("memberArray");
-	if (!memberArray) {
-		memberArray = {};
-	}
-	memberArray[groupId] = memberObj
-	uni.setStorageSync("memberArray", memberArray)
-	changeCurMemberCache(app, memberObj)
-}
-
-function isEmpty(obj) {
-	if (!obj || JSON.stringify(obj) == '{}' || obj == 'undefined') {
-		return true;
-	}
-	return false;
-}
-
-function isNotEmpty(obj) {
-	return !isEmpty(obj);
-}
-
-function memberToWxUserInfo(member) {
-	if (!member) return null;
-	const userInfo = {
-		kipUserId: member.kipUserId
-	}
-	if (member.headimgurl) {
-		userInfo.avatarUrl = member.headimgurl
-	}
-	if (member.nickname) {
-		userInfo.nickName = member.nickname
-	}
-	if (member.countryAddress) {
-		userInfo.country = member.countryAddress
-	}
-	if (member.headimgurl) {
-		userInfo.province = member.headimgurl
-	}
-	if (member.provinceAddress) {
-		userInfo.city = member.provinceAddress
-	}
-	if (member.sex) {
-		if (member.sex == 'U') {
-			userInfo.gender = 0
-		} else if (member.sex == 'M') {
-			userInfo.gender = 1
-		} else if (member.sex == 'F') {
-			userInfo.gender = 2
-		}
-	}
-	return userInfo;
-}
+import log from './log.js';
+import Monitor from '@/utils/monitor.js';
+import uni from './uniHooks';
+export default {
+  cleanMemberCache(app) {
+    app.$store.commit('SET_MEMBER', '');
+    app.$store.commit('SET_USER_INFO', '');
+    app.$store.commit('SET_OPENID', '');
+    // uni.removeStorageSync('memberArray');
+  },
+  cleanCurMemberCache(app) {
+    this.cleanMemberCache(app);
+    // app.$store.commit('SET_MEMBER', '');
+    // app.$store.commit('SET_USER_INFO', '');
+    // app.$store.commit('SET_MEMBER', '');
+    // app.$store.commit('SET_USER_INFO', '');
+    // // return ''
+    // try {
+    // 	app.$store.state.member = null
+    // 	app.$store.state.wxMember = null
+    // 	app.$store.state.userInfo = null;
+    // } catch (err) {
+    // 	console.log(17, err);
+    // }
+    // uni.removeStorageSync('member')
+    // uni.removeStorageSync('wxMember')
+    // uni.removeStorageSync("userInfo");
+  },
+  cleanKipMemberCache(app) {
+    // return ''
+    try {
+      app.$store.state.kipMember = null;
+      app.$store.state.openId = null;
+    } catch (err) {
+      console.log(29, err);
+    }
+    uni.removeStorageSync('kipMember');
+    uni.removeStorageSync('openId');
+  },
+  setMemberCache(app, { member, wxMember }) {
+    if (wxMember) {
+      member.openId = wxMember.openid;
+      member.unionid = wxMember.unionid;
+    } else {
+      wxMember = member;
+    }
+    const userInfo = memberToWxUserInfo(member);
+
+    const memberObj = {
+      member,
+      wxMember,
+      userInfo,
+    };
+
+    setMemberArrayCache(app, member.groupId, memberObj);
+  },
+  setCurMemberCacheByGroupId(app, curGroupId) {
+    if (!curGroupId) {
+      console.error('[setCurMemberCache] curGroupId不存在');
+      return;
+    }
+    const memberArray = uni.getStorageSync('memberArray');
+    if (!memberArray) {
+      console.warn('[setCurMemberCache] memberArray不存在');
+      return null;
+    }
+    if (memberArray && curGroupId) {
+      const curMemberObj = memberArray[curGroupId];
+      if (curMemberObj) {
+        changeCurMemberCache(app, curMemberObj);
+        return curMemberObj;
+      } else {
+        console.info('[setCurMemberCache] 清空当前会员信息');
+        this.cleanCurMemberCache(app);
+      }
+    }
+    return null;
+  },
+  setKipMember(app, kipMember) {
+    if (kipMember) {
+      // app.globalData.kipMember = kipMember
+      // app.globalData.openId = kipMember.openId;
+      uni.setStorageSync('kipMember', kipMember);
+      uni.setStorageSync('openid', kipMember.openId);
+      // Monitor.setConfig({
+      // 	c1: kipMember.id
+      // })
+    }
+  },
+  getKipMember() {
+    const kipMember = uni.getStorageSync('kipMember');
+    if (isNotEmpty(kipMember)) {
+      return kipMember;
+    }
+    return null;
+  },
+  handleKipMemberToCrmMember(kipMemberInfo) {
+    if (!kipMemberInfo) return null;
+    // lastLoginTime: null
+    let crmMember = {
+      kipUserId: kipMemberInfo.id,
+    };
+    if (kipMemberInfo.avatar) {
+      crmMember.headimgUrl = kipMemberInfo.avatar;
+    }
+    if (kipMemberInfo.birthDate) {
+      crmMember.birthday = kipMemberInfo.birthDate;
+    }
+    if (kipMemberInfo.gender || kipMemberInfo.gender == '0') {
+      if (kipMemberInfo.gender == '0') {
+        crmMember.sex = 'U';
+      } else if (kipMemberInfo.gender == '1') {
+        crmMember.sex = 'M';
+      } else if (kipMemberInfo.gender == '2') {
+        crmMember.sex = 'F';
+      }
+    }
+    if (kipMemberInfo.nickName) {
+      crmMember.nickname = kipMemberInfo.nickName;
+    }
+    if (kipMemberInfo.openId) {
+      crmMember.openid = kipMemberInfo.openId;
+    }
+    if (kipMemberInfo.phoneNumber) {
+      crmMember.mobile = kipMemberInfo.phoneNumber;
+    }
+    if (kipMemberInfo.realName) {
+      crmMember.realName = kipMemberInfo.realName;
+    }
+    crmMember.source = '1';
+    return crmMember;
+  },
+  getMemberCacheByGroupId(groupId) {
+    if (!groupId) {
+      console.warn('[getMemberCacheByGroupId] groupId 不能为空');
+      return null;
+    }
+    const memberArray = uni.getStorageSync('memberArray');
+    if (!memberArray) {
+      console.warn('[getMemberCacheByGroupId] memberArray 为空');
+      return null;
+    }
+    return memberArray[groupId];
+  },
+  setOpenId(app, openId) {
+    if (!openId) {
+      return;
+    }
+    if (app) {
+      app.globalData.openId = openId;
+    }
+    uni.setStorageSync('openid', openId);
+  },
+  getOpenId() {
+    // let openId = app.globalData.openId;
+    let openId = '00000';
+    log.info(`===>获取到globalData中的openId: ${openId}`);
+    // if (!openId) {
+    // 	// openId = app.globalData.member?.openId
+    // 	let openId = '00000'
+    // 	log.info(`===>获取到globalData.member中的openId: ${openId}`)
+    // }
+    if (!openId) {
+      openId = uni.getStorageSync('openid');
+      log.info(`===>获取到storage中的openId: ${openId}`);
+    }
+    // if (!openId) {
+    // 	openId = uni.getStorageSync("member")?.openId;
+    // 	log.info(`===>获取到storage.member中的openId: ${openId}`)
+    // }
+    return openId;
+  },
+};
+
+// 改变当前会员信息
+function changeCurMemberCache(app, { member, wxMember, userInfo }) {
+  if (app) {
+    app.globalData.member = member;
+    app.globalData.wxMember = wxMember;
+    app.globalData.userInfo = userInfo;
+  }
+  uni.setStorageSync('member', member);
+  uni.setStorageSync('wxMember', wxMember);
+  uni.setStorageSync('userInfo', userInfo);
+  Monitor.setConfig({
+    setUsername: () => member.vipcode,
+  });
+}
+
+// 将会员信息存入数组
+function setMemberArrayCache(app, groupId, memberObj) {
+  if (!groupId || !memberObj) {
+    return null;
+  }
+  let memberArray = uni.getStorageSync('memberArray');
+  if (!memberArray) {
+    memberArray = {};
+  }
+  memberArray[groupId] = memberObj;
+  uni.setStorageSync('memberArray', memberArray);
+  changeCurMemberCache(app, memberObj);
+}
+
+function isEmpty(obj) {
+  if (!obj || JSON.stringify(obj) == '{}' || obj == 'undefined') {
+    return true;
+  }
+  return false;
+}
+
+function isNotEmpty(obj) {
+  return !isEmpty(obj);
+}
+
+function memberToWxUserInfo(member) {
+  if (!member) return null;
+  const userInfo = {
+    kipUserId: member.kipUserId,
+  };
+  if (member.headimgurl) {
+    userInfo.avatarUrl = member.headimgurl;
+  }
+  if (member.nickname) {
+    userInfo.nickName = member.nickname;
+  }
+  if (member.countryAddress) {
+    userInfo.country = member.countryAddress;
+  }
+  if (member.headimgurl) {
+    userInfo.province = member.headimgurl;
+  }
+  if (member.provinceAddress) {
+    userInfo.city = member.provinceAddress;
+  }
+  if (member.sex) {
+    if (member.sex == 'U') {
+      userInfo.gender = 0;
+    } else if (member.sex == 'M') {
+      userInfo.gender = 1;
+    } else if (member.sex == 'F') {
+      userInfo.gender = 2;
+    }
+  }
+  return userInfo;
+}

+ 112 - 98
src/utils/request-kip.js

@@ -1,41 +1,41 @@
-import { APPID, SOURCE_KEY } from '@/constants.js'
-import CacheTool from '@/utils/cache-tool.js'
-import log from './log.js'
-import { getUTMSource } from '@/utils/utils.js'
-import uni from './uniHooks'
+import { APPID, SOURCE_KEY } from '@/constants.js';
+import CacheTool from '@/utils/cache-tool.js';
+import log from './log.js';
+import { getUTMSource } from '@/utils/utils.js';
+import uni from './uniHooks';
 
 const CONTENT_TYPE_ARRAY = {
-  'json': 'application/json',
-  'form': 'application/x-www-form-urlencoded'
-}
+  json: 'application/json',
+  form: 'application/x-www-form-urlencoded',
+};
 
 function getHeaders(config = {}) {
   const { contentType = 'json' } = config;
   const ct = CONTENT_TYPE_ARRAY[contentType];
   let header = {
-    'appId': APPID,
-    'Content-Type': ct
+    appId: uni.getStorageSync('appid'),
+    'Content-Type': ct,
   };
-  const token = getToken()
+  const token = getToken();
   if (token) {
     header['Authorization'] = `Bearer ${token}`;
   }
 
-  const groupId = uni.getStorageSync("groupId");
-  const mallId = uni.getStorageSync("mallid");
+  const groupId = uni.getStorageSync('groupId');
+  const mallId = uni.getStorageSync('mallid');
   if (groupId) {
-    header['brandId'] = groupId
+    header['brandId'] = groupId;
   }
   if (mallId) {
-    header['lbsId'] = mallId
+    header['lbsId'] = mallId;
   }
   const sourceObj = getUTMSource();
   return Object.assign(header, sourceObj);
 }
 
 function handleConfig(config = {}) {
-  const header = getHeaders(config)
-  const noToken = config.noToken
+  const header = getHeaders(config);
+  const noToken = config.noToken;
   if (noToken) {
     delete header.Authorization;
   }
@@ -43,12 +43,12 @@ function handleConfig(config = {}) {
 }
 
 function getToken() {
-  const token = uni.getStorageSync('kipAccessToken')
+  const token = uni.getStorageSync('kipAccessToken');
   // if (!token || token?.trim() == '' || token == 'null' || token == 'undefined') {
   if (!token || token == 'null' || token == 'undefined') {
     return false;
   }
-  return token
+  return token;
 }
 
 function getUrl(path) {
@@ -57,24 +57,27 @@ function getUrl(path) {
   if (window.ininjectConfig) {
     if (path.indexOf(`/${window.profileApi}`) > -1) {
       // return `${window.ininjectConfig.profileApi}${path}`
-      return `/${window.profileApi}${path}`
+      return `/${window.profileApi}${path}`;
     }
     if (/weixinApi/g.test(path)) {
       return path;
     }
     if (/\/qaPayment/g.test(path)) {
-      return `${window.ininjectConfig.qaPayment}${path.replace(/\/qaPayment/g, '')}`
+      return `${window.ininjectConfig.qaPayment}${path.replace(
+        /\/qaPayment/g,
+        ''
+      )}`;
     }
   }
   // 本地开发环境
-  // path.indexOf('http') > -1 && 
+  // path.indexOf('http') > -1 &&
   if (path.indexOf(`/${window.profileApi}`) > -1 || path) {
     return path;
   } else if (/\/qaPayment/g.test(path)) {
     // 支付
-    return `https://qa-payment.kerryonvip.com${path}`
+    return `https://qa-payment.kerryonvip.com${path}`;
   } else {
-    return CacheTool.getCurEnvConst('KIP_API') + path
+    return CacheTool.getCurEnvConst('KIP_API') + path;
   }
 }
 
@@ -82,24 +85,24 @@ function cleanCacheAndGoLogin() {
   // 删除token以及会员数据
   uni.removeStorageSync('kipAccessToken');
   uni.removeStorageSync('isNewUser');
-  uni.removeStorageSync('kipRefreshToken')
+  uni.removeStorageSync('kipRefreshToken');
   // 直接跳转到登录页面
-  uni.removeStorageSync('member')
-  uni.removeStorageSync('wxMember')
-  uni.removeStorageSync("openId");
-  uni.removeStorageSync("userInfo");
+  uni.removeStorageSync('member');
+  uni.removeStorageSync('wxMember');
+  uni.removeStorageSync('openId');
+  uni.removeStorageSync('userInfo');
   uni.reLaunch({
-    url: '/pages/automatic/automaticMy.vue'
-  })
+    url: '/pages/automatic/automaticMy.vue',
+  });
 }
 
 function handleKipResponse(resp, request) {
   if (resp && resp.data) {
     const { status } = resp;
-    console.log(`kip request resp => errMsg ${status}`)
+    console.log(`kip request resp => errMsg ${status}`);
     const { path } = request.detail;
     let isLogout = false;
-    if (path.indexOf("/logout") > -1) {
+    if (path.indexOf('/logout') > -1) {
       isLogout = true;
     }
     if (!resp || !resp.data) {
@@ -107,11 +110,11 @@ function handleKipResponse(resp, request) {
     }
     const result = resp.data;
     if (result) {
-      const { message, code } = result || {}
-      console.log(`kip api resul => message: ${message} code: ${code}`)
+      const { message, code } = result || {};
+      console.log(`kip api resul => message: ${message} code: ${code}`);
       if (result.code == '300000' && !isLogout) {
-        console.warn('===> kip的access_token已过期')
-        log.info(`kip的access_token已过期`, result)
+        console.warn('===> kip的access_token已过期');
+        log.info(`kip的access_token已过期`, result);
       }
     }
   }
@@ -126,44 +129,49 @@ export default {
       method,
       path,
       param,
-      config
-    }
+      config,
+    };
     return new Promise((resolve, reject) => {
-      const url = getUrl(/\/sns|http/g.test(path) ? path : `/${window.profileApi}${path}`);
+      const url = getUrl(
+        /\/sns|http/g.test(path) ? path : `/${window.profileApi}${path}`
+      );
       // console.log(130, url);
-      const { header } = handleConfig(config)
-      log.info(`===>request-kip url: ${url}`)
-      log.info(`===>request-kip header: ${JSON.stringify(header)}`)
-      uni.request({
-        header: header,
-        method: method,
-        url: url,
-        data: param,
-      }).then(res => {
-        log.info(`===>request-kip response: ${JSON.stringify(res.data)}`)
-        resolve(handleKipResponse(res, _this))
-        if (res.status == 581) {
-          uni.navigateTo({
-            url: '/pages/errorPage/errorLimit?msg=当前访问太火爆了,稍后试试吧~'
-          })
-        }
-      }).catch((response) => {
-        log.error(`===>request-kip error: ${JSON.stringify(response)}`)
-        reject(response)
-      })
-    })
+      const { header } = handleConfig(config);
+      log.info(`===>request-kip url: ${url}`);
+      log.info(`===>request-kip header: ${JSON.stringify(header)}`);
+      uni
+        .request({
+          header: header,
+          method: method,
+          url: url,
+          data: param,
+        })
+        .then((res) => {
+          log.info(`===>request-kip response: ${JSON.stringify(res.data)}`);
+          resolve(handleKipResponse(res, _this));
+          if (res.status == 581) {
+            uni.navigateTo({
+              url: '/pages/errorPage/errorLimit?msg=当前访问太火爆了,稍后试试吧~',
+            });
+          }
+        })
+        .catch((response) => {
+          log.error(`===>request-kip error: ${JSON.stringify(response)}`);
+          reject(response);
+        });
+    });
   },
   get(path, param = {}, config) {
-    return this.base('GET', path, param, config)
+    return this.base('GET', path, param, config);
   },
   post(path, param = {}, config) {
-    return this.base('POST', path, param, config)
+    return this.base('POST', path, param, config);
   },
   put(path, param = {}, config) {
-    return this.base('PUT', path, param, config)
+    return this.base('PUT', path, param, config);
   },
   delete(path, param = {}, config) {
-    return this.base('DELETE', path, param, config)
+    return this.base('DELETE', path, param, config);
   },
   uploadFile(path, param = {}, config) {
     const _this = this;
@@ -171,43 +179,49 @@ export default {
       method: 'POST',
       path,
       param,
-      config
-    }
+      config,
+    };
     return new Promise((resolve, reject) => {
       const url = getUrl(path);
-      const { fileType, file, formData } = param
-      let header = getHeaders(config)
-      header["Content-Type"] = "multipart/form-data"
-      uni.uploadFile({
-        header: header,
-        method: 'POST',
-        url: url,
-        name: "file",
-        fileType: fileType,
-        filePath: file.path,
-        file: file,
-        formData: formData
-      }).then(res => {
-        resolve(handleKipResponse(res[1], _this))
-      }).catch((response) => {
-        reject(response)
-      })
-    })
+      const { fileType, file, formData } = param;
+      let header = getHeaders(config);
+      header['Content-Type'] = 'multipart/form-data';
+      uni
+        .uploadFile({
+          header: header,
+          method: 'POST',
+          url: url,
+          name: 'file',
+          fileType: fileType,
+          filePath: file.path,
+          file: file,
+          formData: formData,
+        })
+        .then((res) => {
+          resolve(handleKipResponse(res[1], _this));
+        })
+        .catch((response) => {
+          reject(response);
+        });
+    });
   },
   refreshToken(path) {
     return new Promise((resolve, reject) => {
       const url = getUrl(path);
-      const header = getHeaders()
+      const header = getHeaders();
       delete header.Authorization;
-      uni.request({
-        header: header,
-        method: 'POST',
-        url: url,
-      }).then(res => {
-        resolve(res[1])
-      }).catch((response) => {
-        reject(response)
-      })
-    })
-  }
-}
+      uni
+        .request({
+          header: header,
+          method: 'POST',
+          url: url,
+        })
+        .then((res) => {
+          resolve(res[1]);
+        })
+        .catch((response) => {
+          reject(response);
+        });
+    });
+  },
+};