reportList.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="container">
  3. <view class="header-box">
  4. <view class="search-box">
  5. <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5"
  6. :input-style="searchInputStyle" placeholder="搜索您想要的内容" @search="toSearch"></u-search>
  7. </view>
  8. <view class="tab-box">
  9. <u-tabs name="label" :list="searchType" :is-scroll="true" v-model="searchForm.type"
  10. @change="onSearchTypeChange" font-size="24" :bold="false" inactive-color="#000000"
  11. active-color="#000000" :bar-style="{'background-color': '#2979ff'}" :gutter="25"
  12. height="45"></u-tabs>
  13. </view>
  14. </view>
  15. <view class="list-box">
  16. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onClickReport(item)">
  17. <view class="image-box">
  18. <image :src="item.imgUrl" mode="aspectFill"></image>
  19. </view>
  20. <view class="info-box">
  21. <view class="title">
  22. {{item.title}}
  23. </view>
  24. <view class="type">
  25. <span>{{item.type}}</span>
  26. </view>
  27. <view class="func">
  28. <!-- 如果是免费,直接显示免费 -->
  29. <view v-if="item.viewMode==='1'" class="func-box" style="justify-content: flex-end;">
  30. <view class="button free" >免费</view>
  31. </view>
  32. <view v-else-if="item.viewMode==='2' && isMember" class="func-box">
  33. <view class="price">¥{{ item.price }}元</view>
  34. <view class="button member-free">会员免费</view>
  35. </view>
  36. <view v-else-if="item.viewMode==='2' && !isMember" class="func-box">
  37. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  38. <view class="member-free">
  39. 会员免费
  40. </view>
  41. <view class="not-member-price">
  42. 非会员:¥{{item.price}}元
  43. </view>
  44. </view>
  45. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  46. {{item.hasBuy ? '已购买' : '立即购买'}}
  47. </view>
  48. </view>
  49. <view v-else-if="item.viewMode==='3' && item.price===item.priceMember" class="func-box">
  50. <view class="price">¥{{ item.price }}元</view>
  51. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  52. {{item.hasBuy ? '已购买' : '立即购买'}}
  53. </view>
  54. </view>
  55. <view v-else-if="item.viewMode==='3' && item.price!==item.priceMember" class="func-box">
  56. <view style="flex: 0 0 auto;display: flex;align-items: center;">
  57. <view class="member-free">
  58. {{`会员:${item.priceMember}元`}}
  59. </view>
  60. <view class="not-member-price">
  61. 非会员:¥{{item.price}}元
  62. </view>
  63. </view>
  64. <view :class="['button', item.hasBuy ? 'free' : 'buy']">
  65. {{item.hasBuy ? '已购买' : '立即购买'}}
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. <u-loadmore :status="status" margin-top="20" margin-bottom="20" @loadmore="loadmore" />
  73. </view>
  74. </template>
  75. <script setup>
  76. import {
  77. ref,
  78. computed
  79. } from 'vue'
  80. import {
  81. onLoad
  82. } from '@dcloudio/uni-app'
  83. import {
  84. loadReportList
  85. } from '@/api/report.js'
  86. import {
  87. useReportStore
  88. } from '@/store/reportStore.js'
  89. import {
  90. useAuthStore
  91. } from '@/store/authStore.js'
  92. const reportStore = useReportStore();
  93. const authStore = useAuthStore();
  94. const customButtonStyle = {
  95. height: '40rpx',
  96. lineHeight: '40rpx',
  97. padding: '0 30rpx'
  98. }
  99. const searchInputStyle = {
  100. backgroundColor: '#E5E5E5'
  101. }
  102. const isMember = ref(false);
  103. const categoryList = ref({});
  104. const pageNum = ref(1);
  105. const pageSize = ref(10);
  106. const count = ref(0);
  107. const model = ref(null);
  108. const status = ref('loadmore');
  109. const searchType = ref([{
  110. label: '全部',
  111. value: ' '
  112. }])
  113. // 对应tab的code
  114. const currentType = ref(null);
  115. function onSearchTypeChange(val) {
  116. currentType.value = searchType.value[val].value;
  117. pageNum.value = 1;
  118. search(searchForm.value.keyword, 1, model.value, currentType.value);
  119. }
  120. const searchForm = ref({
  121. keyword: '',
  122. type: 0
  123. })
  124. const modelName = ref()
  125. const list = ref([{
  126. id: 66,
  127. imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  128. model: "二手住宅市场",
  129. price: 0,
  130. priceMember: 0,
  131. title: "2025年2月从化区二手住宅市场交易简报",
  132. type: "月度成交简报",
  133. viewMode: "1",
  134. viewObject: "4",
  135. },
  136. {
  137. id: 33,
  138. imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  139. model: "二手住宅市场2",
  140. price: 20,
  141. priceMember: 30,
  142. title: "2025年2月从化区二手住宅市场交易简报2",
  143. type: "月度成交简报",
  144. viewMode: "2",
  145. viewObject: "4",
  146. },
  147. {
  148. id: 663,
  149. imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  150. model: "二手住宅市场3",
  151. price: 10,
  152. priceMember: 40,
  153. title: "2025年2月从化区二手住宅市场交易简报3",
  154. type: "月度成交简报",
  155. viewMode: "3",
  156. viewObject: "4",
  157. },
  158. {
  159. id: 663,
  160. imgUrl: "http://www.gzrea.org.cn/upload/news/2025/03/teicvnoekviwelkv214234kk.png",
  161. model: "二手住宅市场3",
  162. price: 10,
  163. priceMember: 10,
  164. title: "2025年2月从化区二手住宅市场交易简报3",
  165. type: "月度成交简报",
  166. viewMode: "3",
  167. viewObject: "4",
  168. },
  169. ])
  170. const listFilter = ref([])
  171. function onClickReport(report) {
  172. uni.navigateTo({
  173. url: `/pages/reportDetail/reportDetail?id=${report.id}&title=${report.title}`
  174. })
  175. }
  176. function init() {
  177. searchForm.value.keyword = '';
  178. pageNum.value = 1
  179. search('', 1, model.value, currentType.value)
  180. }
  181. function search(keyword, pageNumber, model, type, pageSize) {
  182. status.value = 'loading'
  183. const form = {
  184. keyword,
  185. model,
  186. type,
  187. pageNumber,
  188. pageSize: pageSize ? pageSize : 10
  189. }
  190. loadReportList(form).then(res => {
  191. console.log(res)
  192. // if (res.code === 0) {
  193. // if (pageNumber === 1) {
  194. // list.value = res.data
  195. // } else {
  196. // list.value = [...list.value, ...res.data];
  197. // }
  198. // pageNum.value = pageNumber + 1;
  199. // count.value = res.count;
  200. // if(list.value.length===count.value){
  201. // status.value = 'nomore'
  202. // }else{
  203. // status.value ='loadmore'
  204. // }
  205. // }
  206. }).catch(() => {
  207. status.value = 'loadmore'
  208. })
  209. }
  210. function loadmore() {
  211. search(searchForm.value.keyword, pageNum.value, model.value, currentType.value);
  212. }
  213. function toSearch() {
  214. search(searchForm.value.keyword, 1, model.value, currentType.value);
  215. }
  216. onLoad((load) => {
  217. isMember.value = authStore.userInfo.isMember === '0' ? false : true;
  218. if (load.model) {
  219. // console.log(load, reportStore.reportCate , "传过来的值")
  220. searchType.value = reportStore.reportCate[load.model].child;
  221. modelName.value = load.model
  222. model.value = load.value
  223. currentType.value = searchType.value[0].value;
  224. uni.setNavigationBarTitle({
  225. title: modelName.value
  226. })
  227. init()
  228. }
  229. })
  230. </script>
  231. <style lang="scss">
  232. $image-width: 230rpx;
  233. .container {
  234. height: 100vh;
  235. width: 100vw;
  236. background-color: $uni-text-color-inverse;
  237. .header-box {
  238. padding: 0 20rpx;
  239. background-color: $uni-text-color-inverse;
  240. @include topMagnet();
  241. }
  242. .search-box {
  243. margin-bottom: 20rpx;
  244. ::v-deep(.u-search) {
  245. background-color: #e5e5e5;
  246. border-radius: 50rpx;
  247. .u-action {
  248. width: 18%;
  249. background-color: $uni-color-primary;
  250. border-radius: 50rpx;
  251. color: $uni-text-color-inverse;
  252. margin-right: 8rpx;
  253. font-size: 28rpx;
  254. line-height: 50rpx;
  255. letter-spacing: 3rpx;
  256. text-align: center;
  257. }
  258. }
  259. }
  260. .list-box {
  261. padding: 0 20rpx;
  262. .list-item-box {
  263. padding: 30rpx 20rpx;
  264. display: flex;
  265. gap: 20rpx;
  266. // height: 210rpx;
  267. border-bottom: 5rpx solid #E6E6E6;
  268. &:active {
  269. background-color: $uni-bg-color-hover;
  270. }
  271. .image-box {
  272. width: $image-width;
  273. image {
  274. width: $image-width;
  275. flex: 0 0 $image-width;
  276. height: 100%;
  277. border-radius: $uni-card-border-radius;
  278. }
  279. }
  280. .info-box {
  281. .title {
  282. font-size: $uni-title-font-size-2;
  283. font-weight: bold;
  284. line-height: 40rpx;
  285. margin-bottom: 15rpx;
  286. @include text-line-overflow(2);
  287. }
  288. .type {
  289. font-size: $uni-font-size-2;
  290. .iconfont {
  291. font-size: $uni-font-size-2;
  292. padding-right: 10rpx;
  293. }
  294. }
  295. .func {
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: flex-end;
  299. font-size: $uni-font-size-2;
  300. font-weight: bold;
  301. margin-top: 10rpx;
  302. .func-box {
  303. display: flex;
  304. justify-content: space-between;
  305. width: 100%;
  306. align-items: center;
  307. }
  308. .button {
  309. text-align: center;
  310. width: 130rpx;
  311. }
  312. .price {
  313. color: $uni-color-error;
  314. font-size: $uni-title-font-size-3;
  315. }
  316. .not-member-price {
  317. font-size: $uni-font-size-4;
  318. color: $uni-text-color-grey;
  319. text-align: end;
  320. }
  321. .buy {
  322. padding: 6rpx 25rpx;
  323. background-color: $uni-color-error;
  324. border-radius: $uni-card-border-radius;
  325. color: $uni-text-color-inverse;
  326. }
  327. .free {
  328. padding: 6rpx 25rpx;
  329. background-color: $uni-color-primary;
  330. border-radius: $uni-card-border-radius;
  331. color: $uni-text-color-inverse;
  332. }
  333. .member-free {
  334. padding: 10rpx 20rpx;
  335. @include backgroundImg('https://sylwt.top/api/visitor/resources/image?name=/ydl/menber-center/bg-label.png');
  336. color: $uni-text-color;
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. </style>