Sfoglia il codice sorgente

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

shish 10 mesi fa
parent
commit
2046ddfa75

+ 13 - 2
hdApp/src/admin/chat/chatPage.vue

@@ -83,7 +83,7 @@
                 </form>
                 </form>
               </view>
               </view>
             </view>
             </view>
-            <view class="message-time align-right">{{ message.time }}</view>
+            <view class="message-time">{{ message.time }}</view>
           </view>
           </view>
         </view>
         </view>
 
 
@@ -186,6 +186,7 @@ export default {
       },
       },
       // 聊天消息列表
       // 聊天消息列表
       messageList: [],
       messageList: [],
+      today: new Date().toLocaleDateString(),
       // WebSocket相关
       // WebSocket相关
       socket: null,
       socket: null,
       isConnected: true,
       isConnected: true,
@@ -329,6 +330,10 @@ export default {
               newItem.goodsInfo = this.parseGoodsMessage(newItem.message);
               newItem.goodsInfo = this.parseGoodsMessage(newItem.message);
             }
             }
             newItem.isMine = isMine;
             newItem.isMine = isMine;
+            // 每6条消息显示一次时间
+            if (index % 6 === 0) {
+              newItem.time = this.getCurrentTime(newItem.timestamp);
+            }
 
 
             return newItem;
             return newItem;
           });
           });
@@ -937,7 +942,13 @@ export default {
       }
       }
       const hours = String(now.getHours()).padStart(2, '0');
       const hours = String(now.getHours()).padStart(2, '0');
       const minutes = String(now.getMinutes()).padStart(2, '0');
       const minutes = String(now.getMinutes()).padStart(2, '0');
-      return `${hours}:${minutes}`;
+      
+      if (this.today == now.toLocaleDateString()) {
+        return `${hours}:${minutes}`;
+      } else {
+        // return now.toLocaleDateString() + ' ' + `${hours}:${minutes}`;
+        return `${now.getMonth() + 1}/${now.getDate()} ${hours}:${minutes}`;
+      }
     },
     },
     // 输入框聚焦事件
     // 输入框聚焦事件
     onInputFocus() {
     onInputFocus() {

+ 19 - 7
mallApp/src/pages/chat/chatPage.vue

@@ -67,7 +67,7 @@
                 <button  class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
                 <button  class="action-btn buy-btn" @click="toBuy(message.goodsInfo)">去购买</button>
               </view>
               </view>
             </view>
             </view>
-            <view class="message-time align-right">{{ message.time }}</view>
+            <view class="message-time">{{ message.time }}</view>
           </view>
           </view>
         </view>
         </view>
 
 
@@ -201,6 +201,7 @@ export default {
       },
       },
       // 聊天消息列表
       // 聊天消息列表
       messageList: [],
       messageList: [],
+      today: new Date().toLocaleDateString(),
       // WebSocket相关
       // WebSocket相关
       socket: null,
       socket: null,
       isConnected: true,
       isConnected: true,
@@ -281,16 +282,16 @@ export default {
         })
         })
       }
       }
 
 
-      const paramsUserId = this._parseAndValidateId(params.userId, "登录用户数据异常,请稍后再试", false);
+      const paramsUserId = this._parseAndValidateId(params.userId, "登录用户数据异常1,请稍后再试", false);
       // if (paramsUserId === null) return;
       // if (paramsUserId === null) return;
 
 
       if (this.loginInfo.id) {
       if (this.loginInfo.id) {
-        this.currentUser.userId = this._parseAndValidateId(this.loginInfo.id, "登录用户数据异常,请稍后再试");
+        this.currentUser.userId = this._parseAndValidateId(this.loginInfo.id, "登录用户数据异常2,请稍后再试");
         if (this.currentUser.userId === null) return;
         if (this.currentUser.userId === null) return;
 
 
         if (paramsUserId != null && this.currentUser.userId !== paramsUserId) {
         if (paramsUserId != null && this.currentUser.userId !== paramsUserId) {
           console.error("登录用户数据异常 ---- :", this.currentUser.userId, paramsUserId)
           console.error("登录用户数据异常 ---- :", this.currentUser.userId, paramsUserId)
-          this.$msg("登录用户数据异常,请稍后再试");
+          this.$msg("登录用户数据异常3,请稍后再试");
           return;
           return;
         }
         }
       }
       }
@@ -325,6 +326,7 @@ export default {
         this.currentGoodsInfo = {
         this.currentGoodsInfo = {
           ...params
           ...params
         };
         };
+        // console.log("---------- this.currentGoodsInfo: ", this.currentGoodsInfo);
       }
       }
       // 加载聊天记录
       // 加载聊天记录
       this.loadChatHistory();
       this.loadChatHistory();
@@ -341,8 +343,8 @@ export default {
     _parseAndValidateId(id, errorMsg, showMsg=true) {
     _parseAndValidateId(id, errorMsg, showMsg=true) {
       const parsedId = parseInt(id);
       const parsedId = parseInt(id);
       if (isNaN(parsedId) || parsedId <= 0) {
       if (isNaN(parsedId) || parsedId <= 0) {
-        console.error(errorMsg + ' ---------- id: ', id);
         if (showMsg) {
         if (showMsg) {
+          console.error(errorMsg + ' ---------- id: ', id);
           this.$msg(errorMsg);
           this.$msg(errorMsg);
         }
         }
         return null;
         return null;
@@ -388,7 +390,10 @@ export default {
               newItem.goodsInfo = this.parseGoodsMessage(newItem.message, newItem.timestamp);
               newItem.goodsInfo = this.parseGoodsMessage(newItem.message, newItem.timestamp);
             }
             }
             newItem.isMine = isMine;
             newItem.isMine = isMine;
-
+            // 每6条消息显示一次时间
+            if (index % 6 === 0) {
+              newItem.time = this.getCurrentTime(newItem.timestamp);
+            }
             return newItem;
             return newItem;
           });
           });
 
 
@@ -1001,9 +1006,16 @@ export default {
       } else {
       } else {
         now = new Date();
         now = new Date();
       }
       }
+      // 判断是不是今天,如果是今天,则只显示时间,否则显示日期和时间
       const hours = String(now.getHours()).padStart(2, "0");
       const hours = String(now.getHours()).padStart(2, "0");
       const minutes = String(now.getMinutes()).padStart(2, "0");
       const minutes = String(now.getMinutes()).padStart(2, "0");
-      return `${hours}:${minutes}`;
+
+      if (this.today == now.toLocaleDateString()) {
+        return `${hours}:${minutes}`;
+      } else {
+        // return now.toLocaleDateString() + ' ' + `${hours}:${minutes}`;
+        return `${now.getMonth() + 1}/${now.getDate()} ${hours}:${minutes}`;
+      }
     },
     },
 
 
     // 输入框聚焦事件
     // 输入框聚焦事件

+ 4 - 1
mallApp/src/pages/chat/list.vue

@@ -109,7 +109,10 @@ export default {
         shopId: item.id,
         shopId: item.id,
         name: this.getLoginInfo.name,
         name: this.getLoginInfo.name,
         avatar: this.getLoginInfo.avatar,
         avatar: this.getLoginInfo.avatar,
-        chatPerson: item.shopName != "首店" ? item.shopName : item.merchantName || item.mobile
+        chatPerson: item.shopName != "首店" ? item.shopName : item.merchantName || item.mobile,
+        // 补 account 与 hdId
+        // account: item.id,
+        // hdId: item.hdId,
       };
       };
       // console.log("-----handleItemClick----- params: ", params);
       // console.log("-----handleItemClick----- params: ", params);
       uni.navigateTo({
       uni.navigateTo({

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

@@ -243,6 +243,7 @@ class Request {
 		if(account != 0 && hdId != 0){
 		if(account != 0 && hdId != 0){
 			options.url = url + parse({...data,'account':account,'hdId':hdId})
 			options.url = url + parse({...data,'account':account,'hdId':hdId})
 		} else {
 		} else {
+			// console.log("-----get----- data: ", data);
 			// 判断data中有无account和hdId
 			// 判断data中有无account和hdId
 			if(data.account && data.hdId){
 			if(data.account && data.hdId){
 				options.url = url + parse({...data})
 				options.url = url + parse({...data})
@@ -265,6 +266,7 @@ class Request {
 		if(account != 0 && hdId != 0){
 		if(account != 0 && hdId != 0){
 			options.url = url+'?account='+account+'&hdId='+hdId
 			options.url = url+'?account='+account+'&hdId='+hdId
 		} else {
 		} else {
+			//console.log("-----post----- data: ", data);
 			// 判断data中有无account和hdId
 			// 判断data中有无account和hdId
 			if(data.account && data.hdId){
 			if(data.account && data.hdId){
 				options.url = url + parse({...data, 'account':data.account, 'hdId':data.hdId})
 				options.url = url + parse({...data, 'account':data.account, 'hdId':data.hdId})