index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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" style="width: 100%;">
  8. <view class="" >
  9. <img class="homeLogo" :src="homeLogo" alt="">
  10. </view>
  11. <view>
  12. <view class="homeTab" style="
  13. float: left;
  14. ">
  15. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#333" inactive-color="#c4c0c0"></u-tabs>
  16. </view>
  17. <view class="homeAdd" style="
  18. float: right;
  19. height: 34px;
  20. line-height: 34px;
  21. " >
  22. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  23. <span @click="memberQyshowBtn">{{memberQyObj.name}}</span>
  24. </view>
  25. </view>
  26. </view>
  27. </u-navbar>
  28. <view class="homeWrap">
  29. <u-swiper v-if="wrapList.length" :list="wrapList" @click="clickBanner" :img-mode="'aspectFit'" :name="'picUrl'" height="294" border-radius="24"></u-swiper>
  30. </view>
  31. <view class="homeUser">
  32. <view class="homeUser-item"
  33. @click="gotoUrl('pages/friend/personal?id='+item.id)"
  34. v-for="(item ,index) in list" :key="item.id" >
  35. <view class="homeUser-add">
  36. <u-icon custom-prefix="custom-icon" name="map-pin-2-fill"></u-icon>
  37. <span>{{item.orgAreaName}}</span>
  38. </view>
  39. <view class="homeUser-text">
  40. <view class="homeUser-name">
  41. <span>{{showName(item.realName)}}</span>
  42. <u-icon custom-prefix="custom-icon" :name="(item.gender?'women-line':'men-line')" :color="item.gender?'#FF695B':'#1677FF'"></u-icon>
  43. </view>
  44. <view class="homeUser-info">
  45. {{item.age}}岁 {{item.height?'· '+item.height+'cm':''}} {{item.weight?'· '+item.weight+'kg':''}}
  46. </view>
  47. </view>
  48. <u-image class="homeUser-img" :src="(item.faceImage?item.faceImage:'./static/img/head.png')+'?x-oss-process=image/resize,m_fill,w_256,h_256'" height="330" mode="aspectFill"></u-image>
  49. </view>
  50. </view>
  51. <u-divider color="#19be6b" style="margin-bottom:20px;" font-size="28rpx" @click="changeList">点击换一批</u-divider>
  52. </view>
  53. </template>
  54. <script>
  55. import * as Api from '@/apis/index.js'
  56. import * as Api_common from '@/apis/common.js'
  57. var homeLogo=require('@/static/img/homeLogo.png')
  58. export default {
  59. data() {
  60. return {
  61. homeLogo:homeLogo,
  62. memberQyshow:false,
  63. memberQy:0,
  64. memberQyColumns:[],
  65. listQy:[],
  66. list:[],
  67. pageIndex: 1,
  68. recordsTotal:0,
  69. tabList: [{
  70. name: '最新'
  71. }, {
  72. name: '最热'
  73. }],
  74. current: 0,
  75. wrapList: [
  76. ],
  77. timeOut: false,
  78. totalPage: 1,
  79. uuid:'',
  80. }
  81. },
  82. // onReachBottom() {
  83. // if (this.list.length < this.recordsTotal) {
  84. // this.myLoadmore();
  85. // }
  86. // },
  87. computed:{
  88. defaultvalue(){
  89. for(var i in this.listQy){
  90. if(this.listQy[i].value==this.memberQy){
  91. return [i]
  92. }
  93. }
  94. return [0]
  95. },
  96. memberQyObj(){
  97. for(var i in this.listQy){
  98. if(this.listQy[i].value==this.memberQy){
  99. return this.listQy[i]
  100. }
  101. }
  102. return {
  103. id: 0,
  104. name:"荆州市"
  105. }
  106. }
  107. },
  108. methods: {
  109. memberQyshowBtn(){
  110. this.memberQyshow = true;
  111. },
  112. // 回调参数为包含columnIndex、value、values
  113. confirm(e) {
  114. this.memberQy=e[0].value;
  115. console.log(this.memberQy)
  116. // var info= this.carhelp.getPersonInfo();
  117. // if(info){
  118. // this.carhelp.set("index-defaultvalue-memberQy",this.memberQy);
  119. // }
  120. this.memberQyshow = false;
  121. this.list = [];
  122. this.homePage();
  123. },
  124. changeList() {
  125. this.list = [];
  126. this.pageIndex += 1;
  127. if(this.pageIndex == this.totalPage+1) {
  128. this.pageIndex = 1;
  129. }
  130. this.homePage()
  131. clearInterval(this.uuid)
  132. this.uuid='';
  133. if(!this.uuid){
  134. this.uuid=setInterval(()=>{
  135. if(this.timeOut){
  136. this.timingchangeList();
  137. }
  138. },10*1000)
  139. }
  140. },
  141. timingchangeList() {
  142. this.list = [];
  143. this.pageIndex += 1;
  144. if(this.pageIndex == this.totalPage+1) {
  145. this.pageIndex = 1;
  146. }
  147. this.homePage()
  148. },
  149. change(index) {
  150. this.current = index;
  151. this.pageIndex= 1;
  152. this.list = [];
  153. this.homePage()
  154. },
  155. getBaseDictionary(){
  156. this.memberQyColumns=[];
  157. var indexdefaultvaluememberQy=false;// this.carhelp.get("index-defaultvalue-memberQy");
  158. var info= this.carhelp.getPersonInfoPlus();
  159. if(info){
  160. //this.memberQy=info.memberQy
  161. this.listQy = info.qyList;
  162. for(var i in this.listQy){
  163. this.memberQyColumns.push({
  164. label: this.listQy[i].name,
  165. value: this.listQy[i].value
  166. })
  167. }
  168. // if(indexdefaultvaluememberQy){
  169. // this.memberQy=indexdefaultvaluememberQy;
  170. // }
  171. }else{
  172. Api.getBaseDictionary({
  173. }).then((res) => {
  174. this.listQy = res.data.qyList;
  175. for(var i in this.listQy){
  176. this.memberQyColumns.push({
  177. label: this.listQy[i].name,
  178. value: this.listQy[i].value
  179. })
  180. }
  181. }).catch(error => {
  182. uni.showToast({
  183. title: error,icon: "none"
  184. })
  185. })
  186. }
  187. },
  188. homePage(){
  189. //var indexdefaultvaluememberQy=false// this.carhelp.get("index-defaultvalue-memberQy");
  190. // var info= this.carhelp.getPersonInfoPlus();
  191. // if(info){
  192. // this.memberQy=info.memberQy
  193. // if(indexdefaultvaluememberQy){
  194. // this.memberQy=indexdefaultvaluememberQy;
  195. // }
  196. // }
  197. uni.showLoading({
  198. title: "加载中",
  199. mask: true,
  200. })
  201. var memberId=undefined;
  202. if(this.carhelp.getPersonInfo()){
  203. memberId=this.carhelp.getPersonInfo().id;
  204. }
  205. Api.homePage({
  206. pageSize:8,
  207. pageIndex:this.pageIndex,
  208. type:this.current,
  209. qy: this.memberQy,
  210. memberId:memberId
  211. }).then((res) => {
  212. if(this.pageIndex==1){
  213. this.list=[]
  214. }
  215. this.list = [
  216. ...this.list,
  217. ...res.data.data
  218. ];
  219. this.recordsTotal = res.data.recordsTotal
  220. this.totalPage = res.data.totalPage
  221. uni.hideLoading()
  222. this.getBaseDictionary()
  223. }).catch(error => {
  224. uni.showToast({
  225. title: error,icon: "none"
  226. })
  227. })
  228. },getBannerInfo(){
  229. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  230. this.wrapList =res.data;
  231. }).catch(error => {
  232. uni.showToast({
  233. title: error,icon: "none"
  234. })
  235. })
  236. },clickBanner(index){
  237. var obj= this.wrapList[index]
  238. uni.navigateTo({
  239. url:obj.linkUrl
  240. })
  241. }
  242. },
  243. onUnload() {
  244. if(this.uuid){
  245. clearInterval(this.uuid)
  246. }
  247. },
  248. onHide() {
  249. this.timeOut = false;
  250. if(this.uuid){
  251. clearInterval(this.uuid)
  252. this.uuid='';
  253. }
  254. },
  255. onShow() {
  256. this.timeOut=true
  257. if(!this.uuid){
  258. this.uuid=setInterval(()=>{
  259. if(this.timeOut){
  260. this.timingchangeList();
  261. }
  262. },10*1000)
  263. }
  264. },
  265. onLoad() {
  266. var logo=this.carhelp.getConfig().logo
  267. if(logo){
  268. this.homeLogo=logo
  269. }
  270. },
  271. onReady() {
  272. this.getBannerInfo()
  273. this.homePage()
  274. }
  275. }
  276. </script>
  277. <style>
  278. /deep/.u-slot-content{
  279. flex-direction: column;
  280. align-items: flex-start;
  281. }
  282. </style>
  283. <style lang="scss" scoped>
  284. .homeLogo{
  285. margin-left: 15px;
  286. height: 28px;
  287. width: 148px;
  288. }
  289. .home-head{
  290. padding-right: 15px;
  291. background-color: #fff;
  292. z-index: 99;
  293. .homeAdd{
  294. // position: absolute;
  295. // right: -55px;
  296. // top:45px;
  297. color: #FF5E5E;
  298. span{
  299. margin-left: 3px;
  300. }
  301. }
  302. }
  303. .homeWrap{
  304. padding:0 15px;
  305. }
  306. .homeUser{
  307. display: flex;
  308. justify-content: space-between;
  309. flex-wrap: wrap;
  310. padding: 15px;
  311. .homeUser-item{
  312. width: 48%;
  313. height: 165px;
  314. margin-bottom: 15px;
  315. position: relative;
  316. color: #fff;
  317. border-radius: 12px;
  318. overflow: hidden;
  319. .homeUser-add{
  320. position: absolute;
  321. z-index: 9;
  322. right: 10px;
  323. top: 10px;
  324. background: rgba(0,0,0,0.5);
  325. padding:2px 5px;
  326. border-radius: 12px;
  327. span{
  328. margin-left: 3px;
  329. font-size: 14px;
  330. }
  331. }
  332. .homeUser-text{
  333. position: absolute;
  334. z-index: 9;
  335. left:0px ;
  336. bottom: 0px;
  337. right: 0;
  338. padding: 10px;
  339. background: linear-gradient( 180deg,rgba(0,0,0,0),rgba(0,0,0,0.5));
  340. }
  341. .homeUser-name{
  342. display: flex;
  343. align-items: center;
  344. span{
  345. margin-right: 3px;
  346. }
  347. }
  348. .homeUser-info{
  349. margin-top: 3px;
  350. }
  351. .homeUser-img{
  352. position: relative;
  353. z-index: 0;
  354. }
  355. }
  356. }
  357. </style>