Пример #1
0
        public string GetJsapiSignature(string jsapi_ticket, string noncestr, string timestamp, string url)
        {
            //string sign = Senparc.Weixin.MP.Helpers.SHA1UtilHelper.GetSha1(string.Format("jsapi_ticket={0}&noncestr={1}&timestamp={2}&url={3}",jsapi_ticket,noncestr,timestamp,url)).ToLower();
            string s1 = JSSDKHelper.GetSignature(jsapi_ticket, noncestr, timestamp, url);

            return(s1);
        }
Пример #2
0
        public ActionResult Index()
        {
            var     code        = Request.Params["code"];
            var     appid       = ConfigurationManager.AppSettings["AppID"];
            var     secret      = ConfigurationManager.AppSettings["AppSecret"];
            WxModel model       = new WxModel();
            var     ticket      = JsApiTicketContainer.GetJsApiTicket(appid);
            var     noncestr    = JSSDKHelper.GetNoncestr();
            var     timeSpan    = JSSDKHelper.GetTimestamp();
            var     signature   = JSSDKHelper.GetSignature(ticket, noncestr, timeSpan, Request.Url.AbsoluteUri);
            var     accessToken = OAuthApi.GetAccessToken(appid, secret, code);

            if (OAuthApi.Auth(accessToken.access_token, accessToken.openid).errcode == ReturnCode.合法的OpenID)
            {
                accessToken = OAuthApi.RefreshToken(appid, accessToken.refresh_token);
            }
            var accessUserInfo = OAuthApi.GetUserInfo(accessToken.access_token, accessToken.openid);

            model.UnioId    = accessUserInfo.openid;
            model.TimeStamp = timeSpan;
            model.Signature = signature;
            model.NonceStr  = noncestr;

            return(View(model));
        }
Пример #3
0
        public static System.Collections.Hashtable GetData(string appid, string secret)
        {
            if (string.IsNullOrEmpty(appid) || string.IsNullOrEmpty(secret))
            {
                return(null);
            }

            var ticket = AccessTokenContainer.TryGetJsApiTicket(appid, secret);
            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var nonceStr = JSSDKHelper.GetNoncestr();

            return(new System.Collections.Hashtable
            {
                { "appId", appid },
                { "nonceStr", nonceStr },
                { "timestamp", timestamp },
                {
                    "signature",
                    JSSDKHelper.GetSignature(ticket, nonceStr, timestamp,
                                             HttpContext.Current.Request.Url.AbsoluteUri)
                }
            });
        }
Пример #4
0
        /// <summary>
        /// 赠送订单成功
        /// </summary>
        /// <param name="orderId"></param>
        /// <returns></returns>
        public ActionResult SendGiftSuccess(long?orderId)
        {
            var order = new OrderViewModel();

            if (orderId.HasValue)
            {
                var tempOrder = OrderService.GetOrder(this.UserInfo.UserId, orderId.Value, false);
                if (tempOrder != null)
                {
                    var user = UserService.GetUserByUserId(tempOrder.UserId);
                    if (user != null)
                    {
                        order.SendUserMobile = user.Mobile;
                        order.SendUserName   = user.WxNickName;
                        order.OrderId        = tempOrder.OrderId;

                        //获取时间戳
                        var timestamp = JSSDKHelper.GetTimestamp();
                        //获取随机码
                        var         nonceStr = JSSDKHelper.GetNoncestr();
                        string      ticket   = JsApiTicketContainer.TryGetTicket(AppId, AppSecret);
                        JSSDKHelper jsHelper = new JSSDKHelper();
                        //获取签名
                        var signature = jsHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri);

                        ViewData["AppId"]     = AppId;
                        ViewData["Timestamp"] = timestamp;
                        ViewData["NonceStr"]  = nonceStr;
                        ViewData["Signature"] = signature;
                    }
                }
            }

            return(View(order));
        }
Пример #5
0
        /// <summary>
        /// 获取配置微信JSSDK的JS字符串;
        /// </summary>
        /// <param name="url"></param>
        /// <param name="interfaces"></param>
        /// <param name="debug"></param>
        /// <returns></returns>
        public string GetConfigWxJs(string url, string interfaces, bool debug = true)
        {
            if (string.IsNullOrEmpty(Config.AppId))
            {
                return("");
            }
            //url = url.ToLower(); //特别注意,url必须小写,否则验证通不过;
            JSSDKHelper helper    = new JSSDKHelper();
            var         timestamp = JSSDKHelper.GetTimestamp();
            var         nonceStr  = JSSDKHelper.GetNoncestr();
            var         jsticket  = JsTicket;
            var         signature = JSSDKHelper.GetSignature(jsticket, nonceStr, timestamp, url);
            string      interfs   = interfaces.Split(new char[] { ',' })
                                    .Select(a => "'" + a.Trim() + "'").ToArray().ToString(",");
            string debugString = "";

            if (debug)
            {
                debugString = "/**" + jsticket + @"**/";
            }
            string configString = debugString + @"
            wx.config({debug:" + debug.ToString().ToLower() + ",appId:'" + Config.AppId + "',timestamp:" +
                                  timestamp + ",nonceStr:'" + nonceStr + "',signature:'" + signature + "',jsApiList:[" + interfs + "]});";

            return(configString);
        }
Пример #6
0
        public ActionResult PlatStoreDescriptionRichText(int id = 0)
        {
            //string token = AccessTokenContainer.GetAccessToken(AccessTokenContainer.GetFirstOrDefaultAppId());
            string token = WxHelper.GetToken(webview_appid, webview_appsecret, false);

            ViewBag.appid     = AccessTokenContainer.GetFirstOrDefaultAppId();
            ViewBag.ticket    = JsApiTicketContainer.GetJsApiTicket(JsApiTicketContainer.GetFirstOrDefaultAppId());
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.nonceStr  = JSSDKHelper.GetNoncestr();
            ViewBag.signature = JSSDKHelper.GetSignature(ViewBag.ticket, ViewBag.nonceStr, ViewBag.timestamp, GetPageUrl());
            log4net.LogHelper.WriteInfo(this.GetType(), $"token={token};appid={ViewBag.appid};ticket={ViewBag.ticket};timestamp={ ViewBag.timestamp};nonceStr={ViewBag.nonceStr};signature={ViewBag.signature};pageUrl={GetPageUrl()}");

            if (id == 0)
            {
                // string temp = RedisUtil.Get<string>("temp_psd_description_0");
                ViewBag.description = "";//temp ?? "";
            }
            else
            {
                PlatStore platStore = PlatStoreBLL.SingleModel.GetModel(id);
                if (platStore == null || platStore.State == -1)
                {
                    ViewBag.description = "";
                    return(Content("店铺不存在或已删除"));
                }
                ViewBag.description = platStore.StoreDescription;
            }
            return(View());
        }
Пример #7
0
        public ActionResult UserInfoCallback(string code, string state, string returnUrl)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(Content("您拒绝了授权!"));
            }

            if (state != Session["State"] as string)
            {
                return(Content("验证失败!请从正规途径进入!"));
            }
            OAuthAccessTokenResult result   = OAuthApi.GetAccessToken(AppId, AppSecret, code);
            OAuthUserInfo          userInfo = OAuthApi.GetUserInfo(result.access_token, result.openid);
            string ticket = string.Empty;

            timestamp = JSSDKHelper.GetTimestamp();
            nonceStr  = JSSDKHelper.GetNoncestr();
            JSSDKHelper jssdkhelper = new JSSDKHelper();

            ticket            = JsApiTicketContainer.TryGetJsApiTicket(AppId, AppSecret);
            signature         = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri.ToString());
            ViewBag.signature = signature;
            ViewBag.appid     = AppId;
            ViewBag.timestamp = timestamp;
            ViewBag.noncestr  = nonceStr;
            return(View(userInfo));
        }
Пример #8
0
        public static async Task <WeixinResponse> WeixinSignResponse(this string url)
        {
            var response = new WeixinResponse();

            var timestamp = JSSDKHelper.GetTimestamp();
            var noncestr  = JSSDKHelper.GetNoncestr();

            var ticket = await JsApiTicketContainer.TryGetJsApiTicketAsync(AppId, AppSecret);

            if (ticket.IsNullOrEmpty())
            {
                response.Message = "获取ticket出错了~~";
            }

            var signature = JSSDKHelper.GetSignature(ticket, noncestr, timestamp, url);

            if (signature.IsNullOrEmpty())
            {
                response.Message = "获取signature出错了~~";
            }

            response.Timestamp = timestamp;
            response.Noncestr  = noncestr;
            response.Ticket    = ticket;
            response.Signature = signature;

            return(response);
        }
Пример #9
0
        /// <summary>
        /// 同步微信JS信息获取
        /// <para>卡券的票据与其他票据不同,请调用此功能</para>
        /// <param name="cardid"></param>
        /// <returns></returns>
        private WXSyncJSInfoByCard GetWXSyncJSInfo(string cardid, string url)
        {
            WXSyncJSInfoByCard result = null;

            if (!string.IsNullOrWhiteSpace(cardid))
            {
                var card = Context.WXCardLogInfo.FirstOrDefault(d => d.CardId == cardid);
                if (card != null)
                {
                    //string acctoken = GetAccessToken(card.AppId, card.AppSecret);
                    string apiticket = GetJSApiTicket(card.AppId, card.AppSecret);
                    if (!string.IsNullOrWhiteSpace(apiticket))
                    {
                        result = new WXSyncJSInfoByCard();
                        JSSDKHelper jsshelper = new JSSDKHelper();
                        result.appid     = card.AppId;
                        result.apiticket = apiticket;
                        result.timestamp = JSSDKHelper.GetTimestamp();
                        result.nonceStr  = JSSDKHelper.GetNoncestr();
                        result.signature = jsshelper.GetSignature(result.apiticket, result.nonceStr, result.timestamp, url);
                    }
                    else
                    {
                        Log.Info("[Coupon]票据获取失败");
                    }
                }
            }
            return(result);
        }
Пример #10
0
        public ActionResult RichText(int id = 0)
        {
            //string token = AccessTokenContainer.GetAccessToken(AccessTokenContainer.GetFirstOrDefaultAppId());
            string token = WxHelper.GetToken(webview_appid, webview_appsecret, false);

            ViewBag.appid     = AccessTokenContainer.GetFirstOrDefaultAppId();
            ViewBag.ticket    = JsApiTicketContainer.GetJsApiTicket(JsApiTicketContainer.GetFirstOrDefaultAppId());
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.nonceStr  = JSSDKHelper.GetNoncestr();

            ViewBag.signature = JSSDKHelper.GetSignature(ViewBag.ticket, ViewBag.nonceStr, ViewBag.timestamp, GetPageUrl());
            ViewBag.pageUrl   = GetPageUrl();
            if (id == 0)
            {
                ViewBag.description = "";
            }
            else
            {
                EntGoods good = EntGoodsBLL.SingleModel.GetModel(id);
                if (good == null)
                {
                    ViewBag.description = "";
                    return(Content("产品不存在或已删除"));
                }
                ViewBag.description = good.description;
            }
            return(View());
        }
Пример #11
0
        private void GetSingInfo(HttpContext context)
        {
            try
            {
                var list      = new List <object>();
                var appid     = WebConfigurationManager.AppSettings["wxappid"].ToString();
                var appsecret = WebConfigurationManager.AppSettings["wxsecret"].ToString();
                var timeStamp = JSSDKHelper.GetTimestamp();
                var nonceStr  = JSSDKHelper.GetNoncestr();
                var url       = context.Request.Params["urlinfo"];
                if (!JsApiTicketContainer.CheckRegistered(appid))
                {
                    JsApiTicketContainer.Register(appid, appsecret);
                }
                string      jsapiticket = JsApiTicketContainer.GetTicket(appid);
                JSSDKHelper cd          = new JSSDKHelper();
                var         signature   = cd.GetSignature(jsapiticket, nonceStr, timeStamp, url);
                list.Add(new { appid1 = appid, timeStamp1 = timeStamp, nonceStr1 = nonceStr, signature1 = signature });

                string jsonstrlist = JsonHelper.GetJsonString(new jsonResult {
                    code = "succ", result = list, count = list.Count
                });
                context.Response.Write(jsonstrlist);
            }
            catch (Exception)
            {
                string jsonstrlist = JsonHelper.GetJsonString(new jsonResult {
                    code = "succ", result = "", count = 0
                });
                context.Response.Write(jsonstrlist);
            }
        }
Пример #12
0
        public async Task <ResultDto> JsSdkAsync(string url)
        {
            var configSection = _configuration.GetSection("WeChat:Web");
            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var nonceStr  = JSSDKHelper.GetNoncestr();
            var appId     = configSection.GetValue <string>("AppId");
            var appSecret = configSection.GetValue <string>("AppSecret");
            //获取票证

            var jsTicket = await JsApiTicketContainer.TryGetJsApiTicketAsync(appId, appSecret);

            //获取签名
            //nonceStr = "Wm3WZYTPz0wzccnW";
            //jsTicket = "sM4AOVdWfPE4DxkXGEs8VMCPGGVi4C3VM0P37wVUCFvkVAy_90u5h9nbSlYy3-Sl-HhTdfl2fzFy1AOcHKP7qg";
            //timestamp = "1414587457";
            //url = "http://mp.weixin.qq.com?params=value";
            //url = url?? Request.GetAbsoluteUri();
            var signature = JSSDKHelper.GetSignature(jsTicket, nonceStr, timestamp, url);

            var resultDto = new ResultDto
            {
                Result  = true,
                Data    = new { appId, timestamp, nonceStr, signature },
                Message = "查询成功"
            };

            _logger.LogDebug(Serialize.ToJson(new { url, appId, jsTicket, timestamp, nonceStr, signature }));
            return(resultDto);
        }
Пример #13
0
        private WXSyncJSInfoByCard GetWXSyncJSInfo(string cardid, string url)
        {
            WXSyncJSInfoByCard wXSyncJSInfoByCard = null;

            if (!string.IsNullOrWhiteSpace(cardid))
            {
                WXCardLogInfo wXCardLogInfo = context.WXCardLogInfo.FirstOrDefault((WXCardLogInfo d) => d.CardId == cardid);
                if (wXCardLogInfo != null)
                {
                    string jSApiTicket = GetJSApiTicket(wXCardLogInfo.AppId, wXCardLogInfo.AppSecret);
                    if (string.IsNullOrWhiteSpace(jSApiTicket))
                    {
                        Log.Info("[Coupon]票据获取失败");
                    }
                    else
                    {
                        wXSyncJSInfoByCard = new WXSyncJSInfoByCard();
                        JSSDKHelper jSSDKHelper = new JSSDKHelper();
                        wXSyncJSInfoByCard.appid     = wXCardLogInfo.AppId;
                        wXSyncJSInfoByCard.apiticket = jSApiTicket;
                        wXSyncJSInfoByCard.timestamp = JSSDKHelper.GetTimestamp();
                        wXSyncJSInfoByCard.nonceStr  = JSSDKHelper.GetNoncestr();
                        wXSyncJSInfoByCard.signature = JSSDKHelper.GetSignature(wXSyncJSInfoByCard.apiticket, wXSyncJSInfoByCard.nonceStr, wXSyncJSInfoByCard.timestamp, url);
                    }
                }
            }
            return(wXSyncJSInfoByCard);
        }
Пример #14
0
        /// <summary>
        /// 转账
        /// </summary>
        /// <returns></returns>
        public ActionResult TransferAccount(long orderId)
        {
            var payTipViewModel = new PayTipViewModel();
            var orderViewModel  = OrderService.GetOrderViewModel(this.UserInfo.UserId, orderId);

            payTipViewModel.OrderId      = orderViewModel.OrderId;
            payTipViewModel.PayMoney     = orderViewModel.ProductCount * orderViewModel.Price;
            payTipViewModel.IsPaySuccess = orderViewModel.Status == OrderStatus.Paid.GetHashCode();
            payTipViewModel.Message      = payTipViewModel.IsPaySuccess ? "支付成功" : "支付失败";
            payTipViewModel.BuyCount     = orderViewModel.ProductCount;

            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var         nonceStr = JSSDKHelper.GetNoncestr();
            string      ticket   = JsApiTicketContainer.TryGetTicket(AppId, AppSecret);
            JSSDKHelper jsHelper = new JSSDKHelper();
            //获取签名
            var signature = jsHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri);

            ViewData["AppId"]     = AppId;
            ViewData["Timestamp"] = timestamp;
            ViewData["NonceStr"]  = nonceStr;
            ViewData["Signature"] = signature;

            ViewBag.uid = DotNet.Common.CryptographyHelper.Base64Encrypt(this.UserInfo.UserId.ToString());
            return(View(payTipViewModel));
        }
Пример #15
0
        public ActionResult SelectOutlet(string outletCn)
        {
            var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret);

            ViewBag.appId     = _corpId;
            ViewBag.noncestr  = JSSDKHelper.GetNoncestr();
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri());

            WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify");

            if (string.IsNullOrWhiteSpace(outletCn))
            {
                ModelState.AddModelError("", "需要输入网点编号");
                return(View("Identify", dto));
            }

            var outlet = _outletCache.GetList().FindLast(x => x.Cn == outletCn);

            if (outlet != null)
            {
                SelectOutlet(outlet.Id, dto);
                return(View("Identify", dto));
            }
            else
            {
                ModelState.AddModelError("", "此编号没有对应的网点");
                return(View("Identify", dto));
            }
        }
Пример #16
0
        public ActionResult VerifyOutlet(int taskId, string password)
        {
            var jsapiticket = JsApiTicketContainer.GetTicket(_corpId, _secret);

            ViewBag.appId     = _corpId;
            ViewBag.noncestr  = JSSDKHelper.GetNoncestr();
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.signature = JSSDKHelper.GetSignature(jsapiticket, ViewBag.nonceStr, ViewBag.timestamp, AbsoluteUri());

            WxIdentifyDto dto = HttpContext.Session.GetObjectFromJson <WxIdentifyDto>("WxIdentify");

            if (dto != null && !string.IsNullOrEmpty(password) && dto.OutletPassword == password)
            {
                if (taskId != 0)
                {
                    _weixinAppService.SetIdentifyTime(taskId);
                    _context.Clients.All.SendAsync("getMessage", "keypoint " + string.Format("{0},{1}", dto.OutletName, dto.DepotId));
                }
                else
                {
                    string issuer = null;
                    foreach (var w in dto.Workers)
                    {
                        issuer += $"{w.Cn} {w.Name},";
                    }
                    _weixinAppService.SetIdentifyEvent(dto.RouteId, $"{dto.OutletCn} {dto.OutletName}", issuer);
                }
                return(View("Information2", dto));
            }
            else
            {
                ModelState.AddModelError("", "网点密码不符,请重新输入");
                return(View("Identify", dto));
            }
        }
Пример #17
0
        /// <summary>
        /// 若不管用,请在公众号官方后台---功能设置----js接口安全域名 设置
        ///    初始化微信分享
        /// </summary>
        /// <param name="wxModel"></param>
        /// <param name="fxUrl">分享的目标url,如果传过来的值为空字符串或者为null则默认是当前的网址</param>
        public void jssdkInit(Model.wx_userweixin wxModel, string fxUrl = "")
        {
            fxModel.appId     = wxModel.AppId;
            fxModel.timestamp = JSSDKHelper.GetTimestamp();
            fxModel.nonceStr  = JSSDKHelper.GetNoncestr();
            fxModel.thisUrl   = HttpContext.Current.Request.Url.ToString();

            if (fxUrl == null || fxUrl.Trim() == "")
            {
                fxModel.fxUrl = fxModel.thisUrl;
            }
            else
            {
                fxModel.fxUrl = fxUrl;
            }
            string error  = "";
            string ticket = WeiXinPF.WeiXinComm.WeiXinCRMComm.getJsApiTicket(wxModel.id, out error);

            if (error != "")
            {  //取临时票据出现问题
                return;
            }
            JSSDKHelper jsHelper = new JSSDKHelper();
            //获取签名
            var signature = jsHelper.GetSignature(ticket, fxModel.nonceStr, fxModel.timestamp, fxModel.thisUrl);

            fxModel.signature = signature;
        }//end:function
Пример #18
0
        /// <summary>
        /// 拼享惠产品描述编辑
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult PinRichText(int id = 0)
        {
            string token = WxHelper.GetToken(webview_appid, webview_appsecret, false);

            ViewBag.appid     = AccessTokenContainer.GetFirstOrDefaultAppId();
            ViewBag.ticket    = JsApiTicketContainer.GetJsApiTicket(JsApiTicketContainer.GetFirstOrDefaultAppId());
            ViewBag.timestamp = JSSDKHelper.GetTimestamp();
            ViewBag.nonceStr  = JSSDKHelper.GetNoncestr();

            ViewBag.signature = JSSDKHelper.GetSignature(ViewBag.ticket, ViewBag.nonceStr, ViewBag.timestamp, Server.UrlDecode(GetPageUrl()));
            ViewBag.pageUrl   = GetPageUrl();

            if (id == 0)
            {
                //string temp = RedisUtil.Get<string>(PinGoodsBLL.key_new_pin_goods);
                ViewBag.description = ""; //temp ?? "";
            }
            else
            {
                PinGoods good = PinGoodsBLL.SingleModel.GetModel(id);
                if (good == null)
                {
                    ViewBag.description = "";
                    return(Content("产品不存在或已删除"));
                }
                ViewBag.description = good.description;
            }
            return(View("RichText"));
        }
Пример #19
0
        public void GetSignatureTest()
        {
            var result = JSSDKHelper.GetSignature("kgt8ON7yVITDhtdwci0qefK1QvDlwsAPwMnZOO_J0MxaUpuHtIU_IltC7zs3kfNOYTHEqeIEvEXZHbS3xXNx3g", "B7EE6F5F9AA5CD17CA1AEA43CE848496", "1474350784", "https://www.baidu.com");

            Assert.IsNotNull(result);
            Assert.AreEqual("3b1b4171bcfa0f0661be9c5474002d3eb25a3368", result);
            Console.WriteLine(result);
        }
Пример #20
0
        public ActionResult Index()
        {
            string str;

            ViewBag.WeiXin = false;
            if (!string.IsNullOrWhiteSpace(_siteSetting.WeixinAppId) && !string.IsNullOrWhiteSpace(_siteSetting.WeixinAppSecret) && base.PlatformType == ChemCloud.Core.PlatformType.WeiXin)
            {
                ViewBag.WeiXin = true;
                string        empty        = string.Empty;
                IWXApiService wXApiService = ServiceHelper.Create <IWXApiService>();
                empty = wXApiService.GetTicket(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret);
                JSSDKHelper jSSDKHelper = new JSSDKHelper();
                string      timestamp   = JSSDKHelper.GetTimestamp();
                string      noncestr    = JSSDKHelper.GetNoncestr();
                string      signature   = jSSDKHelper.GetSignature(empty, noncestr, timestamp, base.Request.Url.AbsoluteUri);
                ViewBag.Timestamp = timestamp;
                ViewBag.NonceStr  = noncestr;
                ViewBag.Signature = signature;
                ViewBag.AppId     = _siteSetting.WeixinAppId;
            }
            long                        id = base.CurrentUser.Id;
            UserInviteModel             memberInviteInfo   = ServiceHelper.Create <IMemberInviteService>().GetMemberInviteInfo(id);
            InviteRuleInfo              inviteRule         = ServiceHelper.Create <IMemberInviteService>().GetInviteRule();
            MemberIntegralExchangeRules integralChangeRule = ServiceHelper.Create <IMemberIntegralService>().GetIntegralChangeRule();

            if (integralChangeRule != null)
            {
                dynamic viewBag = base.ViewBag;
                int     value   = inviteRule.InviteIntegral.Value / integralChangeRule.IntegralPerMoney;
                viewBag.IntergralMoney = value.ToString("f2");
            }
            string host = base.Request.Url.Host;
            string str1 = host;

            if (base.Request.Url.Port != 80)
            {
                int port = base.Request.Url.Port;
                str = string.Concat(":", port.ToString());
            }
            else
            {
                str = "";
            }
            host = string.Concat(str1, str);
            memberInviteInfo.InviteLink = string.Format("http://{0}/Register/index/{1}", host, id);
            inviteRule.ShareIcon        = string.Format("http://{0}{1}", host, inviteRule.ShareIcon);
            Bitmap       bitmap       = QRCodeHelper.Create(memberInviteInfo.InviteLink);
            MemoryStream memoryStream = new MemoryStream();

            bitmap.Save(memoryStream, ImageFormat.Gif);
            string str2 = string.Concat("data:image/gif;base64,", Convert.ToBase64String(memoryStream.ToArray()));

            memoryStream.Dispose();
            memberInviteInfo.QR = str2;
            Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo> tuple = new Tuple <UserInviteModel, InviteRuleInfo, UserMemberInfo>(memberInviteInfo, inviteRule, base.CurrentUser);

            return(View(tuple));
        }
Пример #21
0
        public (string, string, string, string) getJsSdkSign(string url)
        {
            var    timestamp    = JSSDKHelper.GetTimestamp();
            var    nonceStr     = JSSDKHelper.GetNoncestr();
            string jsapi_ticket = JsApiTicketContainer.TryGetJsApiTicket(_options.Value.AppId, _options.Value.AppSecret);
            string strurl       = url;
            var    signature    = JSSDKHelper.GetSignature(jsapi_ticket, nonceStr, timestamp, strurl);

            return(timestamp, nonceStr, signature, _options.Value.AppId);
        }
Пример #22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string ticket = string.Empty;

        timestamp = JSSDKHelper.GetTimestamp();
        nonceStr  = JSSDKHelper.GetNoncestr();
        appID     = "wx422044a7a4be9609";
        ticket    = JsApiTicketContainer.GetJsApiTicket(appID);
        signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri.ToString());
    }
Пример #23
0
        /// <summary>
        /// 获取微信分享参数
        /// </summary>
        /// <param name="appid"></param>
        /// <param name="appsecret"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public WeiXinShareArgs GetWeiXinShareArgs(string appid, string appsecret, string url)
        {
            string ticket = GetTicket(appid, appsecret);

            var    jssdk     = new JSSDKHelper();
            string timestamp = JSSDKHelper.GetTimestamp();
            string nonceStr  = JSSDKHelper.GetNoncestr();
            string signature = jssdk.GetSignature(ticket, nonceStr, timestamp, url);

            return(new WeiXinShareArgs(appid, timestamp, nonceStr, signature, ticket));
        }
Пример #24
0
        public JsSdkUiPackage GetJsSdkUiPackage(string appId, string appSecret, string url)
        {
            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            string nonceStr = JSSDKHelper.GetNoncestr();
            string ticket   = JsApiTicketContainer.TryGetJsApiTicket(appId, appSecret);
            //获取签名
            string signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, url);

            //返回信息包
            return(new JsSdkUiPackage(appId, timestamp, nonceStr, signature));
        }
Пример #25
0
        public JsSdkUiPackage GetJSSDKConfig([FromBody] JSSDKPostModel model)
        {
            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var nonceStr = JSSDKHelper.GetNoncestr();
            //获取JS票据
            var JsapiTicket = JsApiTicketContainer.TryGetTicket(option.CorpId, option.Secret);
            //获取签名
            var signature = JSSDKHelper.GetSignature(JsapiTicket, nonceStr, timestamp, model.OriginalUrl);

            return(new JsSdkUiPackage(option.CorpId, timestamp.ToString(), nonceStr, signature));
        }
Пример #26
0
        /// <summary>
        /// 获取当前页面JS配置信息
        /// </summary>
        /// <param name="absoluteUrl">The absoluteUrl<see cref="string"/></param>
        /// <returns></returns>
        public JSSDKConfigInfo GetJSSDKConfigInfo(string absoluteUrl)
        {
            var ticket     = WeChatApisContext.Current.TicketApi.SafeGet().Ticket;
            var configInfo = new JSSDKConfigInfo
            {
                AppId     = Current.GetConfig().AppId,
                Timestamp = JSSDKHelper.GetTimestamp(),
                NonceStr  = JSSDKHelper.GetNoncestr()
            };

            configInfo.Signature = JSSDKHelper.GetSignature(ticket, configInfo.NonceStr, configInfo.Timestamp,
                                                            absoluteUrl);
            return(configInfo);
        }
Пример #27
0
        private void SetShareData()
        {
            IWXApiService wXApiService = ServiceHelper.Create <IWXApiService>();
            string        ticket       = wXApiService.GetTicket(_siteSetting.WeixinAppId, _siteSetting.WeixinAppSecret);
            JSSDKHelper   jSSDKHelper  = new JSSDKHelper();
            string        timestamp    = JSSDKHelper.GetTimestamp();
            string        noncestr     = JSSDKHelper.GetNoncestr();
            string        signature    = jSSDKHelper.GetSignature(ticket, noncestr, timestamp, base.Request.Url.AbsoluteUri);

            ViewBag.Timestamp = timestamp;
            ViewBag.NonceStr  = noncestr;
            ViewBag.Signature = signature;
            ViewBag.AppId     = _siteSetting.WeixinAppId;
        }
Пример #28
0
        private void SetViewBag()
        {
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var    nonceStr = JSSDKHelper.GetNoncestr();
            string ticket   = JsApiTicketContainer.GetTicket(_corpId, _secret);
            //获取签名
            var signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, AbsoluteUri());

            ViewBag.AppId     = _corpId;
            ViewBag.Timestamp = timestamp;
            ViewBag.NonceStr  = nonceStr;
            ViewBag.Signature = signature;
        }
Пример #29
0
        /// <summary>
        ///     获取当前页面JS配置信息
        /// </summary>
        /// <returns></returns>
        public JSSDKConfigInfo GetJSSDKConfigInfo()
        {
            var ticket     = WeChatApisContext.Current.TicketApi.SafeGet().Ticket;
            var configInfo = new JSSDKConfigInfo
            {
                AppId     = WeChatConfigManager.Current.GetConfig().AppId,
                Timestamp = JSSDKHelper.GetTimestamp(),
                NonceStr  = JSSDKHelper.GetNoncestr()
            };

            configInfo.Signature = JSSDKHelper.GetSignature(ticket, configInfo.NonceStr, configInfo.Timestamp,
                                                            HttpContext.Current.Request.Url.AbsoluteUri);
            return(configInfo);
        }
Пример #30
0
        /// <summary>
        /// 获取给UI使用的JSSDK信息包
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JsSdkUiPackage GetJsSdkUiPackage(string url)
        {
            string appId = System.Web.Configuration.WebConfigurationManager.AppSettings["WeixinAppId"];
            
            string timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            string nonceStr = JSSDKHelper.GetNoncestr();
            
            string ticket = CommonMicroModels.GetTicket("Ticket");
            //获取签名
            string signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, url);

            return new JsSdkUiPackage { AppId=appId, Timestamp = timestamp, NonceStr=nonceStr, Signature=signature };
        }