1.進入admin->includes->inc_menu.PHP中此文件爲定義左側功能模塊超連接javascript
2.添加include/inc_menu.php秒殺管理超連接找連接php
- $modules['03_promotion']['16_seckill'] = 'seckill_goods.php?act=add';
3.找到languages/zh_cn/admin/common.php 添加秒殺功能css
- $_LANG['16_seckill']='秒殺管理';
4.添加權限管理中的秒殺權限
1>向數據庫中添加秒殺權限,包括查看秒殺表與添加秒殺html
數據庫表中的數據:ecs_admin_action
2>找到languages/zh_cn/admin/priv_action.phpjava
- //秒殺管理
- $_LANG['seckill'] = '秒殺管理';
- $_LANG['seckill_list'] = '秒殺顯示';
- $_LANG['seckill_add'] = '秒殺添加';
3>找到添加include/inc_priv.php 添加秒殺權限的加載配置
- //秒殺管理
- $purview['16_seckill'] = 'seckill';
配置完成後python
打開 後臺>權限管理>管理員列表>分配權限mysql
3.配置秒殺的語言包ajax
在languages/zh_cn/admin/下配置seckill_goods.php;sql
- <?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"}
2.seckill_goods_info.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"}
7.在這裏後臺秒殺正式完成
顯示結果: