标签:
1.进入admin->includes->inc_menu.php中此文件为定义左侧功能模块超链接
2.添加include/inc_menu.php秒杀管理超链接找链接
$modules['03_promotion']['16_seckill'] = 'seckill_goods.php?act=add';
3.找到languages/zh_cn/admin/common.php 添加秒杀功能
$_LANG['16_seckill']='秒杀管理';
1>向数据库中添加秒杀权限,包括查看秒杀表与添加秒杀
数据库表中的数据:ecs_admin_action
2>找到languages/zh_cn/admin/priv_action.php
//秒杀管理 $_LANG['seckill'] = '秒杀管理'; $_LANG['seckill_list'] = '秒杀显示'; $_LANG['seckill_add'] = '秒杀添加';
//秒杀管理 $purview['16_seckill'] = 'seckill';
配置完成后
打开 后台>权限管理>管理员列表>分配权限
3.配置秒杀的语言包
在languages/zh_cn/admin/下配置seckill_goods.php;
<?php /** * ECSHOP 管理中心秒杀活动语言文件 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: seckill.php 17217 2011-01-19 06:29:08Z liubo $ */ /* menu */ $_LANG['seckill_list'] = '秒杀活动列表'; $_LANG['add_seckill'] = '添加秒杀活动'; $_LANG['edit_seckill'] = '编辑秒杀活动'; $_LANG['seckill_log'] = '秒杀活动出价记录'; $_LANG['continue_add_seckill'] = '继续添加秒杀活动'; $_LANG['back_seckill_list'] = '返回秒杀活动列表'; $_LANG['add_seckill_ok'] = '添加秒杀活动成功'; $_LANG['edit_seckill_ok'] = '编辑秒杀活动成功'; $_LANG['settle_deposit_ok'] = '处理冻结的保证金成功'; /* list */ $_LANG['act_is_going'] = '仅显示进行中的活动'; $_LANG['act_name'] = '秒杀活动名称'; $_LANG['goods_name'] = '商品名称'; $_LANG['start_time'] = '开始时间'; $_LANG['end_time'] = '结束时间'; $_LANG['deposit'] = '保证金'; $_LANG['start_price'] = '起拍价'; $_LANG['end_price'] = '一口价'; $_LANG['amplitude'] = '加价幅度'; $_LANG['seckill_not_exist'] = '您要操作的秒杀活动不存在'; $_LANG['seckill_cannot_remove'] = '该秒杀活动已经有人出价,不能删除'; $_LANG['js_languages']['batch_drop_confirm'] = '您确实要删除选中的秒杀活动吗?'; $_LANG['batch_drop_ok'] = '操作完成(已经有人出价的秒杀活动不能删除)'; $_LANG['no_record_selected'] = '没有选择记录'; $_LANG['label_goods_num']='秒杀数量:'; /* info */ $_LANG['label_act_name'] = '秒杀活动名称:'; $_LANG['notice_act_name'] = '如果留空,取秒杀商品的名称(该名称仅用于后台,前台不会显示)'; $_LANG['label_act_desc'] = '秒杀活动描述:'; $_LANG['label_search_goods'] = '根据商品编号、名称或货号搜索商品'; $_LANG['label_goods_name'] = '秒杀商品名称:'; $_LANG['label_start_time'] = '秒杀开始时间:'; $_LANG['label_end_time'] = '秒杀结束时间:'; $_LANG['label_status'] = '当前状态:'; $_LANG['label_start_price'] = '起拍价:'; $_LANG['label_end_price'] = '一口价:'; $_LANG['label_no_top'] = '无封顶'; $_LANG['label_amplitude'] = '加价幅度:'; $_LANG['label_deposit'] = '保证金:'; $_LANG['bid_user_count'] = '已有 %s 个买家出价'; $_LANG['settle_frozen_money'] = '怎样处理买家的冻结资金?'; $_LANG['unfreeze'] = '解冻保证金'; $_LANG['deduct'] = '扣除保证金'; $_LANG['invalid_status'] = '当前状态不正确'; $_LANG['no_deposit'] = '没有保证金需要处理'; $_LANG['unfreeze_seckill_deposit'] = '解冻秒杀活动的保证金:%s'; $_LANG['deduct_seckill_deposit'] = '扣除秒杀活动的保证金:%s'; $_LANG['seckill_status'][PRE_START] = '未开始'; $_LANG['seckill_status'][UNDER_WAY] = '进行中'; $_LANG['seckill_status'][FINISHED] = '已结束'; $_LANG['seckill_status'][SETTLED] = '已结束'; $_LANG['pls_search_goods'] = '请先搜索商品'; $_LANG['search_result_empty'] = '没有找到商品,请重新搜索'; $_LANG['pls_select_goods'] = '请选择秒杀商品'; $_LANG['goods_not_exist'] = '您要秒杀的商品不存在'; $_LANG['js_languages']['start_price_not_number'] = '起拍价格式不正确(数字)'; $_LANG['js_languages']['end_price_not_number'] = '一口价格式不正确(数字)'; $_LANG['js_languages']['end_gt_start'] = '一口价应该大于起拍价'; $_LANG['js_languages']['amplitude_not_number'] = '加价幅度格式不正确(数字)'; $_LANG['js_languages']['deposit_not_number'] = '保证金格式不正确(数字)'; $_LANG['js_languages']['start_lt_end'] = '秒杀开始时间不能大于结束时间'; $_LANG['js_languages']['search_is_null'] = '没有搜索到任何商品,请重新搜索'; /* log */ $_LANG['bid_user'] = '买家'; $_LANG['bid_price'] = '出价'; $_LANG['bid_time'] = '时间'; $_LANG['status'] = '状态'; ?>
4.仿照拍卖功能做秒杀功能
进入upload->admin中建立seckill_goods.php代码如下(就是复制auction.php中复制将auction改为seckill)在这里我已经写好了直接复制
<?php /** * ECSHOP 管理中心拍卖活动管理 * ============================================================================ * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。 * 网站地址: http://www.ecshop.com; * ---------------------------------------------------------------------------- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和 * 使用;不允许对程序代码以任何形式任何目的的再发布。 * ============================================================================ * $Author: liubo $ * $Id: auction.php 17217 2011-01-19 06:29:08Z liubo $ */ define('IN_ECS', true); require(dirname(__FILE__) . '/includes/init.php'); require(ROOT_PATH . 'includes/lib_goods.php'); $exc = new exchange($ecs->table('goods_activity'), $db, 'act_id', 'act_name'); /*------------------------------------------------------ */ //-- 活动列表页 /*------------------------------------------------------ */ if ($_REQUEST['act'] == 'list') { /* 检查权限 */ admin_priv('seckill'); /* 模板赋值 */ $smarty->assign('full_page', 1); $smarty->assign('ur_here', $_LANG['seckill_list']); $smarty->assign('action_link', array('href' => 'seckill.php?act=add', 'text' => $_LANG['add_seckill'])); $list = seckill_list(); $smarty->assign('seckill_list', $list['item']); $smarty->assign('filter', $list['filter']); $smarty->assign('record_count', $list['record_count']); $smarty->assign('page_count', $list['page_count']); $smarty->assign('form_action','add'); $sort_flag = sort_flag($list['filter']); $smarty->assign($sort_flag['tag'], $sort_flag['img']); /* 显示商品列表页面 */ assign_query_info(); $smarty->display('seckill_list.htm'); } /*------------------------------------------------------ */ //-- 分页、排序、查询 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'query') { $list = seckill_list(); $smarty->assign('seckill_list', $list['item']); $smarty->assign('filter', $list['filter']); $smarty->assign('record_count', $list['record_count']); $smarty->assign('page_count', $list['page_count']); $sort_flag = sort_flag($list['filter']); $smarty->assign($sort_flag['tag'], $sort_flag['img']); make_json_result($smarty->fetch('seckill_list.htm'), '', array('filter' => $list['filter'], 'page_count' => $list['page_count'])); } /*------------------------------------------------------ */ //-- 删除 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'remove') { check_authz_json('seckill'); $id = intval($_GET['id']); $name = $auction['act_name']; $exc->drop($id); /* 记日志 */ admin_log($name, 'remove', 'seckill'); /* 清除缓存 */ clear_cache_files(); $url = 'seckill_goods.php?act=query&' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']); ecs_header("Location: $url\n"); exit; } /*------------------------------------------------------ */ //-- 批量操作 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'batch') { /* 取得要操作的记录编号 */ if (empty($_POST['checkboxes'])) { sys_msg($_LANG['no_record_selected']); } else { /* 检查权限 */ admin_priv('auction'); $ids = $_POST['checkboxes']; /* 删除记录 */ $sql = "DELETE FROM " . $ecs->table('goods_activity') . " WHERE act_id " . db_create_in($ids) . " AND act_type = '" . GAT_SECKILL . "'"; $db->query($sql); /* 记日志 */ admin_log('', 'batch_remove', 'seckill'); /* 清除缓存 */ clear_cache_files(); $links[] = array('text' => $_LANG['back_seckill_list'], 'href' => 'seckill_goods.php?act=list&' . list_link_postfix()); sys_msg($_LANG['batch_drop_ok'], 0, $links); } } /*------------------------------------------------------ */ //-- 添加、编辑 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit') { /* 检查权限 */ admin_priv('seckill'); /* 是否添加 */ $is_add = $_REQUEST['act'] == 'add'; $smarty->assign('form_action', $is_add ? 'insert' : 'update'); /* 初始化、取得拍卖活动信息 */ if ($is_add) { $auction = array( 'act_id' => 0, 'act_name' => '', 'act_desc' => '', 'goods_id' => 0, 'product_id' => 0, 'goods_name' => $_LANG['pls_search_goods'], 'start_time' => date('Y-m-d', time() + 86400), 'end_time' => date('Y-m-d', time() + 4 * 86400), ); } /* else { if (empty($_GET['id'])) { sys_msg('invalid param'); } $id = intval($_GET['id']); $auction = auction_info($id, true); if (empty($auction)) { sys_msg($_LANG['auction_not_exist']); } $auction['status'] = $_LANG['auction_status'][$auction['status_no']]; $smarty->assign('bid_user_count', sprintf($_LANG['bid_user_count'], $auction['bid_user_count'])); } */ $smarty->assign('seckill', $seckill); /* 赋值时间控件的语言 */ $smarty->assign('cfg_lang', $_CFG['lang']); /* 商品货品表 */ $smarty->assign('good_products_select', get_good_products_select($seckill['goods_id'])); /* 显示模板 */ if ($is_add) { $smarty->assign('ur_here', $_LANG['add_seckill']); } $smarty->assign('action_link', list_link($is_add)); assign_query_info(); $smarty->display('seckill_goods_info.htm'); } /*------------------------------------------------------ */ //-- 添加、编辑后提交 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update') { /* 检查权限 */ admin_priv('seckill'); /* 是否添加 */ $is_add = $_REQUEST['act'] == 'insert'; /* 检查是否选择了商品 */ $goods_id = intval($_POST['goods_id']); if ($goods_id <= 0) { sys_msg($_LANG['pls_select_goods']); } $sql = "SELECT goods_name FROM " . $ecs->table('goods') . " WHERE goods_id = '$goods_id'"; $row = $db->getRow($sql); if (empty($row)) { sys_msg($_LANG['goods_not_exist']); } $goods_name = $row['goods_name']; /* 提交值 */ $seckill = array( 'act_id' => intval($_POST['id']), 'act_name' => empty($_POST['act_name']) ? $goods_name : sub_str($_POST['act_name'], 255, false), 'act_desc' => $_POST['act_desc'], 'act_type' => GAT_SECKILL, 'goods_id' => $goods_id, 'product_id' => empty($_POST['product_id']) ? 0 : $_POST['product_id'], 'goods_name' => $goods_name, 'start_time' => local_strtotime($_POST['start_time']), 'end_time' => local_strtotime($_POST['end_time']), 'ext_info' => serialize(array( 'start_price' => round(floatval($_POST['start_price']), 2), 'seckill_num' => round(floatval($_POST['seckill_num']), 2) )) ); /* 保存数据 */ if ($is_add) { $seckill['is_finished'] = 0; $db->autoExecute($ecs->table('goods_activity'), $seckill, 'INSERT'); $seckill['act_id'] = $db->insert_id(); } else { $db->autoExecute($ecs->table('goods_activity'), $seckill, 'UPDATE', "act_id = '$seckill[act_id]'"); } /* 记日志 */ if ($is_add) { admin_log($auction['act_name'], 'add', 'seckill'); } else { admin_log($auction['act_name'], 'edit', 'seckill'); } /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ if ($is_add) { $links = array( array('href' => 'seckill_goods.php?act=add', 'text' => $_LANG['continue_add_seckill']), array('href' => 'seckill_goods.php?act=list', 'text' => $_LANG['back_seckill_list']) ); sys_msg($_LANG['add_seckill_ok'], 0, $links); } else { $links = array( array('href' => 'seckill_goods.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_seckill_list']) ); sys_msg($_LANG['edit_seckill_ok'], 0, $links); } } /*------------------------------------------------------ */ //-- 处理冻结资金 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'settle_money') { /* 检查权限 */ admin_priv('auction'); /* 检查参数 */ if (empty($_POST['id'])) { sys_msg('invalid param'); } $id = intval($_POST['id']); $auction = auction_info($id); if (empty($auction)) { sys_msg($_LANG['auction_not_exist']); } if ($auction['status_no'] != FINISHED) { sys_msg($_LANG['invalid_status']); } if ($auction['deposit'] <= 0) { sys_msg($_LANG['no_deposit']); } /* 处理保证金 */ $exc->edit("is_finished = 2", $id); // 修改状态 if (isset($_POST['unfreeze'])) { /* 解冻 */ log_account_change($auction['last_bid']['bid_user'], $auction['deposit'], (-1) * $auction['deposit'], 0, 0, sprintf($_LANG['unfreeze_auction_deposit'], $auction['act_name'])); } else { /* 扣除 */ log_account_change($auction['last_bid']['bid_user'], 0, (-1) * $auction['deposit'], 0, 0, sprintf($_LANG['deduct_auction_deposit'], $auction['act_name'])); } /* 记日志 */ admin_log($auction['act_name'], 'edit', 'auction'); /* 清除缓存 */ clear_cache_files(); /* 提示信息 */ sys_msg($_LANG['settle_deposit_ok']); } /*------------------------------------------------------ */ //-- 搜索商品 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'search_goods') { check_authz_json('auction'); include_once(ROOT_PATH . 'includes/cls_json.php'); $json = new JSON; $filter = $json->decode($_GET['JSON']); $arr['goods'] = get_goods_list($filter); if (!empty($arr['goods'][0]['goods_id'])) { $arr['products'] = get_good_products($arr['goods'][0]['goods_id']); } make_json_result($arr); } /*------------------------------------------------------ */ //-- 搜索货品 /*------------------------------------------------------ */ elseif ($_REQUEST['act'] == 'search_products') { include_once(ROOT_PATH . 'includes/cls_json.php'); $json = new JSON; $filters = $json->decode($_GET['JSON']); if (!empty($filters->goods_id)) { $arr['products'] = get_good_products($filters->goods_id); } make_json_result($arr); } /* * 取得秒杀活动列表 * @return array */ function seckill_list() { $result = get_filter(); if ($result === false) { /* 过滤条件 */ $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['is_going'] = empty($_REQUEST['is_going']) ? 0 : 1; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ""; if (!empty($filter['keyword'])) { $where .= " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'"; } if ($filter['is_going']) { $now = gmtime(); $where .= " AND is_finished = 0 AND start_time <= '$now' AND end_time >= '$now' "; } $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_SECKILL . "' $where"; $filter['record_count'] = $GLOBALS['db']->getOne($sql); /* 分页大小 */ $filter = page_and_size($filter); /* 查询 */ $sql = "SELECT * ". "FROM " . $GLOBALS['ecs']->table('goods_activity') . " WHERE act_type = '" . GAT_SECKILL . "' $where ". " ORDER BY $filter[sort_by] $filter[sort_order] ". " LIMIT ". $filter['start'] .", $filter[page_size]"; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $res = $GLOBALS['db']->query($sql); $list = array(); while ($row = $GLOBALS['db']->fetchRow($res)) { $ext_info = unserialize($row['ext_info']); $arr = array_merge($row, $ext_info); $arr['start_time'] = local_date('Y-m-d H:i', $arr['start_time']); $arr['end_time'] = local_date('Y-m-d H:i', $arr['end_time']); $list[] = $arr; } $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); return $arr; } /** * 列表链接 * @param bool $is_add 是否添加(插入) * @param string $text 文字 * @return array('href' => $href, 'text' => $text) */ function list_link($is_add = true, $text = '') { $href = 'seckill_goods.php?act=list'; if (!$is_add) { $href .= '&' . list_link_postfix(); } if ($text == '') { $text = $GLOBALS['_LANG']['seckill_list']; } return array('href' => $href, 'text' => $text); } ?>
5.在加载秒杀对应常量找到includes/inc_constant.php添加秒杀功能对应的常量
define('GAT_SECKILL', 5);
6.在upload->admin->templates中建立两个html页面进行显示和添加分别是sckill_goods_info.php和seckill_list.php
1.seckill_list.php代码如下:
<!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ --> {include file="pageheader.htm"} <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script> <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" /> {insert_scripts files="validator.js,../js/transport.js,../js/utils.js} <div class="main-div"> <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()"> <table cellspacing="1" cellpadding="3" width="100%"> <tr> <td class="label">{$lang.label_act_name}</td> <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" /> {$lang.notice_act_name}</td> </tr> <tr> <td class="label">{$lang.label_act_desc}</td> <td><textarea name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td> </tr> <tr> <td align="right">{$lang.label_search_goods}</td> <td><input name="keyword" type="text" id="keyword"> <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td> </tr> <tr> <td class="label">{$lang.label_goods_name}</td> <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();"> <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option> </select> <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}> {html_options options=$good_products_select selected=$auction.product_id} </select></td> </tr> <tr> <td class="label">{$lang.label_start_time}</td> <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" /> <input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button" /></td> </tr> <tr> <td class="label">{$lang.label_end_time}</td> <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" /> <input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button" /></td> </tr> <tr> <td class="label">{$lang.label_start_price}</td> <td><input name="start_price" type="text" id="start_price" value=""></td> </tr> <tr> <td class="label">{$lang.label_goods_num}</td> <td><input name="seckill_num" type="text" id="seckill_num" value=""></td> </tr> <tr> <td colspan="2" align="center"> {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"} <input type="submit" class="button" value="{$lang.button_submit}" /> <input type="reset" class="button" value="{$lang.button_reset}" /> <input type="hidden" name="act" value="{$form_action}" /> {elseif $seckill.status_no eq "2"} {$lang.settle_frozen_money} <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" /> <input type="submit" class="button" value="{$lang.deduct}" name="deduct" /> <input type="hidden" name="act" value="settle_money" /> {/if} <input type="hidden" name="id" value="{$seckill.act_id}" /></td> </tr> </table> </form> </div> {literal} <script language="JavaScript"> <!-- var display_yes = (Browser.isIE) ? 'block' : 'table-row-group'; onload = function() { // 开始检查订单 startCheckOrder(); } /** * 检查表单输入的数据 */ function validate() { validator = new Validator("theForm"); validator.isNumber('start_price', start_price_not_number, false); validator.isNumber('end_price', end_price_not_number, false); if (document.forms['theForm'].elements['no_top'].checked == false) { validator.gt('end_price', 'start_price', end_gt_start); } validator.isNumber('amplitude', amplitude_not_number, false); validator.isNumber('deposit', deposit_not_number, false); validator.islt('start_time', 'end_time', start_lt_end); return validator.passed(); } function checked_no_top(o) { if (o.checked) { o.form.elements['end_price'].value = ''; o.form.elements['end_price'].disabled = true; } else { o.form.elements['end_price'].disabled = false; } } function searchGoods() { var filter = new Object; filter.keyword = document.forms['theForm'].elements['keyword'].value; Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET', 'JSON'); } function searchGoodsResponse(result) { if (result.error == '1' && result.message != '') { alert(result.message); return; } var frm = document.forms['theForm']; var sel = frm.elements['goods_id']; var sp = frm.elements['product_id']; if (result.error == 0) { /* 清除 options */ sel.length = 0; sp.length = 0; /* 创建 options */ var goods = result.content.goods; if (goods) { for (i = 0; i < goods.length; i++) { var opt = document.createElement("OPTION"); opt.value = goods[i].goods_id; opt.text = goods[i].goods_name; sel.options.add(opt); } } else { var opt = document.createElement("OPTION"); opt.value = 0; opt.text = search_is_null; sel.options.add(opt); } /* 创建 product options */ var products = result.content.products; if (products) { sp.style.display = display_yes; for (i = 0; i < products.length; i++) { var p_opt = document.createElement("OPTION"); p_opt.value = products[i].product_id; p_opt.text = products[i].goods_attr_str; sp.options.add(p_opt); } } else { sp.style.display = 'none'; var p_opt = document.createElement("OPTION"); p_opt.value = 0; p_opt.text = search_is_null; sp.options.add(p_opt); } } return; } function change_good_products() { var filter = new Object; filter.goods_id = document.forms['theForm'].elements['goods_id'].value; Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET', 'JSON'); } function searchProductsResponse(result) { var frm = document.forms['theForm']; var sp = frm.elements['product_id']; if (result.error == 0) { /* 清除 options */ sp.length = 0; /* 创建 product options */ var products = result.content.products; if (products.length) { sp.style.display = display_yes; for (i = 0; i < products.length; i++) { var p_opt = document.createElement("OPTION"); p_opt.value = products[i].product_id; p_opt.text = products[i].goods_attr_str; sp.options.add(p_opt); } } else { sp.style.display = 'none'; var p_opt = document.createElement("OPTION"); p_opt.value = 0; p_opt.text = search_is_null; sp.options.add(p_opt); } } if (result.message.length > 0) { alert(result.message); } } //--> </script> {/literal} {include file="pagefooter.htm"}
<!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ --> {include file="pageheader.htm"} <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script> <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" /> {insert_scripts files="validator.js,../js/transport.js,../js/utils.js} <div class="main-div"> <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()"> <table cellspacing="1" cellpadding="3" width="100%"> <tr> <td class="label">{$lang.label_act_name}</td> <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" /> {$lang.notice_act_name}</td> </tr> <tr> <td class="label">{$lang.label_act_desc}</td> <td><textarea name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td> </tr> <tr> <td align="right">{$lang.label_search_goods}</td> <td><input name="keyword" type="text" id="keyword"> <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td> </tr> <tr> <td class="label">{$lang.label_goods_name}</td> <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();"> <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option> </select> <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}> {html_options options=$good_products_select selected=$auction.product_id} </select></td> </tr> <tr> <td class="label">{$lang.label_start_time}</td> <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" /> <input name="selbtn1" type="button" id="selbtn1" onclick="return showCalendar('start_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn1');" value="{$lang.btn_select}" class="button" /></td> </tr> <tr> <td class="label">{$lang.label_end_time}</td> <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" /> <input name="selbtn2" type="button" id="selbtn2" onclick="return showCalendar('end_time', '%Y-%m-%d %H:%M', '24', false, 'selbtn2');" value="{$lang.btn_select}" class="button" /></td> </tr> <tr> <td class="label">{$lang.label_start_price}</td> <td><input name="start_price" type="text" id="start_price" value=""></td> </tr> <tr> <td class="label">{$lang.label_goods_num}</td> <td><input name="seckill_num" type="text" id="seckill_num" value=""></td> </tr> <tr> <td colspan="2" align="center"> {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"} <input type="submit" class="button" value="{$lang.button_submit}" /> <input type="reset" class="button" value="{$lang.button_reset}" /> <input type="hidden" name="act" value="{$form_action}" /> {elseif $seckill.status_no eq "2"} {$lang.settle_frozen_money} <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" /> <input type="submit" class="button" value="{$lang.deduct}" name="deduct" /> <input type="hidden" name="act" value="settle_money" /> {/if} <input type="hidden" name="id" value="{$seckill.act_id}" /></td> </tr> </table> </form> </div> {literal} <script language="JavaScript"> <!-- var display_yes = (Browser.isIE) ? 'block' : 'table-row-group'; onload = function() { // 开始检查订单 startCheckOrder(); } /** * 检查表单输入的数据 */ function validate() { validator = new Validator("theForm"); validator.isNumber('start_price', start_price_not_number, false); validator.isNumber('end_price', end_price_not_number, false); if (document.forms['theForm'].elements['no_top'].checked == false) { validator.gt('end_price', 'start_price', end_gt_start); } validator.isNumber('amplitude', amplitude_not_number, false); validator.isNumber('deposit', deposit_not_number, false); validator.islt('start_time', 'end_time', start_lt_end); return validator.passed(); } function checked_no_top(o) { if (o.checked) { o.form.elements['end_price'].value = ''; o.form.elements['end_price'].disabled = true; } else { o.form.elements['end_price'].disabled = false; } } function searchGoods() { var filter = new Object; filter.keyword = document.forms['theForm'].elements['keyword'].value; Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET', 'JSON'); } function searchGoodsResponse(result) { if (result.error == '1' && result.message != '') { alert(result.message); return; } var frm = document.forms['theForm']; var sel = frm.elements['goods_id']; var sp = frm.elements['product_id']; if (result.error == 0) { /* 清除 options */ sel.length = 0; sp.length = 0; /* 创建 options */ var goods = result.content.goods; if (goods) { for (i = 0; i < goods.length; i++) { var opt = document.createElement("OPTION"); opt.value = goods[i].goods_id; opt.text = goods[i].goods_name; sel.options.add(opt); } } else { var opt = document.createElement("OPTION"); opt.value = 0; opt.text = search_is_null; sel.options.add(opt); } /* 创建 product options */ var products = result.content.products; if (products) { sp.style.display = display_yes; for (i = 0; i < products.length; i++) { var p_opt = document.createElement("OPTION"); p_opt.value = products[i].product_id; p_opt.text = products[i].goods_attr_str; sp.options.add(p_opt); } } else { sp.style.display = 'none'; var p_opt = document.createElement("OPTION"); p_opt.value = 0; p_opt.text = search_is_null; sp.options.add(p_opt); } } return; } function change_good_products() { var filter = new Object; filter.goods_id = document.forms['theForm'].elements['goods_id'].value; Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET', 'JSON'); } function searchProductsResponse(result) { var frm = document.forms['theForm']; var sp = frm.elements['product_id']; if (result.error == 0) { /* 清除 options */ sp.length = 0; /* 创建 product options */ var products = result.content.products; if (products.length) { sp.style.display = display_yes; for (i = 0; i < products.length; i++) { var p_opt = document.createElement("OPTION"); p_opt.value = products[i].product_id; p_opt.text = products[i].goods_attr_str; sp.options.add(p_opt); } } else { sp.style.display = 'none'; var p_opt = document.createElement("OPTION"); p_opt.value = 0; p_opt.text = search_is_null; sp.options.add(p_opt); } } if (result.message.length > 0) { alert(result.message); } } //--> </script> {/literal} {include file="pagefooter.htm"}
7.在这里后台秒杀正式完成
显示结果:
标签:
原文地址:http://blog.csdn.net/haoyunyun888/article/details/51377636