search.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view :style="{height:statusBarHeight + 'px'}"></view>
  5. <view class="navbar">
  6. <view class="left" @click="click_left()">
  7. <uni-icons type="arrowleft" color="#fff" size="18"></uni-icons>
  8. </view>
  9. <view class="right">
  10. <view class="input_box">
  11. <view class="input_icon"></view>
  12. <view class="input_text">
  13. <input type="text" v-model="search_text" placeholder="搜索井下人员"
  14. placeholder-style="color:#fff;" />
  15. </view>
  16. </view>
  17. </view>
  18. <view class="btn" @click="search()">搜索</view>
  19. </view>
  20. </view>
  21. <!-- 占位符 -->
  22. <view :style="{height: statusBarHeight + 'px'}"></view>
  23. <view style="height: 93rpx;"></view>
  24. <!-- 搜索列表 -->
  25. <view class="list">
  26. <view class="item" v-for="(item,index) in list" :key="index" v-if="index < 100" @click="open(item.people_id)">
  27. <view class="avatar" :style="{backgroundColor:bgColor[index]}">{{item.remark.split('').pop()}}</view>
  28. <view class="info">
  29. <view class="name">{{item.remark}}</view>
  30. <view class="dept">{{item.dept_name}}</view>
  31. </view>
  32. <view class="position">({{item.position}})</view>
  33. </view>
  34. </view>
  35. <uni-popup ref="popup" type="center">
  36. <view class="popup_box">
  37. <view class="item">定位信息</view>
  38. <view class="item">
  39. <view class="text">姓名:</view>
  40. <view class="text">{{info.name}}</view>
  41. </view>
  42. <view class="item">
  43. <view class="text">所属区队:</view>
  44. <view class="text">{{info.depart_name}}</view>
  45. </view>
  46. <view class="item">
  47. <view class="text">下井时间:</view>
  48. <view class="text">{{info.down_time}}</view>
  49. </view>
  50. <view class="item">
  51. <view class="text">当前位置:</view>
  52. <view class="text">{{info.station_name}}</view>
  53. </view>
  54. <view class="item">
  55. <view class="text">班次:</view>
  56. <view class="text">{{info.classes}}</view>
  57. </view>
  58. </view>
  59. </uni-popup>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. statusBarHeight: 20,
  67. // 搜索关键词
  68. search_text: "",
  69. // 头像随机色
  70. bgColor:[],
  71. list:[],
  72. mine:"",
  73. // 定位信息
  74. info:{}
  75. };
  76. },
  77. onLoad(option) {
  78. this.mine = option.mine
  79. // 获取手机系统信息
  80. const info = uni.getSystemInfoSync()
  81. // 设置状态栏高度
  82. this.statusBarHeight = info.statusBarHeight
  83. // 设置头像
  84. for(let i=0;i<100;i++){
  85. // 获取随机色
  86. let r = parseInt(Math.random() * 256)
  87. let g = parseInt(Math.random() * 256)
  88. let b = parseInt(Math.random() * 256)
  89. // ES6 字符串拼接
  90. // this.bgColor = `rgba(${r},${g},${b},0.3)`
  91. let color = "rgba(" + r + "," + g + "," + b + "," + 0.3 + ")"
  92. // console.log(color)
  93. this.bgColor.push(color)
  94. }
  95. },
  96. methods: {
  97. click_left() {
  98. uni.navigateBack();
  99. },
  100. search() {
  101. uni.showLoading()
  102. // console.log(this.search_text)
  103. this.$p_api.personnel_people_search({
  104. name:this.search_text,
  105. mine:this.mine
  106. }).then((res)=>{
  107. console.log(res)
  108. uni.hideLoading()
  109. this.list = res.data.data
  110. })
  111. },
  112. open(people_id) {
  113. console.log(people_id)
  114. // 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ,type 属性将失效 ,仅支持 ['top','left','bottom','right','center']
  115. this.$refs.popup.open('center')
  116. this.$p_api.personnel_people_info({
  117. people_id:people_id
  118. }).then((res)=>{
  119. console.log(res.data.data)
  120. this.info = res.data.data
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss">
  127. .content {
  128. position: fixed;
  129. top: 0;
  130. left: 0;
  131. background-color: #009FE8;
  132. z-index: 999;
  133. }
  134. .navbar {
  135. width: 750rpx;
  136. box-sizing: border-box;
  137. padding-left: 31rpx;
  138. padding-right: 26rpx;
  139. padding-top: 14rpx;
  140. padding-bottom: 14rpx;
  141. display: flex;
  142. // justify-content: space-between;
  143. .left {
  144. width: 42rpx;
  145. line-height: 65rpx;
  146. margin-right: 15rpx;
  147. }
  148. .right {
  149. width: 500rpx;
  150. height: 65rpx;
  151. background: rgba(255, 255, 255, 0.2);
  152. border-radius: 33rpx;
  153. .input_box {
  154. display: flex;
  155. .input_icon {
  156. margin-left: 43rpx;
  157. margin-top: 16rpx;
  158. width: 34rpx;
  159. height: 34rpx;
  160. background-image: url(icon/search.png);
  161. background-size: cover;
  162. background-repeat: no-repeat;
  163. }
  164. .input_text {
  165. margin-left: 19rpx;
  166. font-size: 24rpx;
  167. font-family: PingFangSC-Regular, PingFang SC;
  168. font-weight: 400;
  169. color: #FFFFFF;
  170. line-height: 65rpx;
  171. input {
  172. font-size: 24rpx;
  173. height: 65rpx;
  174. line-height: 65rpx;
  175. }
  176. }
  177. }
  178. }
  179. .btn {
  180. margin-left: 20rpx;
  181. width: 120rpx;
  182. text-align: center;
  183. height: 65rpx;
  184. line-height: 65rpx;
  185. background: rgba(255, 255, 255, 0.2);
  186. border-radius: 33rpx;
  187. font-size: 24rpx;
  188. font-family: PingFangSC-Regular, PingFang SC;
  189. font-weight: 400;
  190. color: #FFFFFF;
  191. }
  192. }
  193. .list {
  194. .item{
  195. height: 120rpx;
  196. display: flex;
  197. align-items: center;
  198. border-bottom: 1rpx solid #F1F1F1;
  199. box-sizing: border-box;
  200. padding: 0 25rpx;
  201. .avatar{
  202. font-size: 46rpx;
  203. width: 90rpx;
  204. height: 90rpx;
  205. text-align: center;
  206. line-height: 90rpx;
  207. color: #FFFFFF;
  208. border-radius: 50%;
  209. }
  210. .info{
  211. margin-left: 40rpx;
  212. min-width: 200rpx;
  213. font-size: 28rpx;
  214. .name{
  215. }
  216. .dept{
  217. color: #999;
  218. font-size: 24rpx;
  219. }
  220. }
  221. .position{
  222. font-size: 28rpx;
  223. }
  224. }
  225. }
  226. .popup_box{
  227. width: 600rpx;
  228. height: 600rpx;
  229. background-color: #FFFFFF;
  230. border-radius: 16rpx;
  231. .item{
  232. line-height: 100rpx;
  233. box-sizing: border-box;
  234. padding: 0rpx 20rpx;
  235. border-bottom: 2rpx solid #F1F1F1;
  236. display: flex;
  237. justify-content: space-between;
  238. align-items: center;
  239. }
  240. }
  241. </style>