search.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. 'accesskey': "b364b449a18af327867f7edc3431b541"
  113. },
  114. data: {
  115. content: this.search_text
  116. },
  117. success: (res) => {
  118. console.log(res)
  119. uni.hideLoading()
  120. this.people_list = res.data.data
  121. }
  122. })
  123. }
  124. },
  125. // 打开二维码页面
  126. go_record(id) {
  127. uni.navigateTo({
  128. url:"../../index/record/record?pageId=" + id + "&mine_code=" + this.mine_code,
  129. })
  130. },
  131. go_user_info(staff_num) {
  132. if(this.mine_code == 'ningmeijituan'){
  133. uni.navigateTo({
  134. url:"../../origanization/communication/origanization/personal_information/personal_information_peixun?staff_num=" + staff_num
  135. })
  136. }else{
  137. uni.navigateTo({
  138. url:"../../origanization/communication/origanization/personal_information/personal_information_info?staff_num=" + staff_num
  139. })
  140. }
  141. },
  142. phone(mobile) {
  143. if (mobile != null) {
  144. uni.makePhoneCall({
  145. phoneNumber: mobile
  146. });
  147. }else{
  148. uni.showToast({
  149. icon:"none",
  150. title:"未绑定手机号"
  151. })
  152. }
  153. },
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. .content {
  159. position: fixed;
  160. top: 0;
  161. left: 0;
  162. background-color: #009FE8;
  163. z-index: 999;
  164. }
  165. .navbar {
  166. width: 750rpx;
  167. box-sizing: border-box;
  168. padding-left: 31rpx;
  169. padding-right: 26rpx;
  170. padding-top: 14rpx;
  171. padding-bottom: 14rpx;
  172. display: flex;
  173. // justify-content: space-between;
  174. .left {
  175. width: 42rpx;
  176. line-height: 65rpx;
  177. margin-right: 15rpx;
  178. }
  179. .right {
  180. width: 500rpx;
  181. height: 65rpx;
  182. background: rgba(255, 255, 255, 0.2);
  183. border-radius: 33rpx;
  184. .input_box {
  185. display: flex;
  186. .input_icon {
  187. margin-left: 43rpx;
  188. margin-top: 16rpx;
  189. width: 34rpx;
  190. height: 34rpx;
  191. background-image: url(icon/search.png);
  192. background-size: cover;
  193. background-repeat: no-repeat;
  194. }
  195. .input_text {
  196. margin-left: 19rpx;
  197. font-size: 24rpx;
  198. font-family: PingFangSC-Regular, PingFang SC;
  199. font-weight: 400;
  200. color: #FFFFFF;
  201. line-height: 65rpx;
  202. input {
  203. font-size: 24rpx;
  204. height: 65rpx;
  205. line-height: 65rpx;
  206. }
  207. }
  208. }
  209. }
  210. .btn {
  211. margin-left: 20rpx;
  212. width: 120rpx;
  213. text-align: center;
  214. height: 65rpx;
  215. line-height: 65rpx;
  216. background: rgba(255, 255, 255, 0.2);
  217. border-radius: 33rpx;
  218. font-size: 24rpx;
  219. font-family: PingFangSC-Regular, PingFang SC;
  220. font-weight: 400;
  221. color: #FFFFFF;
  222. }
  223. }
  224. .tab{
  225. background-color: #FFFFFF;
  226. z-index: 999;
  227. position: fixed;
  228. top: 1;
  229. left: 0;
  230. width: 750rpx;
  231. box-sizing: border-box;
  232. padding: 20rpx 25rpx;
  233. display: flex;
  234. .item{
  235. box-sizing: border-box;
  236. padding: 10rpx 30rpx;
  237. border-radius: 10rpx;
  238. margin-right: 20rpx;
  239. font-size: 26rpx;
  240. border: 1rpx solid #009fe8;
  241. color: #009fe8;
  242. }
  243. .item.active{
  244. background-color: #009fe8;
  245. color: #FFFFFF;
  246. }
  247. }
  248. .list {
  249. margin-top: 60rpx;
  250. box-sizing: border-box;
  251. padding: 10rpx 25rpx;
  252. .item {
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. box-sizing: border-box;
  257. padding: 35rpx 0;
  258. border-bottom: 1rpx solid #F4F4F4;
  259. .title {
  260. font-size: 32rpx;
  261. }
  262. .icon {}
  263. }
  264. }
  265. .people_list {
  266. margin-top: 60rpx;
  267. box-sizing: border-box;
  268. padding: 10rpx 25rpx;
  269. .item {
  270. height: 110rpx;
  271. display: flex;
  272. justify-content: space-between;
  273. align-items: center;
  274. border-bottom: 1rpx solid #F3F8F7;
  275. .left {
  276. display: flex;
  277. align-items: center;
  278. .icon {
  279. width: 35rpx;
  280. height: 35rpx;
  281. text-align: center;
  282. line-height: 35rpx;
  283. border-radius: 50%;
  284. border: 1rpx solid #00A1E9;
  285. font-size: 24rpx;
  286. color: #00A1E9;
  287. }
  288. .text {
  289. margin-left: 18rpx;
  290. font-size: 30rpx;
  291. }
  292. }
  293. .right {}
  294. }
  295. }
  296. </style>