index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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'">
  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. <view class="friendList">
  19. <view class="friendList-item">
  20. <u-image class="friendList-img" src="/static/img/user1.jpg" height="160" width="160" border-radius="10">
  21. </u-image>
  22. <view class="friendList-text">
  23. <view class="friendList-name">
  24. <span>刘子琪</span>
  25. <u-icon custom-prefix="custom-icon" name="men-line" color="#1677FF"></u-icon>
  26. </view>
  27. <view class="friendList-info">
  28. 24岁 · 160cm · 51kg
  29. </view>
  30. <view class="friendList-label">
  31. <view class="friendList-label-item">
  32. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  33. <span>沙市</span>
  34. </view>
  35. <view class="friendList-label-item">
  36. <span>本科</span>
  37. </view>
  38. <view class="friendList-label-item">
  39. <span>互联网/IT</span>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="friendList-item" v-for="(item ,index) in friendList" :key="item.id" @click="gotoUrl('pages/user/index?id='+item.id)">
  45. <u-image class="friendList-img" src="item.faceImage" height="160" width="160" border-radius="10">
  46. </u-image>
  47. <view class="friendList-text">
  48. <view class="friendList-name">
  49. <span>{{item.realName}}</span>
  50. <u-icon custom-prefix="custom-icon" name="men-line" color="#1677FF"></u-icon>
  51. </view>
  52. <view class="friendList-info">
  53. {{item.age}}岁 · {{item.height}}cm · {{item.weight}}kg
  54. </view>
  55. <view class="friendList-label">
  56. <view class="friendList-label-item">
  57. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  58. <span>{{item.workplace}}</span>
  59. </view>
  60. <view class="friendList-label-item">
  61. <span>{{item.educationN}}</span>
  62. </view>
  63. <view class="friendList-label-item">
  64. <span>{{item.industryN}}/IT</span>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <u-divider color="#B6BDC3" style="margin-top:20px;" bg-color="#f4f0f0">已经到底了</u-divider>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import * as friendApi from '@/apis/friend.js'
  75. export default {
  76. data() {
  77. return {
  78. type: '', //全部0,猜你喜欢1(不传默认查全部)
  79. memberId: '', //未登录不传,登陆了传当前用户ID
  80. oppositeSex: '', //只看异性1,不传值为查看所有
  81. ageStart: '', //年龄起
  82. ageEnd: '', //年龄止
  83. heightStart: '', //身高起
  84. heightEnd: '', //身高止
  85. qy: '', //籍贯(单位所属区域)
  86. xl: '', //学历
  87. hyqk: '', //婚姻情况
  88. znqk: '', //子女情况
  89. pageIndex: 1,
  90. pageSize: 20,
  91. friendList: [],
  92. tabList: [{
  93. name: '全部'
  94. }, {
  95. name: '猜你喜欢'
  96. }],
  97. current: 0,
  98. randomList: [],
  99. }
  100. },
  101. onLoad(op) {
  102. if(this.carhelp.getPersonInfo().id != null) {
  103. this.memberId = this.carhelp.getPersonInfo().id;
  104. }
  105. this.getFriendList();
  106. },
  107. methods: {
  108. change(index) {
  109. this.current = index;
  110. this.type = index;
  111. this.getFriendList();
  112. },
  113. refreshClick() {
  114. var data = {
  115. type: 'type',
  116. memberId: 'memberId',
  117. oppositeSex: 'oppositeSex',
  118. ageStart: 'ageStart',
  119. ageEnd: 'ageEnd',
  120. heightStart: 'heightStart',
  121. heightEnd: 'heightEnd',
  122. qy: 'qy',
  123. xl: 'xl',
  124. hyqk: 'hyqk',
  125. znqk: 'znqk'
  126. };
  127. var list = [];
  128. console.log(data.type)
  129. for(var i = 0; i < 3; i++) {
  130. var num=Math.floor(Math.random()*11+1);
  131. }
  132. },
  133. getFriendList() {
  134. uni.showLoading({
  135. title: "加载中",
  136. mask: true,
  137. })
  138. var data = {
  139. type: this.type,
  140. memberId: this.memberId,
  141. oppositeSex: this.oppositeSex,
  142. ageStart: this.ageStart,
  143. ageEnd: this.ageEnd,
  144. heightStart: this.heightStart,
  145. heightEnd: this.heightEnd,
  146. qy: this.qy,
  147. xl: this.xl,
  148. hyqk: this.hyqk,
  149. znqk: this.znqk,
  150. pageIndex: this.pageIndex,
  151. pageSize: this.pageSize
  152. };
  153. friendApi.findFriendsList(data).then((res) => {
  154. var jsonData = res.data.data;
  155. this.friendList = jsonData;
  156. uni.hideLoading();
  157. }).catch(error => {
  158. uni.showToast({
  159. title: error
  160. })
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style>
  167. page {
  168. background-color: #f4f0f0;
  169. }
  170. </style>
  171. <style lang="scss" scoped>
  172. .home-head {
  173. .navbar-tit{
  174. padding-left:15px;
  175. font-size: 24px;
  176. }
  177. display: flex;
  178. justify-content: space-between;
  179. align-items: center;
  180. padding-right: 15px;
  181. background-color: #FFF;
  182. .homeAdd {
  183. color: #FF5E5E;
  184. span {
  185. margin-left: 3px;
  186. }
  187. }
  188. }
  189. .friendList {
  190. padding: 15px;
  191. .friendList-item {
  192. display: flex;
  193. background-color: #fff;
  194. padding: 12px;
  195. border-radius: 12px;
  196. margin-bottom: 15px;
  197. .friendList-text {
  198. flex: 1;
  199. min-width: 0;
  200. margin-left: 12px;
  201. display: flex;
  202. flex-direction: column;
  203. justify-content: space-between;
  204. .friendList-name {
  205. font-weight: normal;
  206. span {
  207. font-size: 18px;
  208. margin-right: 8px;
  209. }
  210. }
  211. .friendList-info {
  212. color: #999;
  213. font-size: 12px;
  214. }
  215. .friendList-label {
  216. display: flex;
  217. align-items: center;
  218. .friendList-label-item {
  219. background: #F1F3F4;
  220. padding: 2px 8px;
  221. color: #A2A9B5;
  222. border-radius: 4px;
  223. font-size: 12px;
  224. margin-right: 8px;
  225. span {
  226. margin-left: 3px;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. </style>