| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <view class="container">
- <!-- 顶部搜索框区域 -->
- <view class="search">
- <uni-search-bar bgColor="#fff" placeholder="请输入名字或院系" cancelButton="none" v-model="searchValue" @input="input"
- @clear="clear" @blur="blur">
- </uni-search-bar>
- </view>
- <view class="list">
- <!-- 分段器区域 -->
- <view class="control">
- <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem"
- activeColor="#0082FC"></uni-segmented-control>
- </view>
- <!-- 列表区域 -->
- <view class="listbox">
- <!-- 每一个盒子区域 -->
- <view class="item" v-for="item in list" :key="item.id">
- <view class="left">
- <img :src="item.url">
- </view>
- <view class="center">
- <view class="name">
- {{item.name}}
- </view>
- <view class="college">
- {{item.college}}
- </view>
- </view>
- <view class="right">
- {{item.status==1?"正常":"缺卡"}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- searchValue: "",
- items: ['打卡成功(50/150人)', '打卡失败(28/150人)'],
- current: 0,
- list: [],
- list2: [{
- id: 1,
- url: "../../static/ceshi.jpg",
- name: "张三",
- college: "文法学院",
- status: 1
- },
- {
- id: 2,
- url: "../../static/ceshi.jpg",
- name: "李四",
- college: "文法学院",
- status: 1
- },
- {
- id: 3,
- url: "../../static/ceshi.jpg",
- name: "王五",
- college: "文法学院",
- status: 1
- },
- ],
- list3: [{
- id: 1,
- url: "../../static/ceshi.jpg",
- name: "伍六七",
- college: "文法学院",
- status: 2
- },
- {
- id: 2,
- url: "../../static/ceshi.jpg",
- name: "喜羊羊",
- college: "文法学院",
- status: 2
- },
- {
- id: 3,
- url: "../../static/ceshi.jpg",
- name: "灰太狼",
- college: "文法学院",
- status: 2
- },
- ]
- }
- },
- onLoad(options) {
- this.list = this.list2
- },
- methods: {
- onClickItem(e) {
- console.log(e.currentIndex);
- if (e.currentIndex == 0) {
- this.list = this.list2
- } else {
- this.list = this.list3
- }
- },
- // 搜索框失焦回调
- blur(res) {
- uni.showToast({
- title: '搜索:' + res.value,
- icon: 'none'
- })
- },
- // 搜索框输入时的回调
- input(res) {
- console.log('----input:', res)
- },
- // 清除搜索框内容时的回调
- clear(res) {
- uni.showToast({
- title: 'clear事件,清除值为:' + res.value,
- icon: 'none'
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding-top: 20rpx;
- .search {
- width: 750rpx;
- height: 90rpx;
- border-radius: 171rpx;
- background-color: #fff;
- }
- .list {
- margin-top: 20rpx;
- width: 750rpx;
- background-color: #fff;
- .control {
- display: flex;
- flex-direction: column;
- justify-content: center;
- width: 750rpx;
- height: 102rpx;
- }
- .listbox {
- .item {
- display: flex;
- align-items: center;
- margin: 0 30rpx;
- height: 114rpx;
- border-bottom: 1rpx solid #E5E5E5;
- background-color: #fff;
- .left {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- img {
- width: 70rpx;
- height: 70rpx;
- border-radius: 35rpx;
- }
- }
- .center {
- flex: 5;
- display: flex;
- flex-direction: column;
- justify-content: space-evenly;
- margin-left: 10rpx;
- height: 90rpx;
- .name {
- font-size: 28rpx;
- }
- .college {
- font-size: 24rpx;
- color: #808080;
- }
- }
- .right {
- flex: 1;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 28rpx;
- }
- }
- }
- }
- }
- // 解决输入框不居中问题
- ::v-deep .uni-searchbar {
- padding: 10rpx;
- }
- </style>
|