rulesDetail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view class="container">
  3. <!-- 顶部搜索框区域 -->
  4. <view class="search">
  5. <uni-search-bar bgColor="#fff" placeholder="请输入名字或院系" cancelButton="none" v-model="searchValue" @input="input"
  6. @clear="clear" @blur="blur">
  7. </uni-search-bar>
  8. </view>
  9. <view class="list">
  10. <!-- 分段器区域 -->
  11. <view class="control">
  12. <uni-segmented-control :current="current" :values="items" styleType="text" @clickItem="onClickItem"
  13. activeColor="#0082FC"></uni-segmented-control>
  14. </view>
  15. <!-- 列表区域 -->
  16. <view class="listbox">
  17. <!-- 每一个盒子区域 -->
  18. <view class="item" v-for="item in list" :key="item.id">
  19. <view class="left">
  20. <img :src="item.url">
  21. </view>
  22. <view class="center">
  23. <view class="name">
  24. {{item.name}}
  25. </view>
  26. <view class="college">
  27. {{item.college}}
  28. </view>
  29. </view>
  30. <view class="right">
  31. {{item.status==1?"正常":"缺卡"}}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. searchValue: "",
  43. items: ['打卡成功(50/150人)', '打卡失败(28/150人)'],
  44. current: 0,
  45. list: [],
  46. list2: [{
  47. id: 1,
  48. url: "../../static/ceshi.jpg",
  49. name: "张三",
  50. college: "文法学院",
  51. status: 1
  52. },
  53. {
  54. id: 2,
  55. url: "../../static/ceshi.jpg",
  56. name: "李四",
  57. college: "文法学院",
  58. status: 1
  59. },
  60. {
  61. id: 3,
  62. url: "../../static/ceshi.jpg",
  63. name: "王五",
  64. college: "文法学院",
  65. status: 1
  66. },
  67. ],
  68. list3: [{
  69. id: 1,
  70. url: "../../static/ceshi.jpg",
  71. name: "伍六七",
  72. college: "文法学院",
  73. status: 2
  74. },
  75. {
  76. id: 2,
  77. url: "../../static/ceshi.jpg",
  78. name: "喜羊羊",
  79. college: "文法学院",
  80. status: 2
  81. },
  82. {
  83. id: 3,
  84. url: "../../static/ceshi.jpg",
  85. name: "灰太狼",
  86. college: "文法学院",
  87. status: 2
  88. },
  89. ]
  90. }
  91. },
  92. onLoad(options) {
  93. this.list = this.list2
  94. },
  95. methods: {
  96. onClickItem(e) {
  97. console.log(e.currentIndex);
  98. if (e.currentIndex == 0) {
  99. this.list = this.list2
  100. } else {
  101. this.list = this.list3
  102. }
  103. },
  104. // 搜索框失焦回调
  105. blur(res) {
  106. uni.showToast({
  107. title: '搜索:' + res.value,
  108. icon: 'none'
  109. })
  110. },
  111. // 搜索框输入时的回调
  112. input(res) {
  113. console.log('----input:', res)
  114. },
  115. // 清除搜索框内容时的回调
  116. clear(res) {
  117. uni.showToast({
  118. title: 'clear事件,清除值为:' + res.value,
  119. icon: 'none'
  120. })
  121. },
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .container {
  127. padding-top: 20rpx;
  128. .search {
  129. width: 750rpx;
  130. height: 90rpx;
  131. border-radius: 171rpx;
  132. background-color: #fff;
  133. }
  134. .list {
  135. margin-top: 20rpx;
  136. width: 750rpx;
  137. background-color: #fff;
  138. .control {
  139. display: flex;
  140. flex-direction: column;
  141. justify-content: center;
  142. width: 750rpx;
  143. height: 102rpx;
  144. }
  145. .listbox {
  146. .item {
  147. display: flex;
  148. align-items: center;
  149. margin: 0 30rpx;
  150. height: 114rpx;
  151. border-bottom: 1rpx solid #E5E5E5;
  152. background-color: #fff;
  153. .left {
  154. flex: 1;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. img {
  159. width: 70rpx;
  160. height: 70rpx;
  161. border-radius: 35rpx;
  162. }
  163. }
  164. .center {
  165. flex: 5;
  166. display: flex;
  167. flex-direction: column;
  168. justify-content: space-evenly;
  169. margin-left: 10rpx;
  170. height: 90rpx;
  171. .name {
  172. font-size: 28rpx;
  173. }
  174. .college {
  175. font-size: 24rpx;
  176. color: #808080;
  177. }
  178. }
  179. .right {
  180. flex: 1;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. font-size: 28rpx;
  185. }
  186. }
  187. }
  188. }
  189. }
  190. // 解决输入框不居中问题
  191. ::v-deep .uni-searchbar {
  192. padding: 10rpx;
  193. }
  194. </style>