reportHome.vue 14 KB

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