def index(): """商品列表页""" args = request.args p = toint(args.get('p', '1')) ps = toint(args.get('ps', '10')) cat_id = toint(args.get('cat_id', '0')) is_hot = toint(args.get('is_hot', '0')) is_recommend = toint(args.get('is_recommend', '0')) service = ItemListService( p, ps, cat_id=cat_id, is_hot=is_hot, is_recommend=is_recommend) items = service.items() cs = CategoryService() cat = cs.get_category(cat_id) return render_template( 'mobile/item/index.html.j2', items=items, pagination=service.pagination, category=cat, paging_url=url_for('mobile.item.paging', **args))
def index(): """商品列表页""" args = request.args p = toint(args.get('p', '1')) ps = toint(args.get('ps', '10')) cat_id = toint(args.get('cat_id', '0')) is_hot = toint(args.get('is_hot', '0')) is_recommend = toint(args.get('is_recommend', '0')) search_key = args.get('search_key').strip() service = ItemListService( p, ps, cat_id=cat_id, is_hot=is_hot, is_recommend=is_recommend, search_key=search_key) items = service.items() cs = CategoryService() cat = cs.get_category(cat_id) return render_template( 'pc/item/index.html.j2', items=items, pagination=service.pagination, category=cat)
def root(): """手机站 - 首页""" advs = AdvStaticMethodsService.advs({'ac_id': 1}, platform_type=1) # 热门商品列表 hot_service = ItemListService(1, 12, is_hot=1) hot_items = hot_service.items() # 推荐商品列表 recommend_service = ItemListService(1, 12, is_recommend=1) recommend_items = recommend_service.items() return render_template('mobile/index/index.html.j2', advs=advs, hot_items=hot_items, recommend_items=recommend_items)
def hot(): """热卖""" service = ItemListService(1, 10, is_hot=1) items = service.items() return render_template( 'mobile/item/hot.html.j2', items=items, pagination=service.pagination, paging_url=url_for('mobile.item.paging', is_hot=1))
def recommend(): """推荐""" service = ItemListService(1, 10, is_recommend=1) items = service.items() return render_template( 'mobile/item/recommend.html.j2', items=items, pagination=service.pagination, paging_url=url_for('mobile.item.paging', is_recommend=1))
def recommend(): """推荐""" args = request.args p = toint(args.get('p', '1')) ps = toint(args.get('ps', '10')) service = ItemListService(p, ps, is_recommend=1) items = service.items() return render_template( 'pc/item/recommend.html.j2', items=items, pagination=service.pagination)
def hot(): """热卖""" args = request.args p = toint(args.get('p', '1')) ps = toint(args.get('ps', '10')) service = ItemListService(p, ps, is_hot=1) items = service.items() return render_template( 'pc/item/hot.html.j2', items=items, pagination=service.pagination)
def home(): """首页""" resjson.action_code = 10 # 广告 advs = AdvStaticMethodsService.advs( {'ac_id': 1}, platform_type=1) # 热门商品列表 hot_service = ItemListService(1, 12, is_hot=1) hot_items = hot_service.items() # 推荐商品列表 recommend_service = ItemListService(1, 12, is_recommend=1) recommend_items = recommend_service.items() data = { 'advs': advs, 'hot_items': hot_items, 'recommend_items': recommend_items} return resjson.print_json(0, u'ok', data)
def paging(): """加载分页""" args = request.args p = toint(args.get('p', '1')) ps = toint(args.get('ps', '10')) cat_id = toint(args.get('cat_id', '0')) is_hot = toint(args.get('is_hot', '0')) is_recommend = toint(args.get('is_recommend', '0')) service = ItemListService( p, ps, cat_id=cat_id, is_hot=is_hot, is_recommend=is_recommend) items = service.items() return render_template('mobile/item/paging.html.j2', items=items)
def root(cat_id=0): """分类页""" if cat_id == 0: categories = CategoryService().categories() return render_template('mobile/category/index.html.j2', categories=categories) ps = 10 p = toint(request.args.get('p', '1')) cat = CategoryService().get_category(cat_id) if cat is None: return abort(404) service = ItemListService(p, ps, cat_id) return render_template('mobile/item/index.html.j2', items=service.items(), pagination=service.pagination, category=cat, paging_url=url_for('mobile.item.paging', cat_id=cat_id))
def root(cat_id=0): """分类页""" if cat_id == 0: categories = CategoryService().categories() return render_template('pc/category/index.html.j2', categories=categories) args = request.args p = toint(args.get('p', '1')) cat_service = CategoryService() cat = cat_service.get_category(cat_id) if cat is None: return abort(404) service = ItemListService(p, 20, cat_id) items = service.items() return render_template('pc/item/index.html.j2', category=cat, items=items, pagination=service.pagination)
def goods(): """ 商品列表分页 @param cat_id, 商品分类id 0=全部分类 @cat_id is_hot, 是否热卖 0=默认 1=非热卖 2=热卖 @param is_recommend, 是否推荐 0=默认 1=非推荐 2=推荐 """ resjson.action_code = 10 params = request.args.to_dict() p = toint(params.get('p', '1')) ps = toint(params.get('ps', '10')) cat_id = toint(params.get('cat_id', '0')) is_hot = toint(params.get('is_hot', '0')) is_recommend = toint(params.get('is_recommend', '0')) if cat_id < 0 or p <= 0 or ps <= 0: return resjson.print_json(resjson.PARAM_ERROR) if not is_hot in [0, 1, 2]: return resjson.print_json(resjson.PARAM_ERROR) if not is_recommend in [0, 1, 2]: return resjson.print_json(resjson.PARAM_ERROR) is_hot = 1 if is_hot == 2 else 0 is_recommend = 1 if is_recommend == 2 else 0 item_list_service = ItemListService(page=p, page_size=ps, cat_id=cat_id, is_hot=is_hot, is_recommend=is_recommend) items = item_list_service.items() cat_service = CategoryService() cat = cat_service.get_category(cat_id) data = {'goods': items, 'current_cate': cat} return resjson.print_json(0, u'ok', data)