Esempio n. 1
0
        public JsonResult <ResultObject> Login([FromBody] dynamic data)
        {
            string  code   = data.code.Value;
            dynamic result = null;

            result = JsonConvert.DeserializeObject <dynamic>(MiniprogramApiHelper.Login(code));
            string    encryptedData = data.user_data.encryptedData.Value;
            string    iv            = data.user_data.iv.Value;
            string    key           = result.session_key.Value;
            string    nickName      = data.user_data.userInfo.nickName.Value;
            string    avatarUrl     = data.user_data.userInfo.avatarUrl.Value;
            dynamic   decrptObj     = JsonConvert.DeserializeObject <dynamic>(MiniprogramApiHelper.AES_decrypt(encryptedData, key, iv));
            UserModel userModel     = new UserModel();

            userModel.LastLoginTime = DateTime.Now;
            userModel.OpenID        = result.openid;
            //userModel.UserMobile= decrptObj
            userModel.UserName = nickName;
            userModel.Avatars  = avatarUrl;
            string token = UserBussiness.Login(userModel);

            return(Success(new
            {
                signName = nickName,
                access_token = userModel.OpenID,
                nickName,
                phone = "",
                auth = 2,
                avatarUrl = avatarUrl
            }));
        }
Esempio n. 2
0
        public JsonResult Login(string code, View_UserData user_data)
        {
            dynamic result = null;
            dynamic data   = JsonConvert.DeserializeObject <dynamic>(user_data.rawData);

            result = JsonConvert.DeserializeObject <dynamic>(MiniprogramApiHelper.Login(code));
            string    encryptedData = user_data.encryptedData;
            string    iv            = user_data.iv;
            string    key           = result.session_key;
            string    nickName      = data.nickName;
            string    avatarUrl     = data.avatarUrl;
            UserModel userModel     = new UserModel();

            userModel.LastLoginTime = DateTime.Now;
            userModel.OpenID        = result.openid;
            userModel.UserName      = nickName;
            userModel.Avatars       = avatarUrl;
            try
            {
                dynamic decrptObj = JsonConvert.DeserializeObject <dynamic>(MiniprogramApiHelper.AES_decrypt(encryptedData, key, iv));
                userModel.city     = decrptObj.city;
                userModel.province = decrptObj.province;
                userModel.country  = decrptObj.country;
            }
            catch (Exception)
            {
            }
            var user = UserBussiness.GetUserModel(m => m.OpenID == userModel.OpenID);

            if (user == null)
            {
                string token = UserBussiness.Login(userModel);
            }
            else
            {
                UserBussiness.UpdateUserModel(userModel);
            }
            return(Success(new
            {
                uname = nickName,
                upic = avatarUrl,
                signName = nickName,
                access_token = userModel.OpenID,
                nickName,
                phone = userModel.UserMobile,
                userModel.city,
                userModel.province,
                userModel.country,
                auth = 2,
                avatarUrl = avatarUrl,
            }));
        }
Esempio n. 3
0
        public JsonResult AdminQRCode(int eid)
        {
            var md = ActivesManageApplyBussiness.GetActivesManageApplyModel(m => m.ActiveID == eid && m.ExpirseDate <= DateTime.Now && m.Status == 0);

            if (md == null)
            {
                string floder = "/Image/AdminQRCode";
                string path   = Server.MapPath(floder);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                string url = Common.HostUrl + floder + "/" + Guid.NewGuid().ToString() + ".png";
                try
                {
                    MiniprogramApiHelper.CreateShareCode(eid.ToString(), "subpackage/addadmin/addadmin").Save(url);
                }
                catch (Exception)
                {
                    url = "https://res.wx.qq.com/wxdoc/dist/assets/img/WXAQRCode.053ccc63.png";
                }
                md              = new ActivesManageApplyModel();
                md.Status       = 0;
                md.CreateUserID = LoginUserInfo.ID;
                md.URL          = url;
                md.Code         = LeoUtils.GetRandomStr();
                md.CreateTime   = DateTime.Now;
                md.ExpirseDate  = md.CreateTime.Value.AddMinutes(10);
                ActivesManageApplyBussiness.InsertActivesManageApplyModel(md);
            }
            else
            {
                md.Code        = LeoUtils.GetRandomStr();
                md.UpdateTime  = DateTime.Now;
                md.ExpirseDate = md.UpdateTime.Value.AddMinutes(10);
            }

            return(Success(new {
                url = md.URL,
                code = md.Code,
                expire_at = LeoUtils.ConvertDateTimeInt1(md.ExpirseDate)
            }));
        }
Esempio n. 4
0
        public ActionResult Share(int eid)
        {
            string filePath = Server.MapPath("/Images");

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            string fileName = filePath + "/" + Guid.NewGuid().ToString();

            try
            {
                Image img = MiniprogramApiHelper.CreateShareCode(eid.ToString(), "pages/detail/detail");
                img.Save(fileName);
            }
            catch (Exception)
            {
                fileName = "https://res.wx.qq.com/wxdoc/dist/assets/img/WXAQRCode.053ccc63.png";
            }
            return(Success(new
            {
                url = fileName
            }));
        }
Esempio n. 5
0
        public JsonResult CertDetail(int info_id)
        {
            var    signin   = SignInRecordBussiness.GetSignInRecordModel(info_id);
            var    active   = ActivesBussiness.GetActivesModel(signin.ActiveID.Value);
            var    user     = UserBussiness.GetUserModel(signin.CreateUserID ?? 0);
            string filePath = Server.MapPath("/Images");

            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }
            string fileName = filePath + "/" + Guid.NewGuid().ToString();

            try
            {
                Image img = MiniprogramApiHelper.CreateShareCode(signin.ActiveID.Value.ToString() + "_" + info_id, "pages/detail/detail");
                img.Save(fileName);
            }
            catch (Exception ex)
            {
                fileName = "https://res.wx.qq.com/wxdoc/dist/assets/img/WXAQRCode.053ccc63.png";
            }

            return(Success(new
            {
                start_time = LeoUtils.ConvertDateTimeInt1(active.SigninBeginTIme),
                end_time = LeoUtils.ConvertDateTimeInt1(active.SigninEndTime),
                act_start = LeoUtils.ConvertDateTimeInt1(active.ActiveBeginTime),
                act_end = LeoUtils.ConvertDateTimeInt1(active.ActiveEndTime),
                enroll_time = LeoUtils.ConvertDateTimeInt1(signin.CreateTime),
                qrcode = fileName,
                items = new ArrayList(),
                title = active.Title,
                name = user.UserName
            }));
        }