فهرست منبع

Merge pull request #124 from John-Hong/John/release-2.4.0/SCRM-3298

John/release 2.4.0/scrm 3298
Tron 2 سال پیش
والد
کامیت
ed37898acf

+ 13 - 145
src/App.vue

@@ -23,20 +23,17 @@
   </div>
 </template>
 <script>
-import { createAxiosByinterceptors } from '@/api/request';
-import Stomp from '@/lib/stompjs';
 import loginMinix from '@/mixins/login';
-import { Decrypt, Encrypt } from '@/utils/crypto';
-import { getIsMin, getIsWxh5, getUrlParams } from '@/utils/index.js';
-import SockJS from '@/utils/sockjs';
+import { getIsMin,getIsWxh5,getUrlParams,initEnv,requestInit,wssInit } from '@/utils/index.js';
 import uni from '@/utils/uniHooks';
 import { getAppIdByGroupIdAndMallId } from '@/utils/index.js';
-import sensorsFn from '@/plugins/sensors'
+import sensorsFn from '@/plugins/sensors';
+
 export default {
   mixins: [loginMinix],
   async created() {
-    await this.initEnv();
-    await this.requestInit();
+    await initEnv();
+    await requestInit();
     await this.init();
     // await sensorsFn(); // 埋点初始化
     // 初始化环境变量
@@ -84,11 +81,10 @@ export default {
         if (carList) {
           uni.setStorageSync('carList', JSON.parse(carList));
         }
-
         this.$store.commit('SET_IS_INIT', false);
         window.token = `${window.location.href}`.replace(/.*wx\/(.*)\/.*/g, '$1');
         try {
-          const options = await this.wss();
+          const options = await wssInit();
           this.$store.dispatch('baseInit', {
             options,
             callback: () => {
@@ -107,137 +103,10 @@ export default {
         this.micromessengerInit();
       }
     },
-    wss() {
-      return new Promise((resolve, reject) => {
-        try {
-          const socket = new SockJS(`${this.getUrl()}/hafengWebsocket?token=${window.token}`);
-          window.stompClient = Stomp.over(socket);
-          window.stompClient.debug = null;
-          this.windowSendInit();
-          window.stompClient.connect({}, (frame) => {
-            // 请求 projectId
-            window.toWXSendMsg({
-              type: 'getProjectId',
-              options: {},
-            });
-            window.subscribe('projectId', (options) => {
-              resolve(options);
-            });
-          });
-        } catch (err) {
-          // console.log(err);
-          reject(err);
-          // callback && callback();
-        }
-      });
-    },
-    windowSendInit() {
-      const token = window.token;
-      // console.log(118, token);
-      window.toWXSendMsg = function ({ type = '', funcName = '', options = {} }) {
-        /**
-         * 向小程序端发送消息
-         */
-        if (!type) return;
-        // console.log(259, '微信支付的options', options);
-        window.stompClient.send(
-          '/sendToWechat',
-          {},
-          JSON.stringify({
-            token,
-            data: Encrypt(
-              JSON.stringify({
-                type: type,
-                funcName,
-                options,
-              })
-            ),
-          })
-        );
-      };
-
-      // 主动订阅事件回调
-      window.subscribe = function (type, callback) {
-        const subscribeId = window.stompClient.subscribe('/user/' + token + '/toH5', function (response) {
-          try {
-            let res = {
-              token: '', // 微信小程序端 页面的传递过来的token
-              data: '', // 微信小程序端 页面的传递过来的信息(已加密)
-            };
-            if (response.body) {
-              res = JSON.parse(response.body);
-            }
-            // 检查 微信小程序端 发送过来的信息和token是否与当前页面的 token一致。并且 res.data 携带信息,在解密之后是 json 格式
-            if (res.token && res.token === token && res.data) {
-              const msgJson = JSON.parse(Decrypt(res.data));
-              const reg = new RegExp(type);
-              // 获取 projectId
-              if (reg.test(msgJson.type)) {
-                callback(msgJson.options, subscribeId);
-                subscribeId.unsubscribe();
-                return;
-              }
-            }
-          } catch (err) {
-            console.log('stomp error', err);
-          }
-        });
-      };
-    },
-    initEnv() {
-      const href = window.location.href;
-      console.log('当前页面的url地址  ', href);
-      if (/dev-|8080/.test(href)) {
-        // window.env = 'qa';
-        // window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
-        // window.api = 'qaApi';
-        window.env = 'dev';
-        window.profileApi = 'https://dev-gateway-kip.kerryonvip.com/api';
-        window.api = 'devApi';
-        return;
-      }
-      if (/qa-/.test(href)) {
-        window.env = 'qa';
-        window.api = 'qaApi';
-        window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
-        return;
-      }
-      window.env = 'prod';
-      window.profileApi = 'https://apim.kerryplus.com/c/api';
-      window.api = 'api';
-    },
-    requestInit() {
-      let baseURL = window.profileApi + '/temporary-parking/v1';
-      if (window.location.href.indexOf('tparking.') < 0 ) {
-        baseURL = '/msApi'
-      }
-      window.requestms = createAxiosByinterceptors({
-        // baseURL: `https://dev-kip-service-internal.kerryonvip.com/`,
-        // baseURL: `http://tp.hht.test/`,
-        // baseURL: window.profileApi, // TODO: 微服务发布到DEV环境之后取消注释
-        baseURL
-        // baseURL: `/msApi`,
-      });
-    },
-    // websocket 链接
-    getUrl() {
-      return `https://crm.kerryplus.com/xcrm-api`; // TODO: 临时更改websocket域名为prod
-      // 如果 kerry+ 这边的访问环境是 sl 或者 lt,需要把 wss 指向 qa 环境。
-      const href = `${window.location.href}`;
-      if (/dev-|8080/.test(href)) {
-        return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
-      }
-      if (/qa-/.test(href)) {
-        return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
-      }
-      // return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
-      return `https://crm.kerryplus.com/xcrm-api`;
-    },
     micromessengerInit() {
       this.$store.commit('SET_IS_INIT', false);
       let path = '';
       let [groupId, mallId] = window.location.pathname.split('/').filter((elm) => elm);
-      console.log(265, groupId, mallId);
       // return;
       // 如果groupId 是 tparking
       if (groupId === 'tparking') {
@@ -261,7 +130,6 @@ export default {
       const openid = uni.getStorageSync('openid');
 
       const query = getUrlParams();
-      console.log(284, query, groupId, mallId);
       // return;
       // 设置openid
       this.$nextTick(() => {
@@ -302,16 +170,16 @@ export default {
     },
     // 无感积分相关
     async wxEasyPointsCommitStatusInit() {
-      return
+      return;
       this.$refs.wxPointsCommit.open();
       // 判断用户是否登陆
       if (uni.getStorageSync('openid') && uni.getStorageSync('member') && uni.getStorageSync('member') !== {}) {
-				const easyPointsCommitStatus = await getWxEasyPointsCommitStatus()
-				if (easyPointsCommitStatus) {
-					this.$refs.wxPointsCommit.open();
-				}
-			}
-    }
+        const easyPointsCommitStatus = await getWxEasyPointsCommitStatus();
+        if (easyPointsCommitStatus) {
+          this.$refs.wxPointsCommit.open();
+        }
+      }
+    },
   },
 };
 </script>

+ 4 - 2
src/pages/parkingFee/components/base/parkingFeeDetailSuccess.vue

@@ -8,7 +8,9 @@
           <div class="price">{{ detail.actualPayFee | currency }}</div>
           <div class="price-text">
             <!-- {{ ['支付成功', '支付失败', '已退款'][detail.payStatus] }} -->
-            {{ detail.payStatus }}
+
+<!--            {{ detail.refundStatus === '1' ? '已退款' : {'PAID': '已支付','PAY_FAIED': '支付失败'}[detail.paymentStatus] }}-->
+            {{ detail.refundStatus !== 'NO_REFUND' ? '已退款' : {'PAID': '支付成功','UN_PAID': '支付失败'}[detail.payStatus || 'UN_PAID'] }}
           </div>
         </div>
         <div class="parking-part parking-detail">
@@ -63,7 +65,7 @@
           <div class="parking-info-item">
             <span class="info-key">会员等级减免</span>
             <!-- // (detail.discountInfo.memberLevelDiscount / 100) | currency -->
-            <span class="info-value">{{ detail.discountInfo && detail.discountInfo.memberLevelDiscount }}</span>
+            <span class="info-value">{{ detail.discountInfo && detail.discountInfo.memberLevelDiscount | currency }}</span>
           </div>
           <div class="parking-info-item">
             <span class="info-key">消费减免</span>

+ 2 - 2
src/pages/parkingFee/components/base/parkingFeeList.vue

@@ -28,7 +28,7 @@
             {{ item.orderNo + '-' + item.vehicleNo }}
           </div>
           <div style="color: red; margin-right: 6px">
-            {{ item.totalPaidAmount | currency }}
+            {{ item.actualPayFee | currency }}
           </div>
         </div>
 
@@ -47,7 +47,7 @@
         >
           <div>停车时长 : {{ item.serviceMin | parkingTime }}</div>
           <div style="margin-right: 20px">
-            {{ item.orderStatus | orderStatus  }}
+              {{ item.refundStatus !== 'NO_REFUND' ? '已退款' : {'PAID': '支付成功','UN_PAID': '支付失败'}[item.paymentStatus || 'UN_PAID'] }}
             <!-- {{ ['支付成功', '支付失败', '已退款'][] item.refundStatus | orderStatus }} -->
           </div>
         </div>

+ 23 - 3
src/pages/parkingFee/mixins/parkingFee.js

@@ -3,7 +3,7 @@ import { REG_SOURCE } from '@/constants';
 import LoginDom from '@/components/Login/Login.vue';
 import { mapState } from 'vuex';
 import { initWxJsSdkConfig } from '@/utils/login';
-import { getPlatform } from '@/utils/index';
+import { getPlatform,requestInit } from '@/utils/index';
 import { wxToLoginCallback } from '@/utils';
 
 const app = {
@@ -122,7 +122,7 @@ export default {
     // 如果用户未登录的话,返回之后,重新获取数据用户的基础数据
     if (!member && !uni.getStorageSync('isLogin') && window?.toWXSendMsg) {
       wxToLoginCallback('parkingFee', (options) => {
-        if(!this.openid) {
+        /*if(!this.openid) {
           this.$store.commit('SET_IS_INIT', false);
           // 请求 projectId
           window.toWXSendMsg({
@@ -134,6 +134,7 @@ export default {
               options: newOptions,
               callback: () => {
                 this.$nextTick(( ) => {
+                  requestInit();
                   this.getParkInfo();
                   this.$store.commit('SET_IS_INIT', true);
                 })
@@ -141,8 +142,27 @@ export default {
             });
           });
         } else {
+          requestInit();
           this.getParkInfo();
-        }
+        }*/
+        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(( ) => {
+                requestInit();
+                this.getParkInfo();
+                this.$store.commit('SET_IS_INIT', true);
+              })
+            },
+          });
+        });
       });
       // return
     }

+ 9 - 6
src/pages/parkingFee/mixins/parkingFeeDetail.js

@@ -37,6 +37,7 @@ export default {
         title: '停车支付',
       });
     }, 300);
+    this.pageInit();
   },
   computed: {
     ...mapState({
@@ -101,19 +102,18 @@ export default {
       return `${minutes}分钟`
     },
   },
-  created() {
-    this.pageInit();
-  },
   methods: {
     // 前往支付
     async toPay() {
-      const { parkingRecord, discountInfo = {} } = this.orderDetail;
+      const { parkingRecord, discountInfo = {}, parkingRule } = this.orderDetail;
       const { coupons, points } = discountInfo
+      const { hourPrice } = parkingRule
       try {
         const params = {
           // vehicleNo: '', // 车牌号
           // points
           parkingRecord: {
+            ...parkingRecord,
             vehicleNo: parkingRecord.vehicleNo,
             enterTime: parkingRecord.enterTime,
             serviceMin: parkingRecord.serviceMin,
@@ -130,9 +130,9 @@ export default {
           // 15 兑换 5元
           const { pointsPerUnit, unitAmount, discountFee, available } = points[0]
           params.discountInfo.points = {
-            "discountTime": discountFee / pointsPerUnit,
+            "discountTime": discountFee / hourPrice * 60,
             "discountFee": discountFee,
-            "discountPoints": discountFee * (unitAmount / pointsPerUnit)
+            "discountPoints": discountFee / hourPrice * pointsPerUnit
           }
         }
         // 优惠券
@@ -140,6 +140,9 @@ export default {
           const selectedCoupons = coupons.filter(elm => {
             const selected = elm.hasOwnProperty('selected') ? elm.selected : elm.defaultSelected;
             return selected
+          }).map(elm => {
+            elm.discountTime = elm.discountFee / hourPrice * 60
+            return elm
           })
           if (selectedCoupons.length) {
             params.discountInfo.coupons = selectedCoupons

+ 1 - 1
src/pages/parkingFee/mixins/vehicleManagement.js

@@ -147,7 +147,7 @@ export default {
       this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
         name: 'parkingFeeDetail',
       });
-      uni.setStorageSync('carList', [...new Set([carno, ...JSON.parse(uni.getStorageSync('carList'))])].slice(0, 6));
+      uni.setStorageSync('carList', [...new Set([carno, ...JSON.parse(uni.getStorageSync('carList') || '[]')])].slice(0, 6));
       this.$store.commit('cachedViews/DEL_CACHED_VIEW', {
         name: 'parkingFeeDetail',
       });

+ 135 - 3
src/utils/index.js

@@ -1,6 +1,10 @@
+import { createAxiosByinterceptors } from '@/api/request';
+import Stomp from "@/lib/stompjs";
+import { Decrypt,Encrypt } from "@/utils/crypto";
+import SockJS from "@/utils/sockjs";
 import qs from 'qs';
 import { lbsDictionary } from '@/common/js/BaseDictionary';
-import uni from './uniHooks'
+import uni from './uniHooks';
 
 export function getMobileOperatingSystem() {
   // #ifdef H5
@@ -158,6 +162,134 @@ export function wxToLoginCallback(path, callback) {
   }
   // 如果是在微信公众号环境运行的话
   /*if ( getIsWxh5() ) {
-    return
-  }*/
+   return
+   }*/
+}
+
+export function initEnv() {
+  const href = window.location.href;
+  console.log('当前页面的url地址  ', href);
+  if (/dev-|8080/.test(href)) {
+    // window.env = 'qa';
+    // window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
+    // window.api = 'qaApi';
+    window.env = 'dev';
+    window.profileApi = 'https://dev-gateway-kip.kerryonvip.com/api';
+    window.api = 'devApi';
+    return;
+  }
+  if (/qa-/.test(href)) {
+    window.env = 'qa';
+    window.api = 'qaApi';
+    window.profileApi = 'https://qa-apim.kerryplus.com/c/api';
+    return;
+  }
+  window.env = 'prod';
+  window.profileApi = 'https://apim.kerryplus.com/c/api';
+  window.api = 'api';
+}
+
+export function requestInit() {
+  let baseURL = window.profileApi + '/temporary-parking/v1';
+  if (window.location.href.indexOf('tparking.') < 0) {
+    baseURL = '/msApi';
+  }
+  window.requestms = createAxiosByinterceptors({
+    // baseURL: `https://dev-kip-service-internal.kerryonvip.com/`,
+    // baseURL: `http://tp.hht.test/`,
+    // baseURL: window.profileApi, // TODO: 微服务发布到DEV环境之后取消注释
+    baseURL,
+    // baseURL: `/msApi`,
+  });
+}
+
+// websocket 链接
+export function getUrl() {
+  return `https://crm.kerryplus.com/xcrm-api`; // TODO: 临时更改websocket域名为prod
+  // 如果 kerry+ 这边的访问环境是 sl 或者 lt,需要把 wss 指向 qa 环境。
+  const href = `${window.location.href}`;
+  if (/dev-|8080/.test(href)) {
+    return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
+  }
+  if (/qa-/.test(href)) {
+    return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
+  }
+  // return 'https://qa-crm-kpl.kerryprops.com.cn/xcrm-api';
+  return `https://crm.kerryplus.com/xcrm-api`;
+}
+
+export function windowSendInit() {
+  const token = window.token;
+  window.toWXSendMsg = function ({ type = '', funcName = '', options = {} }) {
+    /**
+     * 向小程序端发送消息
+     */
+    if (!type) return;
+    window.stompClient.send(
+      '/sendToWechat',
+      {},
+      JSON.stringify({
+        token,
+        data: Encrypt(
+          JSON.stringify({
+            type: type,
+            funcName,
+            options,
+          })
+        ),
+      })
+    );
+  };
+
+  // 主动订阅事件回调
+  window.subscribe = function (type, callback) {
+    const subscribeId = window.stompClient.subscribe('/user/' + token + '/toH5', function (response) {
+      try {
+        let res = {
+          token: '', // 微信小程序端 页面的传递过来的token
+          data: '', // 微信小程序端 页面的传递过来的信息(已加密)
+        };
+        if (response.body) {
+          res = JSON.parse(response.body);
+        }
+        // 检查 微信小程序端 发送过来的信息和token是否与当前页面的 token一致。并且 res.data 携带信息,在解密之后是 json 格式
+        if (res.token && res.token === token && res.data) {
+          const msgJson = JSON.parse(Decrypt(res.data));
+          const reg = new RegExp(type);
+          // 获取 projectId
+          if (reg.test(msgJson.type)) {
+            callback(msgJson.options, subscribeId);
+            subscribeId.unsubscribe();
+            return;
+          }
+        }
+      } catch (err) {
+        console.log('stomp error', err);
+      }
+    });
+  };
+}
+
+
+export function wssInit() {
+  return new Promise((resolve, reject) => {
+    try {
+      const socket = new SockJS(`${getUrl()}/hafengWebsocket?token=${window.token}`);
+      window.stompClient = Stomp.over(socket);
+      window.stompClient.debug = null;
+      windowSendInit();
+      window.stompClient.connect({}, (frame) => {
+        // 请求 projectId
+        window.toWXSendMsg({
+          type: 'getProjectId',
+          options: {},
+        });
+        window.subscribe('projectId', (options) => {
+          resolve(options);
+        });
+      });
+    } catch (err) {
+      reject(err);
+    }
+  });
 }

+ 5 - 0
vue.config.js

@@ -89,6 +89,11 @@ module.exports = {
       },
     },
   },
+ transpileDependencies: [
+    // can be string or regex
+    '@stomp/stompjs',
+    // /other-dep/
+  ],
   devServer: {
     proxy: {
       '/profileApi': {