Просмотр исходного кода

Merge branch 'master' of http://git.huaml.com/zhh/front-end

shish 10 месяцев назад
Родитель
Сommit
91d9524d32

+ 92 - 25
hdApp/src/admin/chat/chatPage.vue

@@ -68,9 +68,9 @@
               <!-- 改价类型显示重新改价 -->
               <view v-if="message.goodsInfo.goodsPriceType == 2 && isExpired(message.timestamp)" class="action-buttons">
                 <form @submit.prevent="createQrotedPrice(message)">
-                  <text class="goods-price" v-if="message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice"
+                  <!-- <text class="goods-price" v-if="message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice"
                     >¥{{ parseFloat(message.goodsInfo.lastPrice || message.goodsInfo.goodsPrice).toFixed(2) }}</text
-                  >
+                  > -->
                   <input
                     class="price-input"
                     type="number"
@@ -262,30 +262,14 @@ export default {
         });
       }
 
-      if (options.userId) {
-        this.currentUser.userId = parseInt(options.userId);
-        if(this.currentUser.userId == 0) {
-          console.error('userId 出错 ---------- this.currentUser.userId: ', this.currentUser.userId);
-        }
-      }
-      if (options.customId) {
-        this.currentUser.customId = parseInt(options.customId);
-        if(this.currentUser.customId == 0) {
-          console.error('customId 出错 ---------- this.currentUser.customId: ', this.currentUser.customId);
-        }
-      }
-      if (options.shopId) {
-        this.currentUser.shopId = parseInt(options.shopId);
-        if(this.currentUser.shopId == 0) {
-          console.error('shopId 出错 ---------- this.currentUser.shopId: ', this.currentUser.shopId);
-        }
-      }
+      this.currentUser.userId = this._parseAndValidateId(options.userId, 'userId 出错');
+      this.currentUser.customId = this._parseAndValidateId(options.customId, 'customId 出错');
+      this.currentUser.shopId = this._parseAndValidateId(options.shopId, 'shopId 出错');
+      this.currentUser.staffId = this._parseAndValidateId(options.staffId, 'staffId 出错');
+      
       if (options.name) {
         this.currentUser.username = options.name;
       }
-      if (options.staffId) {
-        this.currentUser.staffId = parseInt(options.staffId);
-      }
       if (options.avatar) {
         this.currentUser.avatar = options.avatar;
       }
@@ -305,6 +289,26 @@ export default {
       // 连接WebSocket
       this.connectWebSocket();
     },
+
+    /**
+     * 解析并验证ID
+     * @param {any} id - 需要解析和验证的ID
+     * @param {string} errorMsg - 验证失败时的错误信息
+     * @returns {number|null} - 验证通过则返回ID,否则返回null
+     */
+    _parseAndValidateId(id, errorMsg) {
+      if (id === null || id === undefined) {
+        return null;
+      }
+      const parsedId = parseInt(id);
+      if (isNaN(parsedId) || parsedId <= 0) {
+        console.error(errorMsg + ' ---------- id: ', id);
+        // this.$msg(errorMsg); // 根据项目情况,决定是否需要用户提示
+        return null;
+      }
+      return parsedId;
+    },
+
     // 加载聊天历史记录
     loadChatHistory() {
       getChatHistory({
@@ -313,7 +317,7 @@ export default {
         if (res.code == 1 && res.data) {
           this.allMessages = res.data.map((item, index) => {
             // 判断是否是我(本店)发送的消息
-            const isMine = item.shopId ? parseInt(item.shopId) == this.currentUser.shopId : false;
+            const isMine = item && item.shopId ? parseInt(item.shopId) == this.currentUser.shopId : false;
             //console.log("---isMine---: ", isMine);
 
             const newItem = {
@@ -416,6 +420,8 @@ export default {
           this.isConnected = true;
           this.reconnectCount = 0;
           this.isManualDisconnect = false; // 连接成功时重置标志位
+          // 启动心跳
+          this.startHeartbeat();
         });
 
         // 监听WebSocket消息
@@ -445,7 +451,7 @@ export default {
         // 监听WebSocket错误
         this.socket.onError((error) => {
           console.error('WebSocket连接错误:', error);
-          this.isConnected = true;
+          this.isConnected = false;
           this.handleConnectionError();
         });
       } catch (error) {
@@ -454,6 +460,37 @@ export default {
       }
     },
 
+    /**
+     * 启动心跳
+     */
+    startHeartbeat() {
+      if (this.heartbeatTimer) {
+        clearInterval(this.heartbeatTimer);
+      }
+      this.heartbeatTimer = setInterval(() => {
+        if (this.isConnected) {
+          this.socket.send({
+            data: '*hb*',
+            success: () => {
+              // console.log('发送ping');
+            },
+            fail: (error) => {
+              console.error('发送ping失败:', error);
+            }
+          });
+        }
+      }, 30000); // 每30秒发送一次
+    },
+    /**
+     * 停止心跳
+     */
+    stopHeartbeat() {
+      if (this.heartbeatTimer) {
+        clearInterval(this.heartbeatTimer);
+        this.heartbeatTimer = null;
+      }
+    },
+
     // 构建WebSocket子协议参数(模拟POST body传输)
     buildWebSocketProtocols() {
       try {
@@ -697,6 +734,8 @@ export default {
         this.socket = null;
         this.isConnected = false;
       }
+      // 停止心跳
+      this.stopHeartbeat();
     },
 
     // 重连WebSocket
@@ -1071,6 +1110,34 @@ export default {
     },
     createQrotedPrice(message) {
       // console.log("createPrice", message)
+
+      // 表单验证
+      if (message.quotedPrice == '') {
+        this.$msg('请输入价格');
+        return;
+      }
+      if (isNaN(message.quotedPrice)) {
+        this.$msg('价格格式不正确');
+        return;
+      }
+      if (message.quotedPrice <= 0) {
+        this.$msg('价格不能小于等于0');
+        return;
+      }
+      const keyArr = message.goodsInfo.key.split('-');// shopId-userId-goodsId
+      if (keyArr.length != 3) {
+        //console.log("keyArr.length != 3", keyArr)
+        this.$msg('key格式不正确');
+        return;
+      }
+      const shopId = parseInt(keyArr[0]);
+      const userId = parseInt(keyArr[1]);
+      const goodsId = parseInt(keyArr[2]);
+      if (isNaN(shopId) || isNaN(userId) || isNaN(goodsId)) {
+        console.error("isNaN(shopId) || isNaN(userId) || isNaN(goodsId)", shopId, userId, goodsId)
+        this.$msg('key数据出错');
+        return;
+      }
       createQuotedPrice({
         key: message.goodsInfo.key,
         price: parseFloat(message.quotedPrice).toFixed(2)

+ 149 - 58
mallApp/src/pages/chat/chatPage.vue

@@ -224,7 +224,6 @@ export default {
   onLoad(options) {
     const eventChannel = this.getOpenerEventChannel();
     eventChannel.on('acceptDataFromOpenerPage', (data) => {
-      this.pageParams = data;
       // console.log("---------- pageParams: ", data);
       this.initializePage(data);
     })
@@ -275,12 +274,6 @@ export default {
     init() {},
 
     initializePage(params) {
-      if (params.goodsId) {
-        this.currentGoodsInfo = {
-          ...params
-        };
-      }
-
       if (params.chatPerson) {
         // 设置聊天人名称
         uni.setNavigationBarTitle({
@@ -288,26 +281,30 @@ export default {
         })
       }
 
+      const paramsUserId = this._parseAndValidateId(params.userId, "登录用户数据异常,请稍后再试", false);
+      // if (paramsUserId === null) return;
+
       if (this.loginInfo.id) {
-        this.currentUser.userId = parseInt(this.loginInfo.id);
-        if(this.currentUser.userId == 0) {
-          console.error('userId 出错 ---------- this.currentUser.userId: ', this.currentUser.userId);
+        this.currentUser.userId = this._parseAndValidateId(this.loginInfo.id, "登录用户数据异常,请稍后再试");
+        if (this.currentUser.userId === null) return;
+
+        if (paramsUserId != null && this.currentUser.userId !== paramsUserId) {
+          console.error("登录用户数据异常 ---- :", this.currentUser.userId, paramsUserId)
           this.$msg("登录用户数据异常,请稍后再试");
           return;
         }
       }
+
       if (params.customId) {
-        this.currentUser.customId = parseInt(params.customId);
-        if(this.currentUser.customId == 0) {
-          console.error('customId 出错 ---------- this.currentUser.customId: ', this.currentUser.customId);
-        }
+        this.currentUser.customId = this._parseAndValidateId(params.customId, "客户数据异常,请稍后再试");
+        if (this.currentUser.customId === null) return;
       }
+
       if (params.shopId) {
-        this.currentUser.shopId = parseInt(params.shopId);
-        if(this.currentUser.shopId == 0) {
-          console.error('shopId 出错 ---------- this.currentUser.shopId: ', this.currentUser.shopId);
-        }
+        this.currentUser.shopId = this._parseAndValidateId(params.shopId, "门店数据异常,请稍后再试");
+        if (this.currentUser.shopId === null) return;
       }
+
       if (params.name) {
         this.currentUser.username = params.name;
       }
@@ -324,11 +321,35 @@ export default {
       }
       // console.log("---------- this.room: ", this.room);
 
+      if (params.goodsId) {
+        this.currentGoodsInfo = {
+          ...params
+        };
+      }
       // 加载聊天记录
       this.loadChatHistory();
       // 连接WebSocket
       this.connectWebSocket();
     },
+
+    /**
+     * 解析并验证ID
+     * @param {any} id - 需要解析和验证的ID
+     * @param {string} errorMsg - 验证失败时的错误信息
+     * @returns {number|null} - 验证通过则返回ID,否则返回null
+     */
+    _parseAndValidateId(id, errorMsg, showMsg=true) {
+      const parsedId = parseInt(id);
+      if (isNaN(parsedId) || parsedId <= 0) {
+        console.error(errorMsg + ' ---------- id: ', id);
+        if (showMsg) {
+          this.$msg(errorMsg);
+        }
+        return null;
+      }
+      return parsedId;
+    },
+
     goBack() {
       // 获取事件通道
       const eventChannel = this.getOpenerEventChannel()
@@ -354,7 +375,7 @@ export default {
         if (res.code == 1 && res.data) {
           this.allMessages = res.data.map((item, index) => {
             // 判断是否是我(本客户)发送的消息
-            const isMine = item.customId ? parseInt(item.customId) == this.currentUser.customId : false;
+            const isMine = item && item.customId ? parseInt(item.customId) == this.currentUser.customId : false;
             //console.log("---isMine---: ", isMine);
 
             const newItem = {
@@ -482,6 +503,8 @@ export default {
           this.isConnected = true;
           this.reconnectCount = 0;
           this.isManualDisconnect = false; // 连接成功时重置标志位
+          // 启动心跳
+          this.startHeartbeat();
         });
 
         // 监听WebSocket消息
@@ -520,6 +543,37 @@ export default {
       }
     },
 
+    /**
+     * 启动心跳
+     */
+     startHeartbeat() {
+      if (this.heartbeatTimer) {
+        clearInterval(this.heartbeatTimer);
+      }
+      this.heartbeatTimer = setInterval(() => {
+        if (this.isConnected) {
+          this.socket.send({
+            data: '*hb*',
+            success: () => {
+              // console.log('发送ping');
+            },
+            fail: (error) => {
+              console.error('发送ping失败:', error);
+            }
+          });
+        }
+      }, 30000); // 每30秒发送一次
+    },
+    /**
+     * 停止心跳
+     */
+     stopHeartbeat() {
+      if (this.heartbeatTimer) {
+        clearInterval(this.heartbeatTimer);
+        this.heartbeatTimer = null;
+      }
+    },
+
     // 构建WebSocket子协议参数(模拟POST body传输)
     buildWebSocketProtocols() {
       try {
@@ -754,6 +808,8 @@ export default {
         this.socket = null;
         this.isConnected = false;
       }
+      // 停止心跳
+      this.stopHeartbeat();
     },
 
     // 重连WebSocket
@@ -806,8 +862,6 @@ export default {
         // }
 
         const messageType = messageData.messageType || "text";
-        console.log('messageType -- ', messageType);
-
         // 创建消息对象
         const newMessage = {
           id: "msg_receive_" + Math.floor(Date.now() / 1000) + "_" + Math.floor(Math.random() * 100000) + 1,
@@ -900,7 +954,7 @@ export default {
         this.socket.send({
           data: json,
           success: () => {
-            console.log("消息发送成功");
+            // console.log("消息发送成功");
           },
           fail: (error) => {
             console.error("消息发送失败:", error);
@@ -922,13 +976,13 @@ export default {
 
     // 处理连接错误
     handleConnectionError() {
-      uni.showToast({
-        title: "连接失败",
-        icon: "none",
-        duration: 2000,
-      });
-      // 清除所有连接
-      this.disconnectWebSocket();
+      // uni.showToast({
+      //   title: "连接失败",
+      //   icon: "none",
+      //   duration: 2000,
+      // });
+
+      console.error('连接失败--', this.reconnectCount);
     },
 
     // 滚动到底部
@@ -1094,7 +1148,7 @@ export default {
             const userId = parseInt(keyArr[1]);
             const goodsId = parseInt(keyArr[2]);
             if (isNaN(shopId) || isNaN(userId) || isNaN(goodsId)) {
-              //console.log("isNaN(shopId) || isNaN(userId) || isNaN(goodsId)", shopId, userId, goodsId)
+              console.error("isNaN(shopId) || isNaN(userId) || isNaN(goodsId)", shopId, userId, goodsId)
               return parsed;
             }
             
@@ -1124,7 +1178,7 @@ export default {
                 }
               }
             }).catch(err => {
-              console.log("getQuotedPrice error: ", key, err)
+              console.error("getQuotedPrice error: ", key, err)
             })
           }
           return parsed;
@@ -1154,23 +1208,40 @@ export default {
         return;
       }
 
-      this.$util.pageTo({
-        url: "/pages/goods/detail",
-        query: { // id=2020&categoryId=1402&hdId=229&account=36548&shopId=36548&name=花仙子&avatar=https://img.theflorist.cn/hhb_small.png
-          id: goodsId,
-          account: goodsInfo.account,
-          hdId: goodsInfo.hdId,
-          categoryId: categoryId,
-          shopId: goodsInfo.shopId,
-          name: goodsInfo.name,
-          avatar: goodsInfo.avatar,
-        },
+      // this.$util.pageTo({
+      //   url: "/pages/goods/detail",
+      //   query: { // id=2020&categoryId=1402&hdId=229&account=36548&shopId=36548&name=花仙子&avatar=https://img.theflorist.cn/hhb_small.png
+      //     id: goodsId,
+      //     account: goodsInfo.account,
+      //     hdId: goodsInfo.hdId,
+      //     categoryId: categoryId,
+      //     shopId: goodsInfo.shopId,
+      //     name: goodsInfo.name,
+      //     avatar: goodsInfo.avatar,
+      //   },
+      // });
+
+      const params = {
+        id: goodsId,
+        account: goodsInfo.account,
+        hdId: goodsInfo.hdId,
+        categoryId: categoryId,
+        shopId: goodsInfo.shopId,
+        name: goodsInfo.name,
+        avatar: goodsInfo.avatar,
+      };
+
+      uni.navigateTo({
+        url: '/pages/goods/detail',
+        success: function(res) {
+          res.eventChannel.emit('acceptDataFromChatPage', params)
+        }
       });
     },
     // 去购买
     toBuy(goodsInfo) {
       this.disconnectWebSocket();// 离开本页面,必须断开WebSocket连接
-      console.log("---------- goodsInfo: ", goodsInfo);
+      // console.log("---------- goodsInfo: ", goodsInfo);
       const goodsId = parseInt(goodsInfo.goodsId);
       const categoryId = parseInt(goodsInfo.categoryId);
       const hdId = parseInt(goodsInfo.hdId);
@@ -1178,25 +1249,45 @@ export default {
       const price = parseFloat(goodsInfo.goodsPrice).toFixed(2);
       const priceType = goodsInfo.goodsPriceType;
       if (isNaN(goodsId) || isNaN(categoryId) || isNaN(hdId) || isNaN(account) || isNaN(price)) {
-        console.log("商品数据异常", goodsId, categoryId, hdId, account, price)
+        console.error("商品数据异常", goodsId, categoryId, hdId, account, price)
         this.$msg("商品数据异常");
         return;
       }
 
-      this.$util.pageTo({
-        url: "/pages/goods/detail",
-        query: {
-          id: goodsId,
-          account: goodsInfo.account,
-          hdId: goodsInfo.hdId,
-          categoryId: categoryId,
-          shopId: goodsInfo.shopId,
-          name: goodsInfo.name,
-          avatar: goodsInfo.avatar,
-          price: price,
-          priceType: priceType,
-          key: goodsInfo.key,
-        },
+      // this.$util.pageTo({
+      //   url: "/pages/goods/detail",
+      //   query: {
+      //     id: goodsId,
+      //     account: goodsInfo.account,
+      //     hdId: goodsInfo.hdId,
+      //     categoryId: categoryId,
+      //     shopId: goodsInfo.shopId,
+      //     name: goodsInfo.name,
+      //     avatar: goodsInfo.avatar,
+      //     price: price,
+      //     priceType: priceType,
+      //     key: goodsInfo.key,
+      //   },
+      // });
+
+      const params = {
+        id: goodsId,
+        account: goodsInfo.account,
+        hdId: goodsInfo.hdId,
+        categoryId: categoryId,
+        shopId: goodsInfo.shopId,
+        name: goodsInfo.name,
+        avatar: goodsInfo.avatar,
+        price: price,
+        priceType: priceType,
+        key: goodsInfo.key,
+      };
+
+      uni.navigateTo({
+        url: '/pages/goods/detail',
+        success: function(res) {
+          res.eventChannel.emit('acceptDataFromChatPage', params)
+        }
       });
     },
   },

+ 109 - 7
mallApp/src/pages/goods/detail.vue

@@ -121,12 +121,31 @@ export default {
     };
   },
   onLoad(option) {
-    this.hdId = this.option.hdId ? this.option.hdId : 0;
-    this.account = this.option.account ? this.option.account : 0;
-    if (option.shopId || option.goodsId) {
-      console.log("---------- option: ", option);
-      this.shopInfo = option;
+    // 兼容旧版本通过 options 传递参数
+    if (Object.keys(option).length > 0) {
+      this.initializeOption(option);
+      // 如果是普通路由跳转,直接获取商品信息
+      this.getGoodsInfo();
     }
+
+    const eventChannel = this.getOpenerEventChannel();
+    eventChannel.on('acceptDataFromChatPage', (data) => {
+      console.log("---------- detail data: ", data);
+      // 兼容
+      if (Object.keys(option).length == 0) {
+        this.option = {...data};
+      }
+      this.initializeChatPage(data);
+      // eventChannel 执行完成后,获取商品信息
+      this.getGoodsInfo();
+    });
+
+    // this.hdId = this.option.hdId ? this.option.hdId : 0;
+    // this.account = this.option.account ? this.option.account : 0;
+    // if (option.shopId || option.goodsId) {
+    //   console.log("---------- option: ", option);
+    //   this.shopInfo = option;
+    // }
   },
   onPageScroll(e) {
     // console.log('Scroll position:', parseInt(e.scrollTop))
@@ -147,8 +166,86 @@ export default {
   },
   methods: {
     init() {
-      this.getGoodsInfo();
     },
+
+    initializeOption(option) {
+      this.shopInfo = {
+        ...this.shopInfo,
+        ...option
+      }
+    },
+    // 初始化聊天页面数据
+    initializeChatPage(params) {
+      // 校验数据 --- 旧版本(做对比,没有对比就没有伤害)
+      // if (isNaN(params.hdId) || params.hdId <= 0) {
+      //   this.$msg("hdId数据异常");
+      //   return;
+      // }
+      // if (isNaN(params.account) || params.account <= 0) {
+      //   this.$msg("account数据异常");
+      //   return;
+      // }
+      // if (isNaN(params.shopId) || params.shopId <= 0) {
+      //   this.$msg("shopId数据异常");
+      //   return;
+      // }
+      // if (isNaN(params.goodsId) || params.goodsId <= 0) {
+      //   this.$msg("goodsId数据异常");
+      //   return;
+      // }
+      // if (isNaN(params.categoryId) || params.categoryId <= 0) {
+      //   this.$msg("categoryId数据异常");
+      //   return;
+      // }
+      // if (isNaN(params.name) || params.name == '') {
+      //   this.$msg("name数据异常");
+      //   return;
+      // }
+      // if (params.avatar == '') {
+      //   this.$msg("avatar数据异常");
+      //   return;
+      // }
+      // 参数校验
+      const rules = [
+        { key: 'hdId', type: 'positiveNumber' },
+        { key: 'account', type: 'positiveNumber' },
+        { key: 'shopId', type: 'positiveNumber' },
+        { key: 'id', type: 'positiveNumber' }, // 商品id
+        { key: 'categoryId', type: 'positiveNumber' },
+        { key: 'name', type: 'nonEmpty' },
+        { key: 'avatar', type: null }
+      ];
+
+      for (const rule of rules) {
+        const { key, type } = rule;
+        const value = params[key];
+        let isValid = false;
+
+        if (type === 'positiveNumber') {
+          isValid = !isNaN(value) && value > 0;
+        } else if (type === 'nonEmpty') {
+          isValid = !!value;
+        } else {
+          isValid = true;
+        }
+
+        if (!isValid) {
+          this.$msg(`${key}数据异常`);
+          console.error(`${key}数据异常:`, value)
+          return;
+        }
+      }
+
+      this.hdId = params.hdId || 0;
+      this.account = params.account || 0;
+      if (params.shopId || params.goodsId) {
+        // console.log("---------- params: ", params);
+        this.shopInfo = {
+          ...params
+        };
+      }
+    },
+
     scrollFn(e) {
       // console.log('Scroll position:', parseInt(e.detail.scrollTop))
       // 通过 ref 调用子组件的方法
@@ -164,6 +261,7 @@ export default {
       }
     },
     getGoodsInfo() {
+      console.log("---------- this.option: ", this.option);
       const id = parseInt(this.option.id);
       if (isNaN(id) || id <= 0) {
         this.$msg("商品id数据异常");
@@ -179,6 +277,8 @@ export default {
       getDetail({
         id: id,
         categoryId: categoryId,
+        account: this.option.account,
+        hdId: this.option.hdId,
       }).then((res) => {
         // console.log('商品数据加载成功:', res.data)
         if (this.$util.isEmpty(res.data)) {
@@ -249,12 +349,14 @@ export default {
       //   return;
       // }
       if (isNaN(parseInt(this.shopInfo.shopId))) {
+        console.log("---------- this.shopInfo: ", this.shopInfo)
+        console.error("门店数据异常,请稍后再试:", this.shopInfo.shopId)
         this.$msg("门店数据异常,请稍后再试");
         return;
       }
 
       const params = {
-        //userId: this.loginInfo.id,
+        userId: this.loginInfo.id,
         customId: this.customId,
         //staffId: 0,
         shopId: this.shopInfo.shopId,

+ 28 - 2
mallApp/src/plugins/luch-request_0.0.7/request.js

@@ -240,7 +240,20 @@ class Request {
 	get(url, data = {}, options = {}, config = {}) {
 		const account = uni.getStorageSync('account') || 0;
 		const hdId = uni.getStorageSync('hdId') || 0;
-		options.url = url + parse({...data,'account':account,'hdId':hdId})
+		if(account != 0 && hdId != 0){
+			options.url = url + parse({...data,'account':account,'hdId':hdId})
+		} else {
+			// 判断data中有无account和hdId
+			if(data.account && data.hdId){
+				options.url = url + parse({...data})
+			} else if(data.account && !data.hdId){
+				options.url = url + parse({...data, 'hdId':hdId})
+			} else if(!data.account && data.hdId){
+				options.url = url + parse({...data, 'account':account})
+			} else {
+				options.url = url + parse({...data, 'account':account, 'hdId':hdId})
+			}
+		}
 		options.data = {}
 		options.method = 'GET'
 		return this.request(options, config)
@@ -249,7 +262,20 @@ class Request {
 	post(url, data = {}, options = {}, config = {}) {
 		const account = uni.getStorageSync('account') || 0;
 		const hdId = uni.getStorageSync('hdId') || 0;
-		options.url = url+'?account='+account+'&hdId='+hdId
+		if(account != 0 && hdId != 0){
+			options.url = url+'?account='+account+'&hdId='+hdId
+		} else {
+			// 判断data中有无account和hdId
+			if(data.account && data.hdId){
+				options.url = url + parse({...data})
+			} else if(data.account && !data.hdId){
+				options.url = url + parse({...data, 'hdId':hdId})
+			} else if(!data.account && data.hdId){
+				options.url = url + parse({...data, 'account':account})
+			} else {
+				options.url = url + parse({...data, 'account':account, 'hdId':hdId})
+			}
+		}
 		options.data = data
 		options.method = 'POST'
 		return this.request(options, config)

+ 5 - 0
mallApp/src/utils/util.js

@@ -69,6 +69,11 @@ const isNumber = (num) => {
 	return (typeof num == 'number') && num.constructor == Number
 }
 
+// 是否为整数
+const isInteger = (num) => {
+	return (typeof num == 'number') && num.constructor == Number && num % 1 === 0
+}
+
 // 是否为日期类型
 const isDate = (date) => {
 	return (typeof date == 'object') && date.constructor == Date