search.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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="搜索" placeholder-style="color:#fff;" />
  14. </view>
  15. </view>
  16. </view>
  17. <view class="btn" @click="search()">搜索</view>
  18. </view>
  19. </view>
  20. <!-- 占位符 -->
  21. <view :style="{height: statusBarHeight + 'px'}"></view>
  22. <view style="height: 93rpx;"></view>
  23. <view class="tab">
  24. <view class="item" :class="active == 1?'active':''" @click="change_active(1)">文件</view>
  25. <view class="item" :class="active == 2?'active':''" @click="change_active(2)">人员</view>
  26. </view>
  27. <!-- 搜索列表 -->
  28. <view class="list" v-if="active == 1">
  29. <view class="item" v-for="(item,index) in list" :key="index" @click="go_record(item.id)">
  30. <view class="title">{{item.title}}</view>
  31. <view class="icon">
  32. <uni-icons type="arrowright"></uni-icons>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 搜索人员 -->
  37. <view class="people_list" v-if="active == 2">
  38. <view class="item" v-for="(item,index) in people_list" :key="index" @click="go_user_info(item.staff_num)">
  39. <view class="left">
  40. <view class="icon">{{item.name.charAt(0)}}</view>
  41. <view class="text">{{item.name}} {{item.dept_name}} {{item.duty_num}}</view>
  42. </view>
  43. <view class="right" @click.stop="phone(item.mobile)">
  44. <uni-icons type="phone"></uni-icons>
  45. </view>
  46. </view>
  47. <view v-if="people_list.length == 0" style="font-size: 32rpx;text-align: center;line-height: 400rpx;">暂无搜索结果
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {set_base_url} from '@/common/set_base_url.js'
  54. export default {
  55. data() {
  56. return {
  57. mine_code: "",
  58. statusBarHeight: 25,
  59. // 搜索关键词
  60. search_text: "",
  61. // 搜索结果列表
  62. list: [],
  63. people_list:[],
  64. active:1
  65. };
  66. },
  67. onLoad(option) {
  68. this.mine_code = option.mine_code
  69. // 获取手机系统信息
  70. const info = uni.getSystemInfoSync()
  71. // 设置状态栏高度
  72. this.statusBarHeight = info.statusBarHeight
  73. console.log(this.mine_code)
  74. // 根据矿编码切换首页接口不同的请求基础路径
  75. this.base_url = set_base_url(this.mine_code)
  76. },
  77. methods: {
  78. change_active(index){
  79. this.active = index
  80. this.search()
  81. },
  82. click_left() {
  83. uni.navigateBack();
  84. },
  85. search() {
  86. uni.showLoading()
  87. if(this.active == 1){
  88. uni.request({
  89. url: this.base_url + "/swagger/api/page/v1/getPageList",
  90. method: "GET",
  91. header:{
  92. 'accesskey': "b364b449a18af327867f7edc3431b541"
  93. },
  94. data: {
  95. title: this.search_text,
  96. departmentId: "",
  97. pageNumber: 0,
  98. pageSize: 0
  99. },
  100. success: (res) => {
  101. console.log(res)
  102. uni.hideLoading()
  103. this.list = res.data.data
  104. }
  105. })
  106. }else if(this.active == 2){
  107. uni.request({
  108. url: this.base_url + "/user/search",
  109. method: "POST",
  110. header:{
  111. 'Authorization' : uni.getStorageSync('token_type') +' '+uni.getStorageSync('Authorization')
  112. },
  113. data: {
  114. content: this.search_text
  115. },
  116. success: (res) => {
  117. console.log(res)
  118. uni.hideLoading()
  119. this.people_list = res.data.data
  120. }
  121. })
  122. }
  123. },
  124. // 打开二维码页面
  125. go_record(id) {
  126. uni.navigateTo({
  127. url:"../../index/record/record?pageId=" + id + "&mine_code=" + this.mine_code,
  128. })
  129. },
  130. go_user_info(staff_num) {
  131. uni.navigateTo({
  132. url:"../../origanization/communication/origanization/personal_information/personal_information?staff_num=" + staff_num
  133. })
  134. },
  135. phone(mobile) {
  136. if (mobile != null) {
  137. uni.makePhoneCall({
  138. phoneNumber: mobile
  139. });
  140. }else{
  141. uni.showToast({
  142. icon:"none",
  143. title:"未绑定手机号"
  144. })
  145. }
  146. },
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .content {
  152. position: fixed;
  153. top: 0;
  154. left: 0;
  155. background-color: #009FE8;
  156. z-index: 999;
  157. }
  158. .navbar {
  159. width: 750rpx;
  160. box-sizing: border-box;
  161. padding-left: 31rpx;
  162. padding-right: 26rpx;
  163. padding-top: 14rpx;
  164. padding-bottom: 14rpx;
  165. display: flex;
  166. // justify-content: space-between;
  167. .left {
  168. width: 42rpx;
  169. line-height: 65rpx;
  170. margin-right: 15rpx;
  171. }
  172. .right {
  173. width: 500rpx;
  174. height: 65rpx;
  175. background: rgba(255, 255, 255, 0.2);
  176. border-radius: 33rpx;
  177. .input_box {
  178. display: flex;
  179. .input_icon {
  180. margin-left: 43rpx;
  181. margin-top: 16rpx;
  182. width: 34rpx;
  183. height: 34rpx;
  184. background-image: url(icon/search.png);
  185. background-size: cover;
  186. background-repeat: no-repeat;
  187. }
  188. .input_text {
  189. margin-left: 19rpx;
  190. font-size: 24rpx;
  191. font-family: PingFangSC-Regular, PingFang SC;
  192. font-weight: 400;
  193. color: #FFFFFF;
  194. line-height: 65rpx;
  195. input {
  196. font-size: 24rpx;
  197. height: 65rpx;
  198. line-height: 65rpx;
  199. }
  200. }
  201. }
  202. }
  203. .btn {
  204. margin-left: 20rpx;
  205. width: 120rpx;
  206. text-align: center;
  207. height: 65rpx;
  208. line-height: 65rpx;
  209. background: rgba(255, 255, 255, 0.2);
  210. border-radius: 33rpx;
  211. font-size: 24rpx;
  212. font-family: PingFangSC-Regular, PingFang SC;
  213. font-weight: 400;
  214. color: #FFFFFF;
  215. }
  216. }
  217. .tab{
  218. background-color: #FFFFFF;
  219. z-index: 999;
  220. position: fixed;
  221. top: 1;
  222. left: 0;
  223. width: 750rpx;
  224. box-sizing: border-box;
  225. padding: 20rpx 25rpx;
  226. display: flex;
  227. .item{
  228. box-sizing: border-box;
  229. padding: 10rpx 30rpx;
  230. border-radius: 10rpx;
  231. margin-right: 20rpx;
  232. font-size: 26rpx;
  233. border: 1rpx solid #009fe8;
  234. color: #009fe8;
  235. }
  236. .item.active{
  237. background-color: #009fe8;
  238. color: #FFFFFF;
  239. }
  240. }
  241. .list {
  242. margin-top: 60rpx;
  243. box-sizing: border-box;
  244. padding: 10rpx 25rpx;
  245. .item {
  246. display: flex;
  247. justify-content: space-between;
  248. align-items: center;
  249. box-sizing: border-box;
  250. padding: 35rpx 0;
  251. border-bottom: 1rpx solid #F4F4F4;
  252. .title {
  253. font-size: 32rpx;
  254. }
  255. .icon {}
  256. }
  257. }
  258. .people_list {
  259. margin-top: 60rpx;
  260. box-sizing: border-box;
  261. padding: 10rpx 25rpx;
  262. .item {
  263. height: 110rpx;
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. border-bottom: 1rpx solid #F3F8F7;
  268. .left {
  269. display: flex;
  270. align-items: center;
  271. .icon {
  272. width: 35rpx;
  273. height: 35rpx;
  274. text-align: center;
  275. line-height: 35rpx;
  276. border-radius: 50%;
  277. border: 1rpx solid #00A1E9;
  278. font-size: 24rpx;
  279. color: #00A1E9;
  280. }
  281. .text {
  282. margin-left: 18rpx;
  283. font-size: 30rpx;
  284. }
  285. }
  286. .right {}
  287. }
  288. }
  289. </style>