reportHome.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <view class="container">
  3. <view v-show="menuCurrent === 0">
  4. <view class="menus-box">
  5. <view class="menus-item-box" @click="toReportList(key, data.value)" v-for="(data,key) in categoryList"
  6. :key="key">
  7. <view class="icon-box">
  8. <view class="iconfont" :class="iconList[key]? iconList[key] : 'icon-hetong'"></view>
  9. </view>
  10. <view class="text-box">
  11. {{ key }}
  12. </view>
  13. </view>
  14. <!-- <view class="menus-item-box" @click="toReportList('二手住宅市场')">
  15. <view class="icon-box">
  16. <view class="iconfont icon-hetong"></view>
  17. </view>
  18. <view class="text-box">
  19. 二手住宅市场
  20. </view>
  21. </view>
  22. <view class="menus-item-box" @click="toReportList('住宅租赁市场')">
  23. <view class="icon-box">
  24. <view class="iconfont icon-chengshi"></view>
  25. </view>
  26. <view class="text-box">
  27. 住宅租赁市场
  28. </view>
  29. </view>
  30. <view class="menus-item-box" @click="toReportList('房地产中介行业')">
  31. <view class="icon-box">
  32. <view class="iconfont icon-zhongjie"></view>
  33. </view>
  34. <view class="text-box">
  35. 房地产中介行业
  36. </view>
  37. </view> -->
  38. </view>
  39. </view>
  40. <view v-show="menuCurrent === 1">
  41. <view class="header-box">
  42. <view class="search-box">
  43. <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5"
  44. :input-style="searchInputStyle" placeholder="搜索您想要的内容"
  45. @search="searchHistory(searchForm.keyword, 1)"
  46. @custom="searchHistory(searchForm.keyword, 1)"></u-search>
  47. </view>
  48. </view>
  49. <u-empty margin-top="50" mode="data" v-if="list.length === 0" iconSize="120" textSize="58" text="暂无数据">
  50. </u-empty>
  51. <view class="list-box">
  52. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
  53. <view class="image-box">
  54. <image :src="item.cover" mode="aspectFill"></image>
  55. </view>
  56. <view class="info-box">
  57. <view class="title">
  58. {{item.title}}
  59. </view>
  60. <view class="time">
  61. <span class="iconfont icon-time"></span>
  62. <span>{{item.viewDate}}</span>
  63. </view>
  64. <view class="func">
  65. <view v-if="item.viewMode==='1'" class="func-box" style="justify-content: flex-end;">
  66. <view class="button free">免费</view>
  67. </view>
  68. <view v-else-if="item.viewMode==='2' && isMember" class="func-box">
  69. <view class="price">¥{{ item.price }}元</view>
  70. <view class="button member-free">会员免费</view>
  71. </view>
  72. <view v-else-if="item.viewMode==='2' && !isMember" class="func-box">
  73. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  74. <view class="member-free">
  75. 会员免费
  76. </view>
  77. <view class="not-member-price">
  78. 非会员:¥{{item.price}}元
  79. </view>
  80. </view>
  81. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  82. {{item.hasBuy ? '已购买' : '立即购买'}}
  83. </view>
  84. </view>
  85. <view v-else-if="item.viewMode==='3' && item.price===item.priceMember" class="func-box">
  86. <view class="price">¥{{ item.price }}元</view>
  87. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  88. {{item.hasBuy ? '已购买' : '立即购买'}}
  89. </view>
  90. </view>
  91. <view v-else-if="item.viewMode==='3' && item.price!==item.priceMember" class="func-box">
  92. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  93. <view class="member-free">
  94. {{`会员:${item.priceMember}元`}}
  95. </view>
  96. <view class="not-member-price">
  97. 非会员:¥{{item.price}}元
  98. </view>
  99. </view>
  100. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  101. {{item.hasBuy ? '已购买' : '立即购买'}}
  102. </view>
  103. </view>
  104. <!-- <view v-if="item.free > 0" class="button free">免费</view>
  105. <view v-else-if="item.memberFree > 0" class="button member-free">会员免费</view>
  106. <view v-else :class="['button', item.status > 0 ? 'free' : 'buy']">
  107. {{item.status > 0 ? '已购买' : '立即购买'}}
  108. </view> -->
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. <!-- <u-loadmore :status="status" margin-top="20" margin-bottom="20"/> -->
  114. </view>
  115. <view v-show="menuCurrent === 2">
  116. <view class="header-box">
  117. <view class="search-box">
  118. <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5"
  119. :input-style="searchInputStyle" placeholder="搜索您想要的内容" @search="searchMy(searchForm.keyword, 1)"
  120. @custom="searchMy(searchForm.keyword, 1)"></u-search>
  121. </view>
  122. </view>
  123. <u-empty margin-top="50" mode="data" v-if="list2.length === 0" iconSize="120" textSize="58" text="暂无数据">
  124. </u-empty>
  125. <view class="list-box">
  126. <view class="list-item-box" v-for="item in list2" :key="item.id" @click="onClickReport(item)">
  127. <view class="image-box">
  128. <image :src="item.cover" mode="aspectFill"></image>
  129. </view>
  130. <view class="info-box">
  131. <view class="title">
  132. {{item.title}}
  133. </view>
  134. <view class="time">
  135. <span>购买时间:&nbsp;{{item.buyDate}}</span>
  136. </view>
  137. <view class="func">
  138. <view class="price">实付款:{{item.buyPrice}}元</view>
  139. </view>
  140. </view>
  141. </view>
  142. </view>
  143. </view>
  144. <u-loadmore v-if="menuCurrent !== 0 && status !== 'nomore'" :status="status" margin-top="20" margin-bottom="20"
  145. @loadmore="loadMore" />
  146. <view class="bottom-block"></view>
  147. <view class="bottom-box">
  148. <view class="menu-box">
  149. <view class="menu-item-box" :class="{'is-active': menuCurrent === 0}" @click="onMenuClick(0)">
  150. <view class="iconfont icon-home"></view>
  151. <view class="text">首页</view>
  152. </view>
  153. <view class="menu-item-box" :class="{'is-active': menuCurrent === 1}" @click="onMenuClick(1)">
  154. <view class="iconfont icon-time"></view>
  155. <view class="text">我的浏览</view>
  156. </view>
  157. <view class="menu-item-box" :class="{'is-active': menuCurrent === 2}" @click="onMenuClick(2)">
  158. <view class="iconfont icon-baogao"></view>
  159. <view class="text">我的报告</view>
  160. </view>
  161. </view>
  162. </view>
  163. </view>
  164. </template>
  165. <script setup>
  166. import {
  167. ref,
  168. computed
  169. } from 'vue'
  170. import {
  171. onLoad,
  172. onReachBottom
  173. } from '@dcloudio/uni-app'
  174. import {
  175. getReportCate,
  176. loadReportHistory,
  177. loadMyReport
  178. } from '@/api/report.js'
  179. import {
  180. useReportStore
  181. } from '@/store/reportStore.js'
  182. const reportStore = useReportStore();
  183. const categoryList = ref({});
  184. const pageNum = ref(1);
  185. const status = ref('nomore');
  186. const list = ref([]);
  187. const list2 = ref([]);
  188. const listCount = ref(0);
  189. const listCount2 = ref(0);
  190. const iconList = {
  191. "二手住宅市场": "icon-hetong",
  192. "住宅租赁市场": "icon-chengshi",
  193. "房地产中介行业": "icon-zhongjie"
  194. }
  195. const customButtonStyle = {
  196. height: '40rpx',
  197. lineHeight: '40rpx',
  198. padding: '0 30rpx'
  199. }
  200. const searchInputStyle = {
  201. backgroundColor: '#E5E5E5'
  202. }
  203. const searchForm = ref({
  204. keyword: '',
  205. type: 0
  206. })
  207. const menuCurrent = ref(0)
  208. function onMenuClick(index) {
  209. menuCurrent.value = index;
  210. searchForm.value.keyword = ""
  211. status.value = 'loadmore'
  212. if (index === 1) {
  213. // 浏览记录
  214. searchHistory("", 1)
  215. } else if (index === 2) {
  216. // 我的报告
  217. searchMy("", 1)
  218. }
  219. }
  220. function searchHistory(keyword, pageNumber, pageSize) {
  221. status.value = 'loading'
  222. loadReportHistory({
  223. keyword,
  224. pageNumber: pageNumber,
  225. pageSize: pageSize ? pageSize : 10
  226. }).then(res => {
  227. if (res.code === 0) {
  228. if (pageNumber === 1) {
  229. list.value = res.data
  230. } else {
  231. list.value = [...list.value, ...res.data]
  232. }
  233. listCount.value = res.count
  234. if (list.value.length === res.count) {
  235. status.value = 'nomore'
  236. } else {
  237. status.value = 'loadmore'
  238. }
  239. pageNum.value = pageNumber + 1;
  240. }
  241. })
  242. }
  243. function searchMy(keyword, pageNumber, pageSize) {
  244. status.value = 'loading'
  245. loadMyReport({
  246. keyword,
  247. pageNumber: pageNumber,
  248. pageSize: pageSize ? pageSize : 10
  249. }).then(res => {
  250. if (res.code === 0) {
  251. if (pageNumber === 1) {
  252. list2.value = res.data
  253. } else {
  254. list2.value = [...list2.value, ...res.data]
  255. }
  256. listCount2.value = res.count
  257. if (list2.value.length === res.count) {
  258. status.value = 'nomore'
  259. } else {
  260. status.value = 'loadmore'
  261. }
  262. pageNum.value = pageNumber + 1;
  263. }
  264. })
  265. }
  266. function toReportList(model, val) {
  267. uni.setStorageSync("reportCate", categoryList.value[model].child);
  268. uni.navigateTo({
  269. url: `/pages/researchReport/reportList/reportList?model=${model}&value=${val}`
  270. })
  271. }
  272. async function init() {
  273. const cateRes = await getReportCate();
  274. if (cateRes.code === 0) {
  275. const result = cateRes.data.reduce((acc, curr) => {
  276. const modifiedChild = [{
  277. value: " ",
  278. label: "全部"
  279. }, // 新增的默认项(value 为空格)
  280. ...curr.child.map(child => ({
  281. value: child.code, // 将子对象的 code 改为 value
  282. label: child.name
  283. }))
  284. ];
  285. acc[curr.name] = {
  286. value: curr.code,
  287. child: modifiedChild
  288. };
  289. return acc;
  290. }, {});
  291. categoryList.value = result;
  292. reportStore.setReportCate(result);
  293. }
  294. }
  295. function onClickReport(report) {
  296. let id;
  297. if (menuCurrent.value === 1) {
  298. id = report.reportId
  299. } else {
  300. id = report.id
  301. }
  302. uni.navigateTo({
  303. url: `/pages/reportDetail/reportDetail?id=${id}&title=${report.title}`
  304. })
  305. }
  306. function loadMore() {
  307. if (menuCurrent.value === 1) {
  308. if (list.value.length === listCount) {
  309. return
  310. }
  311. searchHistory(searchForm.value.keyword, pageNum.value)
  312. } else {
  313. if (list2.value.length === listCount2) {
  314. return
  315. }
  316. searchMy(searchForm.value.keyword, pageNum.value)
  317. }
  318. }
  319. onReachBottom(() => {
  320. loadMore()
  321. })
  322. onLoad((load) => {
  323. // console.log(load,"reporthome")
  324. if (load.menuCurrent) {
  325. menuCurrent.value = Number(load.menuCurrent)
  326. }
  327. init()
  328. })
  329. </script>
  330. <style lang="scss" scoped>
  331. $image-width: 200rpx;
  332. $image-height: 160rpx;
  333. .container {
  334. height: 100vh;
  335. width: 100vw;
  336. background-color: $uni-text-color-inverse;
  337. .header-box {
  338. padding: 0 20rpx;
  339. background-color: $uni-text-color-inverse;
  340. @include topMagnet();
  341. }
  342. .search-box {
  343. margin-bottom: 20rpx;
  344. ::v-deep(.u-search) {
  345. background-color: #e5e5e5;
  346. border-radius: 50rpx;
  347. .u-action {
  348. width: 18%;
  349. background-color: $uni-color-primary;
  350. border-radius: 50rpx;
  351. color: $uni-text-color-inverse;
  352. margin-right: 8rpx;
  353. font-size: 28rpx;
  354. line-height: 50rpx;
  355. letter-spacing: 3rpx;
  356. text-align: center;
  357. }
  358. }
  359. }
  360. // .list-box {
  361. // padding: 0 20rpx;
  362. // .list-item-box {
  363. // padding: 30rpx 20rpx;
  364. // display: flex;
  365. // gap: 20rpx;
  366. // height: 210rpx;
  367. // border-bottom: 5rpx solid #E6E6E6;
  368. // &:active {
  369. // background-color: $uni-bg-color-hover;
  370. // }
  371. // .image-box {
  372. // width: $image-width;
  373. // height: $image-height;
  374. // image {
  375. // width: $image-width;
  376. // flex: 0 0 $image-width;
  377. // height: 100%;
  378. // border-radius: $uni-card-border-radius;
  379. // }
  380. // }
  381. // .info-box {
  382. // width: 100%;
  383. // .title {
  384. // font-size: $uni-title-font-size-2;
  385. // font-weight: bold;
  386. // line-height: 40rpx;
  387. // margin-bottom: 15rpx;
  388. // @include text-line-overflow(2);
  389. // }
  390. // .time {
  391. // font-size: $uni-font-size-2;
  392. // color: $uni-text-color-grey;
  393. // .iconfont {
  394. // font-size: $uni-font-size-2;
  395. // padding-right: 10rpx;
  396. // }
  397. // }
  398. // .func {
  399. // display: flex;
  400. // justify-content: flex-end;
  401. // font-size: $uni-font-size-2;
  402. // font-weight: bold;
  403. // .func-box {
  404. // display: flex;
  405. // justify-content: space-between;
  406. // width: 100%;
  407. // align-items: center;
  408. // }
  409. // .button {
  410. // text-align: center;
  411. // width: 130rpx;
  412. // }
  413. // .price {
  414. // color: $uni-color-error;
  415. // font-size: $uni-title-font-size-2;
  416. // }
  417. // .buy {
  418. // padding: 6rpx 25rpx;
  419. // background-color: $uni-color-error;
  420. // border-radius: $uni-card-border-radius;
  421. // color: $uni-text-color-inverse;
  422. // }
  423. // .free {
  424. // padding: 6rpx 25rpx;
  425. // background-color: $uni-color-primary;
  426. // border-radius: $uni-card-border-radius;
  427. // color: $uni-text-color-inverse;
  428. // }
  429. // .member-free {
  430. // padding: 10rpx 20rpx;
  431. // @include backgroundImg('https://www.gzrea.cn/wxmp/static/icon/bg-label.png');
  432. // color: $uni-text-color;
  433. // }
  434. // }
  435. // }
  436. // }
  437. // }
  438. .list-box {
  439. padding: 0 20rpx;
  440. .list-item-box {
  441. padding: 30rpx 20rpx;
  442. display: flex;
  443. gap: 20rpx;
  444. // height: 210rpx;
  445. border-bottom: 5rpx solid #E6E6E6;
  446. // &:first-child {
  447. // padding: 0 20rpx 30rpx;
  448. // }
  449. &:active {
  450. background-color: $uni-bg-color-hover;
  451. }
  452. .image-box {
  453. width: $image-width;
  454. height: $image-height;
  455. image {
  456. width: $image-width;
  457. flex: 0 0 $image-width;
  458. height: 100%;
  459. border-radius: $uni-card-border-radius;
  460. }
  461. }
  462. .info-box {
  463. width: 100%;
  464. .title {
  465. font-size: $uni-title-font-size-2;
  466. font-weight: bold;
  467. line-height: 40rpx;
  468. margin-bottom: 15rpx;
  469. @include text-line-overflow(2);
  470. }
  471. .time {
  472. font-size: $uni-font-size-1;
  473. color: $uni-text-color-grey;
  474. .iconfont {
  475. font-size: $uni-font-size-2;
  476. padding-right: 10rpx;
  477. }
  478. }
  479. .type {
  480. font-size: $uni-font-size-2;
  481. .iconfont {
  482. font-size: $uni-font-size-2;
  483. padding-right: 10rpx;
  484. }
  485. }
  486. .func {
  487. display: flex;
  488. justify-content: space-between;
  489. align-items: flex-end;
  490. font-size: $uni-font-size-2;
  491. font-weight: bold;
  492. margin-top: 10rpx;
  493. .func-box {
  494. display: flex;
  495. justify-content: space-between;
  496. width: 100%;
  497. align-items: center;
  498. }
  499. .button {
  500. text-align: center;
  501. width: 130rpx;
  502. }
  503. .price {
  504. color: $uni-color-error;
  505. font-size: $uni-title-font-size-3;
  506. }
  507. .not-member-price {
  508. font-size: $uni-font-size-4;
  509. color: $uni-text-color-grey;
  510. text-align: end;
  511. }
  512. .buy {
  513. padding: 6rpx 25rpx;
  514. background-color: $uni-color-error;
  515. border-radius: $uni-card-border-radius;
  516. color: $uni-text-color-inverse;
  517. }
  518. .free {
  519. padding: 6rpx 25rpx;
  520. background-color: $uni-color-primary;
  521. border-radius: $uni-card-border-radius;
  522. color: $uni-text-color-inverse;
  523. }
  524. .member-free {
  525. padding: 10rpx 20rpx;
  526. @include backgroundImg('https://www.gzrea.cn/wxmp/static/icon/bg-label.png');
  527. color: $uni-text-color;
  528. }
  529. }
  530. }
  531. }
  532. }
  533. .menus-box {
  534. // padding: 0 20rpx;
  535. width: 85%;
  536. margin: 0 auto;
  537. .menus-item-box {
  538. width: 100%;
  539. // padding: 35rpx 50rpx;
  540. padding: 40rpx 30rpx;
  541. margin: 35rpx 0;
  542. display: flex;
  543. gap: 30rpx;
  544. align-items: center;
  545. background-color: #006AF4;
  546. border-radius: $uni-card-border-radius;
  547. &:active {
  548. background-color: #005AF4;
  549. }
  550. .icon-box {
  551. width: 40%;
  552. text-align: center;
  553. width: 100rpx;
  554. height: 100rpx;
  555. line-height: 100rpx;
  556. text-align: center;
  557. border-radius: 50%;
  558. border: 3rpx solid $uni-text-color-inverse;
  559. background-color: #004DC9;
  560. .iconfont {
  561. font-size: 60rpx;
  562. color: $uni-text-color-inverse;
  563. }
  564. }
  565. .text-box {
  566. font-size: 50rpx;
  567. font-weight: bold;
  568. color: $uni-text-color-inverse;
  569. }
  570. }
  571. }
  572. .bottom-block {
  573. // height: 112rpx;
  574. height: calc(112rpx + env(safe-area-inset-bottom, 0));
  575. }
  576. .bottom-box {
  577. padding: 5rpx 20rpx;
  578. background-color: $uni-bg-color-grey;
  579. border: 1rpx solid #E9E9E9;
  580. padding-bottom: calc(5rpx + env(safe-area-inset-bottom, 0));
  581. @include bottomMagnet();
  582. .menu-box {
  583. height: 100rpx;
  584. display: flex;
  585. align-items: center;
  586. .menu-item-box {
  587. width: calc(100% / 3);
  588. text-align: center;
  589. .iconfont {
  590. font-size: 55rpx;
  591. }
  592. .text {
  593. font-size: $uni-font-size-2;
  594. }
  595. }
  596. .is-active {
  597. color: $uni-color-primary;
  598. }
  599. }
  600. }
  601. }
  602. </style>