index.vue 7.6 KB

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