Beispiel #1
0
def userBackgroupCollect(request):

    isLogin, account = UserInfo.checkIsLogin(request);
    isSuperUser = UserInfo.checkIsSuperUser(request);
    #获取页码
    try:
        page = int(request.GET.get('page', '1'));
    except Exception, e:
        page = 1;
Beispiel #2
0
def userBackgroupAddress(request):
    #获取order信息
    isLogin, account = UserInfo.checkIsLogin(request);
    #获取地址
    addressList = AddressInfo.getAddressData(1, 2000, account, {'account' : account});
    data = {
        'addressList' : addressList,
        'superUser' : UserInfo.checkIsSuperUser(request)
    }

    return Responses.returnCheckLoginDrawPage(isLogin, 'myBackgroup/myAddress.html', 'data', data);
Beispiel #3
0
def userBackgroupUserInfo(request):
    #获取order信息
    isLogin, account = UserInfo.checkIsLogin(request);
    userInfo = UserInfo.getUserInfoData(account);
    data = [];
    if userInfo:
        userInfo=userInfo[0];
        data = {
            'userInfo' : userInfo,
            'superUser' : UserInfo.checkIsSuperUser(request)
        }
    return Responses.returnCheckLoginDrawPage(isLogin, 'myBackgroup/myPersonal.html', 'data', data);
Beispiel #4
0
def managerAllOrder(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    #获取页码
    try:
        page = int(request.GET.get('page', '1'));
    except Exception, e:
        page = 1;
 def shoppingCartRequestPortManager(cls, request=HttpRequest()):
     #检测是否登录
     isLogin, account = UserInfo.checkIsLogin(request)
     if isLogin == True:
         if request.method == 'POST':
             operation = request.POST.get('operation', None)
             if operation == 'add':
                 return cls.addShoppingCart(request, account)
             elif operation == 'delete':
                 return cls.deleteShoppingCart(request, account)
             elif operation == 'modify':
                 return cls.modifyShoppingCart(request, account)
             elif operation == 'checkBox':
                 #修改商品是否选中
                 return cls.modifyCheckBox(request, account)
             elif operation == 'checkBoxAll':
                 return cls.modifyCheckBoxAll(request, account)
             else:
                 return Responses.responseJsonArray('fail', 'operation有误')
         elif request.method == 'GET':
             operation = request.GET.get('operation', None)
             if operation == 'get':
                 return cls.getShoppingCart(request, account)
             elif operation == 'checkStock':
                 return cls.checkStock(request, account)
             else:
                 return Responses.responseJsonArray('fail', 'operation有误')
         else:
             return Responses.responseJsonArray('fail', '请使用get或post请求')
     else:
         return Responses.responseJsonArray('fail', '未登录')
Beispiel #6
0
def home(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    goods, pageResult = GoodsInfo.getGoodsData(1, 30, None);

    try:
        goodsList = {
            'banner1' : goods[1],
            'banner2' : goods[3],
            'banner3' : goods[5],
            'banner4' : goods[9],
            'hotGoods1' : goods[10],
            'hotGoods2' : goods[11],
            'hotGoods3' : goods[12],
            'hotGoods4' : goods[13],
            'hotGoods5' : goods[14],
            'hotGoods6' : goods[15],
            'first1' : goods[16],
            'first2' : goods[17],
            'first3' : goods[18],
            'first4' : goods[19],
            'first5' : goods[20],
            'first6' : goods[21]
        };
    except Exception, e:
        return Responses.returnDrawPage(isLogin, 'home/home.html', 'goodsList', None);
Beispiel #7
0
def shoppingCart(request):
    isLogin, account = UserInfo.checkIsLogin(request);

    goodsList = [];
    totalPrice = 0;
    allSelect = 1;
    try:
        #先从购物车表获取goodsid,再获取商品
        condition = {
            'account' : account,
        }
        data = ShoppingCartInfo.getShoppingCartData(1, 2000, condition);
        if data:
            for obj in data:
                objList, pageResult = GoodsInfo.getGoodsData(1, 2000, {'goodsId' : obj['goodsId']});
                goods = objList[0];
                #从新计算价格,以最新的为准
                obj['sumPrice'] = str(float(goods['price'])*obj['count']);
                if obj['count'] > goods['inventoryCount']:
                    goods['isOverflow'] = 1;  #库存不足
                else:
                    goods['isOverflow'] = 0;
                goods['count'] = obj['count'];  #增加属性
                goods['sumPrice'] = obj['sumPrice'];
                goods['isSelect'] = obj['isSelect'];

                if not obj['isSelect']:
                    allSelect = 0;
                goodsList.append(goods);
                if obj['isSelect']:
                    totalPrice += float(goods['sumPrice']);
    except Exception, e:
        Responses.returnCheckLoginDrawPage(isLogin, 'goods/shoppingCart.html', 'data', None);
Beispiel #8
0
    def orderRequestPortManager(cls, request=HttpRequest()):
        #检测是否登录
        isLogin, account = UserInfo.checkIsLogin(request);
        if isLogin == True:
            if request.method == 'POST':
                operation = request.POST.get('operation', None);
                if operation == None:  #有可能传递过来的是json
                    try:
                        result = json.loads(request.body);
                        operation = result['operation'];
                    except Exception, e:
                        return Responses.responseJsonArray('fail', 'operation无法获取');

                if operation == 'add':
                    return cls.addOrder(request, account);
                elif operation == 'modify':
                    return cls.modifyOrder(request, account);
                elif operation == 'delete':
                    return cls.deleteOrder(request, account);
                else:
                    return Responses.responseJsonArray('fail', 'operation有误');
            elif request.method == 'GET':
                operation = request.GET.get('operation', None);
                if operation == 'get':
                    return cls.getOrder(request, account);
                else:
                    return Responses.responseJsonArray('fail', 'operation有误');
            else:
                return Responses.responseJsonArray('fail', '请使用get或post请求');
Beispiel #9
0
def goodsBrowse(request, subClass):
    isLogin, account = UserInfo.checkIsLogin(request);
    #获取页码
    try:
        page = int(request.GET.get('page', '1'));
    except Exception, e:
        page = 1;
Beispiel #10
0
def orderCheckout(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    try:
        goodsId = request.GET.get('goodsId', None);
        count = int(request.GET.get('count', '1'));
    except Exception, e:
        goodsId = request.GET.get('goodsId', None);
        count = 1;
Beispiel #11
0
def search(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    goodsName = request.GET.get('keyword', None);
    goodsList = GoodsInfo.searchGoods(1, 50, goodsName);
    data = {
        'subClass' : 'undefine',
        'goodsList' : goodsList
    }
    if goodsList:
        return Responses.returnDrawPage(isLogin, 'goods/goodsBrowse.html', 'data', data);
    else:
        return Responses.returnDrawPage(isLogin, 'common/noresult.html', 'data', None);
Beispiel #12
0
def bottomStaticPage(request, page):
    isLogin, account = UserInfo.checkIsLogin(request);
    if page == 'about':
        return Responses.returnDrawPage(isLogin, 'static/about.html', 'about', None);
    elif page == 'bigSale':
        return Responses.returnDrawPage(isLogin, 'static/bigSale.html', 'bigsale', None);
    elif page == 'privacy':
        return Responses.returnDrawPage(isLogin, 'static/privacy.html', 'privacy', None);
    elif page == 'saleBack':
        return Responses.returnDrawPage(isLogin, 'static/saleBack.html', 'saleback', None);
    else:
        return HttpResponseRedirect('noresults/');
Beispiel #13
0
def goodsInfo(request, goodsId):
    isLogin, account = UserInfo.checkIsLogin(request);
    condition = {
        'goodsId': goodsId
    };
    goodsList, pageResult = GoodsInfo.getGoodsData(1, 20, condition);

    minImageUrls = [];
    descImageUrls = [];
    if goodsList:
        for (key, value) in goodsList[0].items():
            if key[0:11] == 'minImageUrl' and value != '':
                minImageUrls.append(value);
            if key[0:12] == 'descImageUrl' and value != '':
                descImageUrls.append(value);
    else:
        return Responses.returnDrawPage(isLogin, 'common/noresult.html', 'data', None);

    goods = goodsList[0];
    goods['minImageUrls'] = minImageUrls;
    goods['descImageUrls'] = descImageUrls;

    return Responses.returnDrawPage(isLogin, 'goods/goodsInfo.html', 'goods', goods);
Beispiel #14
0
 def addressRequestPortManager(cls, request=HttpRequest()):
     #检测是否登录
     isLogin, account = UserInfo.checkIsLogin(request)
     if isLogin == True:
         if request.method == 'POST':
             operation = request.POST.get('operation', None)
             if operation == 'add':
                 return cls.addAddress(request, account)
             elif operation == 'modify':
                 return cls.modifyAddress(request, account)
             elif operation == 'delete':
                 return cls.deleteAddress(request, account)
             else:
                 return Responses.responseJsonArray('fail', 'operation有误')
         elif request.method == 'GET':
             operation = request.GET.get('operation', None)
             if operation == 'get':
                 return cls.getAddress(request, account)
             else:
                 return Responses.responseJsonArray('fail', 'operation有误')
         else:
             return Responses.responseJsonArray('fail', '请使用get或post请求')
     else:
         return Responses.responseJsonArray('fail', '未登录')
Beispiel #15
0
 def collectRequestPortManager(cls, request=HttpRequest()):
     #检测是否登录
     isLogin, account = UserInfo.checkIsLogin(request);
     if isLogin == True:
         if request.method == 'POST':
             operation = request.POST.get('operation', None);
             if operation == 'add':
                 return cls.addCollect(request, account);
             elif operation == 'delete':
                 return cls.deleteCollect(request, account);
             else:
                 return Responses.responseJsonArray('fail', 'operation有误');
         elif request.method == 'GET':
             operation = request.GET.get('operation', None);
             if operation == 'get':
                 return cls.getCollect(request, account);
             elif operation == 'check':
                 return cls.checkCollect(request, account);
             else:
                 return Responses.responseJsonArray('fail', 'operation有误');
         else:
             return Responses.responseJsonArray('fail', '请使用get或post请求');
     else:
         return Responses.responseJsonArray('fail', '未登录');
Beispiel #16
0
def managerUploader(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    data = {
        'superUser' : UserInfo.checkIsSuperUser(request)
    }
    return Responses.returnCheckLoginDrawPage(isLogin, 'managerBackgroup/uploadGoods.html', 'data', data);
Beispiel #17
0
        page = int(request.GET.get('page', '1'));
    except Exception, e:
        page = 1;
    #分页获取所有商品
    goodsList, pageResult = GoodsInfo.getGoodsData(page, 12, None);
    #限定只能看到多少页,例如总的有20页,只限定看2--5页
    new_page_range = [];
    if pageResult:
        for page_number in pageResult.paginator.page_range:
            if abs(page_number-pageResult.number) <= 3:
                new_page_range.append(page_number);
    data = {
        'goodsList' : goodsList,
        'pageResult' : pageResult,
        'new_page_range' : new_page_range,
        'superUser' : UserInfo.checkIsSuperUser(request)
    }
    return Responses.returnCheckLoginDrawPage(isLogin, 'managerBackgroup/allGoods.html', 'data', data);
#管理员所有订单
def managerAllOrder(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    #获取页码
    try:
        page = int(request.GET.get('page', '1'));
    except Exception, e:
        page = 1;

    #获取订单
    allOrder, pageResult = OrderInfo.getOrderData(page, 12, account);
    #限定只能看到多少页,例如总的有20页,只限定看2--5页
    new_page_range = [];
Beispiel #18
0
def userInfoRequestPortManager(request): #check ok
    return UserInfo.userInfoRequestPortManager(request);
Beispiel #19
0
def noresults(request):
    isLogin, account = UserInfo.checkIsLogin(request);
    return Responses.returnDrawPage(isLogin, 'common/noresult.html', 'goodsList', None);