Ver código fonte

0820-1206-h01

Zory 1 mês atrás
pai
commit
cd852b5fbc

+ 33 - 6
奥莱优品/pages/service/chat.vue

@@ -14,7 +14,7 @@
 							<view class="message" :class="[item.userType]">
 								<image :src="chatData.service" v-if="item.userType === 'friend'" class="avatar" mode="widthFix"></image>
 								<view class="message-con">
-									<view v-if="item.msgType == 'text'">
+									<view v-if="item.msgType == 'text'" @click="clickText(item.content)">
 										<view v-html="renderTextMessage(item.content)"></view>
 									</view>
 									<view class="m-address" v-if="item.msgType == 'address'">
@@ -125,16 +125,18 @@ export default {
 			screenWidth:0,
 			pushData: {
 				obj:null,
-				auth:"http://192.168.2.142:9881/plugin/webman/push/auth",
-				url: 'ws://192.168.2.142:3131',
+				auth:"http://192.168.3.16:9881/plugin/webman/push/auth",
+				url: 'ws://192.168.3.16:3131',
 			},
 			isFocus:false,
 			chatData:{
 				userId:"",
 				self:"",
-				service:""
+				service:"",
+				serviceId:0, // 客服ID
 			},
 			isServiceUser:0, // 1已转人工 0未转人工
+			quickData:{}
 		}
 	},
 	onLoad() {
@@ -167,6 +169,20 @@ export default {
 		previewImg(data){
 			return openimg(1,[data])
 		},
+		clickText(text){
+			const regex = /(1[3-9]\d{9})|(\d{3,4}-\d{7,8})|(\d{7,12})/g;
+			const matches = text.match(regex);
+			if (!matches) return ;
+			uni.makePhoneCall({
+				phoneNumber:matches[0],
+				success() {
+
+				},
+				fail(){
+
+				}
+			})
+		},
 		async getServiceData(){
 			var formData = {};
 			const tokenPoi = uni.getStorageSync("contact");
@@ -185,9 +201,11 @@ export default {
 			app.chatData.userId = resp.data.userId;
 			app.chatData.self = resp.data.avatar;
 			app.chatData.service = resp.data.service;
+			app.chatData.serviceId = resp.data.chat_id;
 			var msgData = resp.data.msg.data;
 			var pushData = [];
 			var quickData = resp.data.quick;
+			app.quickData = quickData
 			pushData.push({
 				content: quickData.star_msg,
 				userType: 'friend',
@@ -366,6 +384,13 @@ export default {
 		},
 		async sendingText(){
 			if (app.text === '') return ;
+			console.log("app.chatData.serviceId",app.chatData.serviceId)
+			if (app.chatData.serviceId == 0) {
+				app.text = ''
+				app.sendMessage(app.quickData.unline_msg,"text",'friend');
+				app.scrollToBottom()
+				return ;
+			}
 			app.msgData.isSend = true;
 			const sendMsg = app.text;
 			app.text = ''
@@ -374,6 +399,7 @@ export default {
 			formData.groupId = tokenPoi.poi_id;
 			formData.type = "text";
 			formData.content = sendMsg;
+			formData.chatId = app.chatData.serviceId;
 			var resp = await app.$api.chat.sendText.post(formData);
 			app.msgData.isSend = false;
 			if (resp.code == 0) {
@@ -382,10 +408,10 @@ export default {
 			app.sendMessage(sendMsg,"text");
 			app.scrollToBottom()
 		},
-		sendMessage(content,type){
+		sendMessage(content,type,user = "self"){
 			const message = {
 				content: content,
-				userType: 'self',
+				userType: user,
 				avatar: "/static/logo.jpg",
 				msgType:type,
 				list:[],
@@ -416,6 +442,7 @@ export default {
 			const tokenPoi = uni.getStorageSync("contact");
 			formData.groupId = tokenPoi.poi_id;
 			formData.type = "image";
+			formData.chatId = app.chatData.serviceId;
 			var resp = await app.$api.chat.sendImage.post({'path':file.path,"param":formData});
 			var respData = JSON.parse(resp);
 			app.msgData.isSend = false;

+ 1 - 1
奥莱优品/static/js/request.js

@@ -16,7 +16,7 @@ const axg = {
 		// #endif
 		// #ifdef MP
 		// return 'https://tran.jsshuita.cn/v2'
-		return 'http://192.168.2.142:9881/v2'
+		return 'http://192.168.3.16:9881/v2'
 		// #endif
 	},
 	toast: function(text, duration, success) {