index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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.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. 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: 0,
  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. this.list = [];
  105. this.homePage();
  106. },
  107. myLoadmore() {
  108. this.pageIndex += 1;
  109. this.homePage()
  110. },
  111. change(index) {
  112. this.current = index;
  113. this.pageIndex= 1;
  114. this.list = [];
  115. this.homePage()
  116. },
  117. getBaseDictionary(){
  118. this.memberQyColumns=[];
  119. var indexdefaultvaluememberQy= this.carhelp.get("index-defaultvalue-memberQy");
  120. var info= this.carhelp.getPersonInfoPlus();
  121. if(info){
  122. this.memberQy=info.memberQy
  123. this.listQy = info.qyList;
  124. for(var i in this.listQy){
  125. this.memberQyColumns.push({
  126. label: this.listQy[i].name,
  127. value: this.listQy[i].value
  128. })
  129. }
  130. }else{
  131. Api.getBaseDictionary({
  132. }).then((res) => {
  133. this.listQy = res.data.qyList;
  134. for(var i in this.listQy){
  135. this.memberQyColumns.push({
  136. label: this.listQy[i].name,
  137. value: this.listQy[i].value
  138. })
  139. }
  140. }).catch(error => {
  141. uni.showToast({
  142. title: error,icon: "none"
  143. })
  144. })
  145. }
  146. if(indexdefaultvaluememberQy){
  147. this.memberQy=indexdefaultvaluememberQy;
  148. }
  149. },
  150. homePage(){
  151. var indexdefaultvaluememberQy= this.carhelp.get("index-defaultvalue-memberQy");
  152. var info= this.carhelp.getPersonInfoPlus();
  153. if(info){
  154. this.memberQy=info.memberQy
  155. }
  156. if(indexdefaultvaluememberQy){
  157. this.memberQy=indexdefaultvaluememberQy;
  158. }
  159. uni.showLoading({
  160. title: "加载中",
  161. mask: true,
  162. })
  163. var memberId=undefined;
  164. if(this.carhelp.getPersonInfo()){
  165. memberId=this.carhelp.getPersonInfo().id;
  166. }
  167. Api.homePage({
  168. pageSize:8,
  169. pageIndex:this.pageIndex,
  170. type:this.current,
  171. qy: this.memberQy,
  172. memberId:memberId
  173. }).then((res) => {
  174. if(this.pageIndex==1){
  175. this.list=[]
  176. }
  177. this.list = [
  178. ...this.list,
  179. ...res.data.data
  180. ];
  181. this.recordsTotal = res.data.recordsTotal
  182. uni.hideLoading()
  183. this.getBaseDictionary()
  184. }).catch(error => {
  185. uni.showToast({
  186. title: error,icon: "none"
  187. })
  188. })
  189. },getBannerInfo(){
  190. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  191. this.wrapList =res.data;
  192. }).catch(error => {
  193. uni.showToast({
  194. title: error,icon: "none"
  195. })
  196. })
  197. },clickBanner(index){
  198. var obj= this.wrapList[index]
  199. }
  200. },
  201. onReady() {
  202. this.getBannerInfo()
  203. this.homePage()
  204. }
  205. }
  206. </script>
  207. <style>
  208. /deep/.u-slot-content{
  209. flex-direction: column;
  210. align-items: flex-start;
  211. }
  212. </style>
  213. <style lang="scss" scoped>
  214. .homeLogo{
  215. margin-left: 15px;
  216. height: 28px;
  217. width: 148px;
  218. }
  219. .home-head{
  220. padding-right: 15px;
  221. background-color: #fff;
  222. z-index: 99;
  223. .homeAdd{
  224. position: absolute;
  225. right: -55px;
  226. top:45px;
  227. color: #FF5E5E;
  228. span{
  229. margin-left: 3px;
  230. }
  231. }
  232. }
  233. .homeWrap{
  234. padding:0 15px;
  235. }
  236. .homeUser{
  237. display: flex;
  238. justify-content: space-between;
  239. flex-wrap: wrap;
  240. padding: 15px;
  241. .homeUser-item{
  242. width: 48%;
  243. height: 165px;
  244. margin-bottom: 15px;
  245. position: relative;
  246. color: #fff;
  247. border-radius: 12px;
  248. overflow: hidden;
  249. .homeUser-add{
  250. position: absolute;
  251. z-index: 9;
  252. right: 10px;
  253. top: 10px;
  254. background: rgba(0,0,0,0.5);
  255. padding:2px 5px;
  256. border-radius: 12px;
  257. span{
  258. margin-left: 3px;
  259. font-size: 14px;
  260. }
  261. }
  262. .homeUser-text{
  263. position: absolute;
  264. z-index: 9;
  265. left:0px ;
  266. bottom: 0px;
  267. right: 0;
  268. padding: 10px;
  269. background: linear-gradient( 180deg,rgba(0,0,0,0),rgba(0,0,0,0.5));
  270. }
  271. .homeUser-name{
  272. display: flex;
  273. align-items: center;
  274. span{
  275. margin-right: 3px;
  276. }
  277. }
  278. .homeUser-info{
  279. margin-top: 3px;
  280. }
  281. .homeUser-img{
  282. position: relative;
  283. z-index: 0;
  284. }
  285. }
  286. }
  287. </style>