设置背景颜色就直接在page里设置    page {background-color: rgb(242, 242, 242);}

tab切换:

navigator 页面链接

传参的格式为url="路径?title={{item.title}}"   多个用&&连接

下个页面接收参数:

wxml:

<view class="container">
<view class="swiper-tab">
<view class="swiper-tab-list {{currentTab==0 ? 'on' : ''}}" data-current="0" bindtap="swichNav">进行中</view>
<view class="swiper-tab-list {{currentTab==1 ? 'on' : ''}}" data-current="1" bindtap="swichNav">已完成</view>
</view>
<swiper current="{{currentTab}}" class="swiper-box" duration="800" style="height:{{winHeight - 71}}px" bindchange="bindChange"> <!-- 朴智妍一 -->
<swiper-item>
<view class="content" wx:for="{{loadingList}}" wx:key="id" >
<navigator bindtap="bindIndexId" data-index-id="{{item.id}}" url="../..?act_name={{item.act_name}}&&pro_name={{item.pro_name}}">
<image src="{{item.act_pic}}"></image>
<view class="txt1">{{item.act_name}}</view>
<view>{{item.pro_name}}</view>
</navigator>
</view>
<view class="hb" bindtap="addProject">
<image src="../Image/addT.png" style="width:30rpx;height:30rpx;float:left;margin-top:3rpx;margin-right:16rpx;"></image>
<view class="text2">添加项目</view>
</view>
</swiper-item>
</swiper>
</view>

wxss:

page {
background-color: rgb(242, 242, 242); /*设置背景颜色就直接在page里设置*/
} .container {
width: 100%;
} .swiper-tab {
width: 84%;
text-align: center;
line-height: 60rpx;
margin-top: 40rpx;
margin-bottom: 20rpx;
border: 2rpx solid #1c7bf3;
border-radius: 6rpx;
} .swiper-tab-list {
font-size: 28rpx;
display: inline-block;
width: 50%;
float: left;
color: #1c7bf3;
} .on {
color: #fff;
background-color: #1c7bf3;
box-shadow: 0 0 20rpx #d1e5fd;
} .swiper-box {
display: block;
height: 100%;
width: 100%;
overflow: hidden;
} image {
width: 140rpx;
height: 140rpx;
display: inline-block;
overflow: hidden;
border-radius: 100%;
float: left;
margin-top: 36rpx;
margin-left: 26rpx;
margin-right: 30rpx;
} .content {
width: 94%;
height: 220rpx;
box-shadow: 0 0 20rpx #bbb;
margin: auto;
margin-top: 22rpx;
line-height: 220rpx;
font-size: 32rpx;
margin-left: 3%;
background: #fff;
border-radius: 8rpx;
} .content>view {
float: left;
} .txt1 {
color: #ff5438;
} .hb {
text-align: center;
margin-top:70rpx;
font-size: 28rpx;
width: 100%;
margin-left:36%;
} .text2 {
color: #bbb;
float: left;
} view {
display: inline-block;
}

js:

/*获取系统信息*/
wx.getSystemInfo({
success: function (res) {
that.setData({
winWidth: res.windowWidth,
winHeight: res.windowHeight
});
}
})
}, /** 滑动切换tab **/
bindChange: function (e) {
var that = this;
that.setData({ currentTab: e.detail.current }); },
/** 点击tab切换 **/
swichNav: function (e) {
var that = this;
if (this.data.currentTab === e.target.dataset.current) {
return false;
} else {
that.setData({
currentTab: e.target.dataset.current
})
}
},
var app = getApp()
Page({
data: {
winWidth: 0, /* 页面配置*/
winHeight: 0,
currentTab: 0, // tab切换
oneList: [{ //遍历数组,前台需要请求遍历的参数
id: '',
act_pic:'',
act_name: '',
pro_name: '',
}],
},
//获取点击的产品ID,并保存在本地缓存 (进行中)
bindIndexId: function (e) {
var indexId = e.currentTarget.dataset.indexId
wx.setStorageSync('indexId', indexId)
},
onLoad: function () {
var that = this;
var tokend = wx.getStorageSync('tokend') //取token
//刷新页面后得到进行中的数据
wx.request({
method: 'GET',
url: 'https://....?token=' + tokend,
header: {'content-type': 'application/json'},
data: {},
success: function (res) { // success
console.log(res)
that.setData({ //将后台数值与前台数组匹配(集合)
loadingList: res.data.data
})
}
});

微信小程序--问题汇总及详解之tab切换的更多相关文章

  1. 微信小程序--问题汇总及详解之form表单

    附上微信小程序开发文档链接:https://mp.weixin.qq.com/debug/wxadoc/dev/framework/MINA.html form表单: 当点击 <form/> ...

  2. 微信小程序--问题汇总及详解之图片上传和地图

    地图用的是百度的地图,链接:http://lbsyun.baidu.com/index.php?title=wxjsapi/guide/getlocation 获取日期时间可以用小程序里自带的js文件 ...

  3. 微信小程序--问题汇总及详解之清空电话号码

    wxml: <view class="btns" wx:for="{{phoneList}}" wx:key="id"> < ...

  4. 微信小程序--问题汇总及详解之picker 增、删

    <block wx:for="{{salesList}}" wx:for-index="index" wx:key="id" wx:f ...

  5. 微信小程序 this和that详解及简单实例

    微信小程序中,在wx.request({});方法调用成功或者失败之后,有时候会需要获取页面初始化数据data的情况,这个时候,如果使用,this.data来获取,会出现获取不到的情况,调试页面也会报 ...

  6. 微信小程序获取用户手机号详解

    最近在做一款微信小程序,需要获取用户手机号,具体步骤如下: 流程图: 1.首先,客户端调用wx.login,回调数据了包含jscode,用于获取openid(用户唯一标识)和sessionkey(会话 ...

  7. 【微信小程序】支付过程详解

    一.介绍 今天跟大家分享微信小程序集成支付. 二.分析 1.小程序支付API 地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-pay.html ...

  8. 微信小程序支付之代码详解

    微信小程序自带的一套规则,类似vue语法,但是好多功能都集成在api中,给了很多初学者轮子,所以首先要熟悉这些api,忘记可照官网继续开发 这里主要说下微信小程序的支付,原理类似上篇介绍的公众网页支付 ...

  9. 微信小程序项目wx-store代码详解

    这篇文章会很长,非常长,特别长,无敌长. 真的是挤牙膏般的项目进度,差不多是8月底有开始这个项目的想法,时至今日都1个多月了,抛去频繁的加班时间,王者时间,羽毛球时间...见缝插针的写这个项目,我竟然 ...

随机推荐

  1. java Vamei快速教程13 String类

    作者:Vamei 出处:http://www.cnblogs.com/vamei 欢迎转载,也请保留这段声明.谢谢! 之前的Java基础系列中讨论了Java最核心的概念,特别是面向对象的基础.在Jav ...

  2. 前台使用load一个集合后台接受的方法

    前台: var imageCaseList = []; }; imageCaseList.push(data); $('#showData').load(url, { querys: imageCas ...

  3. SpringMVC+Hibernate框架快速搭建

    1.  新建Maven项目springmvc 2.   pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" ...

  4. Jmeter模拟http请求

    一.获取用户信息(GET请求):http://hostname/getuser?userid=1 1.打开jmeter,创建一个线程组,再添加一个http请求Sampler 2.设置域名.路径.请求方 ...

  5. python之列表推导、迭代器、生成器

    http://blog.chinaunix.net/uid-26722078-id-3484197.html 1.列表推导 看几个例子,一切就明白了. #!/usr/bin/python number ...

  6. 2017年9月22日作业 c++算术运算符 自增 自减 逻辑运算符 位运算符 条件运算符(三元运算符)

    作业1: c++算术运算符试题,分析下面程序的输出结果是什么 //第一个: int x=8999;int value=x*1000/1000; //第二个 int x=8999;int value=x ...

  7. 对于新能源Can数据、电池BMS等字节和比特位的解析

    1.对于1个字节(8个bit)以上的数据需要先进行倒序(因为高位在前 低位在后). CanID CanData 排序后的 字节数据 十进制 分辨率(0.005) 偏移量(40) 0x18FEC117 ...

  8. http 实战练习

    http 实战练习 建立httpd服务器,要求提供两个基于名称的虚拟主机: (1)www.X.com,页面文件目录为/web/vhosts/x:错误日志为/var/log/httpd/x.err,访问 ...

  9. nginx安装与部署

    1:安装工具包 wget.vim和gcc yum install -y wget yum install -y vim-enhanced yum install -y make cmake gcc g ...

  10. 二十三、MySQL 事务

    MySQL 事务 MySQL 事务主要用于处理操作量大,复杂度高的数据.比如说,在人员管理系统中,你删除一个人员,你即需要删除人员的基本资料,也要删除和该人员相关的信息,如信箱,文章等等,这样,这些数 ...