Example #1
0
        public static SelectListItem ToEntity(VIEW_YX_weiUser weiUser)
        {
            SelectListItem item = new SelectListItem();

            item.Value = weiUser.userNum;
            item.Text  = string.IsNullOrEmpty(weiUser.userRelname)?weiUser.nickname:weiUser.userRelname;
            return(item);
        }
Example #2
0
        public static IEnumerable <VIEW_YX_weiUser> ToListViewModel(IEnumerable <YX_weiUser> list)
        {
            var listModel = new List <VIEW_YX_weiUser>();

            foreach (YX_weiUser item in list)
            {
                listModel.Add(VIEW_YX_weiUser.ToViewModel(item));
            }
            return(listModel);
        }
Example #3
0
        public static VIEW_YX_weiUser ToViewModel(YX_weiUser model)
        {
            VIEW_YX_weiUser item = new VIEW_YX_weiUser();

            item.Id               = model.Id;
            item.subscribe        = model.subscribe;
            item.openid           = model.openid;
            item.nickname         = model.nickname;
            item.sex              = model.sex;
            item.city             = model.city;
            item.province         = model.province;
            item.country          = model.country;
            item.U_language       = model.U_language;
            item.headimgurl       = model.headimgurl;
            item.subscribe_time   = model.subscribe_time;
            item.lastAddTime      = model.lastAddTime;
            item.subscribe_value  = model.subscribe_value;
            item.userNum          = model.userNum;
            item.subscribeState   = model.subscribeState;
            item.userTel          = model.userTel;
            item.RelName          = model.RelName;
            item.userWXnum        = model.userWXnum;
            item.F_id             = model.F_id;
            item.F_idList         = model.F_idList;
            item.AddTime          = model.AddTime;
            item.isfenxiao        = model.isfenxiao;
            item.jifen            = model.jifen;
            item.userMoney        = model.userMoney;
            item.userYongJin      = model.userYongJin;
            item.StoreName        = model.StoreName;
            item.StoreDescription = model.StoreDescription;
            item.LogoUrl          = model.LogoUrl;
            item.userQQ           = model.userQQ;
            item.userRelname      = model.userRelname;
            item.userSex          = model.userSex;
            item.userEmail        = model.userEmail;
            item.remark1          = model.remark1;
            item.remark2          = model.remark2;
            item.remark3          = model.remark3;
            item.flat1            = model.flat1;
            item.flat2            = model.flat2;
            item.remark4          = model.remark4;
            item.remark5          = model.remark5;
            item.remark6          = model.remark6;
            item.flat7            = model.flat7;
            item.flat8            = model.flat8;
            item.RegTim1          = model.RegTim1;
            item.RegTim2          = model.RegTim2;
            item.TREE_NODE_ID     = model.TREE_NODE_ID;
            return(item);
        }
Example #4
0
        public ActionResult UserMain()
        {
            ViewBag.PageFlag = "UserMain";
            ViewBag.isok     = "OK";
            ViewBag.Appid    = WeChatConfig.GetKeyValue("appid");
            ViewBag.Uri      = WeChatConfig.GetKeyValue("shareurl");

            noncestr = CommonMethod.GetCode(16);

            string jsapi_ticket = Js_sdk_Signature.IsExistjsapi_ticket(token.IsExistAccess_Token());

            timestamp = DateTime.Now.Ticks.ToString().Substring(0, 10);;
            string url = Request.Url.ToString().Replace("#", "");

            JssdkSignature       = Js_sdk_Signature.GetjsSDK_Signature(noncestr, jsapi_ticket, timestamp, url);
            ViewBag.noncestr     = noncestr;
            ViewBag.jsapi_ticket = jsapi_ticket;
            ViewBag.timestamp    = timestamp;
            openid = CommonMethod.getCookie("openid");
            userid = CommonMethod.getCookie("userid");
            if (string.IsNullOrEmpty(openid))
            {
                //根据授权 获取openid //根据授权  获取用户的openid
                string code = Request.QueryString["code"];//获取授权code
                LogHelper.WriteLog("//////////////////////////////////////////////////////////////////////////////////");
                LogHelper.WriteLog("code:" + code);
                if (string.IsNullOrEmpty(code))
                {
                    string codeurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx242aa47391c159f6&redirect_uri=http://www.aoshacar.com/AoShaCar/userMain&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect";
                    Response.Redirect(codeurl);
                }
                else
                {
                    string openIdUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + WeChatConfig.GetKeyValue("appid") + "&secret=" + WeChatConfig.GetKeyValue("appsecret") + "&code=" + code + "&grant_type=authorization_code";
                    string content   = Tools.GetPage(openIdUrl, "");
                    openid = Tools.GetJsonValue(content, "openid");//根据授权  获取当前人的openid
                }
            }
            var model = VIEW_YX_weiUser.ToViewModel(weiUserM.GetModelWithOutTrace(u => u.openid == openid));

            if (model != null)
            {
                CommonMethod.delCookie("openid");
                CommonMethod.delCookie("userid");
                CommonMethod.setCookie("openid", openid, 1);
                CommonMethod.setCookie("userid", model.userNum, 1);
                ViewBag.nickname   = model.nickname;
                ViewBag.headimgurl = model.headimgurl;
            }
            else
            {
                Senparc.Weixin.MP.AdvancedAPIs.User.UserInfoJson dic = Senparc.Weixin.MP.AdvancedAPIs.UserApi.Info(token.IsExistAccess_Token(), openid);
                //LogHelper.WriteLog("XXXXXXXXXXX:" + openid);
                if (dic != null)
                {
                    ViewBag.nickname   = dic.nickname;
                    ViewBag.headimgurl = dic.headimgurl;
                }
                model                = new MODEL.ViewModel.VIEW_YX_weiUser();
                model.subscribe      = dic.subscribe;
                model.openid         = dic.openid;
                model.nickname       = dic.nickname;
                model.sex            = dic.sex;
                model.U_language     = dic.language;
                model.city           = dic.city;
                model.province       = dic.province;
                model.country        = dic.country;
                model.headimgurl     = dic.headimgurl;
                model.subscribe_time = DateTime.Now;
                model.userSex        = dic.sex == 2 ? "女" : "男";
                model.userNum        = Common.Tools.Get8Digits();
                model.F_id           = 0;
                model.isfenxiao      = 0;
                model.userMoney      = 0;
                model.userYongJin    = 0;
                weiUserM.Add(VIEW_YX_weiUser.ToEntity(model));
            }
            ViewBag.UserType = ConfigSettings.GetSysConfigValue("USERTYPE", model.isfenxiao.ToString());
            return(View(model));
        }