zoukankan      html  css  js  c++  java
  • MVC判断登录


    @{
    ViewBag.Title = "StorecollectIndex";
    Layout = "~/Views/Shared/_Layout.cshtml";
    }

    <h2>StorecollectIndex</h2>
    <script>
    var UId = 0;
    $(function () {
    //判断是否登录
    if (getCookie("UsersInfo") == null) {
    this.location.href = '/Sale/LoginIndex';
    }
    else {
    var list = JSON.parse(getCookie("UsersInfo"));
    UId = list[0].UId;
    }
    StoreBound();
    GoodsBound();
    })
    function StoreBound() {
    $.ajax({
    url: "http://localhost:57190/api/Sale/GetStroesCollectInfos",
    async: false,
    data: { UId: UId },
    type: "get",
    dataType: "json",
    success: function (d) {
    var str = "";
    $("#Store").empty();
    $(d).each(function (i, n) {
    str += "<div style='float:left;margin-left:20px;margin-top:20px'><input id='SId' type='hidden' value='" + n.SId + "'/><img src='http://localhost:57190" + n.StoresInfoSId.SImge + "' width='85px' height='85px'/><br/> <a href='/Sale/GoodsInfoDetailIndex?SId=" + n.SId + "''><lable>" + n.StoresInfoSId.SName + "</lable></a><lable>" + n.StoresInfoSId.SPeople + "</lable></div>"
    })
    $("#Store").append(str);
    },
    complete: function (d) {

    }

    })
    }
    function GoodsBound() {
    $.ajax({
    url: "http://localhost:57190/api/Sale/GetGoodsInfos",
    async: false,
    data: { SId: $("#SId").val() },
    type: "get",
    dataType: "json",
    success: function (d) {
    var str = "";
    $("#Goods").empty();
    $(d).each(function (i, n) {
    str += "<div style='float:left;margin-left:20px'><input id='GId' type='hidden' value='" + n.GId + "'/><img src='http://localhost:57190" + n.GImg + "' width='60px' height='60px'/><br/> <a href='/Sale/GoodsInfoDetailIndex?GId=" + n.GId + "''><lable>" + n.GName + "</lable></a></div>"

    })
    $("#Goods").append(str);
    }
    })
    }

    /* cookie中存值
    */
    function setCookie(name, value) {
    if (value) {
    var days = 1; //定义一天
    var exp = new Date();
    exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1000);
    // 写入Cookie, toGMTString将时间转换成字符串
    document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString;
    }
    };

    /**
    * cookie中取值
    * */
    function getCookie(name) {
    var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); //匹配字段
    if (arr = document.cookie.match(reg)) {
    return unescape(arr[2]);
    } else {
    return null;
    }
    };
    </script>
    <div id="Store" style="float:left">

    </div>
    <div id="Goods" style="float:right">

    </div>

  • 相关阅读:
    JAVA :: MVC
    顺序栈创建
    editplus 配置工具集
    链表之创建
    13.1.22:线性表之单链表
    Web 多线程作业
    给 Mac OS X Lion 刻一张安装光盘
    kubernetes组件之api 安装
    kubeadm 之k8s 多master 部署
    kubernetes集群之部署kubescheduler组件
  • 原文地址:https://www.cnblogs.com/zhang0405/p/13275458.html
Copyright © 2011-2022 走看看