Exemplo n.º 1
0
        //
        // GET: /JSSDK/

        public async Task <ActionResult> Index()
        {
            #region v13.6.4之前的写法
            ////获取时间戳
            //var timestamp = JSSDKHelper.GetTimestamp();
            ////获取随机码
            //var nonceStr = JSSDKHelper.GetNoncestr();
            //string ticket = JsApiTicketContainer.TryGetJsApiTicket(appId, secret);
            ////获取签名
            //var signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, Request.Url.AbsoluteUri);

            //ViewData["AppId"] = appId;
            //ViewData["Timestamp"] = timestamp;
            //ViewData["NonceStr"] = nonceStr;
            //ViewData["Signature"] = signature;
            #endregion

            var jssdkUiPackage = await JSSDKHelper.GetJsSdkUiPackageAsync(appId, appSecret, Request.AbsoluteUri());

            //ViewData["JsSdkUiPackage"] = jssdkUiPackage;
            //ViewData["AppId"] = appId;
            //ViewData["Timestamp"] = jssdkUiPackage.Timestamp;
            //ViewData["NonceStr"] = jssdkUiPackage.NonceStr;
            //ViewData["Signature"] = jssdkUiPackage.Signature;

            return(View(jssdkUiPackage));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 活动宴席
        /// </summary>
        /// <returns></returns>
        public IActionResult ActivityBanquet(string actFormId, int?actFormStatus, string openid, int?userType)
        {
            //actFormId = "E6200916-552A-44A4-FFD4-08D59A3C0EB3";
            //actFormId = "73DF4187-AF25-422D-5601-08D59EB66341";
            //openid = "C9E6F8A3-6A08-418A-A258-0ABCBEC17573";
            //actFormStatus = 2;
            //userType = 2;
            var tenantId = GetTenantId();
            //var user = _weChatUserAppService.GetWeChatUserAsync(openid, tenantId).Result;
            var activityBanquet = _activityBanquetAppService.GetActivityBanquetWeChatByFormIdAsync(Guid.Parse(actFormId), tenantId).Result;

            if (activityBanquet == null)
            {
                activityBanquet = new ActivityBanquets.Dtos.ActivityBanquetWeChatDto();
            }
            var url         = Request.GetAbsoluteUri();
            var jsApiConfig = JSSDKHelper.GetJsSdkUiPackageAsync(WechatAppConfig.AppId, WechatAppConfig.AppSecret, url).Result;

            ViewBag.OpenId             = openid;
            ViewBag.TenantId           = tenantId;
            ViewBag.ActivityFormId     = actFormId;
            ViewBag.UserType           = userType;
            ViewBag.ActivityFormStatus = actFormStatus;
            var root = _appConfiguration["App:ServerRootAddress"];

            ViewBag.ServerRootAddress = root;

            ActivityBanquetModel model = new ActivityBanquetModel();

            model.JsSdkApiConfig = jsApiConfig;
            model.BanquetWeChat  = activityBanquet;
            return(View(model));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取jssdk配置对象
        /// </summary>
        /// <param name="httpContext"></param>
        /// <returns></returns>
        static async Task WxJsSdk(HttpContext httpContext)
        {
            string appName = null, url;

            if (httpContext.Request.Query.TryGetValue("app", out var app))
            {
                appName = app.ToString();
            }
            if (httpContext.Request.Query.TryGetValue("url", out var urlV))
            {
                url = urlV.ToString();
            }
            else
            {
                httpContext.Response.StatusCode = 400;
                return;
            }

            var options   = httpContext.RequestServices.GetRequiredService <IOptions <WxOptions> >().Value;
            var mpOptions = appName.IsNullOrWhiteSpace() ? options.GetDefaultMp() : options.Get(appName);

            if (mpOptions == null || mpOptions.AppType != WxAppType.MP)
            {
                httpContext.Response.StatusCode = 400;
                return;
            }

            var jsSdkUiPackage = await JSSDKHelper.GetJsSdkUiPackageAsync(mpOptions.AppId, mpOptions.AppSecret, url);

            await httpContext.WriteJson(jsSdkUiPackage);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取JS SDK配置
        /// </summary>
        public IActionResult GetJsApiConfig(string url)
        {
            //var host = _appConfiguration["App:ServerRootAddress"];
            //var url = string.Format("{0}/gawechat", host); //Request.GetAbsoluteUri();
            var jsApiConfig = JSSDKHelper.GetJsSdkUiPackageAsync(WechatAppConfig.AppId, WechatAppConfig.AppSecret, url).Result;

            return(Json(jsApiConfig));
        }
Exemplo n.º 5
0
        //单证查询
        public async Task <ActionResult> QueryDoc()
        {
            var jssdkUiPackage = await JSSDKHelper.GetJsSdkUiPackageAsync(appId, appSecret, Request.AbsoluteUri());

            ViewBag.AppId     = appId;
            ViewBag.Timestamp = jssdkUiPackage.Timestamp;
            ViewBag.NonceStr  = jssdkUiPackage.NonceStr;
            ViewBag.Signature = jssdkUiPackage.Signature;

            ViewBag.apihost = this._config.GetValue <string>("AppSetting:apihost");
            ViewBag.zone    = this._config.GetValue <string>("AppSetting:zone");
            return(View());
        }
Exemplo n.º 6
0
        /// <summary>
        /// 行程分享
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="userId">The user identifier.</param>
        /// <returns>Task&lt;Response&lt;StrokeShareResponse&gt;&gt;.</returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task <Response <StrokeShareResponse> > StrokeShare(StrokeShareRequest request)
        {
            var userId     = contextAccessor.UserId();
            var strokeInfo = await this.strokeContext.Strokes.FirstOrDefaultAsync(x => x.Id == request.StrokeId);

            if (strokeInfo == null || strokeInfo.IsActive == false)
            {
                throw new Exception("该行程不存在或已经下架");
            }
            Logger.LogDebug($"dizHi------------{request.ShareUrl}");
            // var resultUrl = "https://bcl.baocailang.com/wechat/oauth2?state=travel";//用此地址
            var result = JSSDKHelper.GetJsSdkUiPackageAsync(this.weChatOptions.AppId, this.weChatOptions.AppSecret, request.ShareUrl).Result;

            #region 另一种方法
            //var timestamp = JSSDKHelper.GetTimestamp();
            //var nonceStr = JSSDKHelper.GetNoncestr();

            //var ticket = Senparc.Weixin.MP.Containers.JsApiTicketContainer.TryGetJsApiTicket(this.weChatOptions.AppId, this.weChatOptions.AppSecret, true);
            //var signature = JSSDKHelper.GetSignature(ticket, nonceStr, timestamp, request.ShareUrl);

            #endregion
            var shareUrl = $"https://bcl.baocailang.com/wechat/oauth2?state=travel%26shareCode={userId}%26from=1%26resultUrl={request.JumpUrl}";

            //var shareUrl = request.ShareUrl + $"&shareCode={userId}&from=1&resultUrl={request.JumpUrl}";
            Logger.LogDebug($"构造的分享地址为:{shareUrl}");
            return(new Response <StrokeShareResponse>
            {
                Data = new StrokeShareResponse
                {
                    AppId = this.weChatOptions.AppId,
                    NonceStr = result.NonceStr,
                    Signature = result.Signature,
                    Timestamp = result.Timestamp,
                    ShareImageUrl = this.weChatOptions.HostUrl + strokeInfo.ImageUrl,
                    ShareUrl = shareUrl
                }
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取JS SDK配置
        /// </summary>
        public IActionResult GetJsApiConfig(string url)
        {
            var jsApiConfig = JSSDKHelper.GetJsSdkUiPackageAsync(WechatAppConfig.AppId, WechatAppConfig.AppSecret, url).Result;

            return(Json(jsApiConfig));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取JS SDK配置
        /// </summary>
        public async Task <IActionResult> GetJsApiConfigAsync(string url)
        {
            var jsApiConfig = await JSSDKHelper.GetJsSdkUiPackageAsync(AppId, AppSecret, url);

            return(Json(jsApiConfig));
        }
Exemplo n.º 9
0
        public async Task <ActionResult> Index()
        {
            var jssdkUiPackage = await JSSDKHelper.GetJsSdkUiPackageAsync(appId, appSecret, Request.AbsoluteUri());

            return(View(jssdkUiPackage));
        }