index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view>
  3. <u-select v-model="memberQyshow"
  4. @confirm="confirm" :default-value="defaultvalue"
  5. :list="memberQyColumns"></u-select>
  6. <u-navbar :is-back="false" :border-bottom="false" height="84" >
  7. <view class="home-head">
  8. <view class="" >
  9. <img class="homeLogo" src="/static/img/homeLogo.png" alt="">
  10. </view>
  11. <view class="homeTab">
  12. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
  13. </view>
  14. <view class="homeAdd" >
  15. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  16. <span @click="memberQyshowBtn">{{memberQyObj.name}}</span>
  17. </view>
  18. </view>
  19. </u-navbar>
  20. <view class="homeWrap">
  21. <u-swiper :list="wrapList" @click="clickBanner" :img-mode="'aspectFit'" :name="'picUrl'" height="300" border-radius="24"></u-swiper>
  22. </view>
  23. <view class="homeUser">
  24. <view class="homeUser-item"
  25. @click="gotoUrl('pages/friend/personal?id='+item.id)"
  26. v-for="(item ,index) in list" :key="item.id" >
  27. <view class="homeUser-add">
  28. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  29. <span>{{item.workplaceN}}</span>
  30. </view>
  31. <view class="homeUser-text">
  32. <view class="homeUser-name">
  33. <span>{{item.realName}}</span>
  34. <u-icon custom-prefix="custom-icon" :name="(item.gender?'women-line':'men-line')" :color="item.gender?'#FF695B':'#1677FF'"></u-icon>
  35. </view>
  36. <view class="homeUser-info">
  37. {{item.age}}岁 · {{item.height}}cm {{item.weight?'· '+item.weight+'kg':''}}
  38. </view>
  39. </view>
  40. <u-image class="homeUser-img" :src="item.faceImage" height="330" mode="aspectFill"></u-image>
  41. </view>
  42. </view>
  43. <u-divider color="#B6BDC3" v-if="list.length ==recordsTotal" style="margin-top:20px;">已经到底了</u-divider>
  44. </view>
  45. </template>
  46. <script>
  47. import * as Api from '@/apis/index.js'
  48. import * as Api_common from '@/apis/common.js'
  49. export default {
  50. data() {
  51. return {
  52. memberQyshow:false,
  53. memberQy:1,
  54. memberQyColumns:[],
  55. listQy:[],
  56. list:[],
  57. pageIndex: 1,
  58. recordsTotal:0,
  59. tabList: [{
  60. name: '最新'
  61. }, {
  62. name: '最热'
  63. }],
  64. current: 0,
  65. wrapList: [
  66. ],
  67. }
  68. },
  69. onReachBottom() {
  70. if (this.list.length < this.recordsTotal) {
  71. this.myLoadmore();
  72. }
  73. },
  74. computed:{
  75. defaultvalue(){
  76. for(var i in this.listQy){
  77. if(this.listQy[i].value==this.memberQy){
  78. return [i]
  79. }
  80. }
  81. return [0]
  82. },
  83. memberQyObj(){
  84. for(var i in this.listQy){
  85. if(this.listQy[i].value==this.memberQy){
  86. return this.listQy[i]
  87. }
  88. }
  89. return {
  90. id:-1,
  91. name:"荆州市"
  92. }
  93. }
  94. },
  95. methods: {
  96. memberQyshowBtn(){
  97. this.memberQyshow = true
  98. },
  99. // 回调参数为包含columnIndex、value、values
  100. confirm(e) {
  101. this.memberQy=e[0].value
  102. this.carhelp.set("index-defaultvalue-memberQy",this.memberQy);
  103. this.memberQyshow = false
  104. },
  105. myLoadmore() {
  106. this.pageIndex += 1;
  107. this.homePage()
  108. },
  109. change(index) {
  110. this.current = index;
  111. this.pageIndex= 1;
  112. this.list = [];
  113. this.homePage()
  114. },
  115. getBaseDictionary(){
  116. this.memberQyColumns=[];
  117. var indexdefaultvaluememberQy= this.carhelp.get("index-defaultvalue-memberQy");
  118. var info= this.carhelp.getPersonInfoPlus();
  119. if(info){
  120. this.memberQy=info.memberQy
  121. this.listQy = info.qyList;
  122. for(var i in this.listQy){
  123. this.memberQyColumns.push({
  124. label: this.listQy[i].name,
  125. value: this.listQy[i].value
  126. })
  127. }
  128. }else{
  129. Api.getBaseDictionary({
  130. }).then((res) => {
  131. this.listQy = res.data.qyList;
  132. for(var i in this.listQy){
  133. this.memberQyColumns.push({
  134. label: this.listQy[i].name,
  135. value: this.listQy[i].value
  136. })
  137. }
  138. }).catch(error => {
  139. uni.showToast({
  140. title: error,icon: "none"
  141. })
  142. })
  143. }
  144. if(indexdefaultvaluememberQy){
  145. this.memberQy=indexdefaultvaluememberQy;
  146. }
  147. },
  148. homePage(){
  149. uni.showLoading({
  150. title: "加载中",
  151. mask: true,
  152. })
  153. var memberId=undefined;
  154. if(this.carhelp.getPersonInfo()){
  155. memberId=this.carhelp.getPersonInfo().id;
  156. }
  157. Api.homePage({
  158. pageSize:8,
  159. pageIndex:this.pageIndex,
  160. type:this.current,
  161. memberId:memberId
  162. }).then((res) => {
  163. this.list = [
  164. ...this.list,
  165. ...res.data.data
  166. ];
  167. this.recordsTotal = res.data.recordsTotal
  168. uni.hideLoading()
  169. this.getBaseDictionary()
  170. }).catch(error => {
  171. uni.showToast({
  172. title: error,icon: "none"
  173. })
  174. })
  175. },getBannerInfo(){
  176. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  177. this.wrapList =res.data;
  178. }).catch(error => {
  179. uni.showToast({
  180. title: error,icon: "none"
  181. })
  182. })
  183. },clickBanner(index){
  184. var obj= this.wrapList[index]
  185. }
  186. },
  187. onReady() {
  188. this.getBannerInfo()
  189. this.homePage()
  190. }
  191. }
  192. </script>
  193. <style>
  194. /deep/.u-slot-content{
  195. flex-direction: column;
  196. align-items: flex-start;
  197. }
  198. </style>
  199. <style lang="scss" scoped>
  200. .homeLogo{
  201. margin-left: 15px;
  202. height: 28px;
  203. width: 148px;
  204. }
  205. .home-head{
  206. padding-right: 15px;
  207. background-color: #fff;
  208. z-index: 99;
  209. .homeAdd{
  210. position: absolute;
  211. right: -55px;
  212. top:45px;
  213. color: #FF5E5E;
  214. span{
  215. margin-left: 3px;
  216. }
  217. }
  218. }
  219. .homeWrap{
  220. padding:0 15px;
  221. }
  222. .homeUser{
  223. display: flex;
  224. justify-content: space-between;
  225. flex-wrap: wrap;
  226. padding: 15px;
  227. .homeUser-item{
  228. width: 48%;
  229. height: 165px;
  230. margin-bottom: 15px;
  231. position: relative;
  232. color: #fff;
  233. border-radius: 12px;
  234. overflow: hidden;
  235. .homeUser-add{
  236. position: absolute;
  237. z-index: 9;
  238. right: 10px;
  239. top: 10px;
  240. background: rgba(0,0,0,0.5);
  241. padding:2px 5px;
  242. border-radius: 12px;
  243. span{
  244. margin-left: 3px;
  245. font-size: 14px;
  246. }
  247. }
  248. .homeUser-text{
  249. position: absolute;
  250. z-index: 9;
  251. left:0px ;
  252. bottom: 0px;
  253. right: 0;
  254. padding: 10px;
  255. background: linear-gradient( 180deg,rgba(0,0,0,0),rgba(0,0,0,0.5));
  256. }
  257. .homeUser-name{
  258. display: flex;
  259. align-items: center;
  260. span{
  261. margin-right: 3px;
  262. }
  263. }
  264. .homeUser-info{
  265. margin-top: 3px;
  266. }
  267. .homeUser-img{
  268. position: relative;
  269. z-index: 0;
  270. }
  271. }
  272. }
  273. </style>