Example #1
0
def shopping():
    print("购物...")

    good_list = [
        ['全家桶', 80],
        ['汉堡套餐', 45],
        ['可乐鸡翅', 15],
        ['绝味鸭脖', 20],
        ['烤猪蹄', 10],
    ]

    shop_cart = {}

    cost = 0

    bal = user.check_balance_interface(user_info['name'])

    while True:
        for index, good in enumerate(good_list):
            print(index, good)
        choice = input("请输入商品编号或者q退出:").strip()
        if choice.isdigit():
            choice = int(choice)
            if choice >= 0 and choice < len(good_list):
                good_name, good_price = good_list[choice]
                if bal >= good_price:
                    if good_name in shop_cart:
                        shop_cart[good_name] += 1
                    else:
                        shop_cart[good_name] = 1
                    cost += good_price
                else:
                    print("穷逼,快去充值!")
            else:
                print("请输入正确的商品编号")

        elif choice == 'q':
            commit = input("是否确认购买,请选择y/n:").strip()
            if commit == 'y':
                flag, msg = shop.shop_interface(user_info['name'], cost)
                if flag:
                    print(msg)
                    break
                else:
                    print(msg)
            elif commit == 'n':
                shop.add_shop_cart_interface(user_info['name'], shop_cart)
                break
        else:
            print("请输入正确的数字!")
Example #2
0
File: src.py Project: AliceMye/www
def check_balance():
    # 调用用户转接口
    msg = user.check_balance_interface(user_info['name'])
    print(msg)
Example #3
0
def check_balance():
    '''查看余额'''
    balance = user.check_balance_interface(user_info['name'])
    print(balance)
Example #4
0
def check_balance():
    print("查看余额...")
    bal = user.check_balance_interface(user_info['name'])
    print(bal)
Example #5
0
def check_balance():
    meg = user.check_balance_interface(user_info["name"])
    print(meg)