twt 2 dagar sedan
förälder
incheckning
41ff9ec1c1
9 ändrade filer med 326 tillägg och 128 borttagningar
  1. 1 1
      main.js
  2. 104 10
      pages/ck.vue
  3. 12 12
      pages/contacts.vue
  4. 3 1
      pages/conversations.vue
  5. 9 1
      pages/groupChat.vue
  6. 6 5
      pages/login.vue
  7. 10 8
      pages/privateChat.vue
  8. 173 83
      pages/qunfa.vue
  9. 8 7
      utils/request.js

+ 1 - 1
main.js

@@ -7,7 +7,7 @@ Vue.prototype.$http = request.http
 Vue.prototype.$request =request
 GoEasy.init({
     host:"hangzhou.goeasy.io",//应用所在的区域地址: 【hangzhou.goeasy.io |singapore.goeasy.io】
-    appkey:"BC-85d9927b66cf41d388dae05bcee5571c",// common key
+    appkey:"BC-729fefdf1ad7417daea8e62b9fce3f74",// common key
     modules: ['im'],
     // true表示支持通知栏提醒,false则表示不需要通知栏提醒
     allowNotification: true //仅有效于app,小程序和H5将会被自动忽略

+ 104 - 10
pages/ck.vue

@@ -5,13 +5,13 @@
 				<image src="/static/images/wx.png" mode="" class="carLogo"></image>
 			</view>
 			<view class="topRight">
-				<view class="brand">大众</view>
-				<view class="carModel">大众CC</view>
+				<view class="brand">{{info.carModelInfo.brand}}</view>
+				<view class="carModel">{{info.title}}</view>
 			</view>
 		</view>
 		
 		<view class="cont">
-			<view class="line" v-for="(item,index) in 5">
+			<view class="line" v-for="(item,index) in info.supplierlist">
 				<view class="lineLeft">
 					<view class="lineCK">
 						<checkbox-group>
@@ -21,8 +21,8 @@
 						</checkbox-group>
 					</view>
 					<view class="nameBox">
-						<view class="name">供应商{{index}}</view>
-						<view class="jingying">经营品牌:大众</view>
+						<view class="name">{{item.supplierName}}</view>
+						<view class="jingying">经营品牌:{{item.brands}}</view>
 					</view>
 				</view>
 				<view class="lineRgiht">
@@ -30,27 +30,109 @@
 						<image class="lineRgihtIMg" src="/static/images/icon_phone@2x.png" mode=""></image>
 					</view>
 					<view>
-						<image  class="lineRgihtIMg" src="/static/images/chat.png" mode=""></image>
+						<image @click="goIm(item)"  class="lineRgihtIMg" src="/static/images/chat.png" mode=""></image>
 					</view>
 				</view>
 			</view>
+		
+		</view>
+		
+		<view class="qunfa" @click="qunfa">
+			一键群发
 		</view>
 		
 	</view>
 </template>
 
 <script>
+	import EmojiDecoder from '../lib/EmojiDecoder';
+	import restApi from '../lib/restapi';
+	import {formatDate} from '../lib/utils';
+	import RecorderManager from '../lib/RecorderManager';
+	
+	const IMAGE_MAX_WIDTH = 200;
+	const IMAGE_MAX_HEIGHT = 150;
+	const recorderManager = new RecorderManager();
+	const GoEasy = uni.$GoEasy;
+	const GRTC = uni.$GRTC;
 	export default {
 		data() {
 			return {
-				title: 'Hello'
+				vin: 'JHMCM56557C404453',
+				list:[],
+				info:'',
+				currentUser:'',
 			}
 		},
-		onLoad() {
-
+		onLoad(opt) {
+		  var token=opt.token
+		  console.log(token)
+		   uni.setStorageSync('token', token);
+          this.vinSupplier()
+		  this.imLoginUrl()
 		},
 		methods: {
-
+		   qunfa(){
+			   uni.setStorageSync('supplierlist', this.info.supplierlist);
+			   uni.navigateTo({
+			   	url:'qunfa'
+			   })
+		   },
+		   goIm(item){
+			   uni.setStorage({
+			   		key: 'friend',
+			   		data: item,
+			   		 success: function () {	
+			   				uni.navigateTo({
+			   				  url: './privateChat?to=' + item.id
+			   				});	
+			   		 }
+			   });
+		   },
+           vinSupplier(){
+			   this.$http('imSys/vinSupplier', {
+			      vin:this.vin,
+			     },'GET').then(res => {
+			    	  //console.log(res)	
+			   		  this.info=res.data[0]	  
+			     }) 
+		   },
+		   imLoginUrl(){
+			   this.$http('imSys/imLoginUrl', {
+			      token:this.token,
+			     },'POST').then(res => {
+			    	 // console.log(res)	
+			   		  var users={
+						  userId:res.data.userId,
+						  name:res.data.users.name,
+						  avatar:'',
+					  }
+					  this.currentUser=users
+					  this.connectGoEasy()
+					 uni.setStorageSync('users', users);
+			     }) 
+		   },
+		   connectGoEasy(){
+			   console.log(this.currentUser)
+			   this.currentUser.id="2C3E3A5C-D449-4439-842F-8E1C5C9EF91E"
+			   uni.setStorageSync('currentUser', this.currentUser);
+			   GoEasy.connect({
+			     id: this.currentUser.id,
+			     data: {
+			       name: this.currentUser.name,
+			       avatar: this.currentUser.avatar
+			     },
+			     onSuccess: () => {
+			       console.log('GoEasy connect successfully.')
+			     },
+			     onFailed: (error) => {
+			       console.log('Failed to connect GoEasy, code:' + error.code + ',error:' + error.content);
+			     },
+			     onProgress: (attempts) => {
+			       console.log('GoEasy is connecting', attempts);
+			     }
+			   });
+		   }
 		}
 	}
 </script>
@@ -109,4 +191,16 @@
 	display: flex;
 	align-items: center;
 }
+.qunfa{
+	width: 650rpx;
+	height: 80rpx;
+	line-height: 80rpx;
+	text-align: center;
+	background: #3F90F7;
+	color: #ffffff;
+	font-size: 30rpx;
+	border-radius: 10rpx;
+	margin: 0 auto;
+	margin-top: 100rpx;
+}
 </style>

+ 12 - 12
pages/contacts.vue

@@ -40,20 +40,20 @@
     },
     onShow() {
       const currentUser = uni.$currentUser;
-	  this.$http('imSys/listUsers', {
-	    /* userCode:this.form.phone,
+	  /* this.$http('imSys/listUsers', {
+	     userCode:this.form.phone,
 	    userPwd:this.form.password,
-	   */
-	   },'GET').then(res => {
-	  	 // console.log(res)	
-	  	this.friends=res.data.Items		
-		var fobj={
-				   ID:'2C3E3A5C-D449-4439-842F-8E1C5C9EF91E',
-				   Name:'杨'
-		}
-		this.friends.push(fobj)
-	   }) 
 	   
+	   },'GET').then(res => {
+	  	  console.log(res)	
+	  	
+	   }) */
+	   this.friends=res.data.Items
+	   var fobj={
+	   	   ID:'2C3E3A5C-D449-4439-842F-8E1C5C9EF91E',
+	   	   Name:'杨'
+	   }
+	   this.friends.push(fobj)
 	 // this.friends=this.friends.concat(fobj)
       //this.friends = restApi.findFriends(currentUser);
 	  console.log(this.friends)

+ 3 - 1
pages/conversations.vue

@@ -26,7 +26,8 @@
                 <text v-else-if="conversation.lastMessage.type === 'image'">[图片消息]</text>
                 <text v-else-if="conversation.lastMessage.type === 'file'">[文件消息]</text>
                 <text v-else-if="conversation.lastMessage.type === 'order'">[自定义消息:订单]</text>
-                <text v-else>[[未识别内容]]</text>
+                <text v-else-if="conversation.lastMessage.type === 'pic'">[图片消息]</text>
+				<text v-else>[[未识别内容]]</text>
               </view>
               <view class="item-info-top_content" v-else>
                 <text>
@@ -153,6 +154,7 @@
       },
       renderConversations(content) {
         this.conversations = content.conversations;
+		console.log("消息列表")
 		console.log(this.conversations)
       },
       setUnreadAmount(content) {

+ 9 - 1
pages/groupChat.vue

@@ -249,7 +249,13 @@
         messageSelector: {
           visible: false,
           messages: []
-        }
+        },
+		toList:[
+			"A69257B1-8603-4BCD-9D32-07C18E6E14D7",
+			"1292F5DA-793B-4549-844E-C5F606869D0C",
+			"421DB63C-B274-478C-8442-CD43AD052A7B",
+			"AB6D0669-A5F8-423F-A6FE-81AC12084AFC"
+		],
       }
     },
     onLoad(options) {
@@ -258,6 +264,7 @@
       this.group = restApi.findGroupById(id);
       this.currentUser = uni.$currentUser;
       this.groupMembers = restApi.findGroupMembers(this.group.id);
+	  
       this.to = {
         id: this.group.id,
         type: GoEasy.IM_SCENE.GROUP,
@@ -430,6 +437,7 @@
           if (this.text.length >= 50) {
             body = this.text.substring(0, 30) + '...';
           }
+		  
           GoEasy.im.createTextMessage({
             text: this.text,
             to: this.to,

+ 6 - 5
pages/login.vue

@@ -92,27 +92,28 @@
 			 password:'',
 			 phone:'',
 		 }
-		  /* this.$http('imSys/imLoginTmp', {
+		 this.$http('imSys/imLoginTmp', {
 		    userCode:this.form.phone,
 		    userPwd:this.form.password,
 		   
 		   },'POST').then(res => {
 		  	  console.log(res)	
 			  obj.name=res.data.supplierName
-			  obj.id=res.data.userid
+			  obj.id=res.data.userId
 			  obj.password=this.form.password
 			  obj.phone=this.form.phone
 			  uni.setStorageSync('currentUser', obj);
+			  uni.setStorageSync('imAccessToken', res.data.imAccessToken);
 			  uni.switchTab({url: './conversations'});
-		   }) */
-          if (this.username.trim() !== '' && this.password.value.trim() !== '') {
+		   }) 
+         /* if (this.username.trim() !== '' && this.password.value.trim() !== '') {
           let user = restApi.findUser(this.username, this.password.value);
           if (user) {
             uni.setStorageSync('currentUser', user);
             uni.switchTab({url: './conversations'});
             return
           }
-          } 
+          } */
        // this.errorVisible = true; 
       }
     }

+ 10 - 8
pages/privateChat.vue

@@ -261,12 +261,14 @@
       let id = options.to;
 	  this.friend = uni.getStorageSync("friend");
       //this.friend = restApi.findUserById(id);
-      this.currentUser = uni.$currentUser;
+      //this.currentUser = uni.$currentUser;
+	  this.currentUser = uni.getStorageSync("currentUser");
+	  
       this.to = {
-        id: this.friend.ID,
+        id: this.friend.id,
         type: GoEasy.IM_SCENE.PRIVATE,
         data: {
-          name: this.friend.Name,
+          name: this.friend.supplierName,
           avatar: '/static/images/Avatar-1.png'
         }
       };
@@ -285,7 +287,7 @@
       this.loadHistoryMessage(true);
       this.videoPlayer.context = uni.createVideoContext('videoPlayer', this);
       // https://uniapp.dcloud.io/api/ui/navigationbar?id=setnavigationbartitle
-      uni.setNavigationBarTitle({ title: this.friend.Name });
+      uni.setNavigationBarTitle({ title: this.friend.supplierName });
     },
     onPullDownRefresh(e) {
       this.loadHistoryMessage(false);
@@ -326,7 +328,7 @@
         let senderId = message.senderId;
         let receiverId = message.receiverId;
         let friendId = this.currentUser.id === senderId ? receiverId : senderId;
-        if (friendId === this.friend.ID) {
+        if (friendId === this.friend.id) {
           this.history.messages.push(message);
           //聊天时,收到消息标记为已读
           this.markPrivateMessageAsRead();
@@ -339,7 +341,7 @@
           let senderId = message.senderId;
           let receiverId = message.receiverId;
           let friendId = this.currentUser.id === senderId ? receiverId : senderId;
-          if (friendId === this.friend.ID) {
+          if (friendId === this.friend.id) {
             let index = this.history.messages.indexOf(message);
             if (index > -1) {
               this.history.messages.splice(index, 1);
@@ -628,7 +630,7 @@
           lastMessageTimeStamp = lastMessage.timestamp;
         }
         GoEasy.im.history({
-          id: this.friend.ID,
+          id: this.friend.id,
           type: GoEasy.IM_SCENE.PRIVATE,
           lastTimestamp: lastMessageTimeStamp,
           limit: 10,
@@ -751,7 +753,7 @@
             const mediaType = res.tapIndex === 0 ? 1 : 0;
             const notificationBody = res.tapIndex === 0 ? '邀请你视频通话' : '邀请你语音通话';
             GRTC.call({
-              calleeId: this.friend.ID,
+              calleeId: this.friend.id,
               mediaType: mediaType,
               notification: {
                 title: this.currentUser.name,

+ 173 - 83
pages/qunfa.vue

@@ -12,13 +12,13 @@
 		  		  <span v-for="(item,index) in 4">供应商{{index}}</span>
 		  		  对话
 		  </view>
-		  <view class="messageLine">
+		<!--  <view class="messageLine">
 			  <view class="messageTxt">大众 速腾 2006款 1.6L自动时尚型LFV456HH85777845</view>
 			  <view class="messageTxt">我想要机油</view>
 			  <view class="messageImgBox">
 				  <image class="messageImg" src="/static/images/uniapp.png" mode="widthFix"></image>
 			  </view>
-		  </view>
+		  </view> -->
 	  </view>
 	  
       <checkbox-group @change="selectMessages">
@@ -268,23 +268,50 @@
         messageSelector: {
           visible: false,
           messages: []
-        }
+        },
+		toList:[
+			"A69257B1-8603-4BCD-9D32-07C18E6E14D7",
+			"1292F5DA-793B-4549-844E-C5F606869D0C",
+			"421DB63C-B274-478C-8442-CD43AD052A7B",
+			"AB6D0669-A5F8-423F-A6FE-81AC12084AFC"
+		],
+		currentUser:'',
       }
     },
     onLoad(options) {
       //聊天对象
-      let id = options.to;
+      //let id = options.to;
 	  this.friend = uni.getStorageSync("friend");
       //this.friend = restApi.findUserById(id);
       this.currentUser = uni.$currentUser;
-      this.to = {
+	   this.currentUser={
+		   avatar: "/static/images/Avatar-1.png",
+		   email: "Mattie@goeasy.io",
+		   id: "08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a",
+		   name: "测试群发",
+		   password: "123",
+		   phone: "138xxxxxxxx",
+	   }
+      /* this.to = {
         id: this.friend.ID,
         type: GoEasy.IM_SCENE.PRIVATE,
         data: {
           name: this.friend.Name,
           avatar: '/static/images/Avatar-1.png'
         }
-      };
+      }; */
+	   this.currentUser = uni.getStorageSync('currentUser')
+	   //this.connectGoEasy()
+	  this.to = {
+	    id: 'A69257B1-8603-4BCD-9D32-07C18E6E14D7',
+	    type: GoEasy.IM_SCENE.PRIVATE,
+	    data: {
+	      name: "群发测试",
+	      avatar: '/static/images/Avatar-1.png'
+	    }
+	  };
+	  
+	  this.toList=uni.getStorageSync('supplierlist')
 
       this.initGoEasyListeners();
       // 语音播放器
@@ -312,6 +339,26 @@
       GoEasy.im.off(GoEasy.IM_EVENT.HISTORY_EXPIRED, this.onHistoryExpired);
     },
     methods: {
+		connectGoEasy() {
+			console.log(this.currentUser)
+		 
+		  GoEasy.connect({
+		    id: this.currentUser.id,
+		    data: {
+		      name: this.currentUser.name,
+		      avatar: this.currentUser.avatar
+		    },
+		    onSuccess: () => {
+		      console.log('GoEasy connect successfully.')
+		    },
+		    onFailed: (error) => {
+		      console.log('Failed to connect GoEasy, code:' + error.code + ',error:' + error.content);
+		    },
+		    onProgress: (attempts) => {
+		      console.log('GoEasy is connecting', attempts);
+		    }
+		  });
+		},
       //渲染文本消息,如果包含表情,替换为图片
       //todo:本不需要该方法,可以在标签里完成,但小程序有兼容性问题,被迫这样实现
       renderTextMessage(message) {
@@ -385,25 +432,34 @@
             });
             return;
           }
-          GoEasy.im.createAudioMessage({
-            to: this.to,
-            file: file,
-            notification: {
-              title: this.currentUser.name + '发来一段语音',
-              body: '[语音消息]',		// 字段最长 50 字符
-              sound: 'message',
-              badge: '+1'
-            },
-            onProgress: function (progress) {
-              console.log(progress)
-            },
-            onSuccess: (message) => {
-              this.sendMessage(message);
-            },
-            onFailed: (e) => {
-              console.log('error :', e);
-            }
-          });
+		  this.toList.forEach((item,index)=>{
+		  		this.to.id=item.id
+				this.to.data.name=item.supplierName
+				var num=0
+				if(index == this.toList.length-1){
+					num=1
+				}
+		  		GoEasy.im.createAudioMessage({
+		  		  to: this.to,
+		  		  file: file,
+		  		  notification: {
+		  		    title: this.currentUser.name + '发来一段语音',
+		  		    body: '[语音消息]',		// 字段最长 50 字符
+		  		    sound: 'message',
+		  		    badge: '+1'
+		  		  },
+		  		  onProgress: function (progress) {
+		  		    console.log(progress)
+		  		  },
+		  		  onSuccess: (message) => {
+		  		    this.sendMessage(message,num);
+		  		  },
+		  		  onFailed: (e) => {
+		  		    console.log('error :', e);
+		  		  }
+		  		});
+		  })
+          
         });
       },
       /**
@@ -428,8 +484,11 @@
           return IMAGE_MAX_HEIGHT * 2;
         }
       },
-      sendMessage(message) {
-        this.history.messages.push(message);
+      sendMessage(message,num) {
+		if(num==1){
+			  this.history.messages.push(message);
+		}
+      
         this.scrollToBottom();
         GoEasy.im.sendMessage({
           message: message,
@@ -451,48 +510,69 @@
           if (this.text.length >= 50) {
             body = this.text.substring(0, 30) + '...';
           }
-          GoEasy.im.createTextMessage({
-            text: this.text,
-            to: this.to,
-            notification: {
-              title: this.currentUser.name + '发来一段文字',
-              body: body,
-              sound: 'message',
-              badge: '+1'
-            },
-            onSuccess: (message) => {
-              this.sendMessage(message);
-            },
-            onFailed: (e) => {
-              console.log('error :', e);
-            }
-          });
+		 
+		  this.toList.forEach((item,index)=>{
+		  		this.to.id=item.id
+		  		this.to.data.name=item.supplierName
+				var num=0
+				if(index == this.toList.length-1){
+					num=1
+				}
+		  		GoEasy.im.createTextMessage({
+		  		  text: this.text,
+		  		  to: this.to,
+		  		  notification: {
+		  		    title: this.currentUser.name + '发来一段文字',
+		  		    body: body,
+		  		    sound: 'message',
+		  		    badge: '+1'
+		  		  },
+		  		  onSuccess: (message) => {
+		  		    this.sendMessage(message,num);
+		  		  },
+		  		  onFailed: (e) => {
+		  		    console.log('error :', e);
+		  		  }
+		  		});	  
+		  })
+		 
+          
         }
         this.text = '';
       },
       sendVideoMessage() {
         uni.chooseVideo({
           success: (res) => {
-            GoEasy.im.createVideoMessage({
-              to: this.to,
-              file: res,
-              notification: {
-                title: this.currentUser.name + '发来一个视频',
-                body: '[视频消息]',		// 字段最长 50 字符
-                sound: 'message',
-                badge: '+1'
-              },
-              onProgress: function (progress) {
-                console.log(progress)
-              },
-              onSuccess: (message) => {
-                this.otherTypesMessagePanelVisible = false;
-                this.sendMessage(message);
-              },
-              onFailed: (e) => {
-                console.log('error :', e);
-              }
-            });
+			this.toList.forEach((item,index)=>{
+					this.to.id=item.id
+					this.to.data.name=item.supplierName
+					var num=0
+					if(index == this.toList.length-1){
+						num=1
+					}
+					GoEasy.im.createVideoMessage({
+					  to: this.to,
+					  file: res,
+					  notification: {
+					    title: this.currentUser.name + '发来一个视频',
+					    body: '[视频消息]',		// 字段最长 50 字符
+					    sound: 'message',
+					    badge: '+1'
+					  },
+					  onProgress: function (progress) {
+					    console.log(progress)
+					  },
+					  onSuccess: (message) => {
+					    this.otherTypesMessagePanelVisible = false;
+					    this.sendMessage(message,num);
+					  },
+					  onFailed: (e) => {
+					    console.log('error :', e);
+					  }
+					});
+						  
+			})
+            
           }
         })
       },
@@ -501,26 +581,36 @@
           count: 9,
           success: (res) => {
             res.tempFiles.forEach(file => {
-              GoEasy.im.createImageMessage({
-                to: this.to,
-                file: file,
-                notification: {
-                  title: this.currentUser.name + '发来一张图片',
-                  body: '[图片消息]',		// 字段最长 50 字符
-                  sound: 'message',
-                  badge: '+1'
-                },
-                onProgress: function (progress) {
-                  console.log(progress)
-                },
-                onSuccess: (message) => {
-                  this.otherTypesMessagePanelVisible = false;
-                  this.sendMessage(message);
-                },
-                onFailed: (e) => {
-                  console.log('error :', e);
-                }
-              });
+				this.toList.forEach((item,index)=>{
+						this.to.id=item.id
+						this.to.data.name=item.supplierName
+						var num=0
+						if(index == this.toList.length-1){
+							num=1
+						}
+						GoEasy.im.createImageMessage({
+						  to: this.to,
+						  file: file,
+						  notification: {
+						    title: this.currentUser.name + '发来一张图片',
+						    body: '[图片消息]',		// 字段最长 50 字符
+						    sound: 'message',
+						    badge: '+1'
+						  },
+						  onProgress: function (progress) {
+						    console.log(progress)
+						  },
+						  onSuccess: (message) => {
+						    this.otherTypesMessagePanelVisible = false;
+						    this.sendMessage(message,num);
+						  },
+						  onFailed: (e) => {
+						    console.log('error :', e);
+						  }
+						});
+							  
+				})
+             
             })
           }
         });

+ 8 - 7
utils/request.js

@@ -1,6 +1,6 @@
 //测试地址
-const baseUrl = 'http://192.168.1.97:20187/'
-
+//const baseUrl = 'http://192.168.1.19:20187/'
+const baseUrl = 'http://dms.66km.com.cn/'
 //正式
 //const baseUrl = 'https://apidms.66km.com/'
 
@@ -11,11 +11,12 @@ const http = (url = '', date = {}, type = 'POST', header = {
 		header={};
 		//console.log(baseUrl)
 		//const wxOpenData = uni.getStorageSync("wxOpenData");
-		/* var wxOpenData= uni.getStorageSync("wxOpenData")
-		if(wxOpenData.loginInfo){
-			header['token']=wxOpenData.loginInfo.token;
-			header['uid']=wxOpenData.loginInfo.uid; 
-		} */
+		var imAccessToken= uni.getStorageSync("imAccessToken")
+		var token= uni.getStorageSync("token")
+		if(imAccessToken){
+			header['token']=token;
+			//header['uid']=wxOpenData.loginInfo.uid; 
+		} 
 		//console.log($store.state.carInfo)
 		//header['token']='98A9FED8814B457288166BDF623F33D1';
 		//header['uid']='39415962-C9D3-466D-A73F-5B5429A8DB2A';