/// <summary> /// 微信公众账号基本信息编辑 /// </summary> /// <returns></returns> public ActionResult Index() { WeChatEditModel weChat = null; if (_wxAccount != null) { weChat = new WeChatEditModel { AppSecret = _wxAccount.Secret, AppId = _wxAccount.AppId, ClientUrl = _wxAccount.CallbackUrl, EncodingAESKey = _wxAccount.Encodingaeskey, Level = _wxAccount.Level, Name = _wxAccount.Name, OriginalId = _wxAccount.Original, QrCode = _wxAccount.QrCode, Token = _wxAccount.AccessToken, WxAccount = _wxAccount.Account, Description = _wxAccount.Description }; } return(View(weChat)); }
public ActionResult Index(WeChatEditModel model) { if (ModelState.IsValid) { if (_wxAccount != null) { var img = FileManage.UploadOneFile(); //有公众账号的情况下,则更新 var r = YunClient.Instance.Execute(new UpdateWxAccountRequest { AppSecret = model.AppSecret, AppId = model.AppId, EncodingAESKey = model.EncodingAESKey, Level = model.Level, Name = model.Name, Original = model.OriginalId, Qrcode = string.IsNullOrEmpty(img) ? model.QrCode : img, Token = model.Token, Account = model.WxAccount, Description = model.Description, Id = _wxAccount.Id }, Token); if (r.Result) { TempData["success"] = "公众号信息已成功更新"; } else { TempData["error"] = "公众号信息更新失败,错误信息:" + r.ErrMsg; return(PartialView(model)); } } else { //否则创建 var r = YunClient.Instance.Execute(new AddWxAccountRequest { AppSecret = model.AppSecret, AppId = model.AppId, EncodingAESKey = model.EncodingAESKey, Level = model.Level, Name = model.Name, Original = model.OriginalId, Qrcode = FileManage.UploadOneFile(), Token = model.Token, Account = model.WxAccount, Description = model.Description }, Token); if (r.Result > 0) { TempData["success"] = "公众号信息已成功更新"; } else { TempData["error"] = "公众号信息更新失败,错误信息:" + r.ErrMsg; return(PartialView(model)); } } return(RedirectToAction("Index")); } TempData["error"] = "请输入必填项"; return(PartialView(model)); }