Example #1
0
        public async Task <JssdkResultDto> GetJssdk(string url, string appName)
        {
            var app = await _appProvider.GetOrNullAsync(appName);

            var appid  = app["appid"] ?? throw new UserFriendlyException($"App:{appName} appid未设置");
            var appSec = app["appsec"] ?? throw new UserFriendlyException($"App:{appName} appsec未设置");


            var ticket = await _weixinManager.GetJsSdkAsync(appid, appSec);

            var nonceStr  = _guidGenerator.Create().ToShortString();
            var timestamp = StringExt.GetTimestamp();

            var signature = $"jsapi_ticket={ticket}&noncestr={nonceStr}&timestamp={timestamp}&url={url}".GetSha1();

            return(new JssdkResultDto(appid, timestamp, nonceStr, signature));
        }