index.vue 15 KB

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