index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. <template>
  2. <view>
  3. <u-select v-model="memberQyshow" @confirm="confirm" :default-value="defaultvalue" :list="memberQyColumns">
  4. </u-select>
  5. <u-navbar :is-back="false" :border-bottom="false" height="84">
  6. <view class="home-head" style="width: 100%;">
  7. <view class="">
  8. <img class="homeLogo" :src="homeLogo" alt="">
  9. </view>
  10. <view>
  11. <view class="homeTab" style="
  12. float: left;
  13. ">
  14. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false"
  15. 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'"
  30. :name="'picUrl'" height="294" border-radius="24"></u-swiper>
  31. </view>
  32. <view class="homeUser">
  33. <view class="homeUser-item" @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')"
  43. :color="item.gender?'#FF695B':'#1677FF'"></u-icon>
  44. </view>
  45. <view class="homeUser-info">
  46. {{item.age}}岁 {{item.height?'· '+item.height+'cm':''}} {{item.weight?'· '+item.weight+'kg':''}}
  47. </view>
  48. </view>
  49. <u-image class="homeUser-img"
  50. :src="(item.faceImage?item.faceImage:'./static/img/head.png')+'?x-oss-process=image/resize,m_fill,w_256,h_256'"
  51. height="330" mode="aspectFill"></u-image>
  52. </view>
  53. <!-- <u-divider color="#19be6b" style="margin-bottom:20px;" font-size="28rpx" ><span @click="changeList" v-show="timeOut" >点击刷新</span><span style="margin-left:20px" @click="onHideMethod" v-show="timeOut" >暂停</span><span style="margin-left:20px" v-show="!timeOut" @click="changeList" >自动刷新</span></u-divider> -->
  54. </view>
  55. <!-- 新闻 相亲活动-->
  56. <view class="news" v-if="newsList.length != 0">
  57. <view class="news-head">
  58. <view class="title">
  59. 新闻资讯
  60. </view>
  61. <view class="more" @click="toNewsTZGG">
  62. 更多<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
  63. </view>
  64. </view>
  65. <view class="news-item" v-for="(item,index) in newsList" :key="item.id"
  66. @click="gotoUrl('pages/news/detalis?id='+item.id)">
  67. <view class="main">
  68. <view class="content">
  69. <view class="text">
  70. <p class="u-line-2" v-text="item.title"></p>
  71. </view>
  72. <view class="time">
  73. {{item.createTime}}
  74. </view>
  75. </view>
  76. <view class="img">
  77. <img :src="item.images ? item.images : '/static/img/default_img.png'" alt="">
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="activity" v-if="activityList.length != 0">
  83. <view class="news-head">
  84. <view class="title">
  85. 相亲活动
  86. </view>
  87. <view class="more" @click="toNewsHDBG">
  88. 更多<u-icon name="arrow-right" color="#999999" size="28"></u-icon>
  89. </view>
  90. </view>
  91. <view class="news-item" v-for="(item,index) in activityList" :key="item.id"
  92. @click="gotoUrl('pages/news/activityDetails?id='+item.id)">
  93. <view class="main">
  94. <view class="content">
  95. <view class="text">
  96. <p class="u-line-2" v-text="item.title"></p>
  97. </view>
  98. <view class="time">
  99. {{item.createTime}}
  100. </view>
  101. </view>
  102. <view class="img">
  103. <img :src="item.images ? item.images : '/static/img/default_img.png'" alt="">
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="bottom">
  109. <u-divider>已经到底了</u-divider>
  110. </view> </view>
  111. </template>
  112. <script>
  113. import * as Api from '@/apis/index.js'
  114. import * as newsAPI from '@/apis/news.js'
  115. import * as Api_common from '@/apis/common.js'
  116. var homeLogo = require('@/static/img/homeLogo.png')
  117. export default {
  118. data() {
  119. return {
  120. homeLogo: homeLogo,
  121. memberQyshow: false,
  122. memberQy: 0,
  123. memberQyColumns: [],
  124. listQy: [],
  125. list: [],
  126. pageIndex: 1,
  127. recordsTotal: 0,
  128. tabList: [{
  129. name: '最新'
  130. }, {
  131. name: '最热'
  132. }],
  133. current: 0,
  134. wrapList: [],
  135. timeOut: false,
  136. totalPage: 1,
  137. uuid: '',
  138. newsList: [],
  139. activityList: [],
  140. type1: 'TZGG',
  141. type2: 'HDBG',
  142. }
  143. },
  144. // onReachBottom() {
  145. // if (this.list.length < this.recordsTotal) {
  146. // this.myLoadmore();
  147. // }
  148. // },
  149. computed: {
  150. defaultvalue() {
  151. for (var i in this.listQy) {
  152. if (this.listQy[i].value == this.memberQy) {
  153. return [i]
  154. }
  155. }
  156. return [0]
  157. },
  158. memberQyObj() {
  159. for (var i in this.listQy) {
  160. if (this.listQy[i].value == this.memberQy) {
  161. return this.listQy[i]
  162. }
  163. }
  164. return {
  165. id: 0,
  166. name: "荆州市"
  167. }
  168. }
  169. },
  170. methods: {
  171. toNewsTZGG() {
  172. this.carhelp.set("newsTypeCurrent", 0);
  173. uni.switchTab({
  174. url: '/pages/news/index'
  175. })
  176. },
  177. toNewsHDBG() {
  178. this.carhelp.set("newsTypeCurrent", 3);
  179. uni.switchTab({
  180. url: '/pages/news/index'
  181. })
  182. },
  183. getActivityList() {
  184. uni.showLoading({
  185. title: "加载中",
  186. mask: true,
  187. })
  188. newsAPI.activityList({
  189. pageSize: 2,
  190. pageIndex: 1
  191. }).then((res) => {
  192. uni.hideLoading();
  193. this.activityList = res.data.data;
  194. }).catch(error => {
  195. uni.showToast({
  196. title: error,
  197. icon: "none"
  198. })
  199. })
  200. },
  201. getNewsList() {
  202. uni.showLoading({
  203. title: "加载中",
  204. mask: true,
  205. })
  206. newsAPI.newscontent({
  207. type: 'TZGG',
  208. pageSize: 3,
  209. pageIndex: 1
  210. }).then((res) => {
  211. uni.hideLoading()
  212. this.newsList = res.data.data;
  213. }).catch(error => {
  214. uni.showToast({
  215. title: error,
  216. icon: "none"
  217. })
  218. })
  219. },
  220. memberQyshowBtn() {
  221. this.memberQyshow = true;
  222. },
  223. // 回调参数为包含columnIndex、value、values
  224. confirm(e) {
  225. this.memberQy = e[0].value;
  226. console.log(this.memberQy)
  227. // var info= this.carhelp.getPersonInfo();
  228. // if(info){
  229. // this.carhelp.set("index-defaultvalue-memberQy",this.memberQy);
  230. // }
  231. this.memberQyshow = false;
  232. this.list = [];
  233. this.homePage();
  234. },
  235. // changeList() {
  236. // this.list = [];
  237. // this.pageIndex += 1;
  238. // if(this.pageIndex == this.totalPage+1) {
  239. // this.pageIndex = 1;
  240. // }
  241. // this.homePage()
  242. // if(this.uuid){
  243. // clearInterval(this.uuid)
  244. // }
  245. // this.uuid='';
  246. // if(!this.uuid){
  247. // this.timeOut=true;
  248. // this.uuid=setInterval(()=>{
  249. // if(this.timeOut){
  250. // this.timingchangeList();
  251. // }
  252. // },10*1500)
  253. // }
  254. // },
  255. timingchangeList() {
  256. this.list = [];
  257. this.pageIndex += 1;
  258. if (this.pageIndex == this.totalPage + 1) {
  259. this.pageIndex = 1;
  260. }
  261. this.homePage()
  262. },
  263. change(index) {
  264. this.current = index;
  265. this.pageIndex = 1;
  266. this.list = [];
  267. this.homePage()
  268. },
  269. getBaseDictionary() {
  270. this.memberQyColumns = [];
  271. var indexdefaultvaluememberQy = false; // this.carhelp.get("index-defaultvalue-memberQy");
  272. var info = this.carhelp.getPersonInfoPlus();
  273. if (info) {
  274. //this.memberQy=info.memberQy
  275. this.listQy = info.qyList;
  276. for (var i in this.listQy) {
  277. this.memberQyColumns.push({ label: this.listQy[i].name, value: this.listQy[i].value
  278. })
  279. }
  280. // if(indexdefaultvaluememberQy){
  281. // this.memberQy=indexdefaultvaluememberQy;
  282. // }
  283. } else {
  284. Api.getBaseDictionary({
  285. }).then((res) => {
  286. this.listQy = res.data.qyList;
  287. for (var i in this.listQy) {
  288. this.memberQyColumns.push({
  289. label: this.listQy[i].name,
  290. value: this.listQy[i].value })
  291. }
  292. }).catch(error => {
  293. uni.showToast({
  294. title: error,
  295. icon: "none"
  296. })
  297. })
  298. }
  299. },
  300. homePage() {
  301. //var indexdefaultvaluememberQy=false// this.carhelp.get("index-defaultvalue-memberQy");
  302. // var info= this.carhelp.getPersonInfoPlus();
  303. // if(info){
  304. // this.memberQy=info.memberQy
  305. // if(indexdefaultvaluememberQy){
  306. // this.memberQy=indexdefaultvaluememberQy;
  307. // }
  308. // }
  309. uni.showLoading({
  310. title: "加载中",
  311. mask: true,
  312. })
  313. var memberId = undefined;
  314. if (this.carhelp.getPersonInfo()) {
  315. memberId = this.carhelp.getPersonInfo().id;
  316. }
  317. Api.homePage({
  318. pageSize: 8,
  319. pageIndex: this.pageIndex,
  320. type: this.current,
  321. qy: this.memberQy,
  322. memberId: memberId
  323. }).then((res) => {
  324. if (this.pageIndex == 1) {
  325. this.list = []
  326. }
  327. this.list = [ ...this.list, ...res.data.data
  328. ] ;
  329. this.recordsTotal = res.data.recordsTotal
  330. this.totalPage = res.data.totalPage
  331. uni.hideLoading()
  332. }).catch(error => {
  333. uni.showToast({
  334. title: error,
  335. icon: "none"
  336. })
  337. })
  338. },
  339. getBannerInfo() {
  340. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  341. this.wrapList = res.data;
  342. }).catch(error => {
  343. uni.showToast({
  344. title: error,
  345. icon: "none"
  346. })
  347. })
  348. },
  349. clickBanner(index) {
  350. var obj = this.wrapList[index]
  351. uni.navigateTo({
  352. url: obj.linkUrl
  353. })
  354. },
  355. onHideMethod() {
  356. this.timeOut = false;
  357. if (this.uuid) {
  358. clearInterval(this.uuid)
  359. this.uuid = '';
  360. }
  361. },
  362. onShowMethod() {
  363. this.timeOut = true
  364. if (!this.uuid) {
  365. this.uuid = setInterval(() => {
  366. if (this.timeOut) {
  367. this.timingchangeList();
  368. }
  369. }, 10 * 1500)
  370. }
  371. }
  372. },
  373. onUnload() {
  374. if (this.uuid) {
  375. clearInterval(this.uuid)
  376. }
  377. },
  378. onHide() {
  379. console.log("onHide")
  380. this.onHideMethod()
  381. },
  382. onShow() {
  383. this.onShowMethod()
  384. },
  385. onLoad() {
  386. var logo = this.carhelp.getConfig().logo
  387. if (logo) {
  388. this.homeLogo = logo
  389. }
  390. } ,
  391. onReady() {
  392. this.getBaseDictionary()
  393. this.getBannerInfo()
  394. this.homePage()
  395. this.getNewsList()
  396. this.getActivityList()
  397. }
  398. }
  399. </script>
  400. <style>
  401. /deep/.u-slot-content {
  402. flex-direction: column;
  403. align-items: flex-start;
  404. }
  405. </style>
  406. <style lang="scss" scoped>
  407. .homeLogo {
  408. margin-left: 15px;
  409. height: 28px;
  410. width: 148px;
  411. }
  412. .home-head {
  413. padding-right: 15px;
  414. background-color: #fff;
  415. z-index: 99;
  416. .homeAdd {
  417. // position: absolute;
  418. // right: -55px;
  419. // top:45px;
  420. color: #FF5E5E;
  421. span {
  422. margin-left: 3px;
  423. }
  424. }
  425. }
  426. .homeWrap {
  427. padding: 0 15px;
  428. }
  429. .homeUser {
  430. display: flex;
  431. justify-content: space-between;
  432. flex-wrap: wrap;
  433. padding: 15px;
  434. .homeUser-item {
  435. width: 48%;
  436. height: 165px;
  437. margin-bottom: 15px;
  438. position: relative;
  439. color: #fff;
  440. border-radius: 12px;
  441. overflow: hidden;
  442. .homeUser-add {
  443. position: absolute;
  444. z-index: 9;
  445. right: 10px;
  446. top: 10px;
  447. background: rgba(0, 0, 0, 0.5);
  448. padding: 2px 5px;
  449. border-radius: 12px;
  450. span {
  451. margin-left: 3px;
  452. font-size: 14px;
  453. }
  454. }
  455. .homeUser-text {
  456. position: absolute;
  457. z-index: 9;
  458. left: 0px;
  459. bottom: 0px;
  460. right: 0;
  461. padding: 10px;
  462. background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
  463. }
  464. .homeUser-name {
  465. display: flex;
  466. align-items: center;
  467. span {
  468. margin-right: 3px;
  469. }
  470. }
  471. .homeUser-info {
  472. margin-top: 3px;
  473. }
  474. .homeUser-img {
  475. position: relative;
  476. z-index: 0;
  477. }
  478. }
  479. }
  480. // 新闻
  481. .news,
  482. .activity {
  483. background-color: #fff;
  484. margin: 20px 16px;
  485. .news-item {
  486. margin-bottom: 48rpx;
  487. }
  488. .news-head {
  489. display: flex;
  490. justify-content: space-between;
  491. align-items: center;
  492. .title {
  493. font-size: 20px;
  494. color: #101010;
  495. }
  496. .more {
  497. color: #999999;
  498. font-size: 16px
  499. }
  500. }
  501. .main {
  502. display: flex;
  503. justify-content: space-between;
  504. margin-top: 26rpx;
  505. .content {
  506. width: 67.3%;
  507. display: flex;
  508. flex-direction: column;
  509. justify-content: space-between;
  510. .text {
  511. width: 100%;
  512. color: #101010;
  513. }
  514. .time {
  515. // margin-top: 40rpx;
  516. font-size: 12px;
  517. color: #999999;
  518. }
  519. }
  520. .img {
  521. width: 200rpx;
  522. height: 150rpx;
  523. border-radius: 4px;
  524. overflow: hidden;
  525. img {
  526. width: 100%;
  527. height: 100%;
  528. }
  529. }
  530. }
  531. }
  532. .bottom {
  533. margin-bottom: 90px;
  534. }
  535. </style>