reportHome.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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
  124. margin-top="50"
  125. mode="data" v-if="list2.length === 0" iconSize="120" textSize="58" text="暂无数据">
  126. </u-empty>
  127. <view class="list-box">
  128. <view class="list-item-box" v-for="item in list2" :key="item.id" @click="onClickReport(item)">
  129. <view class="image-box">
  130. <image :src="item.cover" mode="aspectFill"></image>
  131. </view>
  132. <view class="info-box">
  133. <view class="title">
  134. {{item.title}}
  135. </view>
  136. <view class="time">
  137. <span>购买时间:&nbsp;{{item.buyDate}}</span>
  138. </view>
  139. <view class="func">
  140. <view class="price">实付款:{{item.buyPrice}}元</view>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <u-loadmore v-if="menuCurrent !== 0 && status !== 'nomore'" :status="status" margin-top="20" margin-bottom="20"
  147. @loadmore="loadMore" />
  148. <view class="bottom-block"></view>
  149. <view class="bottom-box">
  150. <view class="menu-box">
  151. <view class="menu-item-box" :class="{'is-active': menuCurrent === 0}" @click="onMenuClick(0)">
  152. <view class="iconfont icon-home"></view>
  153. <view class="text">首页</view>
  154. </view>
  155. <view class="menu-item-box" :class="{'is-active': menuCurrent === 1}" @click="onMenuClick(1)">
  156. <view class="iconfont icon-time"></view>
  157. <view class="text">我的浏览</view>
  158. </view>
  159. <view class="menu-item-box" :class="{'is-active': menuCurrent === 2}" @click="onMenuClick(2)">
  160. <view class="iconfont icon-baogao"></view>
  161. <view class="text">我的报告</view>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script setup>
  168. import {
  169. ref,
  170. computed
  171. } from 'vue'
  172. import {
  173. onLoad,
  174. onReachBottom
  175. } from '@dcloudio/uni-app'
  176. import {
  177. getReportCate,
  178. loadReportHistory,
  179. loadMyReport
  180. } from '@/api/report.js'
  181. import {
  182. useReportStore
  183. } from '@/store/reportStore.js'
  184. const reportStore = useReportStore();
  185. const categoryList = ref({});
  186. const pageNum = ref(1);
  187. const status = ref('nomore');
  188. const list = ref([]);
  189. const list2 = ref([]);
  190. const listCount = ref(0);
  191. const listCount2 = ref(0);
  192. const iconList = {
  193. "二手住宅市场": "icon-hetong",
  194. "住宅租赁市场": "icon-chengshi",
  195. "房地产中介行业": "icon-zhongjie"
  196. }
  197. const customButtonStyle = {
  198. height: '40rpx',
  199. lineHeight: '40rpx',
  200. padding: '0 30rpx'
  201. }
  202. const searchInputStyle = {
  203. backgroundColor: '#E5E5E5'
  204. }
  205. const searchForm = ref({
  206. keyword: '',
  207. type: 0
  208. })
  209. const menuCurrent = ref(0)
  210. function onMenuClick(index) {
  211. menuCurrent.value = index;
  212. searchForm.value.keyword = ""
  213. status.value = 'loadmore'
  214. if (index === 1) {
  215. // 浏览记录
  216. searchHistory("", 1)
  217. } else if (index === 2) {
  218. // 我的报告
  219. searchMy("", 1)
  220. }
  221. }
  222. function searchHistory(keyword, pageNumber, pageSize) {
  223. status.value = 'loading'
  224. loadReportHistory({
  225. keyword,
  226. pageNumber: pageNumber,
  227. pageSize: pageSize ? pageSize : 10
  228. }).then(res => {
  229. if (res.code === 0) {
  230. if (pageNumber === 1) {
  231. list.value = res.data
  232. } else {
  233. list.value = [...list.value, ...res.data]
  234. }
  235. listCount.value = res.count
  236. if (list.value.length === res.count) {
  237. status.value = 'nomore'
  238. } else {
  239. status.value = 'loadmore'
  240. }
  241. pageNum.value = pageNumber + 1;
  242. }
  243. })
  244. }
  245. function searchMy(keyword, pageNumber, pageSize) {
  246. status.value = 'loading'
  247. loadMyReport({
  248. keyword,
  249. pageNumber: pageNumber,
  250. pageSize: pageSize ? pageSize : 10
  251. }).then(res => {
  252. if (res.code === 0) {
  253. if (pageNumber === 1) {
  254. list2.value = res.data
  255. } else {
  256. list2.value = [...list2.value, ...res.data]
  257. }
  258. listCount2.value = res.count
  259. if (list2.value.length === res.count) {
  260. status.value = 'nomore'
  261. } else {
  262. status.value = 'loadmore'
  263. }
  264. pageNum.value = pageNumber + 1;
  265. }
  266. })
  267. }
  268. function toReportList(model, val) {
  269. uni.setStorageSync("reportCate", categoryList.value[model].child);
  270. uni.navigateTo({
  271. url: `/pages/researchReport/reportList/reportList?model=${model}&value=${val}`
  272. })
  273. }
  274. async function init() {
  275. const cateRes = await getReportCate();
  276. if (cateRes.code === 0) {
  277. const result = cateRes.data.reduce((acc, curr) => {
  278. const modifiedChild = [{
  279. value: " ",
  280. label: "全部"
  281. }, // 新增的默认项(value 为空格)
  282. ...curr.child.map(child => ({
  283. value: child.code, // 将子对象的 code 改为 value
  284. label: child.name
  285. }))
  286. ];
  287. acc[curr.name] = {
  288. value: curr.code,
  289. child: modifiedChild
  290. };
  291. return acc;
  292. }, {});
  293. categoryList.value = result;
  294. reportStore.setReportCate(result);
  295. }
  296. }
  297. function onClickReport(report) {
  298. uni.navigateTo({
  299. url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
  300. })
  301. }
  302. function loadMore() {
  303. if (menuCurrent.value === 1) {
  304. if (list.value.length === listCount) {
  305. return
  306. }
  307. searchHistory(searchForm.value.keyword, pageNum.value)
  308. } else {
  309. if (list2.value.length === listCount2) {
  310. return
  311. }
  312. searchMy(searchForm.value.keyword, pageNum.value)
  313. }
  314. }
  315. onReachBottom(() => {
  316. loadMore()
  317. })
  318. onLoad((load) => {
  319. // console.log(load,"reporthome")
  320. if (load.menuCurrent) {
  321. menuCurrent.value = Number(load.menuCurrent)
  322. }
  323. init()
  324. })
  325. </script>
  326. <style lang="scss" scoped>
  327. $image-width: 200rpx;
  328. .container {
  329. height: 100vh;
  330. width: 100vw;
  331. background-color: $uni-text-color-inverse;
  332. .header-box {
  333. padding: 0 20rpx;
  334. background-color: $uni-text-color-inverse;
  335. @include topMagnet();
  336. }
  337. .search-box {
  338. margin-bottom: 20rpx;
  339. ::v-deep(.u-search) {
  340. background-color: #e5e5e5;
  341. border-radius: 50rpx;
  342. .u-action {
  343. width: 18%;
  344. background-color: $uni-color-primary;
  345. border-radius: 50rpx;
  346. color: $uni-text-color-inverse;
  347. margin-right: 8rpx;
  348. font-size: 28rpx;
  349. line-height: 50rpx;
  350. letter-spacing: 3rpx;
  351. text-align: center;
  352. }
  353. }
  354. }
  355. .list-box {
  356. padding: 0 20rpx;
  357. .list-item-box {
  358. padding: 30rpx 20rpx;
  359. display: flex;
  360. gap: 20rpx;
  361. height: 210rpx;
  362. border-bottom: 5rpx solid #E6E6E6;
  363. &:active {
  364. background-color: $uni-bg-color-hover;
  365. }
  366. .image-box {
  367. width: $image-width;
  368. image {
  369. width: $image-width;
  370. flex: 0 0 $image-width;
  371. height: 100%;
  372. border-radius: $uni-card-border-radius;
  373. }
  374. }
  375. .info-box {
  376. .title {
  377. font-size: $uni-title-font-size-2;
  378. font-weight: bold;
  379. line-height: 40rpx;
  380. margin-bottom: 15rpx;
  381. @include text-line-overflow(2);
  382. }
  383. .time {
  384. font-size: $uni-font-size-2;
  385. color: $uni-text-color-grey;
  386. .iconfont {
  387. font-size: $uni-font-size-2;
  388. padding-right: 10rpx;
  389. }
  390. }
  391. .func {
  392. display: flex;
  393. justify-content: flex-end;
  394. font-size: $uni-font-size-2;
  395. font-weight: bold;
  396. .func-box {
  397. display: flex;
  398. justify-content: space-between;
  399. width: 100%;
  400. align-items: center;
  401. }
  402. .button {
  403. text-align: center;
  404. width: 130rpx;
  405. }
  406. .price {
  407. color: $uni-color-error;
  408. font-size: $uni-title-font-size-2;
  409. }
  410. .buy {
  411. padding: 6rpx 25rpx;
  412. background-color: $uni-color-error;
  413. border-radius: $uni-card-border-radius;
  414. color: $uni-text-color-inverse;
  415. }
  416. .free {
  417. padding: 6rpx 25rpx;
  418. background-color: $uni-color-primary;
  419. border-radius: $uni-card-border-radius;
  420. color: $uni-text-color-inverse;
  421. }
  422. .member-free {
  423. padding: 10rpx 20rpx;
  424. @include backgroundImg('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  425. color: $uni-text-color;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. .menus-box {
  432. padding: 0 20rpx;
  433. .menus-item-box {
  434. width: 100%;
  435. padding: 35rpx 50rpx;
  436. margin-bottom: 35rpx;
  437. display: flex;
  438. gap: 30rpx;
  439. align-items: center;
  440. background-color: #006AF4;
  441. border-radius: $uni-card-border-radius;
  442. &:active {
  443. background-color: #005AF4;
  444. }
  445. .icon-box {
  446. width: 40%;
  447. text-align: center;
  448. width: 100rpx;
  449. height: 100rpx;
  450. line-height: 100rpx;
  451. text-align: center;
  452. border-radius: 50%;
  453. border: 3rpx solid $uni-text-color-inverse;
  454. background-color: #004DC9;
  455. .iconfont {
  456. font-size: 60rpx;
  457. color: $uni-text-color-inverse;
  458. }
  459. }
  460. .text-box {
  461. font-size: 50rpx;
  462. font-weight: bold;
  463. color: $uni-text-color-inverse;
  464. }
  465. }
  466. }
  467. .bottom-block {
  468. // height: 112rpx;
  469. height: calc(112rpx + env(safe-area-inset-bottom, 0));
  470. }
  471. .bottom-box {
  472. padding: 5rpx 20rpx;
  473. background-color: $uni-bg-color-grey;
  474. border: 1rpx solid #E9E9E9;
  475. padding-bottom: calc(5rpx + env(safe-area-inset-bottom, 0));
  476. @include bottomMagnet();
  477. .menu-box {
  478. height: 100rpx;
  479. display: flex;
  480. align-items: center;
  481. .menu-item-box {
  482. width: calc(100% / 3);
  483. text-align: center;
  484. .iconfont {
  485. font-size: 55rpx;
  486. }
  487. .text {
  488. font-size: $uni-font-size-2;
  489. }
  490. }
  491. .is-active {
  492. color: $uni-color-primary;
  493. }
  494. }
  495. }
  496. }
  497. </style>