index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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>22~32</p>
  31. </view>
  32. <view class="screenCon-con">
  33. <view class="screenCon-slider">
  34. <u-slider v-model="value"></u-slider>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="screenCon-item">
  39. <view class="screenCon-tit">
  40. <span>身高</span><p>172~182</p>
  41. </view>
  42. <view class="screenCon-con">
  43. <view class="screenCon-slider">
  44. <u-slider v-model="value"></u-slider>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="screenCon-item">
  49. <view class="screenCon-tit">
  50. <span>会员所属工会所在地</span>
  51. </view>
  52. <view class="screenCon-con">
  53. <view class="screenCon-choice">
  54. <view class="choice-item active">荆州市</view>
  55. <view class="choice-item">荆州区</view>
  56. <view class="choice-item">沙市区</view>
  57. <view class="choice-item">江陵县</view>
  58. <view class="choice-item">公安县</view>
  59. <view class="choice-item">松滋市</view>
  60. <view class="choice-item">石首市</view>
  61. <view class="choice-item">监利市</view>
  62. <view class="choice-item">洪湖市</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="screenCon-item">
  67. <view class="screenCon-tit">
  68. <span>会员所属工会所在地</span>
  69. </view>
  70. <view class="screenCon-con">
  71. <view class="screenCon-choice">
  72. <view class="choice-item active">不限</view>
  73. <view class="choice-item">高中及以上</view>
  74. <view class="choice-item">大专及以上</view>
  75. <view class="choice-item">本科及以上</view>
  76. <view class="choice-item">其他</view>
  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="choice-item active">不限</view>
  87. <view class="choice-item">未婚</view>
  88. <view class="choice-item">离异</view>
  89. <view class="choice-item">丧偶</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="choice-item active">不限</view>
  100. <view class="choice-item">无</view>
  101. <view class="choice-item">有</view>
  102. </view>
  103. </view>
  104. </view>
  105. <view class="screenCon-btn">
  106. <u-button type="error" shape="circle" :custom-style="customStyle">确定</u-button>
  107. </view>
  108. </view>
  109. </u-popup>
  110. <view class="friendList">
  111. <view class="friendList-item" v-for="(item ,index) in friendList" :key="item.id" @click="gotoUrl('pages/user/index?id='+item.id)">
  112. <u-image class="friendList-img" :src="item.faceImage" height="160" width="160" border-radius="10">
  113. </u-image>
  114. <view class="friendList-text">
  115. <view class="friendList-name">
  116. <span>{{item.realName}}</span>
  117. <u-icon custom-prefix="custom-icon" name="men-line" color="#1677FF"></u-icon>
  118. </view>
  119. <view class="friendList-info">
  120. <span>{{item.age}}岁 · {{item.height}}cm</span>&nbsp;<span v-if="item.weight != null">· {{item.weight}}kg</span>
  121. </view>
  122. <view class="friendList-label">
  123. <view class="friendList-label-item">
  124. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  125. <span>{{item.orgAreaName}}</span>
  126. </view>
  127. <view class="friendList-label-item">
  128. <span>{{item.educationN}}</span>
  129. </view>
  130. <view class="friendList-label-item">
  131. <span>{{item.industryN}}</span>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <u-divider v-if="friendList.length == recordsTotal" color="#B6BDC3" style="margin-top:20px;" bg-color="#f4f0f0">已经到底了</u-divider>
  137. </view>
  138. </view>
  139. </template>
  140. <script>
  141. import * as friendApi from '@/apis/friend.js'
  142. export default {
  143. data() {
  144. return {
  145. type: '', //全部0,猜你喜欢1(不传默认查全部)
  146. memberId: '', //未登录不传,登陆了传当前用户ID
  147. oppositeSex: '', //只看异性1,不传值为查看所有
  148. ageStart: '', //年龄起
  149. ageEnd: '', //年龄止
  150. heightStart: '', //身高起
  151. heightEnd: '', //身高止
  152. qy: '', //籍贯(单位所属区域)
  153. xl: '', //学历
  154. hyqk: '', //婚姻情况
  155. znqk: '', //子女情况
  156. pageIndex: 1,
  157. pageSize: 20,
  158. recordsTotal: 0,
  159. list: [],
  160. friendList: [],
  161. tabList: [{
  162. name: '全部'
  163. }, {
  164. name: '猜你喜欢'
  165. }],
  166. current: 0,
  167. randomList: [],
  168. show: false,
  169. checked: false,
  170. customStyle:{
  171. background: '#FF5E5E'
  172. },
  173. value: 30
  174. }
  175. },
  176. onLoad(op) {
  177. if(this.carhelp.getPersonInfo().id != null) {
  178. this.memberId = this.carhelp.getPersonInfo().id;
  179. }
  180. this.getFriendList();
  181. },
  182. onReachBottom() {
  183. if (this.friendList.length < this.recordsTotal) {
  184. this.myLoadmore();
  185. }
  186. },
  187. methods: {
  188. change(index) {
  189. this.current = index;
  190. this.type = index;
  191. this.getFriendList();
  192. },
  193. refreshClick() {
  194. var data = {
  195. type: 'typedssdf',
  196. memberId: 'memberId',
  197. oppositeSex: 'oppositeSex',
  198. ageStart: 'ageStart',
  199. ageEnd: 'ageEnd',
  200. heightStart: 'heightStart',
  201. heightEnd: 'heightEnd',
  202. qy: 'qy',
  203. xl: 'xl',
  204. hyqk: 'hyqk',
  205. znqk: 'znqk'
  206. };
  207. let list = [];
  208. for(var item in data) {
  209. var sgd = {};
  210. sgd[item] = data[item]
  211. list.push(sgd);
  212. }
  213. console.log(list)
  214. for(var i = 0; i < 3; i++) {
  215. var num=Math.floor(Math.random()*10+0);
  216. console.log(list[num])
  217. }
  218. },
  219. getFriendList() {
  220. uni.showLoading({
  221. title: "加载中",
  222. mask: true,
  223. })
  224. var data = {
  225. type: this.type,
  226. memberId: this.memberId,
  227. oppositeSex: this.oppositeSex,
  228. ageStart: this.ageStart,
  229. ageEnd: this.ageEnd,
  230. heightStart: this.heightStart,
  231. heightEnd: this.heightEnd,
  232. qy: this.qy,
  233. xl: this.xl,
  234. hyqk: this.hyqk,
  235. znqk: this.znqk,
  236. pageIndex: this.pageIndex,
  237. pageSize: this.pageSize
  238. };
  239. friendApi.findFriendsList(data).then((res) => {
  240. this.friendList = [
  241. ...this.friendList,
  242. ...res.data.data
  243. ];
  244. this.recordsTotal = res.data.recordsTotal;
  245. uni.hideLoading();
  246. }).catch(error => {
  247. uni.showToast({
  248. title: error
  249. })
  250. })
  251. },
  252. myLoadmore() {
  253. this.pageIndex += 1;
  254. this.getFriendList()
  255. },
  256. }
  257. }
  258. </script>
  259. <style>
  260. page {
  261. background-color: #f4f0f0;
  262. }
  263. </style>
  264. <style lang="scss" scoped>
  265. .screenCon-btn{
  266. padding: 15px;
  267. }
  268. .screenCon-slider{
  269. height: 24px;
  270. }
  271. .screenCon-choice{
  272. display: flex;
  273. flex-wrap: wrap;
  274. .choice-item{
  275. background-color: #F1F3F4;
  276. border-radius: 4px;
  277. padding:8px 0;
  278. color:#6C6A6A;
  279. width: 22%;
  280. text-align: center;
  281. margin-right: 10px;
  282. margin-bottom: 10px;
  283. }
  284. .active{
  285. background-color: #FF5E5E;
  286. color:#fff;
  287. }
  288. }
  289. .screenCon-item{
  290. padding: 10px 0;
  291. .screenCon-tit{
  292. display: flex;
  293. align-items: center;
  294. span{font-size: 16px;}
  295. p{font-size: 16px;color:#999;margin-left: 8px;}
  296. }
  297. .screenCon-con{
  298. margin-top: 12px;
  299. }
  300. }
  301. .screenCon-row{
  302. display: flex;
  303. justify-content: space-between;
  304. align-items: center;
  305. padding: 10px 0;
  306. span{
  307. font-size: 16px;
  308. }
  309. }
  310. .screenCon{
  311. height: 540px;
  312. padding: 0 15px;
  313. margin-top: 50px;
  314. }
  315. .screenTit{
  316. height: 50px;
  317. position:fixed;
  318. left: 0;
  319. top: 0;
  320. right: 0;
  321. background-color: #fff;
  322. z-index: 2;
  323. h4{
  324. position: absolute;
  325. font-weight: normal;
  326. left: 50%;
  327. top:12px;
  328. font-size: 16PX;
  329. margin-left: -32px;
  330. }
  331. span{
  332. position: absolute;
  333. color:#999;
  334. right: 15px;
  335. top: 15px;
  336. }
  337. }
  338. .navbar-tit{
  339. padding-left:15px;
  340. font-size: 24px;
  341. }
  342. .home-head {
  343. display: flex;
  344. justify-content: space-between;
  345. align-items: center;
  346. padding-right: 15px;
  347. position: fixed;
  348. left: 0;
  349. right: 0;
  350. top: 55px;
  351. z-index: 99;
  352. background-color: #FFF;
  353. .homeAdd {
  354. color: #FF5E5E;
  355. span {
  356. margin-left: 3px;
  357. }
  358. }
  359. }
  360. .friendList {
  361. padding: 15px;
  362. margin-top: 40px;
  363. .friendList-item {
  364. display: flex;
  365. background-color: #fff;
  366. padding: 12px;
  367. border-radius: 12px;
  368. margin-bottom: 15px;
  369. .friendList-text {
  370. flex: 1;
  371. min-width: 0;
  372. margin-left: 12px;
  373. display: flex;
  374. flex-direction: column;
  375. justify-content: space-between;
  376. .friendList-name {
  377. font-weight: normal;
  378. span {
  379. font-size: 18px;
  380. margin-right: 8px;
  381. }
  382. }
  383. .friendList-info {
  384. color: #999;
  385. font-size: 12px;
  386. }
  387. .friendList-label {
  388. display: flex;
  389. align-items: center;
  390. .friendList-label-item {
  391. background: #F1F3F4;
  392. padding: 2px 8px;
  393. color: #A2A9B5;
  394. border-radius: 4px;
  395. font-size: 12px;
  396. margin-right: 8px;
  397. span {
  398. margin-left: 3px;
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. </style>