コード例 #1
0
ファイル: food_vm.py プロジェクト: zcxyun/food_shop
    def __init__(self, food):
        self.id = food.id
        self.name = food.name
        self.summary = food.summary
        self.price = str(food.price)
        self.min_price = str(food.price)
        self.stock = food.stock

        self.total_count = food.total_count
        self.comment_count = food.comment_count

        self.main_image = buildImageUrl(food.main_image)
        self.pic_url = buildImageUrl(food.main_image)
        self.pics = [buildImageUrl(food.main_image)]
コード例 #2
0
 def _deal_data(self, data):
     return {
         'id': data.id,
         'name': data.name,
         'price': str(data.price),
         'pic_url': buildImageUrl(data.main_image),
         'number': self.food_dic[data.id]
     }
コード例 #3
0
 def __init__(self, cart):
     food = cart.food
     self.id = cart.id
     self.number = cart.quantity
     self.stock = food.stock
     self.food_id = cart.food_id
     self.name = food.name
     self.price = str(food.price)
     self.pic_url = buildImageUrl(food.main_image)
     self.active = True
コード例 #4
0
ファイル: order.py プロジェクト: zcxyun/food_shop
 def _deal_data(self, data):
     """
     根据单个商品信息提取指定信息
     :param data:
     :return: 指定信息
     """
     return {
         'id': data.id,
         'name': data.name,
         'price': str(data.price),
         'pic_url': buildImageUrl(data.main_image),
         'number': self.products_dic[data.id]
     }
コード例 #5
0
    def __init__(self, order):
        self.name = order.snap_name
        self.status = order.order_status
        self.status_desc = order.order_status_desc
        self.date = order.format_create_time
        self.order_number = order.order_number
        self.order_sn = order.order_sn
        self.note = order.note
        self.pay_price = str(order.pay_price)
        self.freight = str(order.freight)
        self.total_price = str(order.total_price)
        self.address_dict = json.loads(order.snap_address)
        self.address_str = AddressService().set_address_info(self.address_dict)

        goods_list = json.loads(order.snap_items)
        for goods in goods_list:
            goods['main_image'] = buildImageUrl(goods['main_image'])
        self.goods_list = goods_list

        self.deadline = order.date_create_time + timedelta(minutes=30)
コード例 #6
0
def index():
    cat_list = FoodCat.query.filter_by().order_by(FoodCat.weight.desc()).all_or_404()
    food_list = Food.query.filter_by().order_by(
        Food.total_count.desc(), Food.id.desc()).limit(3).all_or_404()

    data_cat_list = [{'id': item.id, 'name': item.name} for item in cat_list]
    data_cat_list.insert(0, {'id': 0, 'name': '全部'})

    data_food_list = []
    for item in food_list:
        tmp = {
            'id': item.id,
            'pic_url': buildImageUrl(item.main_image)
        }
        data_food_list.append(tmp)

    resp = {
        'cat_list': data_cat_list,
        'banner_list': data_food_list
    }
    return jsonify(resp)