欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)運(yùn)動(dòng)步數(shù)排行功能(可刪除)

 更新時(shí)間:2018年07月05日 15:50:59   作者:祈澈姑娘  
這篇文章主要介紹了微信小程序?qū)崿F(xiàn)運(yùn)動(dòng)步數(shù)排行功能(可刪除),實(shí)現(xiàn)代碼也很簡(jiǎn)單,需要的朋友可以參考下

效果圖如下所示:

wxml

<!-- 向左滑動(dòng)刪除功能 -->
<view class="item-box">
 <view class="items">
  <view wx:for="{{list}}" wx:key="{{index}}" class="item">
   
   <view bindtouchstart="touchS" bindtouchmove="touchM" bindtouchend="touchE" data-index="{{index}}" style="{{item.txtStyle}}" class="inner txt">
   <i>{{item.rank}}</i>
   <image class="item-icon" mode="widthFix" src="{{item.icon}}"></image>
    <i> {{item.name}}</i>
   <span class="item-data">
  
    <i class="rankpace"> {{item.pace}}</i>
    <!-- <span class="rankxin">{{item.xin}}</span> -->
   </span>
   
   </view>
   
   <view data-index="{{index}}" bindtap = "delItem" class="inner del">刪除</view>
  </view>
 </view>
</view>

wxss

/* pages/leftSwiperDel/index.wxss */
view{
  box-sizing: border-box;
}
.item-box{
  width: 700rpx;
  margin: 0 auto;
  padding:40rpx 0;
}
.items{
  width: 100%;
}
.item{
  position: relative;
  border-top: 2rpx solid #eee;
  height: 120rpx;
  line-height: 120rpx;
  overflow: hidden;
   
}


.item:last-child{
  border-bottom: 2rpx solid #eee;
}
.inner{
  position: absolute;
  top:0;
}
.inner.txt{
  background-color: #fff;
  width: 100%;
  z-index: 5;
  padding:0 10rpx;
  transition: left 0.2s ease-in-out;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.inner.del{
  background-color: #e64340;
  width: 180rpx;text-align: center;
  z-index: 4;
  right: 0;
  color: #fff
}
.item-icon{
  width: 64rpx;
  height: 64rpx;
  vertical-align: middle;
  margin-right: 16rpx;
  margin-left:13px;
  border-radius:50%;

}

.item-data{
 float: right;
 margin-right:5%;}

.rankpace{
 color: #fa7e04;
}

js

// pages/leftSwiperDel/index.js
Page({
 data: {
  delBtnWidth: 180//刪除按鈕寬度單位(rpx)
 },
 onLoad: function (options) {
  // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
  this.initEleWidth();
  this.tempData();
 },
 onReady: function () {
  // 頁面渲染完成
 },
 onShow: function () {
  // 頁面顯示
 },
 onHide: function () {
  // 頁面隱藏
 },
 onUnload: function () {
  // 頁面關(guān)閉
 },
 touchS: function (e) {
  if (e.touches.length == 1) {
   this.setData({
    //設(shè)置觸摸起始點(diǎn)水平方向位置
    startX: e.touches[0].clientX
   });
  }
 },
 touchM: function (e) {
  if (e.touches.length == 1) {
   //手指移動(dòng)時(shí)水平方向位置
   var moveX = e.touches[0].clientX;
   //手指起始點(diǎn)位置與移動(dòng)期間的差值
   var disX = this.data.startX - moveX;
   var delBtnWidth = this.data.delBtnWidth;
   var txtStyle = "";
   if (disX == 0 || disX < 0) {//如果移動(dòng)距離小于等于0,文本層位置不變
    txtStyle = "left:0px";
   } else if (disX > 0) {//移動(dòng)距離大于0,文本層left值等于手指移動(dòng)距離
    txtStyle = "left:-" + disX + "px";
    if (disX >= delBtnWidth) {
     //控制手指移動(dòng)距離最大值為刪除按鈕的寬度
     txtStyle = "left:-" + delBtnWidth + "px";
    }
   }
   //獲取手指觸摸的是哪一項(xiàng)
   var index = e.target.dataset.index;
   var list = this.data.list;
   list[index].txtStyle = txtStyle;
   //更新列表的狀態(tài)
   this.setData({
    list: list
   });
  }
 },
 touchE: function (e) {
  if (e.changedTouches.length == 1) {
   //手指移動(dòng)結(jié)束后水平位置
   var endX = e.changedTouches[0].clientX;
   //觸摸開始與結(jié)束,手指移動(dòng)的距離
   var disX = this.data.startX - endX;
   var delBtnWidth = this.data.delBtnWidth;
   //如果距離小于刪除按鈕的1/2,不顯示刪除按鈕
   var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "px" : "left:0px";
   //獲取手指觸摸的是哪一項(xiàng)
   var index = e.target.dataset.index;
   var list = this.data.list;
   list[index].txtStyle = txtStyle;
   //更新列表的狀態(tài)
   this.setData({
    list: list
   });
  }
 },
 //獲取元素自適應(yīng)后的實(shí)際寬度
 getEleWidth: function (w) {
  var real = 0;
  try {
   var res = wx.getSystemInfoSync().windowWidth;
   var scale = (750 / 2) / (w / 2);//以寬度750px設(shè)計(jì)稿做寬度的自適應(yīng)
   // console.log(scale);
   real = Math.floor(res / scale);
   return real;
  } catch (e) {
   return false;
   // Do something when catch error
  }
 },
 initEleWidth: function () {
  var delBtnWidth = this.getEleWidth(this.data.delBtnWidth);
  this.setData({
   delBtnWidth: delBtnWidth
  });
 },
 //點(diǎn)擊刪除按鈕事件
 delItem: function (e) {
  //獲取列表中要?jiǎng)h除項(xiàng)的下標(biāo)
  var index = e.target.dataset.index;
  var list = this.data.list;
  //移除列表中下標(biāo)為index的項(xiàng)
  list.splice(index, 1);
  //更新列表的狀態(tài)
  this.setData({
   list: list
  });
 },
 //測(cè)試臨時(shí)數(shù)據(jù)
 tempData: function () {
  var list = [
   {
    rank: "1",
    txtStyle: "",
    icon: "/images/my.png",
    name: "李飛",
    pace: "23456",
   },
   {
    rank: "2",
    txtStyle: "", 
    icon: "/images/my.png",
    name: "張葉",
    pace: "23450",
   },
   {
    rank: "3",
    txtStyle: "",
    icon: "/images/my.png",
    name: "王小婷",
    pace: "22345",
   },
   {
    rank: "4",
    txtStyle: "",
    icon: "/images/my.png",
    name: "袁經(jīng)理",
    pace: "21687",
   },
   {
    rank: "5",
    txtStyle: "",
    icon: "/images/my.png",
    name: "陳雅婷",
    pace: "21680",
   },
   {
    rank: "6",
    txtStyle: "",
    icon: "/images/my.png",
    name: "許安琪",
    pace: "20890",
   },
   {
    rank: "7",
    txtStyle: "",
    icon: "/images/my.png",
    name: "里俊飛",
    pace: "20741",
   },
   {
    rank: "8",
    txtStyle: "",
    icon: "/images/my.png",
    name: "李小俊",
    pace: "19511",
   },
   {
    rank: "9",
    txtStyle: "",
    icon: "/images/my.png",
    name: "陳俊飛",
    pace: "19501",
   },]
  //
  this.setData({
   list: list
  });
 }
})

總結(jié)

以上所述是小編給大家介紹的微信小程序?qū)崿F(xiàn)運(yùn)動(dòng)步數(shù)排行功能(可刪除),希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 扒一扒JavaScript 預(yù)解釋

    扒一扒JavaScript 預(yù)解釋

    這篇文章主要介紹了JavaScript 預(yù)解釋,包含帶var關(guān)鍵字預(yù)解釋、帶function關(guān)鍵字預(yù)解釋,需要的朋友可以參考下
    2015-01-01
  • List the Codec Files on a Computer

    List the Codec Files on a Computer

    List the Codec Files on a Computer...
    2007-06-06
  • javascript秒數(shù)倒計(jì)時(shí)自動(dòng)跳轉(zhuǎn)代碼

    javascript秒數(shù)倒計(jì)時(shí)自動(dòng)跳轉(zhuǎn)代碼

    幾秒后跳轉(zhuǎn)功能,動(dòng)態(tài)生成按鈕并動(dòng)態(tài)生成8位隨機(jī)數(shù),
    2008-09-09
  • js的表單操作 簡(jiǎn)單計(jì)算器

    js的表單操作 簡(jiǎn)單計(jì)算器

    javascript寫的簡(jiǎn)單的加減乘除計(jì)算器,里面涉及到一些方法還是很實(shí)用的哦,新手不要錯(cuò)過
    2011-12-12
  • webpack -v報(bào)錯(cuò)解決方案

    webpack -v報(bào)錯(cuò)解決方案

    這篇文章主要介紹了webpack -v報(bào)錯(cuò)解決方案,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-09-09
  • 解決js下referer兼容各大瀏覽器的方法

    解決js下referer兼容各大瀏覽器的方法

    眾所周知,我們web開發(fā)人員痛恨IE瀏覽器,因?yàn)镮E不支持標(biāo)準(zhǔn),標(biāo)準(zhǔn)外的默認(rèn)行為又和其他瀏覽器經(jīng)常不一致,所以我們?cè)谧鲰?xiàng)目的時(shí)候,經(jīng)常需要專門針對(duì)IE來做些文章,當(dāng)然對(duì)于referer也不例外,今天我們就來看下如何讓referer兼容主流瀏覽器
    2014-11-11
  • JS中雙擊和單擊事件沖突的解決方法

    JS中雙擊和單擊事件沖突的解決方法

    這篇文章主要為大家詳細(xì)介紹了JS中雙擊和單擊事件沖突的解決方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • 基于SVG的web頁面圖形繪制API介紹及編程演示

    基于SVG的web頁面圖形繪制API介紹及編程演示

    SVG的全稱是可擴(kuò)展的矢量圖形跟傳統(tǒng)的Raster方式的圖形(JPG, PNG, GIF等)有很大的差別,下面與大家分享下JavaScript中SVG API編程演示,感興趣的朋友可以參考下哈
    2013-06-06
  • js window.event對(duì)象詳盡解析

    js window.event對(duì)象詳盡解析

    最近因?yàn)楣ぷ餍枰?,弄了好多天的js了,老婆一問我在弄 ajax, 一問我在弄js,她都聽得沒有一點(diǎn)興趣了,我自己感覺還好,畢竟做出來了東西就有成就感吧,這里把幾個(gè)有用但是不常見的東西貼出來供大家參考參考
    2009-02-02
  • JS與CSS3實(shí)現(xiàn)圖片響應(yīng)鼠標(biāo)移動(dòng)放大效果示例

    JS與CSS3實(shí)現(xiàn)圖片響應(yīng)鼠標(biāo)移動(dòng)放大效果示例

    這篇文章主要介紹了JS與CSS3實(shí)現(xiàn)圖片響應(yīng)鼠標(biāo)移動(dòng)放大效果,結(jié)合實(shí)例形式分析了javascript與css3響應(yīng)鼠標(biāo)事件動(dòng)態(tài)修改頁面元素屬性實(shí)現(xiàn)圖片放大效果相關(guān)操作技巧,需要的朋友可以參考下
    2018-05-05

最新評(píng)論