首页 文章 精选 留言 我的

精选列表

搜索[Swift开发],共10000篇文章
优秀的个人博客,低调大师

JavaScript表格的隔行换色开发

Html代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>隔行换色</title> </head> <body> <table id="tab1" border="1" width="800" align="center" > <tr style="background-color: #999999;" align ="center"> <th>分校ID</th> <th>分校地区</th> <th>操作</th> </tr> <tr align ="center"> <td>1</td> <td>济南分校</td> <td><a href="">修改</a>|<a href="">删除</a></td> </tr> <tr align ="center"> <td>2</td> <td>昆山分校</td> <td><a href="">修改</a>|<a href="">删除</a></td> </tr> <tr align ="center"> <td>3</td> <td>重庆分校</td> <td><a href="">修改</a>|<a href="">删除</a></td> </tr> <tr align ="center"> <td>4</td> <td>内蒙分校</td> <td><a href="">修改</a>|<a href="">删除</a></td> </tr> <tr align ="center"> <td>5</td> <td>大连分校</td> <td><a href="">修改</a>|<a href="">删除</a></td> </tr> </table> </body> </html> JavaScript代码: <script> //页面一打开就自动加载成功 window.onload=function(){ //1.通过标签名称进行获取所有的tr,存放到arr数组中去 var arr=document.getElementsByTagName("tr"); //2.判断奇偶数 添加不同的样式 遍历数组 for(var i=1;i<arr.length;i++){ //如果是偶数行 if(i%2==0){ // 偶数的某一行的样式背景颜色设置为= 亮粉色 arr[i].style.backgroundColor="lightpink"; }else{//否则是奇数行 // 奇数的某一行的样式背景颜色设置为 深天空蓝 arr[i].style.backgroundColor="deepskyblue"; } } } </script> 效果图: 作者: 杨校 出处:http://www.cnblogs.com/xiaoxiao5016 分享是快乐的,也见证了个人成长历程,文章大多都是工作经验总结以及平时学习积累,基于自身认知不足之处在所难免,也请大家指正,共同进步。 本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 如有问题, 可邮件(397583050@qq.com)咨询。

优秀的个人博客,低调大师

iOS开发之UIRefreshControl使用踩坑

问题描述 接上一个话题,实现了TabBar的点击刷新以后,开始继续写完成功能,刷新UITableView,于是考虑到iOS 10以后,UIScrollView已经有UIRefreshControl的属性了,干脆用自带的写。于是就有了如下的代码: 添加UIRefreshControl到UITableView上去 UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; refreshControl.tintColor = [UIColor grayColor]; refreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"下拉刷新"]; [refreshControl addTarget:self action:@selector(refreshTabView) forControlEvents:UIControlEventValueChanged]; self.newsTableView.refreshControl = refreshControl; 下拉刷新事件 -(void)refreshTabView { //添加一条数据 [self.newsData insertObject:[self.newsData firstObject] atIndex:0]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.newsTableView reloadData]; if ([self.newsTableView.refreshControl isRefreshing]) { [self.newsTableView.refreshControl endRefreshing]; } }); } TabBar点击事件 -(void)doubleClickTab:(NSNotification *)notification{ //这里有个坑 就是直接用NSInteger接收会有问题 数字不对 //因为上个界面传过来的时候封装成了对象,所以用NSNumber接收后再取值 NSNumber *index = notification.object; if ([index intValue] == 1) { //刷新 [self.newsTableView.refreshControl beginRefreshing]; } } 此时的效果如下,直接下拉刷新可以,但是点击TabBar不可以: 刷新异常情况.gif 分析问题 经过Google帮助,终于知道原因,因为系统自带的UIRefreshControl有两个陷阱: 调用-beginRefreshing方法不会触发UIControlEventValueChanged事件; 调用-beginRefreshing方法不会自动显示进度圈。 也就是说,只是调用-beginRefreshing方法是不管用的,那么对应的需要做两件事: 手动设置UIRefreshControl的事件; 手动设置UITableView的ContentOffset,露出进度圈。 解决问题 只需要修改上面第3步中的代码如下: -(void)doubleClickTab:(NSNotification *)notification{ //这里有个坑 就是直接用NSInteger接收会有问题 数字不对 //因为上个界面传过来的时候封装成了对象,所以用NSNumber接收后再取值 NSNumber *index = notification.object; if ([index intValue] == 1) { //刷新 //animated不要为YES,否则菊花会卡死 [self.newsTableView setContentOffset:CGPointMake(0, self.newsTableView.contentOffset.y - self.newsTableView.refreshControl.frame.size.height) animated:NO]; [self.newsTableView.refreshControl beginRefreshing]; [self.newsTableView.refreshControl sendActionsForControlEvents:UIControlEventValueChanged]; } } 最终效果: 刷新正常情况.gif

优秀的个人博客,低调大师

ecshop后台订单自动确认开发详解

image CREATE TABLE `order_auto_confirm` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_id` INT(10) UNSIGNED NOT NULL DEFAULT '0', `order_sn` VARCHAR(20) NOT NULL, `execute_time` INT(10) UNSIGNED NOT NULL DEFAULT '0', `order_status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0未确定,1已经确定', `addtime` INT(10) UNSIGNED NOT NULL DEFAULT '0', `update_time` INT(10) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE INDEX `order_id` (`order_id`), INDEX `execute_time` (`execute_time`) ) COMMENT='订单定期自动确定' COLLATE='utf8_general_ci' ENGINE=MyISAM; 一、 /admin/order.php加入以下代码: elseif($_REQUEST['act'] == 'order_cron') { $act1 = empty($_POST['act1']) ? 0 : $_POST['act1']; if(empty($act1) || !in_array($act1, array('add', 'cancel'))) make_json_response('', -1, '未知请求act1'); $order_id = intval($_POST['order_id']); $order = order_info($order_id); if(empty($order)) make_json_response('', -2, '没有此订单ID'); if($order['order_status']) make_json_response('', -3, '此订单已经确认,不用自动确认'); if($order['pay_status']) make_json_response('', -4, '此订单支付状态已经变动,无法添加任务'); if($act1 == 'add'){ $order_cron_time = empty($_POST['order_cron_time']) ? 0 : $_POST['order_cron_time']; if(empty($order_cron_time)) make_json_response('', -10, '请求的时间错误'); $sql = 'select order_id from '.$ecs->table('order_auto_confirm').' where order_id='.$order_id; $rs = $db->getRow($sql); if($rs['order_id'] == $order_id){ make_json_response('', -30, '此订单任务已经存在,不能重复添加'); } $execute_time = local_strtotime($order_cron_time); $sql = "insert into ".$ecs->table('order_auto_confirm')."(order_id, order_sn, execute_time, order_status, addtime) values(".$order_id.",'".$order['order_sn']."',".$execute_time.", 0, ".local_gettime().")"; $result = $db->query($sql); if($result){ make_json_response('', 0, ''); } make_json_response('', -9, '添加任务计划失败'); }elseif($act1 == 'cancel'){ $sql = 'delete from '.$ecs->table('order_auto_confirm').' where order_id='.$order_id.' and order_status=0 '; $db->query($sql); make_json_response('', 0, ''); } } 二、 在elseif($_REQUEST['act'] == 'info')里加入: //取自动确定订单信息 $sql = 'select order_status, execute_time, addtime, update_time from '.$ecs->table('order_auto_confirm').' where order_id='.$order['order_id']; $cron= $db->getRow($sql); if(!empty($cron)){ if($cron['order_status'] == 1) $cron['update_time'] = sprintf($_LANG['order_auto_croned'], local_date('Y-m-d H:i:s', $cron['update_time'])); else $cron['execute_time']= sprintf($_LANG['order_auto_cron'], local_date('Y-m-d H:i:s', $cron['execute_time'])); } $smarty->assign('cron', $cron); 三、 /includes/modules/cron/order_auto_confirm.php if (!defined('IN_ECS')) { die('Hacking attempt'); } require_once(ROOT_PATH . 'includes/lib_order.php'); $cron_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/cron/order_auto_confirm.php'; if (file_exists($cron_lang)) { global $_LANG; include_once($cron_lang); }/* 模块的基本信息 */ if (isset($set_modules) && $set_modules == TRUE) { $i = isset($modules) ? count($modules) : 0; /* 代码 */ $modules[$i]['code'] = basename(__FILE__, '.php'); /* 描述对应的语言项 */ $modules[$i]['desc'] = 'order_auto_confirm_desc'; /* 作者 */ $modules[$i]['author'] = 'wjzhhr'; /* 网址 */ $modules[$i]['website'] = 'http://www.wodeqingchun.com'; /* 版本号 */ $modules[$i]['version'] = '1.0.0'; /* 配置信息 */ $modules[$i]['config'] = array( array('name' => 'order_auto_confirm_count', 'type' => 'select', 'value' => '10'), ); return; } $time = gmtime(); //$time = local_gettime(); $limit = empty($cron['order_auto_confirm_count']) ? 5 : $cron['order_auto_confirm_count']; $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('order_auto_confirm') . " WHERE execute_time <= ".$time." and order_status=0 LIMIT $limit"; $autodb= $db->getAll($sql); $i = 0; foreach ($autodb as $key => $val) { $order_id = $val['order_id']; $order_sn = $val['order_sn']; /* 标记订单为已确认 */ $update_status = update_order($order_id, array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime())); update_order_amount($order_id); /* 记录log */ $action_note = "计划任务:定期自动确定订单,订单号:".$order_sn.",执行状态:".($update_status ? '成功' : '失败'); order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, PS_UNPAYED, $action_note, 'system_cron'); /* 如果原来状态不是“未确认”,且使用库存,且下订单时减库存,则减少库存 */ if ($val['order_status'] != OS_UNCONFIRMED && $_CFG['use_storage'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE) { change_order_goods_storage($order_id, true, SDT_PLACE); } if($update_status) { $i += 1; $sql = "update " . $GLOBALS['ecs']->table('order_auto_confirm') . " set order_status=1, update_time=".$time." where order_id=".$order_id; $db->query($sql); } }$string = '此次共更新:'.$i.'条数据'; echo $string;file_put_contents('./a.txt', $time . '----' . date('Y-m-d H:i:s').$string."\r\n", FILE_APPEND); /** * 更新订单总金额 * @param int $order_id 订单id * @return bool //zuimoban.com */ function update_order_amount($order_id) { include_once(ROOT_PATH . 'includes/lib_order.php'); //更新订单总金额 $sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_amount = " . order_due_field() . " WHERE order_id = '$order_id' LIMIT 1"; return $GLOBALS['db']->query($sql); } ?> 四、 /languages/zh_cn/admin/order.php里加入: // $_LANG['order_auto_croned'] = '此订单于 %s 已被确认'; $_LANG['order_auto_cron'] = '此订单于 %s 进行定时确认'; $_LANG['order_auto'] = '将此订单加入自动定时确认'; $_LANG['order_auto_time'] = '自动确认时间:'; 五、 /admin/themes/order_info.htm在:{$lang.base_info}后面加入: image 在此页面的JS里面加入: function order_cron(order_id, act){ var order_cron_time = 0; if(act == 'add'){ order_cron_time = document.getElementById('order_cron_time').value; if(!order_cron_time){ alert('无法获取时间'); return false; } } Ajax.call('order.php?act=order_cron', 'order_id=' + order_id + '&act1=' + act + '&order_cron_time=' + order_cron_time, order_cron_response, 'POST', 'JSON');}function order_cron_response(res){ if (res.error == 0) { alert('保存成功'); } else { alert(res.message); } return false;} 还有/themes/default/footer.dwt里是否含有:{insert name='query_info'} 这一句,比较重要,前人把这句去掉了,害最模板到处找原因。共涉及5个文件,两个新添加的 我只是个搬运工。侵删。原文:httpwww.ktshou.comportal.phpmod=view&aid=121

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码