1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Data;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using System.Web;
- using MySystem.MainModels;
- using LitJson;
- using Library;
- using System.Text;
- /// <summary>
- /// 邀请好友接口
- /// </summary>
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("/Api/v1/[controller]/[action]")]
- public class UserInviteFriendsController : BaseController
- {
- public UserInviteFriendsController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
- {
- }
- #region 获取邀请图片列表
- [Authorize]
- public JsonResult InviteFriendsPhotoList(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = InviteFriendsPhotoListDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = dataList });
- }
- public List<Dictionary<string, object>> InviteFriendsPhotoListDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- List<Dictionary<string, object>> dataList = new List<Dictionary<string, object>>();
- for (int i = 1; i <= 4; i++)
- {
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- var photo = DefaultPic("/static/qrcodebg/" + i + ".png");
- Obj.Add("Id", i);
- Obj.Add("PicPath", photo);
- dataList.Add(Obj);
- }
- return dataList;
- }
- #endregion
- #region 根据邀请图片生成信息
- [Authorize]
- public JsonResult InviteFriendsList(string value)
- {
- value = DesDecrypt(value);
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = InviteFriendsListDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public Dictionary<string, object> InviteFriendsListDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- var photoId = function.CheckInt(data["photoId"].ToString());
- int UserId = int.Parse(function.CheckInt(data["UserId"].ToString())); //创客Id
- string result = function.GetWebRequest(Library.ConfigurationManager.AppSettings["QrCodeHost"].ToString() + "/home/getqrcode?uid=" + UserId + "&pid=" + photoId + "");//通过http请求获取数据路径
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- Users query = UsersDbconn.Instance.Get(UserId) ?? new Users();
- Obj.Add("RealName", query.RealName); //创客姓名
- Obj.Add("MakerCode", query.MakerCode); //创客推荐码
- Obj.Add("ReferenceQrCode", SourceHost + result); //推广二维码地址
- return Obj;
- }
- #endregion
- }
- }
|