刘远航 5 سال پیش
والد
کامیت
24cb89a4f6
5فایلهای تغییر یافته به همراه87 افزوده شده و 18 حذف شده
  1. 8 0
      main.js
  2. 46 11
      pages/conversation/conversation.vue
  3. 2 5
      pages/conversation/conversationWindow.vue
  4. 25 1
      pages/zixun/xiangqing.vue
  5. 6 1
      store/index.js

+ 8 - 0
main.js

xqd
@@ -28,6 +28,14 @@ const app = new Vue({
 })
 app.$mount()
 
+
+
+
+
+
+
+
+
 Vue.prototype.formatDate = function (t) {
     t = t || Date.now();
     let time = new Date(t);

+ 46 - 11
pages/conversation/conversation.vue

xqd xqd xqd xqd
@@ -8,7 +8,7 @@
 		</view>
 		<!-- 这是聊天列表 当值为true时显示-->
 		<view class="cu-list menu-avatar margin-top-xs" v-if="qiehuan == true">
-			<view class="cu-item u-border-bottom" v-for="(item,index) in list" :key="index" @click="goliaotian">
+			<view class="cu-item u-border-bottom" v-for="(item,index) in list" :key="index" @click="goliaotian(index)">
 				<view class="cu-avatar radius lg" :style="'background-image:url('+item.avatar+');'">
 					<view class="cu-tag badge">10</view>
 				</view>
@@ -49,27 +49,49 @@
 	} from "../../common/goeasyimutil.js"
 	import GoEasyAudioPlayer from "../../components/GoEasyAudioPlayer/GoEasyAudioPlayer.vue";
 	const recorderManager = uni.getRecorderManager()
+	import IMService from "../../common/goeasyimutil.js"
 	export default {
 		components: {
 			GoEasyAudioPlayer
 		},
+		onShow() {
+			var i = 0;
+			while(i<3){
+				console.log('我是i',i);
+				if(typeof getApp().globalData.imService =='undefined'){
+					 let res = uni.getStorageSync('user');
+						getApp().globalData.imService = new IMService();
+						let loginResult = getApp().globalData.imService.login({
+							uuid: res.data.flag,
+							name: res.data.name,
+							avatar: res.data.avatar
+						});
+						if (loginResult) {
+							//连接IM
+							getApp().globalData.imService.connectIM();
+						}
+				}else{
+					break;
+				}
+				i++;			
+			}
+			this.getcnversationList()
+		},
 		onLoad() {
 		 this.imService = getApp().globalData.imService;
-		 console.log(this.imService.sendPrivateTextMessage())
+		 // console.log(this.imService.sendPrivateTextMessage())
 		 // console.log(this.imService.getFrindList())
 			
 		},
 		mounted() {
 		},
-		onShow() {
-			this.getcnversationList()
-		},
+	 
 		data() {
 			return {
 				//控制聊天列表和通话记录
 				//false为通话记录,true为聊天列表
 				qiehuan: true,
-
+				index:0,
 				keyword: "",
 				list:[],
 				listPhone:[],
@@ -85,9 +107,25 @@
 					this.qiehuan = true
 				}
 			},
-			goliaotian() {
+			goliaotian(e) {
+				let data = this.list[e];
+				var index=data.flag.lastIndexOf("\_");
+				var user_id=data.flag.substring(index+1,data.flag.length);
+					 
+				let obj = {
+					'user_id':user_id,
+					'user_name':data.nickname,
+					'user_avatar':data.avatar,
+				}
+				var urls = "";
+				if(data.order_status==3){
+					urls = "../conversation/conversationWindow?patient=" + JSON.stringify(obj) + "&type=1"
+				}else{
+					urls = "../conversation/conversationWindow?patient=" + JSON.stringify(obj) + "&type=2"
+				}
+				// ?patient=" + JSON.stringify(this.info) + "&type=1
 				uni.navigateTo({
-					url: "conversationWindow"
+					url: urls
 				})
 			},
 			call() {
@@ -100,9 +138,6 @@
 				if(res.status==0){
 					if(res.data.length!=0){
 						this.list = res.data;
-				 
-						
-						
 					}
 				}
 				

+ 2 - 5
pages/conversation/conversationWindow.vue

xqd xqd xqd
@@ -55,7 +55,9 @@
 	import {
 		sendMessages
 	} from "../../common/goeasyimutil.js"
+	import store from '@/store'
 	import GoEasyAudioPlayer from "../../components/GoEasyAudioPlayer/GoEasyAudioPlayer.vue";
+	import IMService from "../../common/goeasyimutil.js"
 	const recorderManager = uni.getRecorderManager()
 	export default {
 		components: {
@@ -65,10 +67,8 @@
 			if(op.type==2){
 				this.sures=false;
 			}
-			
 			this.imService = getApp().globalData.imService;
 			this.doctorInfo = JSON.parse(op.patient)
-			
 			//对话数据
 			this.friend = {
 				uuid: "member_" + this.doctorInfo.user_id,
@@ -84,11 +84,8 @@
 			});
 
 			this.initialListeners();
-
-
 			//每次进入聊天页面,总是滚动到底部
 			this.scrollToBottom()
-
 			//收到的消息设置为已读
 			if (this.messages.length != 0) {
 				this.imService.markPrivateMessageAsRead(this.friend.uuid);

+ 25 - 1
pages/zixun/xiangqing.vue

xqd xqd xqd
@@ -195,11 +195,34 @@
 </template>
 
 <script>
+		import IMService from "../../common/goeasyimutil.js"
 	export default {
 		onLoad(options) {
 			console.log('获取ID:', options.data);
 			this.pageid = options.data
 			this.getInfo(options.data);
+			
+			// 心跳三次
+			var i = 0;
+			while(i<3){
+				console.log('我是i',i);
+				if(typeof getApp().globalData.imService =='undefined'){
+					 let res = uni.getStorageSync('user');
+						getApp().globalData.imService = new IMService();
+						let loginResult = getApp().globalData.imService.login({
+							uuid: res.data.flag,
+							name: res.data.name,
+							avatar: res.data.avatar
+						});
+						if (loginResult) {
+							//连接IM
+							getApp().globalData.imService.connectIM();
+						}
+				}else{
+					break;
+				}
+				i++;			
+			}
 		},
 		mounted() {
 
@@ -279,7 +302,7 @@
 			getInfo:async function(id){
 				let res = await this.$request.post("patient/orderPatientDetail",{'patient_id':id});		
 				if(res.status==0){
-
+					
 					let list = res.data;
 					this.info = res.data
 					this.orderID = list.order_sn;
@@ -332,6 +355,7 @@
 			//发起会话
 			huihu(e) {
 				console.log("1111")
+				console.log(this.info);
 				uni.navigateTo({
 					url: "../conversation/conversationWindow?patient=" + JSON.stringify(this.info) + "&type=1"
 				})

+ 6 - 1
store/index.js

xqd xqd xqd
@@ -7,7 +7,7 @@ const store = new Vuex.Store({
 	state: {
 		hasLogin: false,
 		jwt: uni.getStorageSync('jwt'),
-		user: {}
+		user: uni.getStorageSync('user'),
 	},
 	// getters
 	getters: {
@@ -15,6 +15,9 @@ const store = new Vuex.Store({
 		getJwt: state => {
 			return state.jwt;
 		},
+		getUser: state => {
+			return state.user
+		},
 		// ÑéÖ¤ÊÇ·ñÓÐtoken
 		verifyJwt: state => {
 			if (state.jwt) {
@@ -30,8 +33,10 @@ const store = new Vuex.Store({
 			uni.setStorageSync('jwt', state.jwt);
 		},
 		login(state) {
+ 
 			state.hasLogin = true;
 			try {
+				uni.setStorageSync('user',state.user);
 				uni.setStorageSync('jwt', state.jwt);
 			} catch (e) {
 				// error