Exemple #1
0
        /// <summary>
        /// 分享
        /// </summary>
        /// <returns></returns>
        public PartialViewResult _PartialShare()
        {
            //获得微信基础类
            BaseWxModel baseModel = GetWxModel();
            ShareModel  fxModel   = new ShareModel()
            {
                appid     = baseModel.appid,
                nonce     = baseModel.nonce,
                signature = baseModel.signature,
                thisUrl   = baseModel.thisUrl,
                timestamp = baseModel.timestamp,
                fxTitle   = "韩师傅网络投票-生态板十大品牌!",
                fxContent = "请大家积极投票转发分享。",
                fxImg     = Config.GetValue("Domain") + Url.Content("/Content/images/icon/logo2.png"),
            };

            return(PartialView(fxModel));
        }
Exemple #2
0
        /// <summary>
        /// 分享
        /// </summary>
        /// <param name="title"></param>
        /// <param name="Img"></param>
        /// <returns></returns>
        public PartialViewResult _PartialShare(string title, string Img)
        {
            //获得微信基础类
            BaseWxModel baseModel = GetWxModel();
            ShareModel  fxModel   = new ShareModel()
            {
                appid     = baseModel.appid,
                nonce     = baseModel.nonce,
                signature = baseModel.signature,
                thisUrl   = baseModel.thisUrl,
                timestamp = baseModel.timestamp,
                fxTitle   = title,
                fxContent = Config.GetValue("fxContent"),
                fxImg     = Config.GetValue("Domain") + Url.Content("/Content/images/liang/" + Img),
            };

            return(PartialView(fxModel));
        }
        //获得微信js sdk config
        protected BaseWxModel GetWxModel2()
        {
            BaseWxModel model = new BaseWxModel();

            model.appid     = WeixinConfig.AppID;
            model.timestamp = JSSDKHelper.GetTimestamp();
            model.nonce     = JSSDKHelper.GetNoncestr();

            model.thisUrl = Request.Url.ToString();//MyCommFun.getTotalUrl();

            string ticket = JsApiTicketContainer.TryGetJsApiTicket(WeixinConfig.AppID, WeixinConfig.AppSecret);

            JSSDKHelper jsHelper = new JSSDKHelper();
            //最后一个参数url,必须为当前的网址
            var signature = JSSDKHelper.GetSignature(ticket, model.nonce, model.timestamp, model.thisUrl);

            model.signature = signature;
            return(model);
        }
Exemple #4
0
        /// <summary>
        /// 分享
        /// </summary>
        /// <param name="playerId"></param>
        /// <param name="playerName"></param>
        /// <returns></returns>
        public PartialViewResult _PartialShare(string playerId, string playerName)
        {
            //获得微信基础类
            BaseWxModel baseModel = GetWxModel();
            ShareModel  fxModel   = new ShareModel()
            {
                appid     = baseModel.appid,
                nonce     = baseModel.nonce,
                signature = baseModel.signature,
                thisUrl   = baseModel.thisUrl,
                timestamp = baseModel.timestamp,
                fxTitle   = "思科莱“生活设计家”设计大赛,【" + playerName + "】参赛作品,快来帮Ta投一票吧!",
                fxContent = "思科莱,为美好生活而来;全屋定制,让爱如约而至。",
                fxImg     = Config.GetValue("Domain") + Url.Content("/Content/images/icon/logo.jpg"),
            };

            ViewBag.playerId   = playerId;
            ViewBag.playerName = playerName;
            return(PartialView(fxModel));
        }
Exemple #5
0
        /// <summary>
        /// 分享
        /// </summary>
        /// <param name="cardId"></param>
        /// <param name="cardName"></param>
        /// <param name="photoUrl"></param>
        /// <returns></returns>
        public PartialViewResult _PartialShare(string cardId, string cardName, string photoUrl)
        {
            //获得微信基础类
            BaseWxModel baseModel = GetWxModel();
            ShareModel  fxModel   = new ShareModel()
            {
                appid     = baseModel.appid,
                nonce     = baseModel.nonce,
                signature = baseModel.signature,
                thisUrl   = baseModel.thisUrl,
                timestamp = baseModel.timestamp,
                fxTitle   = $"{cardName}-电子名片",
                fxContent = Config.GetValue("CompanyProfile"),
                fxImg     = Config.GetValue("Domain") + Url.Content(photoUrl),
            };

            ViewBag.userId   = cardId;
            ViewBag.userName = cardName;
            return(PartialView(fxModel));
        }
Exemple #6
0
        //获得微信js sdk config
        protected BaseWxModel GetWxModel()
        {
            BaseWxModel model = new BaseWxModel();

            model.appid     = WeixinConfig.AppID;
            model.timestamp = JSSDKHelper.GetTimestamp();
            model.nonce     = JSSDKHelper.GetNoncestr();
            model.thisUrl   = Request.Url.ToString();//MyCommFun.getTotalUrl();

            //string ticket = JsApiTicketContainer.TryGetJsApiTicket(WeixinConfig.AppID, WeixinConfig.AppSecret);
            //https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi

            var cacheTicket = CacheFactory.Cache().GetCache <string>("jsapi_ticket");

            if (cacheTicket == null)
            {
                //全局token
                var cacheToken = CacheFactory.Cache().GetCache <string>("access_token");
                if (cacheToken == null)
                {
                    var userInfoBase = AnalyzeHelper.Get <WeixinTokenBase>(WeixinConfig.GetTokenBaseUrl);
                    cacheToken = userInfoBase.access_token;
                    CacheFactory.Cache().WriteCache(cacheToken, "access_token", DateTime.Now.AddSeconds(7000));
                }

                string ticketUrl   = string.Format(WeixinConfig.GetTicketUrl, cacheToken);
                var    ticketModel = AnalyzeHelper.Get <WeixinTicket>(ticketUrl);
                cacheTicket = ticketModel.ticket;
                if (!string.IsNullOrEmpty(cacheTicket))
                {
                    CacheFactory.Cache().WriteCache(cacheTicket, "jsapi_ticket", DateTime.Now.AddSeconds(7000));
                }
            }

            JSSDKHelper jsHelper = new JSSDKHelper();
            //最后一个参数url,必须为当前的网址
            var signature = JSSDKHelper.GetSignature(cacheTicket, model.nonce, model.timestamp, model.thisUrl);

            model.signature = signature;
            return(model);
        }