zoukankan      html  css  js  c++  java
  • ecshop二次开发之后台秒杀

    1.进入admin->includes->inc_menu.PHP此文件为定义左侧功能模块超链接













    2.添加include/inc_menu.php秒杀管理超链接找链接



    1. $modules['03_promotion']['16_seckill']       = 'seckill_goods.php?act=add';  

    3.找到languages/zh_cn/admin/common.php 添加秒杀功能




    1. $_LANG['16_seckill']='秒杀管理';  

    4.添加权限管理中的秒杀权限

    1>向数据库中添加秒杀权限,包括查看秒杀表与添加秒杀

    数据库表中的数据:ecs_admin_action





    2>找到languages/zh_cn/admin/priv_action.php





    1. //秒杀管理  
    2. $_LANG['seckill']         = '秒杀管理';  
    3. $_LANG['seckill_list']         = '秒杀显示';  
    4. $_LANG['seckill_add']         = '秒杀添加';  

    3>找到添加include/inc_priv.php 添加秒杀权限的加载配置



    1. //秒杀管理  
    2.     $purview['16_seckill']        = 'seckill';  

    配置完成后

    打开 后台>权限管理>管理员列表>分配权限




    3.配置秒杀的语言包

    在languages/zh_cn/admin/下配置seckill_goods.php;

    1. <?php  
    2.   
    3. /**  
    4.  * ECSHOP 管理中心秒杀活动语言文件  
    5.  * ============================================================================  
    6.  * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。  
    7.  * 网站地址: http://www.ecshop.com;  
    8.  * ----------------------------------------------------------------------------  
    9.  * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和  
    10.  * 使用;不允许对程序代码以任何形式任何目的的再发布。  
    11.  * ============================================================================  
    12.  * $Author: liubo $  
    13.  * $Id: seckill.php 17217 2011-01-19 06:29:08Z liubo $  
    14.  */  
    15.   
    16. /* menu */  
    17. $_LANG['seckill_list'] = '秒杀活动列表';  
    18. $_LANG['add_seckill'] = '添加秒杀活动';  
    19. $_LANG['edit_seckill'] = '编辑秒杀活动';  
    20. $_LANG['seckill_log'] = '秒杀活动出价记录';  
    21. $_LANG['continue_add_seckill'] = '继续添加秒杀活动';  
    22. $_LANG['back_seckill_list'] = '返回秒杀活动列表';  
    23. $_LANG['add_seckill_ok'] = '添加秒杀活动成功';  
    24. $_LANG['edit_seckill_ok'] = '编辑秒杀活动成功';  
    25. $_LANG['settle_deposit_ok'] = '处理冻结的保证金成功';  
    26.   
    27. /* list */  
    28. $_LANG['act_is_going'] = '仅显示进行中的活动';  
    29. $_LANG['act_name'] = '秒杀活动名称';  
    30. $_LANG['goods_name'] = '商品名称';  
    31. $_LANG['start_time'] = '开始时间';  
    32. $_LANG['end_time'] = '结束时间';  
    33. $_LANG['deposit'] = '保证金';  
    34. $_LANG['start_price'] = '起拍价';  
    35. $_LANG['end_price'] = '一口价';  
    36. $_LANG['amplitude'] = '加价幅度';  
    37. $_LANG['seckill_not_exist'] = '您要操作的秒杀活动不存在';  
    38. $_LANG['seckill_cannot_remove'] = '该秒杀活动已经有人出价,不能删除';  
    39. $_LANG['js_languages']['batch_drop_confirm'] = '您确实要删除选中的秒杀活动吗?';  
    40. $_LANG['batch_drop_ok'] = '操作完成(已经有人出价的秒杀活动不能删除)';  
    41. $_LANG['no_record_selected'] = '没有选择记录';  
    42. $_LANG['label_goods_num']='秒杀数量:';  
    43. /* info */  
    44. $_LANG['label_act_name'] = '秒杀活动名称:';  
    45. $_LANG['notice_act_name'] = '如果留空,取秒杀商品的名称(该名称仅用于后台,前台不会显示)';  
    46. $_LANG['label_act_desc'] = '秒杀活动描述:';  
    47. $_LANG['label_search_goods'] = '根据商品编号、名称或货号搜索商品';  
    48. $_LANG['label_goods_name'] = '秒杀商品名称:';  
    49. $_LANG['label_start_time'] = '秒杀开始时间:';  
    50. $_LANG['label_end_time'] = '秒杀结束时间:';  
    51. $_LANG['label_status'] = '当前状态:';  
    52. $_LANG['label_start_price'] = '起拍价:';  
    53. $_LANG['label_end_price'] = '一口价:';  
    54. $_LANG['label_no_top'] = '无封顶';  
    55. $_LANG['label_amplitude'] = '加价幅度:';  
    56. $_LANG['label_deposit'] = '保证金:';  
    57. $_LANG['bid_user_count'] = '已有 %s 个买家出价';  
    58. $_LANG['settle_frozen_money'] = '怎样处理买家的冻结资金?';  
    59. $_LANG['unfreeze'] = '解冻保证金';  
    60. $_LANG['deduct'] = '扣除保证金';  
    61. $_LANG['invalid_status'] = '当前状态不正确';  
    62. $_LANG['no_deposit'] = '没有保证金需要处理';  
    63. $_LANG['unfreeze_seckill_deposit'] = '解冻秒杀活动的保证金:%s';  
    64. $_LANG['deduct_seckill_deposit'] = '扣除秒杀活动的保证金:%s';  
    65.   
    66. $_LANG['seckill_status'][PRE_START] = '未开始';  
    67. $_LANG['seckill_status'][UNDER_WAY] = '进行中';  
    68. $_LANG['seckill_status'][FINISHED] = '已结束';  
    69. $_LANG['seckill_status'][SETTLED] = '已结束';  
    70.   
    71. $_LANG['pls_search_goods'] = '请先搜索商品';  
    72. $_LANG['search_result_empty'] = '没有找到商品,请重新搜索';  
    73.   
    74. $_LANG['pls_select_goods'] = '请选择秒杀商品';  
    75. $_LANG['goods_not_exist'] = '您要秒杀的商品不存在';  
    76.   
    77. $_LANG['js_languages']['start_price_not_number'] = '起拍价格式不正确(数字)';  
    78. $_LANG['js_languages']['end_price_not_number'] = '一口价格式不正确(数字)';  
    79. $_LANG['js_languages']['end_gt_start'] = '一口价应该大于起拍价';  
    80. $_LANG['js_languages']['amplitude_not_number'] = '加价幅度格式不正确(数字)';  
    81. $_LANG['js_languages']['deposit_not_number'] = '保证金格式不正确(数字)';  
    82. $_LANG['js_languages']['start_lt_end'] = '秒杀开始时间不能大于结束时间';  
    83. $_LANG['js_languages']['search_is_null'] = '没有搜索到任何商品,请重新搜索';  
    84.   
    85. /* log */  
    86. $_LANG['bid_user'] = '买家';  
    87. $_LANG['bid_price'] = '出价';  
    88. $_LANG['bid_time'] = '时间';  
    89. $_LANG['status'] = '状态';  
    90.   
    91. ?>  

    4.仿照拍卖功能做秒杀功能

    进入upload->admin中建立seckill_goods.php代码如下(就是复制auction.php中复制将auction改为seckill)在这里我已经写好了直接复制

    1. <?php  
    2.   
    3. /**  
    4.  * ECSHOP 管理中心拍卖活动管理  
    5.  * ============================================================================  
    6.  * * 版权所有 2005-2012 上海商派网络科技有限公司,并保留所有权利。  
    7.  * 网站地址: http://www.ecshop.com;  
    8.  * ----------------------------------------------------------------------------  
    9.  * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和  
    10.  * 使用;不允许对程序代码以任何形式任何目的的再发布。  
    11.  * ============================================================================  
    12.  * $Author: liubo $  
    13.  * $Id: auction.php 17217 2011-01-19 06:29:08Z liubo $  
    14.  */  
    15.   
    16. define('IN_ECS', true);  
    17. require(dirname(__FILE__) . '/includes/init.php');  
    18. require(ROOT_PATH . 'includes/lib_goods.php');  
    19.   
    20. $exc = new exchange($ecs->table('goods_activity'), $db, 'act_id''act_name');  
    21.   
    22. /*------------------------------------------------------ */  
    23. //-- 活动列表页  
    24. /*------------------------------------------------------ */  
    25.   
    26. if ($_REQUEST['act'] == 'list')  
    27. {  
    28.     /* 检查权限 */  
    29.     admin_priv('seckill');  
    30.   
    31.     /* 模板赋值 */  
    32.     $smarty->assign('full_page',   1);  
    33.     $smarty->assign('ur_here',     $_LANG['seckill_list']);  
    34.     $smarty->assign('action_link', array('href' => 'seckill.php?act=add''text' => $_LANG['add_seckill']));  
    35.   
    36.     $list = seckill_list();  
    37.   
    38.     $smarty->assign('seckill_list', $list['item']);  
    39.     $smarty->assign('filter',       $list['filter']);  
    40.     $smarty->assign('record_count', $list['record_count']);  
    41.     $smarty->assign('page_count',   $list['page_count']);  
    42.     $smarty->assign('form_action','add');  
    43.     $sort_flag  = sort_flag($list['filter']);  
    44.     $smarty->assign($sort_flag['tag'], $sort_flag['img']);  
    45.   
    46.     /* 显示商品列表页面 */  
    47.     assign_query_info();  
    48.     $smarty->display('seckill_list.htm');  
    49. }  
    50.   
    51. /*------------------------------------------------------ */  
    52. //-- 分页、排序、查询  
    53. /*------------------------------------------------------ */  
    54.   
    55. elseif ($_REQUEST['act'] == 'query')  
    56. {  
    57.     $list = seckill_list();  
    58.   
    59.     $smarty->assign('seckill_list', $list['item']);  
    60.     $smarty->assign('filter',       $list['filter']);  
    61.     $smarty->assign('record_count', $list['record_count']);  
    62.     $smarty->assign('page_count',   $list['page_count']);  
    63.   
    64.     $sort_flag  = sort_flag($list['filter']);  
    65.     $smarty->assign($sort_flag['tag'], $sort_flag['img']);  
    66.   
    67.     make_json_result($smarty->fetch('seckill_list.htm'), '',  
    68.         array('filter' => $list['filter'], 'page_count' => $list['page_count']));  
    69. }  
    70.   
    71. /*------------------------------------------------------ */  
    72. //-- 删除  
    73. /*------------------------------------------------------ */  
    74. elseif ($_REQUEST['act'] == 'remove')  
    75. {  
    76.     check_authz_json('seckill');  
    77.   
    78.     $id = intval($_GET['id']);  
    79.     $name = $auction['act_name'];  
    80.     $exc->drop($id);  
    81.   
    82.     /* 记日志 */  
    83.     admin_log($name, 'remove''seckill');  
    84.   
    85.     /* 清除缓存 */  
    86.     clear_cache_files();  
    87.   
    88.     $url = 'seckill_goods.php?act=query&' . str_replace('act=remove''', $_SERVER['QUERY_STRING']);  
    89.   
    90.     ecs_header("Location: $url ");  
    91.     exit;  
    92. }  
    93.   
    94. /*------------------------------------------------------ */  
    95. //-- 批量操作  
    96. /*------------------------------------------------------ */  
    97. elseif ($_REQUEST['act'] == 'batch')  
    98. {  
    99.     /* 取得要操作的记录编号 */  
    100.     if (empty($_POST['checkboxes']))  
    101.     {  
    102.         sys_msg($_LANG['no_record_selected']);  
    103.     }  
    104.     else  
    105.     {  
    106.         /* 检查权限 */  
    107.         admin_priv('auction');  
    108.   
    109.         $ids = $_POST['checkboxes'];  
    110.   
    111.                 /* 删除记录 */  
    112.                 $sql = "DELETE FROM " . $ecs->table('goods_activity') .  
    113.                         " WHERE act_id " . db_create_in($ids) .  
    114.                         " AND act_type = '" . GAT_SECKILL . "'";  
    115.                 $db->query($sql);  
    116.   
    117.                 /* 记日志 */  
    118.                 admin_log('''batch_remove''seckill');  
    119.   
    120.                 /* 清除缓存 */  
    121.                 clear_cache_files();  
    122.             $links[] = array('text' => $_LANG['back_seckill_list'], 'href' => 'seckill_goods.php?act=list&' . list_link_postfix());  
    123.             sys_msg($_LANG['batch_drop_ok'], 0, $links);  
    124.         }  
    125.     }  
    126.   
    127.   
    128.   
    129.   
    130. /*------------------------------------------------------ */  
    131. //-- 添加、编辑  
    132. /*------------------------------------------------------ */  
    133.   
    134. elseif ($_REQUEST['act'] == 'add' || $_REQUEST['act'] == 'edit')  
    135. {  
    136.     /* 检查权限 */  
    137.     admin_priv('seckill');  
    138.   
    139.     /* 是否添加 */  
    140.     $is_add = $_REQUEST['act'] == 'add';  
    141.     $smarty->assign('form_action', $is_add ? 'insert' : 'update');  
    142.   
    143.     /* 初始化、取得拍卖活动信息 */  
    144.     if ($is_add)  
    145.     {  
    146.         $auction = array(  
    147.             'act_id'        => 0,  
    148.             'act_name'      => '',  
    149.             'act_desc'      => '',  
    150.             'goods_id'      => 0,  
    151.             'product_id'    => 0,  
    152.             'goods_name'    => $_LANG['pls_search_goods'],  
    153.             'start_time'    => date('Y-m-d', time() + 86400),  
    154.             'end_time'      => date('Y-m-d', time() + 4 * 86400),  
    155.         );  
    156.     }  
    157.     /*  
    158.     else  
    159.     {  
    160.         if (empty($_GET['id']))  
    161.         {  
    162.             sys_msg('invalid param');  
    163.         }  
    164.         $id = intval($_GET['id']);  
    165.         $auction = auction_info($id, true);  
    166.         if (empty($auction))  
    167.         {  
    168.             sys_msg($_LANG['auction_not_exist']);  
    169.         }  
    170.         $auction['status'] = $_LANG['auction_status'][$auction['status_no']];  
    171.         $smarty->assign('bid_user_count', sprintf($_LANG['bid_user_count'], $auction['bid_user_count']));  
    172.     }  
    173.     */  
    174.     $smarty->assign('seckill', $seckill);  
    175.   
    176.     /* 赋值时间控件的语言 */  
    177.     $smarty->assign('cfg_lang', $_CFG['lang']);  
    178.   
    179.     /* 商品货品表 */  
    180.     $smarty->assign('good_products_select', get_good_products_select($seckill['goods_id']));  
    181.   
    182.     /* 显示模板 */  
    183.     if ($is_add)  
    184.     {  
    185.         $smarty->assign('ur_here', $_LANG['add_seckill']);  
    186.     }  
    187.     $smarty->assign('action_link', list_link($is_add));  
    188.     assign_query_info();  
    189.     $smarty->display('seckill_goods_info.htm');  
    190. }  
    191.   
    192. /*------------------------------------------------------ */  
    193. //-- 添加、编辑后提交  
    194. /*------------------------------------------------------ */  
    195.   
    196. elseif ($_REQUEST['act'] == 'insert' || $_REQUEST['act'] == 'update')  
    197. {  
    198.     /* 检查权限 */  
    199.     admin_priv('seckill');  
    200.   
    201.     /* 是否添加 */  
    202.     $is_add = $_REQUEST['act'] == 'insert';  
    203.   
    204.     /* 检查是否选择了商品 */  
    205.     $goods_id = intval($_POST['goods_id']);  
    206.     if ($goods_id <= 0)  
    207.     {  
    208.         sys_msg($_LANG['pls_select_goods']);  
    209.     }  
    210.     $sql = "SELECT goods_name FROM " . $ecs->table('goods') . " WHERE goods_id = '$goods_id'";  
    211.     $row = $db->getRow($sql);  
    212.     if (empty($row))  
    213.     {  
    214.         sys_msg($_LANG['goods_not_exist']);  
    215.     }  
    216.     $goods_name = $row['goods_name'];  
    217.   
    218.     /* 提交值 */  
    219.     $seckill = array(  
    220.         'act_id'        => intval($_POST['id']),  
    221.         'act_name'      => empty($_POST['act_name']) ? $goods_name : sub_str($_POST['act_name'], 255, false),  
    222.         'act_desc'      => $_POST['act_desc'],  
    223.         'act_type'      => GAT_SECKILL,  
    224.         'goods_id'      => $goods_id,  
    225.         'product_id'    => empty($_POST['product_id']) ? 0 : $_POST['product_id'],  
    226.         'goods_name'    => $goods_name,  
    227.         'start_time'    => local_strtotime($_POST['start_time']),  
    228.         'end_time'      => local_strtotime($_POST['end_time']),  
    229.         'ext_info'      => serialize(array(  
    230.                     'start_price'   => round(floatval($_POST['start_price']), 2),  
    231.                     'seckill_num'     => round(floatval($_POST['seckill_num']), 2)  
    232.                 ))  
    233.     );  
    234.   
    235.     /* 保存数据 */  
    236.     if ($is_add)  
    237.     {  
    238.         $seckill['is_finished'] = 0;  
    239.         $db->autoExecute($ecs->table('goods_activity'), $seckill, 'INSERT');  
    240.         $seckill['act_id'] = $db->insert_id();  
    241.     }  
    242.     else  
    243.     {  
    244.         $db->autoExecute($ecs->table('goods_activity'), $seckill, 'UPDATE'"act_id = '$seckill[act_id]'");  
    245.     }  
    246.   
    247.     /* 记日志 */  
    248.     if ($is_add)  
    249.     {  
    250.         admin_log($auction['act_name'], 'add''seckill');  
    251.     }  
    252.     else  
    253.     {  
    254.         admin_log($auction['act_name'], 'edit''seckill');  
    255.     }  
    256.   
    257.     /* 清除缓存 */  
    258.     clear_cache_files();  
    259.   
    260.     /* 提示信息 */  
    261.     if ($is_add)  
    262.     {  
    263.         $links = array(  
    264.             array('href' => 'seckill_goods.php?act=add''text' => $_LANG['continue_add_seckill']),  
    265.             array('href' => 'seckill_goods.php?act=list''text' => $_LANG['back_seckill_list'])  
    266.         );  
    267.         sys_msg($_LANG['add_seckill_ok'], 0, $links);  
    268.     }  
    269.     else  
    270.     {  
    271.         $links = array(  
    272.             array('href' => 'seckill_goods.php?act=list&' . list_link_postfix(), 'text' => $_LANG['back_seckill_list'])  
    273.         );  
    274.         sys_msg($_LANG['edit_seckill_ok'], 0, $links);  
    275.     }  
    276. }  
    277.   
    278. /*------------------------------------------------------ */  
    279. //-- 处理冻结资金  
    280. /*------------------------------------------------------ */  
    281.   
    282. elseif ($_REQUEST['act'] == 'settle_money')  
    283. {  
    284.     /* 检查权限 */  
    285.     admin_priv('auction');  
    286.   
    287.     /* 检查参数 */  
    288.     if (empty($_POST['id']))  
    289.     {  
    290.         sys_msg('invalid param');  
    291.     }  
    292.     $id = intval($_POST['id']);  
    293.     $auction = auction_info($id);  
    294.     if (empty($auction))  
    295.     {  
    296.         sys_msg($_LANG['auction_not_exist']);  
    297.     }  
    298.     if ($auction['status_no'] != FINISHED)  
    299.     {  
    300.         sys_msg($_LANG['invalid_status']);  
    301.     }  
    302.     if ($auction['deposit'] <= 0)  
    303.     {  
    304.         sys_msg($_LANG['no_deposit']);  
    305.     }  
    306.   
    307.     /* 处理保证金 */  
    308.     $exc->edit("is_finished = 2", $id); // 修改状态  
    309.     if (isset($_POST['unfreeze']))  
    310.     {  
    311.         /* 解冻 */  
    312.         log_account_change($auction['last_bid']['bid_user'], $auction['deposit'],  
    313.             (-1) * $auction['deposit'], 00, sprintf($_LANG['unfreeze_auction_deposit'], $auction['act_name']));  
    314.     }  
    315.     else  
    316.     {  
    317.         /* 扣除 */  
    318.         log_account_change($auction['last_bid']['bid_user'], 0,  
    319.             (-1) * $auction['deposit'], 00, sprintf($_LANG['deduct_auction_deposit'], $auction['act_name']));  
    320.     }  
    321.   
    322.     /* 记日志 */  
    323.     admin_log($auction['act_name'], 'edit''auction');  
    324.   
    325.     /* 清除缓存 */  
    326.     clear_cache_files();  
    327.   
    328.     /* 提示信息 */  
    329.     sys_msg($_LANG['settle_deposit_ok']);  
    330. }  
    331.   
    332. /*------------------------------------------------------ */  
    333. //-- 搜索商品  
    334. /*------------------------------------------------------ */  
    335.   
    336. elseif ($_REQUEST['act'] == 'search_goods')  
    337. {  
    338.     check_authz_json('auction');  
    339.   
    340.     include_once(ROOT_PATH . 'includes/cls_json.php');  
    341.   
    342.     $json   = new JSON;  
    343.     $filter = $json->decode($_GET['JSON']);  
    344.     $arr['goods']    = get_goods_list($filter);  
    345.   
    346.     if (!empty($arr['goods'][0]['goods_id']))  
    347.     {  
    348.         $arr['products'] = get_good_products($arr['goods'][0]['goods_id']);  
    349.     }  
    350.   
    351.     make_json_result($arr);  
    352. }  
    353.   
    354. /*------------------------------------------------------ */  
    355. //-- 搜索货品  
    356. /*------------------------------------------------------ */  
    357.   
    358. elseif ($_REQUEST['act'] == 'search_products')  
    359. {  
    360.     include_once(ROOT_PATH . 'includes/cls_json.php');  
    361.     $json = new JSON;  
    362.   
    363.     $filters = $json->decode($_GET['JSON']);  
    364.   
    365.     if (!empty($filters->goods_id))  
    366.     {  
    367.         $arr['products'] = get_good_products($filters->goods_id);  
    368.     }  
    369.   
    370.     make_json_result($arr);  
    371. }  
    372.   
    373. /*  
    374.  * 取得秒杀活动列表  
    375.  * @return   array  
    376.  */  
    377. function seckill_list()  
    378. {  
    379.     $result = get_filter();  
    380.     if ($result === false)  
    381.     {  
    382.         /* 过滤条件 */  
    383.         $filter['keyword']    = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);  
    384.         if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1)  
    385.         {  
    386.             $filter['keyword'] = json_str_iconv($filter['keyword']);  
    387.         }  
    388.         $filter['is_going']   = empty($_REQUEST['is_going']) ? 0 : 1;  
    389.         $filter['sort_by']    = empty($_REQUEST['sort_by']) ? 'act_id' : trim($_REQUEST['sort_by']);  
    390.         $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);  
    391.   
    392.         $where = "";  
    393.         if (!empty($filter['keyword']))  
    394.         {  
    395.             $where .= " AND goods_name LIKE '%" . mysql_like_quote($filter['keyword']) . "%'";  
    396.         }  
    397.         if ($filter['is_going'])  
    398.         {  
    399.             $now = gmtime();  
    400.             $where .= " AND is_finished = 0 AND start_time <= '$now' AND end_time >= '$now' ";  
    401.         }  
    402.   
    403.         $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('goods_activity') .  
    404.                 " WHERE act_type = '" . GAT_SECKILL . "' $where";  
    405.         $filter['record_count'] = $GLOBALS['db']->getOne($sql);  
    406.   
    407.         /* 分页大小 */  
    408.         $filter = page_and_size($filter);  
    409.   
    410.         /* 查询 */  
    411.         $sql = "SELECT * ".  
    412.                 "FROM " . $GLOBALS['ecs']->table('goods_activity') .  
    413.                 " WHERE act_type = '" . GAT_SECKILL . "' $where ".  
    414.                 " ORDER BY $filter[sort_by] $filter[sort_order] ".  
    415.                 " LIMIT ". $filter['start'] .", $filter[page_size]";  
    416.   
    417.         $filter['keyword'] = stripslashes($filter['keyword']);  
    418.         set_filter($filter, $sql);  
    419.     }  
    420.     else  
    421.     {  
    422.         $sql    = $result['sql'];  
    423.         $filter = $result['filter'];  
    424.     }  
    425.     $res = $GLOBALS['db']->query($sql);  
    426.   
    427.     $list = array();  
    428.     while ($row = $GLOBALS['db']->fetchRow($res))  
    429.     {  
    430.         $ext_info = unserialize($row['ext_info']);  
    431.         $arr = array_merge($row, $ext_info);  
    432.   
    433.         $arr['start_time']  = local_date('Y-m-d H:i', $arr['start_time']);  
    434.         $arr['end_time']    = local_date('Y-m-d H:i', $arr['end_time']);  
    435.   
    436.         $list[] = $arr;  
    437.     }  
    438.     $arr = array('item' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);  
    439.   
    440.     return $arr;  
    441. }  
    442.   
    443. /**  
    444.  * 列表链接  
    445.  * @param   bool    $is_add     是否添加(插入)  
    446.  * @param   string  $text       文字  
    447.  * @return  array('href' => $href, 'text' => $text)  
    448.  */  
    449. function list_link($is_add = true, $text = '')  
    450. {  
    451.     $href = 'seckill_goods.php?act=list';  
    452.     if (!$is_add)  
    453.     {  
    454.         $href .= '&' . list_link_postfix();  
    455.     }  
    456.     if ($text == '')  
    457.     {  
    458.         $text = $GLOBALS['_LANG']['seckill_list'];  
    459.     }  
    460.   
    461.     return array('href' => $href, 'text' => $text);  
    462. }  
    463.   
    464. ?>  

    5.在加载秒杀对应常量找到includes/inc_constant.php添加秒杀功能对应的常量




    1. define('GAT_SECKILL',               5);  

    6.在upload->admin->templates中建立两个html页面进行显示和添加分别是sckill_goods_info.php和seckill_list.php

    1.seckill_list.php代码如下:

    1. <!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ -->  
    2.   
    3. {include file="pageheader.htm"}  
    4.   
    5. <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>  
    6.   
    7. <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />  
    8.   
    9. {insert_scripts files="validator.js,../js/transport.js,../js/utils.js}  
    10.   
    11. <div class="main-div">  
    12.   
    13.     <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()">  
    14.   
    15.         <table cellspacing="1" cellpadding="3" width="100%">  
    16.   
    17.             <tr>  
    18.   
    19.                 <td class="label">{$lang.label_act_name}</td>  
    20.   
    21.                 <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" />  
    22.   
    23.                     {$lang.notice_act_name}</td>  
    24.   
    25.             </tr>  
    26.   
    27.             <tr>  
    28.   
    29.                 <td class="label">{$lang.label_act_desc}</td>  
    30.   
    31.                 <td><textarea  name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td>  
    32.   
    33.             </tr>  
    34.   
    35.             <tr>  
    36.   
    37.                 <td align="right">{$lang.label_search_goods}</td>  
    38.   
    39.                 <td><input name="keyword" type="text" id="keyword">  
    40.   
    41.                     <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td>  
    42.   
    43.             </tr>  
    44.   
    45.             <tr>  
    46.   
    47.                 <td class="label">{$lang.label_goods_name}</td>  
    48.   
    49.                 <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();">  
    50.   
    51.                     <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option>  
    52.   
    53.                 </select>  
    54.   
    55.                     <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}>  
    56.   
    57.                     {html_options options=$good_products_select selected=$auction.product_id}  
    58.   
    59.                     </select></td>  
    60.   
    61.             </tr>  
    62.   
    63.             <tr>  
    64.   
    65.                 <td class="label">{$lang.label_start_time}</td>  
    66.   
    67.                 <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" />  
    68.   
    69.                     <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>  
    70.   
    71.             </tr>  
    72.   
    73.             <tr>  
    74.   
    75.                 <td class="label">{$lang.label_end_time}</td>  
    76.   
    77.                 <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" />  
    78.   
    79.                     <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>  
    80.   
    81.             </tr>  
    82.   
    83.             <tr>  
    84.   
    85.                 <td class="label">{$lang.label_start_price}</td>  
    86.   
    87.                 <td><input name="start_price" type="text" id="start_price" value=""></td>  
    88.   
    89.             </tr>  
    90.   
    91.             <tr>  
    92.   
    93.                 <td class="label">{$lang.label_goods_num}</td>  
    94.   
    95.                 <td><input name="seckill_num" type="text" id="seckill_num" value=""></td>  
    96.   
    97.             </tr>  
    98.   
    99.             <tr>  
    100.   
    101.                 <td colspan="2" align="center">  
    102.   
    103.                     {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"}  
    104.   
    105.                     <input type="submit" class="button" value="{$lang.button_submit}" />  
    106.   
    107.                     <input type="reset" class="button" value="{$lang.button_reset}" />  
    108.   
    109.                     <input type="hidden" name="act" value="{$form_action}" />  
    110.   
    111.                     {elseif $seckill.status_no eq "2"}  
    112.   
    113.                     {$lang.settle_frozen_money}  
    114.   
    115.                     <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" />  
    116.   
    117.                     <input type="submit" class="button" value="{$lang.deduct}" name="deduct" />  
    118.   
    119.                     <input type="hidden" name="act" value="settle_money" />  
    120.   
    121.                     {/if}  
    122.   
    123.                     <input type="hidden" name="id" value="{$seckill.act_id}" /></td>  
    124.   
    125.             </tr>  
    126.   
    127.         </table>  
    128.   
    129.     </form>  
    130.   
    131. </div>  
    132.   
    133.   
    134.   
    135. {literal}  
    136.   
    137. <script language="JavaScript">  
    138.   
    139.     <!--  
    140.   
    141.     var display_yes = (Browser.isIE) ? 'block' : 'table-row-group';  
    142.   
    143.   
    144.   
    145.     onload = function()  
    146.   
    147.     {  
    148.   
    149.         // 开始检查订单  
    150.   
    151.         startCheckOrder();  
    152.   
    153.     }  
    154.   
    155.     /**  
    156.   
    157.      * 检查表单输入的数据  
    158.   
    159.      */  
    160.   
    161.     function validate()  
    162.   
    163.     {  
    164.   
    165.         validator = new Validator("theForm");  
    166.   
    167.         validator.isNumber('start_price', start_price_not_number, false);  
    168.   
    169.         validator.isNumber('end_price', end_price_not_number, false);  
    170.   
    171.   
    172.   
    173.         if (document.forms['theForm'].elements['no_top'].checked == false)  
    174.   
    175.         {  
    176.   
    177.             validator.gt('end_price''start_price', end_gt_start);  
    178.   
    179.         }  
    180.   
    181.         validator.isNumber('amplitude', amplitude_not_number, false);  
    182.   
    183.         validator.isNumber('deposit', deposit_not_number, false);  
    184.   
    185.         validator.islt('start_time''end_time', start_lt_end);  
    186.   
    187.         return validator.passed();  
    188.   
    189.     }  
    190.   
    191.     function checked_no_top(o)  
    192.   
    193.     {  
    194.   
    195.         if (o.checked)  
    196.   
    197.         {  
    198.   
    199.             o.form.elements['end_price'].value = '';  
    200.   
    201.             o.form.elements['end_price'].disabled = true;  
    202.   
    203.         }  
    204.   
    205.         else  
    206.   
    207.         {  
    208.   
    209.             o.form.elements['end_price'].disabled = false;  
    210.   
    211.         }  
    212.   
    213.     }  
    214.   
    215.     function searchGoods()  
    216.   
    217.     {  
    218.   
    219.         var filter = new Object;  
    220.   
    221.         filter.keyword  = document.forms['theForm'].elements['keyword'].value;  
    222.   
    223.   
    224.   
    225.         Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET''JSON');  
    226.   
    227.     }  
    228.   
    229.   
    230.   
    231.     function searchGoodsResponse(result)  
    232.   
    233.     {  
    234.   
    235.         if (result.error == '1' && result.message != '')  
    236.   
    237.         {  
    238.   
    239.             alert(result.message);  
    240.   
    241.             return;  
    242.   
    243.         }  
    244.   
    245.   
    246.   
    247.         var frm = document.forms['theForm'];  
    248.   
    249.         var sel = frm.elements['goods_id'];  
    250.   
    251.         var sp = frm.elements['product_id'];  
    252.   
    253.   
    254.   
    255.         if (result.error == 0)  
    256.   
    257.         {  
    258.   
    259.             /* 清除 options */  
    260.   
    261.             sel.length = 0;  
    262.   
    263.             sp.length = 0;  
    264.   
    265.   
    266.   
    267.             /* 创建 options */  
    268.   
    269.             var goods = result.content.goods;  
    270.   
    271.             if (goods)  
    272.   
    273.             {  
    274.   
    275.                 for (i = 0; i < goods.length; i++)  
    276.   
    277.                 {  
    278.   
    279.                     var opt = document.createElement("OPTION");  
    280.   
    281.                     opt.value = goods[i].goods_id;  
    282.   
    283.                     opt.text  = goods[i].goods_name;  
    284.   
    285.                     sel.options.add(opt);  
    286.   
    287.                 }  
    288.   
    289.             }  
    290.   
    291.             else  
    292.   
    293.             {  
    294.   
    295.                 var opt = document.createElement("OPTION");  
    296.   
    297.                 opt.value = 0;  
    298.   
    299.                 opt.text  = search_is_null;  
    300.   
    301.                 sel.options.add(opt);  
    302.   
    303.             }  
    304.   
    305.   
    306.   
    307.             /* 创建 product options */  
    308.   
    309.             var products = result.content.products;  
    310.   
    311.             if (products)  
    312.   
    313.             {  
    314.   
    315.                 sp.style.display = display_yes;  
    316.   
    317.   
    318.   
    319.                 for (i = 0; i < products.length; i++)  
    320.   
    321.                 {  
    322.   
    323.                     var p_opt = document.createElement("OPTION");  
    324.   
    325.                     p_opt.value = products[i].product_id;  
    326.   
    327.                     p_opt.text  = products[i].goods_attr_str;  
    328.   
    329.                     sp.options.add(p_opt);  
    330.   
    331.                 }  
    332.   
    333.             }  
    334.   
    335.             else  
    336.   
    337.             {  
    338.   
    339.                 sp.style.display = 'none';  
    340.   
    341.   
    342.   
    343.                 var p_opt = document.createElement("OPTION");  
    344.   
    345.                 p_opt.value = 0;  
    346.   
    347.                 p_opt.text  = search_is_null;  
    348.   
    349.                 sp.options.add(p_opt);  
    350.   
    351.             }  
    352.   
    353.         }  
    354.   
    355.   
    356.   
    357.         return;  
    358.   
    359.     }  
    360.   
    361.   
    362.   
    363.     function change_good_products()  
    364.   
    365.     {  
    366.   
    367.         var filter = new Object;  
    368.   
    369.         filter.goods_id = document.forms['theForm'].elements['goods_id'].value;  
    370.   
    371.   
    372.   
    373.         Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET''JSON');  
    374.   
    375.     }  
    376.   
    377.   
    378.   
    379.     function searchProductsResponse(result)  
    380.   
    381.     {  
    382.   
    383.         var frm = document.forms['theForm'];  
    384.   
    385.         var sp = frm.elements['product_id'];  
    386.   
    387.   
    388.   
    389.         if (result.error == 0)  
    390.   
    391.         {  
    392.   
    393.             /* 清除 options */  
    394.   
    395.             sp.length = 0;  
    396.   
    397.   
    398.   
    399.             /* 创建 product options */  
    400.   
    401.             var products = result.content.products;  
    402.   
    403.             if (products.length)  
    404.   
    405.             {  
    406.   
    407.                 sp.style.display = display_yes;  
    408.   
    409.   
    410.   
    411.                 for (i = 0; i < products.length; i++)  
    412.   
    413.                 {  
    414.   
    415.                     var p_opt = document.createElement("OPTION");  
    416.   
    417.                     p_opt.value = products[i].product_id;  
    418.   
    419.                     p_opt.text  = products[i].goods_attr_str;  
    420.   
    421.                     sp.options.add(p_opt);  
    422.   
    423.                 }  
    424.   
    425.             }  
    426.   
    427.             else  
    428.   
    429.             {  
    430.   
    431.                 sp.style.display = 'none';  
    432.   
    433.   
    434.   
    435.                 var p_opt = document.createElement("OPTION");  
    436.   
    437.                 p_opt.value = 0;  
    438.   
    439.                 p_opt.text  = search_is_null;  
    440.   
    441.                 sp.options.add(p_opt);  
    442.   
    443.             }  
    444.   
    445.         }  
    446.   
    447.   
    448.   
    449.         if (result.message.length > 0)  
    450.   
    451.         {  
    452.   
    453.             alert(result.message);  
    454.   
    455.         }  
    456.   
    457.     }  
    458.   
    459.     //-->  
    460.   
    461. </script>  
    462.   
    463. {/literal}  
    464.   
    465. {include file="pagefooter.htm"}  

    2.seckill_goods_info.php代码如下:
    1. <!-- $Id: auction_info.htm 16992 2010-01-19 08:45:49Z wangleisvn $ -->  
    2.   
    3. {include file="pageheader.htm"}  
    4.   
    5. <script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>  
    6.   
    7. <link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />  
    8.   
    9. {insert_scripts files="validator.js,../js/transport.js,../js/utils.js}  
    10.   
    11. <div class="main-div">  
    12.   
    13.     <form method="post" action="seckill_goods.php" name="theForm" enctype="multipart/form-data" onSubmit="return validate()">  
    14.   
    15.         <table cellspacing="1" cellpadding="3" width="100%">  
    16.   
    17.             <tr>  
    18.   
    19.                 <td class="label">{$lang.label_act_name}</td>  
    20.   
    21.                 <td><input name="act_name" type="text" id="act_name" value="{$seckill.act_name}" maxlength="60" />  
    22.   
    23.                     {$lang.notice_act_name}</td>  
    24.   
    25.             </tr>  
    26.   
    27.             <tr>  
    28.   
    29.                 <td class="label">{$lang.label_act_desc}</td>  
    30.   
    31.                 <td><textarea  name="act_desc" cols="60" rows="4" id="act_desc">{$seckill.act_desc}</textarea></td>  
    32.   
    33.             </tr>  
    34.   
    35.             <tr>  
    36.   
    37.                 <td align="right">{$lang.label_search_goods}</td>  
    38.   
    39.                 <td><input name="keyword" type="text" id="keyword">  
    40.   
    41.                     <input name="search" type="button" id="search" value="{$lang.button_search}" class="button" onclick="searchGoods()" /></td>  
    42.   
    43.             </tr>  
    44.   
    45.             <tr>  
    46.   
    47.                 <td class="label">{$lang.label_goods_name}</td>  
    48.   
    49.                 <td><select name="goods_id" id="goods_id" onchange="javascript:change_good_products();">  
    50.   
    51.                     <option value="{$seckill.goods_id}" selected="selected">{$seckill.goods_name}</option>  
    52.   
    53.                 </select>  
    54.   
    55.                     <select name="product_id" {if $auction.product_id <= 0}style="display:none"{/if}>  
    56.   
    57.                     {html_options options=$good_products_select selected=$auction.product_id}  
    58.   
    59.                     </select></td>  
    60.   
    61.             </tr>  
    62.   
    63.             <tr>  
    64.   
    65.                 <td class="label">{$lang.label_start_time}</td>  
    66.   
    67.                 <td><input name="start_time" type="text" id="start_time" value="{$seckill.start_time}" readonly="readonly" />  
    68.   
    69.                     <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>  
    70.   
    71.             </tr>  
    72.   
    73.             <tr>  
    74.   
    75.                 <td class="label">{$lang.label_end_time}</td>  
    76.   
    77.                 <td><input name="end_time" type="text" id="end_time" value="{$seckill.end_time}" readonly="readonly" />  
    78.   
    79.                     <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>  
    80.   
    81.             </tr>  
    82.   
    83.             <tr>  
    84.   
    85.                 <td class="label">{$lang.label_start_price}</td>  
    86.   
    87.                 <td><input name="start_price" type="text" id="start_price" value=""></td>  
    88.   
    89.             </tr>  
    90.   
    91.             <tr>  
    92.   
    93.                 <td class="label">{$lang.label_goods_num}</td>  
    94.   
    95.                 <td><input name="seckill_num" type="text" id="seckill_num" value=""></td>  
    96.   
    97.             </tr>  
    98.   
    99.             <tr>  
    100.   
    101.                 <td colspan="2" align="center">  
    102.   
    103.                     {if $seckill.act_id eq 0 or $seckill.status_no eq "0" or $auction.status_no eq "1"}  
    104.   
    105.                     <input type="submit" class="button" value="{$lang.button_submit}" />  
    106.   
    107.                     <input type="reset" class="button" value="{$lang.button_reset}" />  
    108.   
    109.                     <input type="hidden" name="act" value="{$form_action}" />  
    110.   
    111.                     {elseif $seckill.status_no eq "2"}  
    112.   
    113.                     {$lang.settle_frozen_money}  
    114.   
    115.                     <input type="submit" class="button" value="{$lang.unfreeze}" name="unfreeze" />  
    116.   
    117.                     <input type="submit" class="button" value="{$lang.deduct}" name="deduct" />  
    118.   
    119.                     <input type="hidden" name="act" value="settle_money" />  
    120.   
    121.                     {/if}  
    122.   
    123.                     <input type="hidden" name="id" value="{$seckill.act_id}" /></td>  
    124.   
    125.             </tr>  
    126.   
    127.         </table>  
    128.   
    129.     </form>  
    130.   
    131. </div>  
    132.   
    133.   
    134.   
    135. {literal}  
    136.   
    137. <script language="JavaScript">  
    138.   
    139.     <!--  
    140.   
    141.     var display_yes = (Browser.isIE) ? 'block' : 'table-row-group';  
    142.   
    143.   
    144.   
    145.     onload = function()  
    146.   
    147.     {  
    148.   
    149.         // 开始检查订单  
    150.   
    151.         startCheckOrder();  
    152.   
    153.     }  
    154.   
    155.     /**  
    156.   
    157.      * 检查表单输入的数据  
    158.   
    159.      */  
    160.   
    161.     function validate()  
    162.   
    163.     {  
    164.   
    165.         validator = new Validator("theForm");  
    166.   
    167.         validator.isNumber('start_price', start_price_not_number, false);  
    168.   
    169.         validator.isNumber('end_price', end_price_not_number, false);  
    170.   
    171.   
    172.   
    173.         if (document.forms['theForm'].elements['no_top'].checked == false)  
    174.   
    175.         {  
    176.   
    177.             validator.gt('end_price''start_price', end_gt_start);  
    178.   
    179.         }  
    180.   
    181.         validator.isNumber('amplitude', amplitude_not_number, false);  
    182.   
    183.         validator.isNumber('deposit', deposit_not_number, false);  
    184.   
    185.         validator.islt('start_time''end_time', start_lt_end);  
    186.   
    187.         return validator.passed();  
    188.   
    189.     }  
    190.   
    191.     function checked_no_top(o)  
    192.   
    193.     {  
    194.   
    195.         if (o.checked)  
    196.   
    197.         {  
    198.   
    199.             o.form.elements['end_price'].value = '';  
    200.   
    201.             o.form.elements['end_price'].disabled = true;  
    202.   
    203.         }  
    204.   
    205.         else  
    206.   
    207.         {  
    208.   
    209.             o.form.elements['end_price'].disabled = false;  
    210.   
    211.         }  
    212.   
    213.     }  
    214.   
    215.     function searchGoods()  
    216.   
    217.     {  
    218.   
    219.         var filter = new Object;  
    220.   
    221.         filter.keyword  = document.forms['theForm'].elements['keyword'].value;  
    222.   
    223.   
    224.   
    225.         Ajax.call('auction.php?is_ajax=1&act=search_goods', filter, searchGoodsResponse, 'GET''JSON');  
    226.   
    227.     }  
    228.   
    229.   
    230.   
    231.     function searchGoodsResponse(result)  
    232.   
    233.     {  
    234.   
    235.         if (result.error == '1' && result.message != '')  
    236.   
    237.         {  
    238.   
    239.             alert(result.message);  
    240.   
    241.             return;  
    242.   
    243.         }  
    244.   
    245.   
    246.   
    247.         var frm = document.forms['theForm'];  
    248.   
    249.         var sel = frm.elements['goods_id'];  
    250.   
    251.         var sp = frm.elements['product_id'];  
    252.   
    253.   
    254.   
    255.         if (result.error == 0)  
    256.   
    257.         {  
    258.   
    259.             /* 清除 options */  
    260.   
    261.             sel.length = 0;  
    262.   
    263.             sp.length = 0;  
    264.   
    265.   
    266.   
    267.             /* 创建 options */  
    268.   
    269.             var goods = result.content.goods;  
    270.   
    271.             if (goods)  
    272.   
    273.             {  
    274.   
    275.                 for (i = 0; i < goods.length; i++)  
    276.   
    277.                 {  
    278.   
    279.                     var opt = document.createElement("OPTION");  
    280.   
    281.                     opt.value = goods[i].goods_id;  
    282.   
    283.                     opt.text  = goods[i].goods_name;  
    284.   
    285.                     sel.options.add(opt);  
    286.   
    287.                 }  
    288.   
    289.             }  
    290.   
    291.             else  
    292.   
    293.             {  
    294.   
    295.                 var opt = document.createElement("OPTION");  
    296.   
    297.                 opt.value = 0;  
    298.   
    299.                 opt.text  = search_is_null;  
    300.   
    301.                 sel.options.add(opt);  
    302.   
    303.             }  
    304.   
    305.   
    306.   
    307.             /* 创建 product options */  
    308.   
    309.             var products = result.content.products;  
    310.   
    311.             if (products)  
    312.   
    313.             {  
    314.   
    315.                 sp.style.display = display_yes;  
    316.   
    317.   
    318.   
    319.                 for (i = 0; i < products.length; i++)  
    320.   
    321.                 {  
    322.   
    323.                     var p_opt = document.createElement("OPTION");  
    324.   
    325.                     p_opt.value = products[i].product_id;  
    326.   
    327.                     p_opt.text  = products[i].goods_attr_str;  
    328.   
    329.                     sp.options.add(p_opt);  
    330.   
    331.                 }  
    332.   
    333.             }  
    334.   
    335.             else  
    336.   
    337.             {  
    338.   
    339.                 sp.style.display = 'none';  
    340.   
    341.   
    342.   
    343.                 var p_opt = document.createElement("OPTION");  
    344.   
    345.                 p_opt.value = 0;  
    346.   
    347.                 p_opt.text  = search_is_null;  
    348.   
    349.                 sp.options.add(p_opt);  
    350.   
    351.             }  
    352.   
    353.         }  
    354.   
    355.   
    356.   
    357.         return;  
    358.   
    359.     }  
    360.   
    361.   
    362.   
    363.     function change_good_products()  
    364.   
    365.     {  
    366.   
    367.         var filter = new Object;  
    368.   
    369.         filter.goods_id = document.forms['theForm'].elements['goods_id'].value;  
    370.   
    371.   
    372.   
    373.         Ajax.call('snatch.php?is_ajax=1&act=search_products', filter, searchProductsResponse, 'GET''JSON');  
    374.   
    375.     }  
    376.   
    377.   
    378.   
    379.     function searchProductsResponse(result)  
    380.   
    381.     {  
    382.   
    383.         var frm = document.forms['theForm'];  
    384.   
    385.         var sp = frm.elements['product_id'];  
    386.   
    387.   
    388.   
    389.         if (result.error == 0)  
    390.   
    391.         {  
    392.   
    393.             /* 清除 options */  
    394.   
    395.             sp.length = 0;  
    396.   
    397.   
    398.   
    399.             /* 创建 product options */  
    400.   
    401.             var products = result.content.products;  
    402.   
    403.             if (products.length)  
    404.   
    405.             {  
    406.   
    407.                 sp.style.display = display_yes;  
    408.   
    409.   
    410.   
    411.                 for (i = 0; i < products.length; i++)  
    412.   
    413.                 {  
    414.   
    415.                     var p_opt = document.createElement("OPTION");  
    416.   
    417.                     p_opt.value = products[i].product_id;  
    418.   
    419.                     p_opt.text  = products[i].goods_attr_str;  
    420.   
    421.                     sp.options.add(p_opt);  
    422.   
    423.                 }  
    424.   
    425.             }  
    426.   
    427.             else  
    428.   
    429.             {  
    430.   
    431.                 sp.style.display = 'none';  
    432.   
    433.   
    434.   
    435.                 var p_opt = document.createElement("OPTION");  
    436.   
    437.                 p_opt.value = 0;  
    438.   
    439.                 p_opt.text  = search_is_null;  
    440.   
    441.                 sp.options.add(p_opt);  
    442.   
    443.             }  
    444.   
    445.         }  
    446.   
    447.   
    448.   
    449.         if (result.message.length > 0)  
    450.   
    451.         {  
    452.   
    453.             alert(result.message);  
    454.   
    455.         }  
    456.   
    457.     }  
    458.   
    459.     //-->  
    460.   
    461. </script>  
    462.   
    463. {/literal}  
    464.   
    465. {include file="pagefooter.htm"}  

    7.在这里后台秒杀正式完成

    显示结果:
























  • 相关阅读:
    光脚丫学LINQ(025):如何验证DBML和外部映射文件
    使用LINQ to SQL将数据从一个数据库复制到另一个数据库
    用VS2010 C#写DLL文件并且调用(原创)
    linux初识
    Run Only One Copy Of Application
    SQL Server 2008开启远程连接
    用Visual C#做DLL文件
    SQL Server代理服务无法启动的处理方法(转载)
    QTP连接Oracle
    What's AJAX?
  • 原文地址:https://www.cnblogs.com/hehe520/p/6147483.html
Copyright © 2011-2022 走看看