index.vue 13 KB

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