Ejemplo n.º 1
0
        public ActionResult GetShareQRCode(int id = 0)
        {
            CustomPage pageModel = CustomPageBLL.SingleModel.GetModel(id);

            if (pageModel == null)
            {
                return(ApiResult(false, "页面不存在"));
            }
            if (!string.IsNullOrEmpty(pageModel.qrcode))
            {
                return(ApiResult(true, pageModel.qrcode));
            }

            string scene    = $"{id}";
            string postData = JsonConvert.SerializeObject(new {
                scene      = scene,
                page       = "pages/index/pagePreview",
                width      = 210,
                auto_color = true,
                line_color = new { r = "0", g = "0", b = "0" }
            });
            string appid        = WebConfigurationManager.AppSettings["xiaowei_appid"];
            string appsecret    = WebConfigurationManager.AppSettings["xiaowei_appsecret"];
            string access_token = WxHelper.GetToken(appid, appsecret, false);
            string errorMessage = "";
            string qrCode       = CommondHelper.HttpPostSaveImg("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + access_token, postData, ref errorMessage);

            if (string.IsNullOrEmpty(qrCode))
            {
                return(ApiResult(false, $"获取二维码失败!{errorMessage}"));
            }
            pageModel.qrcode = qrCode;
            CustomPageBLL.SingleModel.Update(pageModel, "qrcode");
            return(ApiResult(true, qrCode));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取邀请拼团分享小程序码
        /// </summary>
        /// <param name="buid">参团ID</param>
        /// <param name="AppId"></param>
        /// <param name="UserId">分享者ID</param>
        /// <returns></returns>
        public ActionResult GetShareCutPrice(int guid, string AppId, int UserId)
        {
            if (guid <= 0 || string.IsNullOrEmpty(AppId) || UserId <= 0)
            {
                return(Json(new { isok = false, msg = "参数错误", JsonRequestBehavior.AllowGet }));
            }
            C_UserInfo loginCUser = C_UserInfoBLL.SingleModel.GetModel(UserId);

            if (loginCUser == null)
            {
                return(Json(new { isok = false, msg = "登录过期!", JsonRequestBehavior.AllowGet }));
            }
            XcxAppAccountRelation xcxrelation = XcxAppAccountRelationBLL.SingleModel.GetModelByAppid(AppId);

            if (xcxrelation == null)
            {
                return(Json(new { isok = false, msg = "模板权限无效!", JsonRequestBehavior.AllowGet }));
            }
            string token = "";

            if (!XcxApiBLL.SingleModel.GetToken(xcxrelation, ref token))
            {
                return(Json(new { isok = false, msg = token, JsonRequestBehavior.AllowGet }));
            }
            //  log4net.LogHelper.WriteInfo(GetType(), r.AppId+"===token:"+access_token);
            //表示新增


            string scene        = $"{guid}";
            string postData     = Newtonsoft.Json.JsonConvert.SerializeObject(new { scene = scene, path = "pages/bargaindetail/bargaindetail", width = 200, auto_color = true, line_color = new { r = "0", g = "0", b = "0" } });
            string errorMessage = "";
            string qrCode       = CommondHelper.HttpPostSaveImg("https://api.weixin.qq.com/wxa/getwxacode?access_token=" + token, postData, ref errorMessage);

            if (string.IsNullOrEmpty(qrCode))
            {
                return(Json(new { isok = false, msg = $"获取失败!{errorMessage}", JsonRequestBehavior.AllowGet }));
            }
            return(Json(new { isok = true, msg = "获取二维码成功!", qrcode = qrCode, JsonRequestBehavior.AllowGet }));
        }