def goods_get(): f = request.args.get('f', 'search') goodsDao = GoodsDao() schema = GoodsSchema() res = {} key_words = request.args.get('kwd', '') page = int(request.args.get('page', 1)) page_size = int(request.args.get('page_size', 30)) args = {} args['cate'] = str(request.args.get('cate', '')) args['order'] = request.args.get('order', '') args['activity'] = int(request.args.get('activity', 0)) args['classes'] = request.args.get('cls', '') if len(args['cate']) == 2: args['classes'] = args['cate'] pagination = goodsDao.search(key_words, page, page_size, **args) res['items'] = schema.dump(pagination.items, many=True).data res['page'] = { 'pages': pagination.pages, 'page': pagination.page, 'has_next': pagination.has_next } return resp_200(res)
def get_taokouling(): goodsDao = GoodsDao() try: if request.method == 'POST': id = request.form.get('id') else: id = request.args.get('id') goods = goodsDao.get_by_id(id) tkl = goodsDao.get_tkl_by_url(goods.googs_coupon_buy_url) msg = "[" + goods.goods_name + "]\n复制这条信息, " + tkl + ", 打开手机淘宝, 即可在手机淘宝中领券购买. 来自[一起淘券网(17taoquan.wang)]优惠分享" res = {"success":True, "data":{"toukouling":msg}} if request.method == 'GET': callback = request.args.get('callback', '') return '{0}({1})'.format(callback, json.dumps(res)) else: return json.dumps(res) except Exception as e: print(e) traceback.print_exc() app.logger.error(e) return '淘口令生成失败, 请稍后重试'
def show(id): goodsDao = GoodsDao() goods = goodsDao.get_by_id(id) if goods is not None: data = { 'goods' : goods, 'link_goods' : goodsDao.get_link_goods(goods.goods_category) } site_info = { 'title' : goods.goods_name } url_args = { } return render_template('show.html', data = data, site_info = site_info, url_args = url_args) else: data = { 'goods' : None, 'link_goods' : goodsDao.get_hot_selld(6) } site_info = { 'title' : '优惠券抢完了, 为您推荐更多优惠券' } url_args = { } return render_template('show.html', data = data, site_info = site_info, url_args = url_args)
def goods_taokouling(id): goodsDao = GoodsDao() goods = goodsDao.get_by_id(id) tkl = goodsDao.get_tkl_by_url(goods.googs_coupon_buy_url) if tkl is None: return resp_500('淘口令生成失败, 请稍候再试') tkl = "[" + goods.goods_name + "]\n复制这条信息, " + tkl + ", 打开手机淘宝, 即可在手机淘宝中领券购买. 来自[一起淘券网(17taoquan.wang)]优惠分享" return resp_200(tkl)
def goods_details(id): goodsDao = GoodsDao() schema = GoodsSchema() res = {} goods = goodsDao.get_by_id(id) if goods is not None: res = schema.dump(goods).data else: res = {} return resp_200(res)
def index(): site_info = { 'title':'首页' } goodsDao = GoodsDao() data = { 'hot_selled' : goodsDao.get_hot_selld(), 'super_coupon' : goodsDao.get_super_coupon(), 'super_fanli' : goodsDao.get_super_fanli() } url_args = { } return render_template('index.html', data = data, site_info = site_info, url_args = url_args)
def search(): goodsDao = GoodsDao() goodsClassDao = GoodsClassDao() goodsOrderDao = GoodsOrderDao() key_words = request.args.get('kwd', '') page = int(request.args.get('page', 1)) args = {} args['cate'] = str(request.args.get('cate', '')) args['order'] = request.args.get('order', '') args['activity'] = int(request.args.get('activity', 0)) args['classes'] = request.args.get('cls', '') goodsList = goodsDao.search(key_words, page, 60, **args) goodsOrders = goodsOrderDao.get_order() for o in goodsOrders: if str(args['order']).find(o['order']) >= 0: o['selected'] = 'Y' if str(args['order']).find('asc') >= 0: o['next'] = 'desc' else: o['next'] = 'asc' else: o['selected'] = 'N' data = { 'pagination': goodsList, 'cls': goodsClassDao.get_cls(), 'orders': goodsOrders, 'more_coupon': [] } url_args = { 'kwd': key_words, 'cur_path': 'search', 'cate': args['cate'], 'order': args['order'], 'activity': args['activity'] } site_info = {'title': '搜索' + url_args['kwd']} return render_template('list.html', data=data, url_args=url_args, site_info=site_info)