Pārlūkot izejas kodu

开启 im开关2

wangdy 8 gadi atpakaļ
vecāks
revīzija
a92fe9b661

+ 28 - 45
src/main/webapp/resources/js/common/module/chat_web_module.js

@@ -145,56 +145,39 @@ define([ 'common/query/chat', 'common/query/enterprise' ], function() {
 						toaster.pop('warning', '该店铺暂无管理员电话号码!');
 						return;
 					}*/
-					console.log(phone, enUU, userType);
-					var newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
-						chatInfoDto = {
-							userPhone: vm.param.phone,
-							enUU: vm.param.enUU,
-							userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
-							toPhone: phone,
-							otherEnUU: enUU,
-							otherUserType: userType
-						};
-					ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
-						if (!gid || gid == ''){
-							newTab.close();
-							toaster.pop('warning', '您暂未开通聊天帐号!');
-							return;
-						}
-						//newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
-						newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
-					}, function (error) {
-						console.log(error);
-						newTab.close();
-						toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
-					});
+					console.log(phone, enUU, userType,iTop,iLeft);
+					startChat(phone,enUU,userType,iTop,iLeft);
 				});
 			}else {
-				var newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
-					chatInfoDto = {
-						userPhone: vm.param.phone,
-						enUU: vm.param.enUU,
-						userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
-						toPhone: phone,
-						otherEnUU: enUU,
-						otherUserType: userType
-					};
-				ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
-					if (!gid || gid == ''){
-						newTab.close();
-						toaster.pop('warning', '您暂未开通聊天帐号!');
-						return;
-					}
-					//newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
-					newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
-				}, function (error) {
-					console.log(error);
-					newTab.close();
-					toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
-				});
+                startChat(phone,enUU,userType,iTop,iLeft);
 			}
 		}
 
+		var startChat= function (phone,enUU,userType,iTop,iLeft) {
+            var newTab = window.open('', '即时对话框', 'height=750, width=1000, top=' + iTop + ', left=' + iLeft + ', toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no'),
+                chatInfoDto = {
+                    userPhone: vm.param.phone,
+                    enUU: vm.param.enUU,
+                    userType: userType == vm.UserType.STORE ? vm.UserType.ENTERPRISE : vm.UserType.STORE,
+                    toPhone: phone,
+                    otherEnUU: enUU,
+                    otherUserType: userType
+                };
+            ChatBusinessLayer.visitWebChat(chatInfoDto, 'CHAT').then(function (gid) {
+                if (!gid || gid == ''){
+                    newTab.close();
+                    toaster.pop('warning', '您暂未开通聊天帐号!');
+                    return;
+                }
+                //newTab.location.href = 'http://192.168.253.121:20220/chat/visit?gid=' +  gid;
+                newTab.location.href = 'http://im.ubtob.com/chat/visit?gid=' + gid;
+            }, function (error) {
+                console.log(error);
+                newTab.close();
+                toaster.pop('warning', '对方没有开通客服系统,请联系官方客服!');
+            });
+        }
+
 	}]);
 
 });