예제 #1
0
        /// <summary>
        /// 获取给UI使用的JSSDK信息包
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static JsSdkUiPackage GetJsSdkUiPackage(string appId, string appSecret, string url)
        {
            //获取时间戳
            var timestamp = GetTimestamp();
            //获取随机码
            string nonceStr = GetNoncestr();
            string ticket   = JsApiTicketContainer.TryGetJsApiTicket(appId, appSecret);
            //获取签名
            string signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, url);

            //返回信息包
            return(new JsSdkUiPackage(appId, timestamp, nonceStr, signature));
        }
예제 #2
0
        /// <summary>
        /// 【异步方法】获取给UI使用的JSSDK信息包
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="appSecret"></param>
        /// <param name="url"></param>
        /// <returns></returns>
        public static async Task <JsSdkUiPackage> GetJsSdkUiPackageAsync(string appId, string appSecret, string url)
        {
            //获取时间戳
            var timestamp = GetTimestamp();
            //获取随机码
            string nonceStr = GetNoncestr();
            string ticket   = await JsApiTicketContainer.TryGetJsApiTicketAsync(appId, appSecret).ConfigureAwait(false);

            //获取签名
            string signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, url);

            //返回信息包
            return(new JsSdkUiPackage(appId, timestamp, nonceStr, signature));
        }
        //
        // GET: /JSSDK/
        public ActionResult Index()
        {
            //获取时间戳
            var timestamp = JSSDKHelper.GetTimestamp();
            //获取随机码
            var nonceStr = JSSDKHelper.GetNoncestr();
            string ticket = JsApiTicketContainer.TryGetTicket(appId, secret);
            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();
        }
예제 #4
0
        public ActionResult PreSaleProduct()
        {
            var products=PreSaleProductService.GetPreSaleProducts(p=>p.IsSale,p=>p.CreateTime, "order");

            #region 分享相关
            //获取时间戳
            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;


            #endregion
            return View(products);
        }
예제 #5
0
        public JsonResult GetShareParms()
        {
            //获取时间戳
            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);
            var obj = new {
                appid = AppId,
                timestamp = timestamp,
                nonceStr = nonceStr,
                signature = signature
            };

            return Json(obj);
        }
예제 #6
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);
        }