login.58235.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. var _this;
  2. new Vue({
  3. el: '#app',
  4. data: function() {
  5. return {
  6. userName: "",
  7. userPwd: "",
  8. codeImg: "",
  9. userCode:"",
  10. uuId: "",
  11. logining: false
  12. }
  13. },
  14. created() {
  15. _this = this;
  16. if(location.search != ""){
  17. let dh = location.search.indexOf("android");
  18. if(dh != -1){
  19. localStorage.setItem("ptType", "android");
  20. }
  21. }
  22. _this.getCodeImg();
  23. if (getCookie("ylToken") != "null" && getCookie("ylToken") != null) {
  24. top.location.href = staticUrl + (IsPC()?"/view/main.html":"/view/mainPh.html");
  25. } else {
  26. clearStor();
  27. }
  28. },
  29. methods: {
  30. getCodeImg(){
  31. let _opts = {
  32. url: baseUrl + "/captchaImage",
  33. type:"GET"
  34. };
  35. getAxios(_opts, {}, {}).then((res) => {
  36. if(res.code == 200){
  37. _this.uuId = res.uuid;
  38. _this.codeImg = "data:image/jpg;base64,"+res.img;
  39. }
  40. })
  41. },
  42. logIn(){
  43. if(_this.userName == ""){
  44. _this.$message({
  45. message: '请填写用户账号!',
  46. type: 'warning'
  47. });
  48. return;
  49. }
  50. if(_this.userPwd == ""){
  51. _this.$message({
  52. message: '请填写用户密码!',
  53. type: 'warning'
  54. });
  55. return;
  56. }
  57. if(_this.userCode == ""){
  58. _this.$message({
  59. message: '请填写验证码!',
  60. type: 'warning'
  61. });
  62. return;
  63. }
  64. _this.logining = true;
  65. let _opts = {
  66. url: baseUrl + "/login",
  67. type:"POST"
  68. };
  69. let _hea = {
  70. "Content-Type": 'application/json; charset=UTF-8'
  71. };
  72. let _data = JSON.stringify({
  73. code: _this.userCode,
  74. password: _this.userPwd,
  75. username: _this.userName,
  76. uuid: _this.uuId
  77. });
  78. postAxios(_opts, _data, _hea).then((res) => {
  79. if (res.code == "200"){
  80. delCookie("Admin-Token");
  81. setCookie("Admin-Token",res.token);
  82. _this.getEzviz();
  83. }else{
  84. _this.$message({
  85. message: "错误原因:"+res.msg+"!",
  86. type: 'warning'
  87. });
  88. _this.getCodeImg();
  89. _this.logining = false;
  90. }
  91. })
  92. },
  93. getEzviz(){
  94. let _opts = {
  95. url: ys7Url + "/api/lapp/token/get",
  96. type:"POST"
  97. };
  98. let _data = {
  99. appKey:"443b2b196905436dbdf1ad6f30b0ac0d",
  100. appSecret:"08d8c3401a809115d442108883735c70"
  101. };
  102. let _hea = {};
  103. postAxios(_opts, _data, _hea).then((res) => {
  104. if(res.code == 200){
  105. delCookie("ylToken");
  106. setCookie("ylToken",res.data.accessToken);
  107. _this.getHTok();
  108. }else{
  109. if(res.code == "10017"){
  110. _this.$message({
  111. message: '用户账号错误!',
  112. type: 'warning'
  113. });
  114. }else if(res.code == "10030"){
  115. _this.$message({
  116. message: '用户密码错误!',
  117. type: 'warning'
  118. });
  119. }
  120. _this.getCodeImg();
  121. _this.logining = false;
  122. }
  123. })
  124. },
  125. getHTok(){
  126. let _opts = {
  127. url: helUrl + "/index.php?ctl=tool&act=get_token",
  128. type:"POST"
  129. };
  130. let _data = {
  131. user_name: "易站智联",
  132. pkey: "e7d7cbe91171c493e8022a418d16bb7d"
  133. };
  134. let _hea = {};
  135. postAxios(_opts, _data, _hea).then((res) => {
  136. if(res.status){
  137. delCookie("hemlTok");
  138. setCookie("hemlTok",res.token);
  139. _this.getZTok();
  140. // top.location.href = staticUrl + (IsPC()?"/view/main.html":"/view/mainPh.html");
  141. }else{
  142. _this.getCodeImg();
  143. }
  144. _this.logining = false;
  145. })
  146. },
  147. getZTok(){
  148. let _opts = {
  149. url: "https://hsws.enstation.com/radar_war/login",
  150. type:"POST"
  151. };
  152. let _data = JSON.stringify({
  153. username: "n5cMa8laaQm+x24QXdu2+A==",
  154. password: "n/kedxFbY0pPAAbTPfIbZg==",
  155. code: null,
  156. uuid: "f53582934d844429a52be829a9291789"
  157. });
  158. let _hea = {
  159. "Content-Type": "application/json"
  160. };
  161. postAxios(_opts, _data, _hea).then((res) => {
  162. if(res.code == 200){
  163. delCookie("tzToken");
  164. setCookie("tzToken", res.token);
  165. top.location.href = staticUrl + (IsPC()?"/view/main.html":"/view/mainPh.html");
  166. }else{
  167. _this.getCodeImg();
  168. }
  169. _this.logining = false;
  170. })
  171. },
  172. keyDown(ev){
  173. console.log(ev)
  174. }
  175. }
  176. })