index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <view>
  3. <u-navbar :is-back="false" :border-bottom="false"><view class="navbar-tit">交友</view></u-navbar>
  4. <view class="home-head">
  5. <view class="homeTab">
  6. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333"
  7. inactive-color="#c4c0c0"></u-tabs>
  8. </view>
  9. <view class="homeAdd" v-if="current == '0'" @click="show = true">
  10. <u-icon custom-prefix="custom-icon" name="filter-2-fill"></u-icon>
  11. <span>筛选</span>
  12. </view>
  13. <view class="homeAdd" v-if="current == '1'">
  14. <u-icon custom-prefix="custom-icon" name="refresh-line"></u-icon>
  15. <span @click="refreshClick">刷新</span>
  16. </view>
  17. </view>
  18. <u-popup v-model="show" mode="bottom" :closeable="true" border-radius="20" close-icon-pos="top-left">
  19. <view class="screenTit">
  20. <h4>条件筛选</h4>
  21. <span>重置</span>
  22. </view>
  23. <view class="screenCon">
  24. <view class="screenCon-row">
  25. <span>只看异性</span>
  26. <u-switch v-model="checked" active-color="#FF5E5E"></u-switch>
  27. </view>
  28. <view class="screenCon-item">
  29. <view class="screenCon-tit">
  30. <span>年龄</span><p>{{rangeValues[0]}}~{{rangeValues[1]}}</p>
  31. </view>
  32. <view class="screenCon-con">
  33. <view class="screenCon-slider">
  34. <RangeSlider
  35. :width="slideWidth"
  36. :height="slideHeight"
  37. :blockSize="slideBlockSize"
  38. :min="slideMin"
  39. :max="slideMax"
  40. :values="rangeValues"
  41. :step="step"
  42. :liveMode="isLiveMode"
  43. @rangechange="onRangeChange"
  44. >
  45. <view slot="minBlock" class="range-slider-block"></view>
  46. <!-- 左边滑块的内容 -->
  47. <view slot="maxBlock" class="range-slider-block"></view>
  48. <!-- 右边滑块的内容 -->
  49. </RangeSlider>
  50. <!-- <u-slider v-model="value"></u-slider> -->
  51. </view>
  52. </view>
  53. </view>
  54. <view class="screenCon-item">
  55. <view class="screenCon-tit">
  56. <span>身高</span><p>{{rangeValues2[0]}}~{{rangeValues2[1]}}</p>
  57. </view>
  58. <view class="screenCon-con">
  59. <view class="screenCon-slider">
  60. <RangeSlider
  61. :width="slideWidth"
  62. :height="slideHeight"
  63. :blockSize="slideBlockSize"
  64. :min="slideMin2"
  65. :max="slideMax2"
  66. :values="rangeValues2"
  67. :step="step"
  68. :liveMode="isLiveMode"
  69. @rangechange="onRangeChange2"
  70. >
  71. <view slot="minBlock" class="range-slider-block"></view>
  72. <!-- 左边滑块的内容 -->
  73. <view slot="maxBlock" class="range-slider-block"></view>
  74. <!-- 右边滑块的内容 -->
  75. </RangeSlider>
  76. <!-- <u-slider v-model="value"></u-slider> -->
  77. </view>
  78. </view>
  79. </view>
  80. <view class="screenCon-item">
  81. <view class="screenCon-tit">
  82. <span>会员所属工会所在地</span>
  83. </view>
  84. <view class="screenCon-con">
  85. <view class="screenCon-choice" v-for="(item ,index) in qyList" :key="item.id" @click="qyClick(item,index)">
  86. <view :class="activeClass == index ? 'choice-item active':'choice-item'">{{item.name}}</view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="screenCon-item">
  91. <view class="screenCon-tit">
  92. <span>学历</span>
  93. </view>
  94. <view class="screenCon-con">
  95. <view class="screenCon-choice" v-for="(item ,index) in xlList" :key="item.id" @click="xlClick(item,index)">
  96. <view :class="activeClass == index ? 'choice-item active':'choice-item'">{{item.name}}</view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="screenCon-item">
  101. <view class="screenCon-tit">
  102. <span>婚姻状况</span>
  103. </view>
  104. <view class="screenCon-con">
  105. <view class="screenCon-choice" v-for="(item ,index) in hyqkList" :key="item.id" @click="hyqkClick(item,index)">
  106. <view :class="activeClass == index ? 'choice-item active':'choice-item'">{{item.name}}</view>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="screenCon-item">
  111. <view class="screenCon-tit">
  112. <span>子女状况</span>
  113. </view>
  114. <view class="screenCon-con">
  115. <view class="screenCon-choice" v-for="(item ,index) in znqkList" :key="item.id" @click="znqkClick(item,index)">
  116. <view :class="activeClass == index ? 'choice-item active':'choice-item'">{{item.name}}</view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="screenCon-btn">
  121. <u-button type="error" shape="circle" :custom-style="customStyle" @click="sure">确定</u-button>
  122. </view>
  123. </view>
  124. </u-popup>
  125. <view class="friendList">
  126. <view class="friendList-item" v-for="(item ,index) in friendList" :key="item.id" @click="gotoUrl('pages/user/index?id='+item.id)">
  127. <u-image class="friendList-img" :src="item.faceImage" height="160" width="160" border-radius="10">
  128. </u-image>
  129. <view class="friendList-text">
  130. <view class="friendList-name">
  131. <span>{{item.realName}}</span>
  132. <u-icon custom-prefix="custom-icon" name="men-line" color="#1677FF"></u-icon>
  133. </view>
  134. <view class="friendList-info">
  135. <span>{{item.age}}岁 · {{item.height}}cm</span>&nbsp;<span v-if="item.weight != null">· {{item.weight}}kg</span>
  136. </view>
  137. <view class="friendList-label">
  138. <view class="friendList-label-item">
  139. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  140. <span>{{item.orgAreaName}}</span>
  141. </view>
  142. <view class="friendList-label-item">
  143. <span>{{item.educationN}}</span>
  144. </view>
  145. <view class="friendList-label-item">
  146. <span>{{item.industryN}}</span>
  147. </view>
  148. </view>
  149. </view>
  150. </view>
  151. <u-divider v-if="friendList.length == recordsTotal" color="#B6BDC3" style="margin-top:20px;" bg-color="#f4f0f0">已经到底了</u-divider>
  152. </view>
  153. </view>
  154. </template>
  155. <script>
  156. import * as friendApi from '@/apis/friend.js'
  157. import * as loginApi from '@/apis/login.js'
  158. import RangeSlider from '../../components/range-slider/range-slider.vue';
  159. export default {
  160. data() {
  161. return {
  162. rangeValues: [22, 35],
  163. slideWidth: 600,
  164. slideHeight: 80,
  165. slideBlockSize: 30,
  166. //年龄
  167. slideMin: 18,
  168. slideMax: 80,
  169. //身高
  170. slideMin2: 140,
  171. slideMax2: 220,
  172. isLiveMode: true,
  173. rangeValues2: [170, 180],
  174. step:1,
  175. data: {
  176. type: '', //全部0,猜你喜欢1(不传默认查全部)
  177. memberId: '', //未登录不传,登陆了传当前用户ID
  178. oppositeSex: '', //只看异性1,不传值为查看所有
  179. ageStart: '', //年龄起
  180. ageEnd: '', //年龄止
  181. heightStart: '', //身高起
  182. heightEnd: '', //身高止
  183. qy: '', //籍贯(单位所属区域)
  184. xl: '', //学历
  185. hyqk: '', //婚姻情况
  186. znqk: '', //子女情况
  187. pageIndex: 1,
  188. pageSize: 20,
  189. },
  190. recordsTotal: 0,
  191. list: [],
  192. friendList: [],
  193. qyList: [], //所属区域
  194. xlList: [], //学历
  195. hyqkList: [], //婚姻情况
  196. znqkLis: [], //子女情况
  197. activeClass: 0,
  198. tabList: [{
  199. name: '全部'
  200. }, {
  201. name: '猜你喜欢'
  202. }],
  203. current: 0,
  204. randomList: [],
  205. show: false,
  206. checked: false,
  207. customStyle:{
  208. background: '#FF5E5E'
  209. },
  210. value: 30
  211. }
  212. },
  213. components: {
  214. RangeSlider
  215. },
  216. onLoad(op) {
  217. if(this.carhelp.getPersonInfo().id != null) {
  218. this.data.memberId = this.carhelp.getPersonInfo().id;
  219. }
  220. this.getConditionList();
  221. },
  222. onReachBottom() {
  223. if (this.friendList.length < this.recordsTotal) {
  224. this.myLoadmore();
  225. }
  226. },
  227. methods: {
  228. pad: function(num, n) {
  229. return Array(n - ('' + num).length + 1).join(0) + num;
  230. },
  231. onRangeChange: function(e) {
  232. this.rangeValues = [e.minValue, e.maxValue];
  233. },
  234. onRangeChange2: function(e) {
  235. this.rangeValues2 = [e.minValue, e.maxValue];
  236. },
  237. formatTimeBySliderValue(value) {
  238. //按比例,将滑块上面的数值进行转换为时间形式
  239. //转换为分钟数
  240. let minutes = (24 * 60 * value) / this.slideMax;
  241. //转换为小时数
  242. let hours = parseInt(minutes / 60);
  243. //剩余分钟数
  244. let minutes_min = parseInt(minutes % 60);
  245. return '' + this.pad(hours, 2) + ':' + this.pad(minutes_min, 2) + ':' + '00';
  246. },
  247. qyClick(item,index) {
  248. this.activeClass = index;
  249. this.data.qy = item.name;
  250. },
  251. xlClick(item,index) {
  252. this.activeClass = index;
  253. this.data.xl = item.name;
  254. },
  255. hyqkClick(item,index) {
  256. this.activeClass = index;
  257. this.data.hyqk = item.name;
  258. },
  259. znqkClick(item,index) {
  260. this.activeClass = index;
  261. this.data.znqk = item.name;
  262. },
  263. sure() {
  264. this.show = false;
  265. if(this.checked) {
  266. this.data.oppositeSex = '1';
  267. }
  268. this.data.ageStart = this.rangeValues[0];
  269. this.data.ageEnd = this.rangeValues[1];
  270. this.data.heightStart = this.rangeValues2[0];
  271. this.data.heightEnd = this.rangeValues2[1];
  272. console.log(this.qyList[0].name)
  273. if(this.data.qy == ''){
  274. this.data.qy = this.qyList[0].name;
  275. }
  276. if(this.data.xl == ''){
  277. this.data.xl = this.xlList[0].name;
  278. }
  279. if(this.data.hyqk == ''){
  280. this.data.hyqk = this.hyqkList[0].name;
  281. }
  282. if(this.data.znqk == ''){
  283. this.data.znqk = this.znqkList[0].name;
  284. }
  285. this.getFriendList();
  286. },
  287. change(index) {
  288. this.current = index;
  289. this.data.type = index;
  290. this.getFriendList();
  291. },
  292. myLoadmore() {
  293. this.data.pageIndex += 1;
  294. this.getFriendList()
  295. },
  296. refreshClick() {
  297. var data = {
  298. type: 'typedssdf',
  299. memberId: 'memberId',
  300. oppositeSex: 'oppositeSex',
  301. ageStart: 'ageStart',
  302. ageEnd: 'ageEnd',
  303. heightStart: 'heightStart',
  304. heightEnd: 'heightEnd',
  305. qy: 'qy',
  306. xl: 'xl',
  307. hyqk: 'hyqk',
  308. znqk: 'znqk'
  309. };
  310. let list = [];
  311. for(var item in data) {
  312. var sgd = {};
  313. sgd[item] = data[item]
  314. list.push(sgd);
  315. }
  316. console.log(list)
  317. for(var i = 0; i < 3; i++) {
  318. var num=Math.floor(Math.random()*10+0);
  319. console.log(list[num])
  320. }
  321. },
  322. getFriendList() {
  323. uni.showLoading({
  324. title: "加载中",
  325. mask: true,
  326. })
  327. friendApi.findFriendsList(this.data).then((res) => {
  328. this.friendList = [
  329. ...this.friendList,
  330. ...res.data.data
  331. ];
  332. this.recordsTotal = res.data.recordsTotal;
  333. uni.hideLoading();
  334. }).catch(error => {
  335. uni.showToast({
  336. title: error
  337. })
  338. })
  339. },
  340. getConditionList() {
  341. uni.showLoading({
  342. title: "加载中",
  343. mask: true,
  344. })
  345. loginApi.getBaseDictionary().then((res) => {
  346. this.qyList = res.data.qyList;
  347. this.xlList = res.data.xlList;
  348. this.hyqkList = res.data.hyqkList;
  349. this.znqkList = res.data.znqkList;
  350. uni.hideLoading();
  351. }).catch(error => {
  352. uni.showToast({
  353. title: error
  354. })
  355. })
  356. },
  357. onReady() {
  358. this.getFriendList();
  359. }
  360. }
  361. }
  362. </script>
  363. <style>
  364. page {
  365. background-color: #f4f0f0;
  366. }
  367. </style>
  368. <style lang="scss" scoped>
  369. .screenCon-btn{
  370. padding: 15px;
  371. }
  372. .screenCon-slider{
  373. height: 24px;
  374. }
  375. .screenCon-choice{
  376. display: flex;
  377. flex-wrap: wrap;
  378. .choice-item{
  379. background-color: #F1F3F4;
  380. border-radius: 4px;
  381. padding:8px 0;
  382. color:#6C6A6A;
  383. width: 22%;
  384. text-align: center;
  385. margin-right: 10px;
  386. margin-bottom: 10px;
  387. }
  388. .active{
  389. background-color: #FF5E5E;
  390. color:#fff;
  391. }
  392. }
  393. .screenCon-item{
  394. padding: 10px 0;
  395. .screenCon-tit{
  396. display: flex;
  397. align-items: center;
  398. span{font-size: 16px;}
  399. p{font-size: 16px;color:#999;margin-left: 8px;}
  400. }
  401. .screenCon-con{
  402. margin-top: 12px;
  403. }
  404. }
  405. .screenCon-row{
  406. display: flex;
  407. justify-content: space-between;
  408. align-items: center;
  409. padding: 10px 0;
  410. span{
  411. font-size: 16px;
  412. }
  413. }
  414. .screenCon{
  415. height: 540px;
  416. padding: 0 15px;
  417. margin-top: 50px;
  418. }
  419. .screenTit{
  420. height: 50px;
  421. position:fixed;
  422. left: 0;
  423. top: 0;
  424. right: 0;
  425. background-color: #fff;
  426. z-index: 2;
  427. h4{
  428. position: absolute;
  429. font-weight: normal;
  430. left: 50%;
  431. top:12px;
  432. font-size: 16PX;
  433. margin-left: -32px;
  434. }
  435. span{
  436. position: absolute;
  437. color:#999;
  438. right: 15px;
  439. top: 15px;
  440. }
  441. }
  442. .navbar-tit{
  443. padding-left:15px;
  444. font-size: 24px;
  445. }
  446. .home-head {
  447. display: flex;
  448. justify-content: space-between;
  449. align-items: center;
  450. padding-right: 15px;
  451. position: fixed;
  452. left: 0;
  453. right: 0;
  454. top: 55px;
  455. z-index: 99;
  456. background-color: #FFF;
  457. .homeAdd {
  458. color: #FF5E5E;
  459. span {
  460. margin-left: 3px;
  461. }
  462. }
  463. }
  464. .friendList {
  465. padding: 15px;
  466. margin-top: 40px;
  467. .friendList-item {
  468. display: flex;
  469. background-color: #fff;
  470. padding: 12px;
  471. border-radius: 12px;
  472. margin-bottom: 15px;
  473. .friendList-text {
  474. flex: 1;
  475. min-width: 0;
  476. margin-left: 12px;
  477. display: flex;
  478. flex-direction: column;
  479. justify-content: space-between;
  480. .friendList-name {
  481. font-weight: normal;
  482. span {
  483. font-size: 18px;
  484. margin-right: 8px;
  485. }
  486. }
  487. .friendList-info {
  488. color: #999;
  489. font-size: 12px;
  490. }
  491. .friendList-label {
  492. display: flex;
  493. align-items: center;
  494. .friendList-label-item {
  495. background: #F1F3F4;
  496. padding: 2px 8px;
  497. color: #A2A9B5;
  498. border-radius: 4px;
  499. font-size: 12px;
  500. margin-right: 8px;
  501. span {
  502. margin-left: 3px;
  503. }
  504. }
  505. }
  506. }
  507. }
  508. }
  509. </style>