<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="com.Admin.vo.Attr"%> <%@ page import="com.Admin.vo.User"%> <%@ page import="com.Admin.vo.AppUser"%> <%@ page import="com.Admin.vo.RecommendProduct"%> <%@ page import="com.Admin.vo.Recommend"%> <%@ page import="com.Admin.daoimpl.AdminUserDaoImpl" %> <%@ page import="com.Admin.daoimpl.AdminProdDaoImpl" %> <%@ page import="net.sf.json.JSONArray"%> <%@ page import="net.sf.json.JSONObject"%> <%@ page import="com.wx.SignUtil"%> <%@ page import="java.net.URLEncoder"%> <%@ page import="java.util.ArrayList"%> <%@ page import="java.util.List"%> <%@ page import="com.common.IConstant"%> <%@ page import="com.common.Redis"%> <%@ page import="com.common.ReadDBPropertiesFile"%> <%@ page import="redis.clients.jedis.Jedis"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ taglib prefix="cf" uri="/WEB-INF/els.tld" %> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String realPath = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath()+request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/")+1); String context = request.getServletPath().substring(1,request.getServletPath().lastIndexOf("/")); String apppath = getServletContext().getRealPath("/"+context); String currentUrl = null; if(request.getServerPort() == 80){ currentUrl = request.getScheme()+"://"+ request.getServerName() + request.getRequestURI()+(request.getQueryString()==null?"":("?"+request.getQueryString())); } else{ currentUrl = request.getScheme()+"://"+ request.getServerName()+ ":" + request.getServerPort() +request.getRequestURI()+(request.getQueryString()==null?"":("?"+request.getQueryString())); } String t = request.getParameter("t"); String userid = request.getParameter("userid"); String wx = request.getParameter("openid"); String appid = request.getParameter("appid"); String html= request.getParameter("r"); int role = 0; System.out.println("-------openid "+wx); User user = null; JSONObject app = null; if(wx!=null){//首先判断来自微信登录,其次判断是否是来自userid登录和已登录 user = new AdminUserDaoImpl().getUserByWX(wx, null); System.out.println("-----------wx user is "+user); if(user==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html?openid="+wx; response.sendRedirect(url); return; } else{ appid = user.getAppid(); request.getSession().setAttribute(IConstant.CURRENT_USER,user); request.getSession().setAttribute(IConstant.CURRENT_APPID,appid); } } else{ if(userid!=null){ user = new AdminUserDaoImpl().getUserById(userid, null); if(user==null){ app = IConstant.getAppInfo(appid); if(app==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html"; response.sendRedirect(url); } else{ JSONObject pages = app.getJSONObject("page"); String p = null; try{ p = pages.getString("mlogin.html"); }catch(Exception ex){ } if( p==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html"; response.sendRedirect(url); }else{ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+p; response.sendRedirect(url); } } return; } request.getSession().setAttribute(IConstant.CURRENT_USER,user); } else { user = (User)request.getSession().getAttribute(IConstant.CURRENT_USER); } if(user==null){ app = IConstant.getAppInfo(appid); if(app==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html"; response.sendRedirect(url); } else{ JSONObject pages = app.getJSONObject("page"); String p = null; try{ p = pages.getString("mlogin.html"); }catch(Exception ex){ } if( p==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html?m=1"; response.sendRedirect(url); }else{ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+p; response.sendRedirect(url); } } return; } else{ appid = user.getAppid(); request.getSession().setAttribute(IConstant.CURRENT_USER,user); request.getSession().setAttribute(IConstant.CURRENT_APPID,appid); } } JSONObject jsonUser = null; role = user.getRole(); appid = user.getAppid(); userid = user.getUserid(); jsonUser = JSONObject.fromObject(user); if(appid==null){ request.getSession().setAttribute(IConstant.CURRENT_PAGE,currentUrl); String url = basePath+"m/mlogin.html"; response.sendRedirect(url); return; } if(t!=null){ app = IConstant.refreshAppInfo(appid); } else{ app = IConstant.getAppInfo(appid); } //get weixin System.out.println("weixin currenturl is "+currentUrl); JSONObject JSWX = null; JSONObject gzh = null; if(t==null){ JSWX = SignUtil.getJs_Ticket(appid,currentUrl,0); gzh = IConstant.getGzh(appid, 0); } else{ JSWX = SignUtil.getJs_Ticket(appid,currentUrl,1); gzh = IConstant.getGzh(appid, 1); } System.out.println("weixin gzh is "+gzh.toString()+" wx token is "+JSWX); String gzh_appid = null; try{ gzh_appid = gzh.getString("gzh_appid"); }catch(Exception ex){ gzh_appid = SignUtil.APPID; } //get data if(html!=null){ role=0;//如果强制展示管理员可以看到课程范围,但是访客身份 user=null; userid="0"; } String str = IConstant.getUserRoleInfo(appid, user.getUserid(), String.valueOf(role),null, null); JSONObject rtn = JSONObject.fromObject(str); JSONArray jsonTypes = null; jsonTypes = rtn.getJSONArray("types"); /* String key = IConstant.KEY_TYPES(appid, role); if(t!=null) redis.expire(key, 0); jsonTypes = IConstant.getTypes(appid, String.valueOf(role)); */ //------HTML 静态化------------------ if(appid.equals("1")){ for(int i=0;i indexes=null; AdminProdDaoImpl prod = new AdminProdDaoImpl(); JSONArray inds = null; key = IConstant.KEY_RECOMMEND_MOBILE(appid); if(t==null){ str = Redis.get(key); } if(str==null||str.isEmpty()||str.equalsIgnoreCase("[]")){ indexes = prod.getRecommendMobile(appid,"0"); if(indexes==null||indexes.size()==0){ indexes = prod.getRecommendMobile("1","0"); } inds = JSONArray.fromObject(indexes); Redis.set(key,inds.toString()); } else { inds = JSONArray.fromObject(str); } //get product recommend ArrayList recommendProducts=null; JSONArray recommends = null; key = IConstant.KEY_RECOMMEND_PRODUCTS(appid); if(t==null) { str = Redis.get(key); } if(str==null||str.isEmpty()){ recommendProducts = prod.getRecommendProduct(appid,"0"); recommends = JSONArray.fromObject(recommendProducts); Redis.set(key,recommends.toString()); } else { recommends = JSONArray.fromObject(str); } //get product new JSONArray news = null; key = IConstant.KEY_NEW_PRODUCTS(appid); if(t==null) { str = Redis.get(key); } if(str==null||str.isEmpty()){ recommendProducts = prod.getNewProduct(appid,"0"); news = JSONArray.fromObject(recommendProducts); Redis.set(key,news.toString()); } else { news = JSONArray.fromObject(str); } %> 教学中心

加载中...

<%for(int i=0;i

<%=inds.getJSONObject(i).getString("title") %>

<%=inds.getJSONObject(i).getString("title2") %>

" class="responsive-image" alt="img">
<%} %>

欢迎<%=(user==null?"您":user.getTruename()) %>,最新公告

<%int count = 0; %> <%for(int i=notices.size()-1;i>=0;i--){ if(count>=1) break; JSONObject n = notices.getJSONObject(i); count++; String picture = n.getString("picture"); if(picture.contains("www.andisk.com/andisk")){ picture = picture.replaceAll("www.andisk.com/andisk", "bk.andisk.com"); } %>

<% }%>

<%for(int i=0;i <% JSONObject sp = jsonTypes.getJSONObject(i); %> <% JSONArray types = sp.getJSONArray("subtype"); if(types.size()>0) out.print("

产品:"+sp.getString("typename")+"

"); for (int j=0;j
<% JSONObject sb = types.getJSONObject(j); String ssb = sb.getString("subType"); String ssbid = sb.getString("subTypeId"); //获得类别对应的头4个课件 // out.print("

"+ssb+"

"); out.print("
"); out.print("

"+ssb+"

浏览全部"); out.print("
"); int ps=0; for(int m=0;m=2){ break; } if(ps==0){ out.print(""); out.print(""); out.print("

"+p.getString("productname")+"

"); out.print("
"); } else{ out.print(""); out.print(""); out.print("

"+p.getString("productname")+"

"); out.print("
"); } ps++; } } out.print("
"); } %> <%} %>