MoblieHome.module.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. function signalViewModel(account, name, personid) {
  2. var clickNum = 0;
  3. mui.back = function (event) {
  4. clickNum++; if (clickNum > 1) { plus.runtime.quit(); }
  5. else {
  6. mui.toast("再按一次退出应用");
  7. } setTimeout(function () { clickNum = 0 }, 2000); return false;
  8. }
  9. //账户
  10. this.Account = account;
  11. //登录名
  12. this.Name = name;
  13. //人员ID
  14. this.PersonId = personid;
  15. //登录的集成代理类
  16. this.LoginProxy = $.connection.LoginHub;
  17. //初始化连接服务器成功后调用
  18. //this.LoginProxy.client.connectedSuccess = function (connectId) {
  19. // ZLPMS.Msg('成功获取到在线用户信息');
  20. //}
  21. //被踢下线
  22. this.LoginProxy.client.MoblieOffline = function () {
  23. $.post("/MobileAccount/LogOut", {}, function (data) {
  24. mui.alert('您的账号在其它客户端登录,被强制下线', function () {
  25. window.location.href = '/MobileAccount/MobileProblemLogin'
  26. });
  27. })
  28. }
  29. //向服务端发起注册
  30. this.register = function () {
  31. var that = this;
  32. //向服务器注册客户端
  33. $.connection.hub.start().done(function () {
  34. //客户端向服务器的Hub类注册成功事件(成功后,执行登录)
  35. that.LoginProxy.server.MoblieLogin(that.Account, that.Name, that.PersonId);
  36. }).fail(function () {
  37. //客户端向服务器的Hub类注册失败事件
  38. mui.toast('客户端向服务器的Hub类注册失败事件');
  39. });
  40. };
  41. }