微信小程序修改swiper默认指示器样式的实例代码,shell实现自动adsl拨号并检测连接状况脚本分享

今天公司同事要我整个adsl自动重拨的shell,并检测是否连上了,这样才能保证内部测试服务器不掉网,好吧,下面我把脚本发出来.

修改官方swiper样式

公司近来服务器测试,需要经常调整系统时间,一两台还好半,稍微多点,就各种纠结了,笔者这几台都把笔者快弄疯了。老大一句话:全部调快3分钟…过会又全部调慢5分钟……然后咱们干活的,各种date
01021511….你懂的.于是为了解放生产力–代码如下:

系统:centos 5.x

从微信官方微信开发文档中心复制swiper 代码块。

复制代码 代码如下:

脚本1:

wxml定义

#!/bin/bash
# Author: MOS
# Script name: etime.sh
# Date & Time: 2013-01-02/21:47:58
# Version: 1.0.1
# Description:
#
#ntpserver
Tip=’time.nist.gov’
 
# sync now system time, yes: $3=”-u”  no: $3 is none.
if [[ “$3” == “-u” ]];then
    Tcmd=’/usr/bin/rdate’
    [ ! -x $Tcmd ] && echo ‘rdate not install!!’ && exit 1
    “$Tcmd” -s “$Tip”
fi
 
# Modf
if [[ -n “$2” &&  “$1” == ‘-‘ || “$1” == ‘+’ ]];then
    Func=$1
    [[ “$3” == “-s” ]] && Num=$2 || Num=$(($2*60))
    Ntime=`date +%s`
    Ltime=$(($Ntime$Func$Num))
    #Date=`/bin/date -d @”$Ltime” 2>/dev/null`
    #echo $Ltime
    Res=`date -d “1970-01-01 UTC $Ltime seconds” +%m%d%H%M%Y.%S`
    date
    date $Res
else
    echo ‘First,input + or -;Second,input a number.’
    exit 2
fi

复制代码 代码如下:

<view class="wrap">
 <swiper class="swipers" autoplay="{{autoplay}}" current="{{currentSwiper}}" bindchange="swiperChange"> 
  <block wx:for="{{imgUrls}}"> 
   <swiper-item> 
     <image src="{{item}}" class="slide-image" width="100%" height="150" ></image> 
   </swiper-item> 
  </block> 
 </swiper> 
 <!--重置小圆点的样式 -->
 <view class="dots"> 
  <block wx:for="{{imgUrls}}"> 
   <view class="dot{{index == currentSwiper ? ' active' : ''}}"></view> 
  </block> 
 </view> 
</view>

笔者已上传到附件,下载后,先给个执行权限,然后放到系统路径:

cat /root/soft_shell/auto_adsl_1.sh
#!/bin/bash
gateway=`ifconfig ppp0 |grep P-t-P| cut -f 3 -d “:”|cut -f 1 -d ” “`
inter=`ifconfig |grep ppp0|awk ‘{print $1}’`
N=2
if [[ $inter -eq ppp0 ]]
then
/sbin/adsl-stop
sleep 10
/sbin/adsl-start
sleep 20
pkgloss=`ping -c4 $gateway|grep ‘transm’ |awk -F’,’ ‘{print $2}’ |awk
‘{print $1}’`
if [[ $pkgloss -lt $N ]]
then
echo “`date +%Y-%m-%d/%T` The network is not
stable”>>/root/adsl.txt
else
echo “`date +%Y-%m-%d/%T` The network is
normal”>>/root/adsl.txt
fi
fi

wxss定义样式

复制代码 代码如下:

脚本2:

.wrap {
 height: auto;
 position: relative;
 width: 100%;
}
.swipers {
 height: 350rpx;
 width: 100%;
}
.slide-image {
 display: block;
 width: 100%;
 height: 100%;
}
/*用来包裹所有的小圆点 */
.dots {
 width: 156rpx;
 height: 36rpx;
 display: flex;
 flex-direction: row;
 position: absolute;
 left: 320rpx;
 bottom: 20rpx;
}
/*未选中时的小圆点样式 */
.dot {
 width: 26rpx;
 height: 26rpx;
 border-radius: 50%;
 margin-right: 26rpx;
 background-color: white;
}
/*选中以后的小圆点样式 */
.active {
 width: 26rpx;
 height: 26rpx;
 background-color: coral;
}

[root@vpn1 scripts]# ls
casetup.sh  etime.sh
[root@vpn1 scripts]# chmod +x etime.sh
[root@vpn1 scripts]# mv etime.sh /bin/etime

复制代码 代码如下:

赋值

用法格式如下:

cat /root/soft_shell/auto_adsl_2.sh
#!/bin/bash
gateway=`ifconfig ppp0 |grep P-t-P| cut -f 3 -d “:”|cut -f 1 -d ” “`
inter=`ifconfig |grep ppp0|awk ‘{print $1}’`
N=2
if [[ $inter != ppp0 ]]
then
/sbin/adsl-start
sleep 20
pkgloss=`ping -c4 $gateway|grep ‘transm’ |awk -F’,’ ‘{print $2}’ |awk
‘{print $1}’`
if [[ $pkgloss -lt $N ]]
then
echo “`date +%Y-%m-%d/%T` The network is not
stable”>>/root/adsl.txt
else
echo “`date +%Y-%m-%d/%T` The network is
normal”>>/root/adsl.txt
fi
fi

Page({
 data: {
 imgUrls: [
  'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
  'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
  'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
 ],
 currentSwiper: 0,
 autoplay: true
 },
 swiperChange: function (e) {
 this.setData({
  currentSwiper: e.detail.current
 })
 }
}) 

复制代码 代码如下:

ps:脚本2的作用就是检测adsl拨号是否有连上.

效果图:

command [+|-] number [option]

发表评论

电子邮件地址不会被公开。 必填项已用*标注

标签:
网站地图xml地图