index.vue 7.1 KB

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