public ActionResult ServiceEval(Core.ServiceEvalInfo model, string code = "", string state = "") { model.State = 0; if (ModelState.IsValid) { model.CreateTime = DateTime.Now; model.Courier = Request.Params["Courier"].ToString(); if (Services.ServiceEval.Create(model) > 0) { return(RedirectToAction("ServiceEvalSuccess")); } else { return(Content("提交失败")); } } foreach (var s in ModelState.Values) { foreach (var p in s.Errors) { new LogHelper().Write(p.ErrorMessage); } } return(View(model)); }
public ActionResult ServiceEval(string code = "", string state = "") { Core.ServiceEvalInfo model = new Core.ServiceEvalInfo() { EvalProduct = 3, EvalLogistics = 3, EvalService = 3, State = 0 }; string useragent = Request.UserAgent; if (useragent.ToLower().Contains("micromessenger")) { //1.不包含code和state的情况下,转去微信认证 if (string.IsNullOrEmpty(code) && string.IsNullOrEmpty(state)) { //转向微信认证 string url = "http://www.kingsdown.com.cn/Plugins/ServiceEval"; string requestUrl = string.Format(getCodeUrl, appID, System.Web.HttpUtility.UrlEncode(url), Guid.NewGuid().ToString()); return(Redirect(requestUrl)); } //2.在有code和state的情况下,获取access_token accessTokenInfo tokenInfo = GetAccessTokenInfo(getAccessTokenUrl, appID, appsecret, code); if (tokenInfo != null) { new LogHelper().Write(tokenInfo.access_token); weChatUserInfo wechatInfo = GetWeChatUserInfo(getUserInfoUrl, tokenInfo.access_token, tokenInfo.openid); if (wechatInfo != null) { model.Name = wechatInfo.nickname; model.WeChatOpenId = wechatInfo.openid; model.WeChatName = wechatInfo.nickname; model.Province = wechatInfo.province; model.City = wechatInfo.city; } } List <SelectListItem> selList = new List <SelectListItem>(); selList.Add(new SelectListItem() { Text = "01", Value = "01" }); selList.Add(new SelectListItem() { Text = "02", Value = "02" }); selList.Add(new SelectListItem() { Text = "03", Value = "03" }); selList.Add(new SelectListItem() { Text = "04", Value = "04" }); ViewData["selList"] = selList; } return(View(model)); }