index.vue 6.3 KB

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