zoukankan      html  css  js  c++  java
  • MS-MVCAJAS 秒杀的添加功能吧

    -----------------------控制器

    public ActionResult Index()
    {
    return View();
    }

    public ActionResult GetKill()
    {
    return View();
    }

    public ActionResult DingDan()
    {
    return View();
    }

    ------------------------------------------------------------------------------------


    @{
    ViewBag.Title = "Kill";
    }

    <h2>商品秒杀页面</h2>
    <script src="~/Scripts/jquery-3.3.1.js"></script>
    <link href="~/Content/bootstrap.css" rel="stylesheet" />

    <div style="800px;height:600px;align-content:center;margin-left:150px">

    <div style="float:left;margin-left:100px">
    <h4 style="color:red"><b>距离活动结束仅剩:<span id="EndTime"></span><input id="hid" type="hidden" value="75255" /></b></h4>
    <img src="~/image/Iphone.png" style="300px;height:430px" alt="" />
    </div>
    <div style="float:right;margin-top:50px;">
    <h3>商品品牌:Iphone</h3>
    <h3>商品名称:<span id="Spname"></span></h3><br />
    <h4>商品原价:<span id="MarkMoney"></span></h4>
    <div style="margin-top:-32px;margin-left:-120px"><hr style="75px;border-bottom:2px solid #5c5c3d;color:black" /></div>
    <br />
    <h2 style="color:red">秒杀价:<span id="KillMoney"></span></h2><br />
    <h4 id="dome1">557*98982用户已经抢到最新版Iphone一台</h4>
    <h4>338*98982用户已经抢到最新版Iphone一台</h4>
    <h4>999*98982用户已经抢到最新版Iphone一台</h4><br /><br />
    <input id="Button1" type="button" class="btn btn-danger" onclick="MiaoKill()" value="立即秒杀" style="250px;height:50px" />
    </div>
    </div>
    <script>

    $(function () {
    SpShow();
    })

    function SpShow() {
    $.ajax({
    url: "http://localhost:51025/api/GetProduct",
    type: "get",
    DataType: "json",
    success: function (i) {
    FuDong();
    setLeftTime();
    $("#Spname").text(i.SPName);
    $("#MarkMoney").text(i.MarkPrice);
    $("#KillMoney").text(i.KillPrice);
    }
    })
    }

    function showSeconds() {
    var day1 = Math.floor(seconds / (60 * 60 * 24));
    var hour = Math.floor((seconds - day1 * 24 * 60 * 60) / 3600);
    var minute = Math.floor((seconds - day1 * 24 * 60 * 60 - hour * 3600) / 60);
    var second = Math.floor(seconds - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60);
    if (day1 < 0) {
    clearInterval(timer);
    $("#EndTime").html("已经结束!");
    } else {
    $("#EndTime").html(day1 + " 天 " + hour + " 小时 " + minute + " 分 " + second + " 秒");
    }
    seconds--;
    }
    function setLeftTime() {
    seconds = parseInt($("#hid").val(), 10);
    timer = setInterval(showSeconds, 1000);
    }

    function FuDong() {
    var $this = $("#dome1");

    var scrollTimer;
    //事件 鼠标移入停止滚动,移出重置事件,间隔2000毫秒       

    $this.hover(

    function () { clearInterval(scrollTimer); },
    function () {
    scrollTimer = setInterval(
    function () { scrollNews($this); }, 2000);
    }).trigger("mouseleave");
    //滚动函数,传入div 寻找ul 获得行高,每次上移行高高度,添加行首到末尾
    function scrollNews(obj) {
    var $self = obj.find("ul");
    var lineHeight = $self.find("li:first").height();
    $self.animate({ "marginTop": -lineHeight + "px" }, 500, function () {
    $self.css("marginTop", "0").find("li:first").appendTo($self);
    })
    }
    }

    function MiaoKill() {
    alert("秒杀成功!");
    location.href = 'Kill/DingDan';
    //$.ajax({
    // url: "http://localhost:51025/api/GetKill",
    // type: "get",
    // DataType: "json",
    // success: function (i) {
    // var r = i.res;
    // if (r == 1) {
    // alert("秒杀成功!");
    // }
    // else {
    // alert("秒杀失败!");
    // }
    // }
    //})
    }

    </script>

  • 相关阅读:
    IDEA手动创建JFinal项目(404问题处理)
    php 把数字1-1亿换成汉字表述,例如 150 转成 一百五十
    模仿console自写函数打印js的对象
    每瓶啤酒2元,2个空酒瓶或4个瓶盖可换1瓶啤酒。10元最多可喝多少瓶啤酒? php
    js-Event构造函数,也许你需要
    js将金额专成每隔3位数加逗号
    js-PC版监听键盘大小写事件
    用php脚本给html中引用的js和css路径打上版本
    通过js的console优雅的将php调试信息输出
    android中加载的html获取的宽高不正确
  • 原文地址:https://www.cnblogs.com/gc1229/p/13196168.html
Copyright © 2011-2022 走看看