search.vue 7.8 KB

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