index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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="toNews">
  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="toNews">
  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. }
  141. },
  142. // onReachBottom() {
  143. // if (this.list.length < this.recordsTotal) {
  144. // this.myLoadmore();
  145. // }
  146. // },
  147. computed: {
  148. defaultvalue() {
  149. for (var i in this.listQy) {
  150. if (this.listQy[i].value == this.memberQy) {
  151. return [i]
  152. }
  153. }
  154. return [0]
  155. },
  156. memberQyObj() {
  157. for (var i in this.listQy) {
  158. if (this.listQy[i].value == this.memberQy) {
  159. return this.listQy[i]
  160. }
  161. }
  162. return {
  163. id: 0,
  164. name: "荆州市"
  165. }
  166. }
  167. },
  168. methods: {
  169. toNews() {
  170. uni.switchTab({
  171. url: '/pages/news/index'
  172. })
  173. },
  174. getActivityList() {
  175. uni.showLoading({
  176. title: "加载中",
  177. mask: true,
  178. })
  179. newsAPI.activityList({
  180. pageSize: 2,
  181. pageIndex: 1
  182. }).then((res) => {
  183. uni.hideLoading();
  184. this.activityList = res.data.data;
  185. }).catch(error => {
  186. uni.showToast({
  187. title: error,
  188. icon: "none"
  189. })
  190. })
  191. },
  192. getNewsList() {
  193. uni.showLoading({
  194. title: "加载中",
  195. mask: true,
  196. })
  197. newsAPI.newscontent({
  198. type: 'TZGG',
  199. pageSize: 3,
  200. pageIndex: 1
  201. }).then((res) => {
  202. uni.hideLoading()
  203. this.newsList = res.data.data;
  204. }).catch(error => {
  205. uni.showToast({
  206. title: error,
  207. icon: "none"
  208. })
  209. })
  210. },
  211. memberQyshowBtn() {
  212. this.memberQyshow = true;
  213. },
  214. // 回调参数为包含columnIndex、value、values
  215. confirm(e) {
  216. this.memberQy = e[0].value;
  217. console.log(this.memberQy)
  218. // var info= this.carhelp.getPersonInfo();
  219. // if(info){
  220. // this.carhelp.set("index-defaultvalue-memberQy",this.memberQy);
  221. // }
  222. this.memberQyshow = false;
  223. this.list = [];
  224. this.homePage();
  225. },
  226. // changeList() {
  227. // this.list = [];
  228. // this.pageIndex += 1;
  229. // if(this.pageIndex == this.totalPage+1) {
  230. // this.pageIndex = 1;
  231. // }
  232. // this.homePage()
  233. // if(this.uuid){
  234. // clearInterval(this.uuid)
  235. // }
  236. // this.uuid='';
  237. // if(!this.uuid){
  238. // this.timeOut=true;
  239. // this.uuid=setInterval(()=>{
  240. // if(this.timeOut){
  241. // this.timingchangeList();
  242. // }
  243. // },10*1500)
  244. // }
  245. // },
  246. timingchangeList() {
  247. this.list = [];
  248. this.pageIndex += 1;
  249. if (this.pageIndex == this.totalPage + 1) {
  250. this.pageIndex = 1;
  251. }
  252. this.homePage()
  253. },
  254. change(index) {
  255. this.current = index;
  256. this.pageIndex = 1;
  257. this.list = [];
  258. this.homePage()
  259. },
  260. getBaseDictionary() {
  261. this.memberQyColumns = [];
  262. var indexdefaultvaluememberQy = false; // this.carhelp.get("index-defaultvalue-memberQy");
  263. var info = this.carhelp.getPersonInfoPlus();
  264. if (info) {
  265. //this.memberQy=info.memberQy
  266. this.listQy = info.qyList;
  267. for (var i in this.listQy) {
  268. this.memberQyColumns.push({ label: this.listQy[i].name, value: this.listQy[i].value
  269. })
  270. }
  271. // if(indexdefaultvaluememberQy){
  272. // this.memberQy=indexdefaultvaluememberQy;
  273. // }
  274. } else {
  275. Api.getBaseDictionary({
  276. }).then((res) => {
  277. this.listQy = res.data.qyList;
  278. for (var i in this.listQy) {
  279. this.memberQyColumns.push({
  280. label: this.listQy[i].name,
  281. value: this.listQy[i].value })
  282. }
  283. }).catch(error => {
  284. uni.showToast({
  285. title: error,
  286. icon: "none"
  287. })
  288. })
  289. }
  290. },
  291. homePage() {
  292. //var indexdefaultvaluememberQy=false// this.carhelp.get("index-defaultvalue-memberQy");
  293. // var info= this.carhelp.getPersonInfoPlus();
  294. // if(info){
  295. // this.memberQy=info.memberQy
  296. // if(indexdefaultvaluememberQy){
  297. // this.memberQy=indexdefaultvaluememberQy;
  298. // }
  299. // }
  300. uni.showLoading({
  301. title: "加载中",
  302. mask: true,
  303. })
  304. var memberId = undefined;
  305. if (this.carhelp.getPersonInfo()) {
  306. memberId = this.carhelp.getPersonInfo().id;
  307. }
  308. Api.homePage({
  309. pageSize: 8,
  310. pageIndex: this.pageIndex,
  311. type: this.current,
  312. qy: this.memberQy,
  313. memberId: memberId
  314. }).then((res) => {
  315. if (this.pageIndex == 1) {
  316. this.list = []
  317. }
  318. this.list = [ ...this.list, ...res.data.data
  319. ] ;
  320. this.recordsTotal = res.data.recordsTotal
  321. this.totalPage = res.data.totalPage
  322. uni.hideLoading()
  323. }).catch(error => {
  324. uni.showToast({
  325. title: error,
  326. icon: "none"
  327. })
  328. })
  329. },
  330. getBannerInfo() {
  331. Api_common.getBannerInfo("HOMEPAGE").then((res) => {
  332. this.wrapList = res.data;
  333. }).catch(error => {
  334. uni.showToast({
  335. title: error,
  336. icon: "none"
  337. })
  338. })
  339. },
  340. clickBanner(index) {
  341. var obj = this.wrapList[index]
  342. uni.navigateTo({
  343. url: obj.linkUrl
  344. })
  345. },
  346. onHideMethod() {
  347. this.timeOut = false;
  348. if (this.uuid) {
  349. clearInterval(this.uuid)
  350. this.uuid = '';
  351. }
  352. },
  353. onShowMethod() {
  354. this.timeOut = true
  355. if (!this.uuid) {
  356. this.uuid = setInterval(() => {
  357. if (this.timeOut) {
  358. this.timingchangeList();
  359. }
  360. }, 10 * 1500)
  361. }
  362. }
  363. },
  364. onUnload() {
  365. if (this.uuid) {
  366. clearInterval(this.uuid)
  367. }
  368. },
  369. onHide() {
  370. console.log("onHide")
  371. this.onHideMethod()
  372. },
  373. onShow() {
  374. this.onShowMethod()
  375. },
  376. onLoad() {
  377. var logo = this.carhelp.getConfig().logo
  378. if (logo) {
  379. this.homeLogo = logo
  380. }
  381. } ,
  382. onReady() {
  383. this.getBaseDictionary()
  384. this.getBannerInfo()
  385. this.homePage()
  386. this.getNewsList()
  387. this.getActivityList()
  388. }
  389. }
  390. </script>
  391. <style>
  392. /deep/.u-slot-content {
  393. flex-direction: column;
  394. align-items: flex-start;
  395. }
  396. </style>
  397. <style lang="scss" scoped>
  398. .homeLogo {
  399. margin-left: 15px;
  400. height: 28px;
  401. width: 148px;
  402. }
  403. .home-head {
  404. padding-right: 15px;
  405. background-color: #fff;
  406. z-index: 99;
  407. .homeAdd {
  408. // position: absolute;
  409. // right: -55px;
  410. // top:45px;
  411. color: #FF5E5E;
  412. span {
  413. margin-left: 3px;
  414. }
  415. }
  416. }
  417. .homeWrap {
  418. padding: 0 15px;
  419. }
  420. .homeUser {
  421. display: flex;
  422. justify-content: space-between;
  423. flex-wrap: wrap;
  424. padding: 15px;
  425. .homeUser-item {
  426. width: 48%;
  427. height: 165px;
  428. margin-bottom: 15px;
  429. position: relative;
  430. color: #fff;
  431. border-radius: 12px;
  432. overflow: hidden;
  433. .homeUser-add {
  434. position: absolute;
  435. z-index: 9;
  436. right: 10px;
  437. top: 10px;
  438. background: rgba(0, 0, 0, 0.5);
  439. padding: 2px 5px;
  440. border-radius: 12px;
  441. span {
  442. margin-left: 3px;
  443. font-size: 14px;
  444. }
  445. }
  446. .homeUser-text {
  447. position: absolute;
  448. z-index: 9;
  449. left: 0px;
  450. bottom: 0px;
  451. right: 0;
  452. padding: 10px;
  453. background: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
  454. }
  455. .homeUser-name {
  456. display: flex;
  457. align-items: center;
  458. span {
  459. margin-right: 3px;
  460. }
  461. }
  462. .homeUser-info {
  463. margin-top: 3px;
  464. }
  465. .homeUser-img {
  466. position: relative;
  467. z-index: 0;
  468. }
  469. }
  470. }
  471. // 新闻
  472. .news,
  473. .activity {
  474. background-color: #fff;
  475. margin: 20px 16px;
  476. .news-item {
  477. margin-bottom: 48rpx;
  478. }
  479. .news-head {
  480. display: flex;
  481. justify-content: space-between;
  482. align-items: center;
  483. .title {
  484. font-size: 20px;
  485. color: #101010;
  486. }
  487. .more {
  488. color: #999999;
  489. font-size: 16px
  490. }
  491. }
  492. .main {
  493. display: flex;
  494. justify-content: space-between;
  495. margin-top: 26rpx;
  496. .content {
  497. width: 67.3%;
  498. display: flex;
  499. flex-direction: column;
  500. justify-content: space-between;
  501. .text {
  502. width: 100%;
  503. color: #101010;
  504. }
  505. .time {
  506. // margin-top: 40rpx;
  507. font-size: 12px;
  508. color: #999999;
  509. }
  510. }
  511. .img {
  512. width: 200rpx;
  513. height: 150rpx;
  514. border-radius: 4px;
  515. overflow: hidden;
  516. img {
  517. width: 100%;
  518. height: 100%;
  519. }
  520. }
  521. }
  522. }
  523. .bottom {
  524. margin-bottom: 90px;
  525. }
  526. </style>