index.vue 14 KB

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