/// <summary> /// 长按二维码 /// </summary> /// <param name="activityId"></param> /// <param name="userId"></param> /// <param name="ownerUserId"></param> /// <param name="publicityId"></param> /// <param name="openId"></param> /// <param name="innerCodeId"></param> /// <returns></returns> public ActionResult LongPress(string activityId, string userId, string ownerUserId, string publicityId, string openId, string innerCodeId) { //获取信息 var requestJson = JsonConvert.SerializeObject(new { activityId, userId, ownerUserId, publicityId, openId, innerCodeId }); HttpContent httpContent = new StringContent(requestJson); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var httpClient = new HttpClient(); var responseJson = httpClient.PostAsync(LongPressUrl, httpContent).Result.Content.ReadAsStringAsync().Result; //转换为json对象 //转换为json对象 AbpResult <ResultDto> longPressResponse = JsonConvert.DeserializeObject <AbpResult <ResultDto> >(responseJson); return(Json(longPressResponse)); }
/// <summary> /// 获取年级 /// </summary> private void GetGradeAll() { try { if (GradeDtos.Count == 0) { //获取信息 //var requestJson = JsonConvert.SerializeObject(new { SkipCount=0, MaxResultCount=int.MaxValue }); var responseJson = HttpClientHelper.Get(GetGradeUrl, $"SkipCount=0&MaxResultCount={int.MaxValue}"); //转换为json对象 AbpResult <PagedResultDto <GradeDto> > gradeResponse = JsonConvert.DeserializeObject <AbpResult <PagedResultDto <GradeDto> > >(responseJson); GradeDtos = gradeResponse.result.Items.ToList(); } } catch (Exception) { return; } }
/// <summary> /// /// </summary> /// <param name="openId"></param> /// <param name="activityId"></param> /// <param name="userId"></param> /// <param name="ownerUserId"></param> /// <param name="publicityId"></param> /// <returns></returns> private ScanQrCodeResult ScanCode(string openId, string activityId, string userId, string ownerUserId, string publicityId) { ScanQrCodeResult result = new ScanQrCodeResult(); try { var httpClient = new HttpClient(); var requestJson = JsonConvert.SerializeObject(new { openid = openId, userId, activityId, ownerUserId, publicityId, }); var responseJson = HttpClientHelper.Post(ScanCodeUrl, requestJson); AbpResult <ScanQrCodeResult> scanCodeResult = JsonConvert.DeserializeObject <AbpResult <ScanQrCodeResult> >(responseJson); if (scanCodeResult != null && scanCodeResult.result != null) { result = scanCodeResult.result; } else if (scanCodeResult == null || scanCodeResult.result == null) { result.IsSucess = false; result.Message = $"<h1>服务器出现错误,请稍后在扫码!{responseJson}</h1>"; } else if (scanCodeResult.result != null && scanCodeResult.result.InnerCode == null && scanCodeResult.result.QrCodeActivity == null) { result.IsSucess = false; result.Message = $"<h1>{scanCodeResult.result.Message}</h1>"; } else if (scanCodeResult.result.InnerCode != null && string.IsNullOrEmpty(scanCodeResult.result.InnerCode.HeaderImg)) { scanCodeResult.result.InnerCode.HeaderImg = "http://qrcodes-mskb.oss-cn-shanghai.aliyuncs.com/%E5%A4%B4%E5%83%8F.png"; } } catch (Exception ex) { result.IsSucess = false; result.Message = $"扫码错误:{ex.Message}</h1>"; } return(result); }
/// <summary> /// 获取微信用户信息 /// </summary> /// <param name="code"></param> /// <param name="state"></param> /// <returns></returns> private GetWeChatUserInfoResult GetWeChatUserInfo(string code, string state) { try { //获取信息 var requestJson = JsonConvert.SerializeObject(new { code, state }); var responseJson = HttpClientHelper.Post(GetWeChatUserInfoUrl, requestJson); //转换为json对象 AbpResult <GetWeChatUserInfoResult> userInfoResponse = JsonConvert.DeserializeObject <AbpResult <GetWeChatUserInfoResult> >(responseJson); if (userInfoResponse == null || userInfoResponse.result == null) { return(null); } else { return(userInfoResponse.result); } } catch (Exception) { return(null); } }
public JsonResult SendSignUpSms(string mobile) { try { //获取信息 var requestJson = JsonConvert.SerializeObject(new { mobile }); var responseJson = HttpClientHelper.Post(SendMsgUrl, requestJson); //转换为json对象 AbpResult <SendSmsResultDto> abpResult = JsonConvert.DeserializeObject <AbpResult <SendSmsResultDto> >(responseJson); if (abpResult != null && abpResult.result != null && abpResult.result.Success) { return(Json(new { success = true }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, msg = "请稍后再试!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public JsonResult SignUpCommit(QrCodeActivityRegister input) { try { //获取信息 var requestJson = JsonConvert.SerializeObject(input); var responseJson = HttpClientHelper.Post(CommitSignUpUrl, requestJson); //转换为json对象 AbpResult <QrCodeActivityRegister> abpResult = JsonConvert.DeserializeObject <AbpResult <QrCodeActivityRegister> >(responseJson); if (abpResult != null && abpResult.result != null && abpResult.result.Id > 0) { /* if (input.JumpToCustomService.HasValue && input.JumpToCustomService.Value && !string.IsNullOrWhiteSpace(input.CustomServiceUrl)) * { * return RedirectPermanent(input.CustomServiceUrl); * }*/ return(Json(new { success = true, input.JumpToCustomService, input.CustomServiceUrl }, JsonRequestBehavior.AllowGet)); } else if (!abpResult.success) { return(Json(new { success = false, msg = abpResult.error?.message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, msg = "报名失败,请稍后再试!" }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { success = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }