index.vue 6.2 KB

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