index.vue 7.3 KB

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