예제 #1
0
        /// <summary>
        /// 用户状态检测
        /// <para>@userid:用户Id</para>
        /// </summary>
        private ActionResult CheckUser(NxpDictionary<string, object> nxpDictionary)
        {
            int userid = nxpDictionary.GetInt32("userid", 0);
            var member = _memberService.GetById(userid);
            int value = 0;
            if(member != null)
                value = member.Status;

            return ShowResult(value);
        }
예제 #2
0
        /// <summary>
        /// 手机解除绑定
        /// <para>@userid:用户Id</para>
        /// </summary>
        private ActionResult MemberUnbinding(NxpDictionary<string, object> nxpDictionary)
        {
            var userid = nxpDictionary.GetInt32("userid", 0);
            var code = nxpDictionary.GetString("code", string.Empty);
            var mobile = nxpDictionary.GetString("mobile", string.Empty);

            if (!Security(userid))
                return LogError("验证用户失败请重新登陆!", -1);

            int errorNumber = Session["UNBINDING_CODE_COUNT_" + WebHelper.Md5(mobile)].To<int>();
            if (errorNumber >= 3)
            {
                return LogError("验证码不正确");
            }

            var myCode = Session["UNBINDING_CODE_" + WebHelper.Md5(mobile)].To<string>("");
            if (code == "" || code != myCode)
            {
                Session["UNBINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = errorNumber++;
                return LogError("验证码不正确");
            }

            var member = _memberService.GetById(userid);
            if (member == null || member.Id == 0)
                return LogError("用户不存在");

            if (member.IsBindingMobile == 0)
            {
                return LogError("用户已解除绑定");
            }

            var httpModel = _memberService.UpdateMobileHttpModel(userid, mobile, 0);

            if (httpModel.Code == 0)
                return ShowResult(httpModel.Data, httpModel.Attachments);
            else
                return LogError(httpModel.Message);
        }
예제 #3
0
        /// <summary>
        /// 发送解绑手机验证码
        /// <para>@mobile:手机号</para>
        /// <para>@rv:验证码</para>
        /// </summary>
        private ActionResult SendUnBindingCode(NxpDictionary<string, object> nxpDictionary)
        {
            var mobile = nxpDictionary.GetString("mobile", string.Empty);
            var userid = nxpDictionary.GetInt32("userid", 0);

            var member = _memberService.GetById(userid);
            if (member.Mobile != mobile)
            {
                return LogError("请输入正确的手机号");
            }

            if (string.IsNullOrWhiteSpace(member.Mobile))
            {
                return LogError("手机号已解除绑定");
            }

            var code = new Random().Next(1000, 9999);

            var res = _memberService.SendSmsUnbindingMobileMessage(mobile, code.To<string>());

            if (!res)
            {
                return LogError("发送失败或使用次数已满");
            }

            //验证码写入Session
            Session["UNBINDING_CODE_" + WebHelper.Md5(mobile)] = code;
            Session["UNBINDING_CODE_COUNT_" + WebHelper.Md5(mobile)] = 0;

            return ShowResult("验证码已发送");
        }
예제 #4
0
        /// <summary>
        /// 获取绑定信息
        /// <para>@userid:用户Id</para>
        /// </summary>
        private ActionResult GetBinding(NxpDictionary<string, object> nxpDictionary)
        {
            var userid = nxpDictionary.GetInt32("userid", 0);
            if (!Security(userid))
                return LogError("验证用户失败请重新登陆!", -1);

            var member = _memberService.GetById(userid);

            return ShowResult(member.IsBindingMobile, !string.IsNullOrEmpty(member.Mobile)
                    ? string.Format("你已绑定手机号为:{0}***{1}", member.Mobile.Substring(0, 4), member.Mobile.Substring(member.Mobile.Length - 3))
                    : "");
        }