search.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <template>
  2. <view>
  3. <!-- 搜索 -->
  4. <view class="search flex align-center justify-center">
  5. <view class="search-box">
  6. <u-search placeholder="搜索岗位" shape="square" @clear="clear" v-model="keyword" @custom="custom"
  7. @search="custom"></u-search>
  8. </view>
  9. </view>
  10. <block v-if="show">
  11. <view class="searchJl flex justify-center">
  12. <view class="searchJl-box">
  13. <view class="searchJl-box-title">
  14. 热门搜索
  15. </view>
  16. <view class="searchJl-box-label flex align-center flex-wrap">
  17. <view class="searchJl-box-item" @click="goSearch(item.keyWord)"
  18. v-for="(item,index) in searchList" :key="index">
  19. {{item.keyWord}}
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </block>
  25. <block v-else>
  26. <!-- 筛选 -->
  27. <view class="screen flex justify-center align-center">
  28. <view class="screen-box">
  29. <view class="topbg-sx-box flex justify-between align-center">
  30. <view class="topbg-sx-box-l flex align-center">
  31. <view class="topbg-sx-box-l-i" :class="currentSx==index?'active3':''"
  32. @click="currentSx = index" v-for="(item,index) in sxTypeList" :key="index">
  33. {{item.name}}
  34. </view>
  35. </view>
  36. <view class="topbg-sx-box-r flex align-center">
  37. <text style="color: #00B78F;font-size: 28rpx;font-weight: 500;margin-right: 10rpx;"
  38. @click="goNav('/package/screen/city?city='+city+'&county='+county)">{{county?county:city}}</text>
  39. <u-icon name="arrow-down-fill" color="#00B78F" size="20"
  40. @click="goNav('/package/screen/city?city='+city+'&county='+county)"></u-icon>
  41. <text style="color: #CCCCCC;margin-left: 30rpx;margin-right: 30rpx;">|</text>
  42. <text style="color: #999999;font-size: 28rpx;font-weight: 500;margin-right: 10rpx;"
  43. @click="goNav('/package/screen/screen')">筛选</text>
  44. <u-icon name="arrow-down-fill" color="#CCCCCC" size="20"
  45. @click="goNav('/package/screen/screen')"></u-icon>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 岗位推荐 -->
  51. <view class="gwList flex justify-center" v-if="dataList.length>0">
  52. <view class="gwList-box">
  53. <scroll-view scroll-y="true" style="width: 100%;height: 100%;">
  54. <view class="gwList-box-item flex justify-center" @click="gotoInfo(item.postPushId)"
  55. v-for="(item,index) in dataList" :key="index">
  56. <view class="gwList-box-item-box">
  57. <view class="gwList-box-item-box-title flex justify-between align-center">
  58. <view class=""
  59. style="max-width: 450rpx;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;-o-text-overflow:ellipsis;">
  60. <block v-if="isSameName(item.ruleClassifyName,item.stationName)">
  61. {{item.ruleClassifyName}}-
  62. </block>
  63. <block>
  64. {{item.stationName}}
  65. </block>
  66. </view>
  67. <text>{{item.salaryRange}}</text>
  68. </view>
  69. <view class="gwList-box-item-box-label flex align-center flex-wrap">
  70. <text
  71. style="color: #666666;font-size: 26rpx;padding: 10rpx 25rpx 10rpx 25rpx;background-color: #F6F6F6;border-radius: 8rpx;margin-right: 20rpx;margin-bottom: 20rpx;"
  72. v-for="(ite,ind) in item.positionWelfare" :key="ind">{{ite}}</text>
  73. </view>
  74. <view class="gwList-box-item-box-name flex justify-between align-center">
  75. <text>{{item.company?item.company.companyName:''}}</text>
  76. <text v-if="item.company">{{item.company?item.company.companyPeople:''}}</text>
  77. </view>
  78. <view class="gwList-box-item-box-line"></view>
  79. <view class="gwList-box-item-box-info flex justify-between align-center">
  80. <view class="gwList-box-item-box-info-l flex align-center">
  81. <image :src="item.company?item.company.companyLogo:'../../static/logo.png'"
  82. style="width: 58rpx;height: 58rpx;border-radius: 50%;margin-right: 20rpx;"
  83. mode=""></image>
  84. <text
  85. v-if="item.company">{{item.company?item.company.companyLegalPerson:'未知'}}·创始人</text>
  86. </view>
  87. <view class="gwList-box-item-box-info-r">
  88. {{item.county}}
  89. {{item.address}}
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </scroll-view>
  95. </view>
  96. </view>
  97. <!-- 暂无数据 -->
  98. <view class="gwList" v-else>
  99. <empty />
  100. </view>
  101. </block>
  102. </view>
  103. </template>
  104. <script>
  105. import empty from '../../components/empty.vue'
  106. export default {
  107. components: {
  108. empty
  109. },
  110. data() {
  111. return {
  112. show: false,
  113. keyword: '',
  114. currentSx: 0,
  115. sxTypeList: [{
  116. id: 1,
  117. name: '推荐',
  118. },
  119. {
  120. id: 2,
  121. name: '最新',
  122. }
  123. ],
  124. token: '',
  125. page: 1,
  126. limit: 10,
  127. totlo: 1,
  128. city: '',
  129. county: '', //区
  130. education: '', //学历
  131. salaryRange: '', //薪资
  132. experience: '', //经验
  133. companyPeople: '', //公司规模
  134. industry: '', //行业
  135. longitude: '',
  136. latitude: '',
  137. dataList: [],
  138. searchList: [],
  139. };
  140. },
  141. watch: {
  142. currentSx(newData, oldData) {
  143. this.getUserList();
  144. },
  145. },
  146. onLoad() {
  147. let that = this
  148. //获取经纬度后请求岗位接口,经纬度用于筛选距离
  149. uni.getLocation({
  150. type: 'wgs84', //wgs84 gcj02
  151. success: function(res) {
  152. console.log(res, '地理位置');
  153. that.latitude = res.latitude;
  154. that.longitude = res.longitude;
  155. that.getUserList();
  156. },
  157. fail: function() {
  158. console.log('获取地址失败');
  159. }
  160. })
  161. this.getMyRecordList()
  162. },
  163. onShow() {
  164. let that = this;
  165. if (!this.city) {
  166. if (uni.getStorageSync('city')) {
  167. this.city = uni.getStorageSync('city')
  168. } else {
  169. this.city = ''
  170. }
  171. }
  172. uni.$once('filterCity', data => {
  173. console.log(data, '选择的市')
  174. that.city = data.city
  175. that.county = data.county
  176. that.getUserList();
  177. })
  178. this.token = uni.getStorageSync('token');
  179. console.log(uni.getStorageSync('filter'), '1111111111');
  180. if (uni.getStorageSync('filter') && (uni.getStorageSync('filter')).length > 0) {
  181. let filter = uni.getStorageSync('filter')
  182. filter.map(item => {
  183. let arr = []
  184. item.list.map(ite => {
  185. if (ite.value != '不限') {
  186. arr.push(ite.value)
  187. }
  188. })
  189. switch (item.name) {
  190. case '学历':
  191. this.education = arr.join(',')
  192. break;
  193. case '薪资':
  194. this.salaryRange = arr.join(',')
  195. break;
  196. case '经验':
  197. this.experience = arr.join(',')
  198. break;
  199. case '公司规模':
  200. this.companyPeople = arr.join(',')
  201. break;
  202. case '行业':
  203. this.industry = arr.join(',')
  204. break;
  205. }
  206. })
  207. } else {
  208. this.education = '' //学历
  209. this.experience = '' //经验
  210. this.industry = '' //行业
  211. this.salaryRange = '' //薪资
  212. this.companyPeople = '' //公司规模
  213. }
  214. that.getUserList();
  215. },
  216. onPullDownRefresh() {
  217. this.page = 1
  218. this.getUserList();
  219. },
  220. onReachBottom() {
  221. if (this.page < this.totlo) {
  222. this.page += 1
  223. this.getUserList();
  224. }
  225. },
  226. methods: {
  227. //判断岗位名称与职位名称是否相同(不区分大小写)
  228. isSameName(className, name) {
  229. let str1 = className.trim();
  230. let str2 = name.trim();
  231. if (str1.length !== str2.length) {
  232. return true;
  233. }
  234. return str1.toLowerCase() !== str2.toLowerCase();
  235. },
  236. /**
  237. * @param {Object} postPushId
  238. * 岗位详情
  239. */
  240. gotoInfo(postPushId) {
  241. if (uni.getStorageSync('token')) {
  242. uni.navigateTo({
  243. url: '/pages/index/game/order?postPushId=' + postPushId
  244. })
  245. } else {
  246. this.noLogin()
  247. }
  248. },
  249. //我的搜索关键词
  250. getMyRecordList() {
  251. this.$Request.get('/app/record/getMyRecordList', {
  252. userId: uni.getStorageSync('userId') ? uni.getStorageSync('userId') : ''
  253. }).then(res => {
  254. if (res.code == 0) {
  255. this.searchList = res.data.records
  256. if (this.searchList.length > 0) {
  257. this.show = true
  258. } else {
  259. this.show = false
  260. this.custom()
  261. }
  262. }
  263. })
  264. },
  265. /**
  266. * 清空搜索内容
  267. */
  268. clear() {
  269. this.page = 1
  270. this.getUserList();
  271. },
  272. /**
  273. * @param {Object} keyword
  274. * 热词搜索
  275. */
  276. goSearch(keyword) {
  277. this.show = false
  278. this.keyword = keyword
  279. this.getUserList();
  280. },
  281. /**
  282. * @param {Object} e
  283. * 用户点击搜索时触发
  284. */
  285. custom(e) {
  286. this.show = false
  287. this.page = 1
  288. this.getUserList()
  289. },
  290. /**
  291. * 获取岗位列表
  292. */
  293. getUserList() {
  294. let data = {
  295. page: this.page,
  296. limit: this.limit,
  297. postType: '',
  298. ruleClassifyName: this.keyword, //岗位名称
  299. screen: +this.currentSx + 1, //1推荐 2最新
  300. county: this.county, //区
  301. city: this.city, //城市
  302. salaryRange: this.salaryRange, //薪资范围
  303. education: this.education, //学历
  304. experience: this.experience, //经验
  305. industry: this.industry, //行业
  306. companyPeople: this.companyPeople, //公司规模
  307. lng: this.longitude,
  308. lat: this.latitude,
  309. userId: uni.getStorageSync('userId') ? uni.getStorageSync('userId') : ''
  310. }
  311. this.$Request.get('/app/postPush/userGetPostPushList', data).then(res => {
  312. uni.stopPullDownRefresh()
  313. if (res.code == 0) {
  314. res.data.records.map(item => {
  315. if (item.positionWelfare) {
  316. item.positionWelfare = item.positionWelfare.split(',')
  317. } else {
  318. item.positionWelfare = []
  319. }
  320. })
  321. if (this.page == 1) {
  322. this.dataList = res.data.records
  323. } else {
  324. this.dataList = [...this.dataList, ...res.data.records]
  325. }
  326. this.totlo = res.data.pages
  327. }
  328. })
  329. },
  330. //跳转
  331. goNav(url) {
  332. if (uni.getStorageSync('token')) {
  333. uni.navigateTo({
  334. url: url
  335. })
  336. } else {
  337. this.noLogin()
  338. }
  339. },
  340. //未登录
  341. noLogin() {
  342. uni.showModal({
  343. title: '提示',
  344. content: '您还未登录,请先登录',
  345. confirmColor: '#00B88F',
  346. success: function(res) {
  347. if (res.confirm) {
  348. console.log('用户点击确定');
  349. // uni.reLaunch({
  350. // url:'/pages/public/login'
  351. // })
  352. uni.navigateTo({
  353. url: '/pages/public/login'
  354. })
  355. } else if (res.cancel) {
  356. console.log('用户点击取消');
  357. }
  358. }
  359. })
  360. },
  361. },
  362. }
  363. </script>
  364. <style lang="scss">
  365. page {
  366. background: #F2F2F7;
  367. }
  368. .active3 {
  369. color: #1A1A1A !important;
  370. font-size: 28rpx !important;
  371. font-weight: 800 !important;
  372. }
  373. .search {
  374. width: 100%;
  375. height: 88rpx;
  376. background-color: #ffffff;
  377. position: fixed;
  378. top: 0;
  379. z-index: 9999;
  380. .search-box {
  381. width: 686rpx;
  382. height: 60rpx;
  383. }
  384. }
  385. .screen {
  386. width: 100%;
  387. height: 100rpx;
  388. background-color: #ffffff;
  389. position: fixed;
  390. top: 88rpx;
  391. z-index: 9999;
  392. .screen-box {
  393. width: 686rpx;
  394. height: 80rpx;
  395. .topbg-sx-box {
  396. width: 686rpx;
  397. height: 25rpx;
  398. margin-top: 30rpx;
  399. .topbg-sx-box-l-i {
  400. color: #999999;
  401. font-size: 28rpx;
  402. font-weight: 500;
  403. margin-right: 38rpx;
  404. }
  405. }
  406. }
  407. }
  408. .searchJl {
  409. width: 100%;
  410. background-color: #ffffff;
  411. position: fixed;
  412. top: 80rpx;
  413. height: calc(100vh - 80rpx);
  414. .searchJl-box {
  415. width: 686rpx;
  416. height: 100%;
  417. .searchJl-box-title {
  418. color: #333333;
  419. font-size: 28rpx;
  420. font-weight: bold;
  421. margin-top: 40rpx;
  422. }
  423. .searchJl-box-label {
  424. width: 100%;
  425. margin-top: 20rpx;
  426. .searchJl-box-item {
  427. padding: 20rpx;
  428. border-radius: 8rpx;
  429. background-color: #F5F5F5;
  430. color: #333333;
  431. font-size: 24rpx;
  432. font-weight: 500;
  433. margin-right: 20rpx;
  434. margin-top: 20rpx;
  435. }
  436. }
  437. }
  438. }
  439. .gwList {
  440. width: 100%;
  441. margin-top: 200rpx;
  442. .gwList-box {
  443. width: 686rpx;
  444. height: 100%;
  445. .gwList-box-item {
  446. width: 100%;
  447. // height: 329rpx;
  448. background-color: #ffffff;
  449. border-radius: 24rpx;
  450. margin-bottom: 20rpx;
  451. padding-bottom: 20rpx;
  452. }
  453. .gwList-box-item-box {
  454. width: 623rpx;
  455. height: 100%;
  456. .gwList-box-item-box-title {
  457. margin-top: 30rpx;
  458. view:nth-of-type(1) {
  459. color: #1F1F1F;
  460. font-size: 38rpx;
  461. font-weight: 800;
  462. }
  463. text:nth-of-type(1) {
  464. color: #00B88F;
  465. font-size: 38rpx;
  466. font-weight: bold;
  467. }
  468. }
  469. .gwList-box-item-box-label {
  470. margin-top: 30rpx;
  471. }
  472. .gwList-box-item-box-name {
  473. margin-top: 24rpx;
  474. color: #999999;
  475. font-size: 28rpx;
  476. font-weight: 500;
  477. }
  478. .gwList-box-item-box-line {
  479. width: 100%;
  480. border: 1rpx solid #E6E6E6;
  481. margin-top: 30rpx;
  482. margin-bottom: 20rpx;
  483. }
  484. .gwList-box-item-box-info {
  485. font-size: 26rpx;
  486. .gwList-box-item-box-info-l {
  487. color: #1A1A1A;
  488. }
  489. .gwList-box-item-box-info-r {
  490. color: #999999;
  491. max-width: 300rpx;
  492. }
  493. }
  494. }
  495. }
  496. }
  497. </style>