123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- var _this;
- new Vue({
- el: '#app',
- data: function() {
- return {
- userName: "",
- userPwd: "",
- codeImg: "",
- codePwd: "",
- uuId: "",
- logining: false
- }
- },
- created() {
- _this = this;
- _this.getCode();
- _this.checkUuid(0);
- let _src = window.location.href.split("?id=");
- defUrl = _src.length > 1?_src[1]:"main";
- if (localStorage.getItem("ylToken") != "null" && localStorage.getItem("ylToken") != null) {
- top.location.href = "./view/"+defUrl+".html";
- } else {
- }
- },
- methods: {
- checkUuid(num){
- $.ajax({
- url: genUrl + "/gps-web/h5/blogin?&_t="+new Date().getTime(),
- type: "GET",
- dataType: "JSON",
- async: true,
- data:{},
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- if(res.result!=""){
- _this.getSeId(res.result.uuid,num);
- }
- }
- })
- },
- getSeId(code,_num){
- $.ajax({
- url: genUrl + "/gps-web/h5/login?_t="+new Date().getTime(),
- type: "POST",
- dataType: "JSON",
- contentType: 'application/json; charset=UTF-8',
- async: true,
- data: JSON.stringify({
- code: [{x: 135, y: 501, t: 28185}],
- codeId: code,
- h5login: true,
- loginLang: "zh_CN",
- loginType: "user",
- loginWay: "ie",
- password: "827ccb0eea8a706c4c34a16891f84e7b",
- plateColor: "1",
- smsCode: null,
- userId: "YZ"
- }),
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- if(res.result!=""){
- _SeId = res.result.split("ok#")[1];
- if(_num == 1){
- _this.getCTok();
- }
- }
- }
- })
- },
- getCTok(){
- $.ajax({
- url: genUrl + "/gps-web/h5/alogin?sessionId="+_SeId+"&_t="+new Date().getTime(),
- type: "GET",
- dataType: "JSON",
- async: true,
- data:{},
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- if(res.result!=""){
- localStorage.removeItem("AjaxGen");
- localStorage.setItem("AjaxGen",res.result.authorization);
- _this.getYsyTok()
- }else{
- _this.checkUuid(1);
- }
- }
- })
- },
- getYsyTok(){
- $.ajax({
- url: "https://open.ys7.com/api/lapp/token/get",
- type: "POST",
- dataType: "JSON",
- async: false,
- data:{
- appKey:"443b2b196905436dbdf1ad6f30b0ac0d",
- appSecret:"08d8c3401a809115d442108883735c70"
- },
- success:function (json) {
- if(json.code == 200){
- localStorage.removeItem("ysyToken");
- localStorage.setItem("ysyToken",json.data.accessToken);
- top.location.href = "./view/"+defUrl+".html";
- }
- }
- })
- },
- getCode(){
- $.ajax({
- url: "http://121.37.6.200:8088/captchaImage",
- type: "GET",
- dataType: "JSON",
- async: true,
- data:{},
- error: function(XMLHttpRequest) {
- console.log(11111)
- },
- success:function (res) {
- if(res.code == 200){
- _this.uuId = res.uuid;
- _this.codeImg = "data:image/jpg;base64,"+res.img;
- }
- }
- })
- },
- logIn(){
- if(_this.userName == ""){
- _this.$message({
- message: '请填写用户账号!',
- type: 'warning'
- });
- return;
- }
- if(_this.userPwd == ""){
- _this.$message({
- message: '请填写用户密码!',
- type: 'warning'
- });
- return;
- }
- if(_this.codePwd == ""){
- _this.$message({
- message: '请填写验证码!',
- type: 'warning'
- });
- return;
- }
- _this.logining = true;
- $.ajax({
- url: "http://121.37.6.200:8088/login",
- type: "POST",
- dataType: "JSON",
- async: false,
- contentType: 'application/json; charset=UTF-8',
- data: JSON.stringify({
- code: _this.codePwd,
- password: _this.userPwd,
- username: _this.userName,
- uuid: _this.uuId
- }),
- success:function (json) {
- if(json.code == 200){
- localStorage.removeItem("ylToken");
- localStorage.setItem("ylToken",json.token);
- _this.getCTok();
- }else{
- _this.$message({
- message: json.msg,
- type: 'warning'
- });
- _this.getCode();
- _this.logining = false;
- }
- }
- })
- },
- keyDown(ev){
- console.log(ev)
- }
- }
- })
|