(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Script/route/Route.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '797f3IlG+dA3LvsFv3r+fA7', 'Route', __filename);
// Script/route/Route.js

"use strict";

// Learn cc.Class:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
//  - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
//  - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
// TODO 路由
// let Http=require("../comment/Http")
var Http = require("NGame");
cc.Class({
    extends: Http,

    properties: {},
    /**
     * 验证token 是否失效
     */
    getoken: function getoken(userid, callback) {
        var _this = this;

        this.Http("/web/login/getoken", { userid: userid }, function (req) {
            var result = req.data;
            if (result.bool == true) {
                _this.sets("token", result.token); //设置用户token
                var data = JSON.stringify(result);
                _this.sets("user", data); // 设置用户数据
            } else {
                _this.sets("token", result.token); //设置用户token
                var _data = JSON.stringify(result);
                _this.sets("user", _data); // 设置用户数据
            }
        });
    },

    /**
     * 登录
     */
    login: function login(callback) {
        var _this2 = this;

        var userid = this.getsParam("shop_token") ? this.getsParam("shop_token") : 1;
        // let token=this.gets("token")
        // if (!token){
        // this.Http("/web/login/index",{userid:userid}, (req) => {
        this.Http("/web/login/logins", { shop_token: userid }, function (req) {
            console.log("登录数据", req);
            if (req.code == 1) {
                _this2.sets("token", req.data.token); //设置用户token
                var data = JSON.stringify(req.data);
                _this2.sets("user", data); // 设置用户数据
            }
            callback(req);
        });
        // }else {
        //     this.getoken(userid)
        //     callback("已经登录")
        // }
    }
});

cc._RF.pop();
        }
        if (CC_EDITOR) {
            __define(__module.exports, __require, __module);
        }
        else {
            cc.registerModuleFunc(__filename, function () {
                __define(__module.exports, __require, __module);
            });
        }
        })();
        //# sourceMappingURL=Route.js.map
        