search.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. mine:this.mine,
  118. people_id:people_id
  119. }).then((res)=>{
  120. console.log(res.data.data)
  121. this.info = res.data.data
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. .content {
  129. position: fixed;
  130. top: 0;
  131. left: 0;
  132. background-color: #009FE8;
  133. z-index: 999;
  134. }
  135. .navbar {
  136. width: 750rpx;
  137. box-sizing: border-box;
  138. padding-left: 31rpx;
  139. padding-right: 26rpx;
  140. padding-top: 14rpx;
  141. padding-bottom: 14rpx;
  142. display: flex;
  143. // justify-content: space-between;
  144. .left {
  145. width: 42rpx;
  146. line-height: 65rpx;
  147. margin-right: 15rpx;
  148. }
  149. .right {
  150. width: 500rpx;
  151. height: 65rpx;
  152. background: rgba(255, 255, 255, 0.2);
  153. border-radius: 33rpx;
  154. .input_box {
  155. display: flex;
  156. .input_icon {
  157. margin-left: 43rpx;
  158. margin-top: 16rpx;
  159. width: 34rpx;
  160. height: 34rpx;
  161. background-image: url(icon/search.png);
  162. background-size: cover;
  163. background-repeat: no-repeat;
  164. }
  165. .input_text {
  166. margin-left: 19rpx;
  167. font-size: 24rpx;
  168. font-family: PingFangSC-Regular, PingFang SC;
  169. font-weight: 400;
  170. color: #FFFFFF;
  171. line-height: 65rpx;
  172. input {
  173. font-size: 24rpx;
  174. height: 65rpx;
  175. line-height: 65rpx;
  176. }
  177. }
  178. }
  179. }
  180. .btn {
  181. margin-left: 20rpx;
  182. width: 120rpx;
  183. text-align: center;
  184. height: 65rpx;
  185. line-height: 65rpx;
  186. background: rgba(255, 255, 255, 0.2);
  187. border-radius: 33rpx;
  188. font-size: 24rpx;
  189. font-family: PingFangSC-Regular, PingFang SC;
  190. font-weight: 400;
  191. color: #FFFFFF;
  192. }
  193. }
  194. .list {
  195. .item{
  196. height: 120rpx;
  197. display: flex;
  198. align-items: center;
  199. border-bottom: 1rpx solid #F1F1F1;
  200. box-sizing: border-box;
  201. padding: 0 25rpx;
  202. .avatar{
  203. font-size: 46rpx;
  204. width: 90rpx;
  205. height: 90rpx;
  206. text-align: center;
  207. line-height: 90rpx;
  208. color: #FFFFFF;
  209. border-radius: 50%;
  210. }
  211. .info{
  212. margin-left: 40rpx;
  213. min-width: 200rpx;
  214. font-size: 28rpx;
  215. .name{
  216. }
  217. .dept{
  218. color: #999;
  219. font-size: 24rpx;
  220. }
  221. }
  222. .position{
  223. font-size: 28rpx;
  224. }
  225. }
  226. }
  227. .popup_box{
  228. width: 600rpx;
  229. height: 600rpx;
  230. background-color: #FFFFFF;
  231. border-radius: 16rpx;
  232. .item{
  233. line-height: 100rpx;
  234. box-sizing: border-box;
  235. padding: 0rpx 20rpx;
  236. border-bottom: 2rpx solid #F1F1F1;
  237. display: flex;
  238. justify-content: space-between;
  239. align-items: center;
  240. }
  241. }
  242. </style>