index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <template>
  2. <view class="sell-container">
  3. <!-- 顶部背景图 -->
  4. <image class="top-bg-image" src="/pages-sell/static/top-bg.png" mode="widthFix"></image>
  5. <!-- 导航栏 -->
  6. <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
  7. <view class="navbar-content">
  8. <text class="navbar-title">书嗨</text>
  9. <!-- 右侧胶囊占位,保持布局平衡 -->
  10. <view class="nav-right-placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 主要内容区域 -->
  14. <view class="main-content" :style="{ marginTop: (statusBarHeight + 44) + 'px' }">
  15. <!-- 搜索框 -->
  16. <view class="search-wrapper" @click="navigateTo('/pages-sell/pages/search')">
  17. <view class="search-box-uview">
  18. <u-search placeholder="搜索关键字" :show-action="false" bg-color="transparent" height="40"
  19. :clearabled="true" v-model="keyword" :disabled="true"
  20. search-icon="/pages-sell/static/search-icon.png"></u-search>
  21. <view class="search-btn-overlay">
  22. <text>搜索</text>
  23. </view>
  24. </view>
  25. </view>
  26. <!-- tab标签 -->
  27. <!-- <view class="tabs-wrapper">
  28. <u-tabs :list="hotTagList" :current="currentHotTag" @change="changeHotTag" bgColor="transparent"
  29. lineColor="transparent" :active-item-style="{ fontWeight: 'bold', color: '#333' }"
  30. inactive-color="#3C4F3E" :barStyle="barStyle" :bar-height="27" :bar-width="52"></u-tabs>
  31. </view> -->
  32. <!-- 顶部横幅 Banner -->
  33. <view class="top-banner-wrapper">
  34. <image src="/pages-sell/static/top-banner.png" class="top-banner-img" mode="widthFix"></image>
  35. </view>
  36. <!-- 金刚区分类图标 (2行5列) -->
  37. <view class="category-grid">
  38. <view class="grid-item" v-for="(item, index) in categoryList" :key="index"
  39. @click="handleCategory(item)">
  40. <view class="icon-circle">
  41. <image :src="item.imgUrl" class="cat-icon" mode="aspectFit"></image>
  42. </view>
  43. <text class="cat-name">{{ item.showCateName || '-' }}</text>
  44. </view>
  45. </view>
  46. <!-- 推广与热销双卡片 -->
  47. <view class="promo-dual-card">
  48. <!-- 左侧:推广卖书 -->
  49. <view class="card-left">
  50. <view class="card-content">
  51. <u-swiper :list="swiperList" :autoplay="true" :interval="3000" name="imgUrl"></u-swiper>
  52. </view>
  53. </view>
  54. <!-- 右侧:热销商品 -->
  55. <view class="card-right">
  56. <view class="right-header" @click="navigateTo('/pages-sell/pages/hot-sell')">
  57. <image src="/pages-sell/static/icon-fire.png" class="fire-icon" mode="widthFix"></image>
  58. <text class="right-title">热销商品</text>
  59. <image src="/pages-sell/static/icon-fire.png" class="fire-icon flip" mode="widthFix"></image>
  60. </view>
  61. <view class="products-container">
  62. <!-- 使用网络图片作为书的封面占位 -->
  63. <image v-for="(item, index) in bookList" :key="index" :src="item.imgUrl" class="product-cover" mode="aspectFill" @click="navigateTo(item.jumpUrl)"></image>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 健康与成长双卡片 -->
  68. <view class="info-dual-card">
  69. <swiper class="info-card-swiper" :autoplay="true" :interval="3000" :circular="true" >
  70. <swiper-item v-for="(item, index) in leftBookList" :key="index">
  71. <view class="info-card bg-orange" @click="navigateTo(item.jumpUrl)">
  72. <view class="info-text-group">
  73. <text class="info-title text-orange">{{ item.showCateName }}</text>
  74. <text class="info-desc text-orange-light">{{ item.remark }}</text>
  75. </view>
  76. <image :src="item.imgUrl" class="info-icon" mode="aspectFit"
  77. style="width: 125rpx;height: 111rpx;"></image>
  78. </view>
  79. </swiper-item>
  80. </swiper>
  81. <swiper class="info-card-swiper" :autoplay="true" :interval="3500" :circular="true">
  82. <swiper-item v-for="(item, index) in rightBookList" :key="index">
  83. <view class="info-card bg-green" @click="navigateTo(item.jumpUrl)">
  84. <view class="info-text-group">
  85. <text class="info-title text-green">{{ item.showCateName }}</text>
  86. <text class="info-desc text-green-light">{{ item.remark }}</text>
  87. </view>
  88. <image :src="item.imgUrl" class="info-icon" mode="aspectFit"></image>
  89. </view>
  90. </swiper-item>
  91. </swiper>
  92. </view>
  93. <!-- 公众号横幅 -->
  94. <view class="gzh-section">
  95. <view class="gzh-bg-wrapper">
  96. <image src="/pages-sell/static/gzh-banner.png" class="gzh-img-bg" mode="aspectFill"></image>
  97. <view class="gzh-content-overlay">
  98. <text class="gzh-title">关注公众号 ,定期领红包</text>
  99. <view class="gzh-subtitle-pill">
  100. <text class="gzh-subtitle">别让好书蒙尘 ,书嗨陪你逐页品读</text>
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. <!-- 书嗨推荐 -->
  106. <view class="recommend-section" @click="navigateTo(item.jumpUrl)" v-for="(item, index) in topicList" :key="index">
  107. <view class="section-header">
  108. <text class="section-title">{{item.showCateName}}</text>
  109. <view class="view-more">
  110. <text>查看全部</text>
  111. <image src="/pages-sell/static/right-arrow.png" class="arrow-icon" mode="widthFix"></image>
  112. </view>
  113. </view>
  114. <view class="book-list">
  115. <view class="book-item" v-for="(book, index) in getDisplayBooks(item)" :key="index" @click="navigateTo('/pages-sell/pages/detail?isbn=' + book.bookIsbn)">
  116. <image :src="book.bookImg" class="book-image" mode="aspectFill"></image>
  117. <text class="book-name">{{ book.bookName }}</text>
  118. <view class="price-row">
  119. <text class="currency">¥</text>
  120. <text class="price-val">{{ book.bookPrice }}</text>
  121. <text class="price-old">¥{{ book.bookOriginalPrice }}</text>
  122. </view>
  123. <view class="add-btn">
  124. <text>加入购物车</text>
  125. <image src="/pages-sell/static/shape-10.png" class="cart-symbol"></image>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <!-- 底部留白,防止遮挡 -->
  131. <view class="bottom-safe-area"></view>
  132. </view>
  133. </view>
  134. </template>
  135. <script>
  136. export default {
  137. name: 'SellContainer',
  138. data() {
  139. return {
  140. barStyle: {
  141. backgroundColor: 'transparent',
  142. background: "url('/pages-sell/static/tab-selected.png') no-repeat center",
  143. backgroundSize: '100% 100%',
  144. position: 'relative',
  145. top: '-6rpx',
  146. },
  147. swiperList: [],
  148. statusBarHeight: 20,
  149. keyword: '',
  150. // u-tabs 需要对象数组 [{name: 'xxx'}]
  151. hotTagList: [
  152. { name: '热搜' },
  153. { name: '励志' },
  154. { name: '绘本' },
  155. { name: '诺贝尔文学奖' },
  156. { name: '茅盾奖' },
  157. { name: '童书' }
  158. ],
  159. currentHotTag: 0,
  160. // 临时的网络书封面图片
  161. bookCoverUrl: 'https://img.yzcdn.cn/vant/cat.jpeg',
  162. categoryList: [], //金刚区
  163. bookList: [], // 右侧推荐书籍
  164. recommendBooks: [
  165. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  166. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' },
  167. { title: '山河岁月', price: '6.80', original: '36.80', cover: 'https://img.yzcdn.cn/vant/cat.jpeg' }
  168. ],
  169. topicList:[], //专题推荐
  170. leftBookList:[], // 左侧推荐书籍
  171. rightBookList:[] // 右侧推荐书籍
  172. }
  173. },
  174. created() {
  175. const systemInfo = uni.getSystemInfoSync();
  176. this.statusBarHeight = systemInfo.statusBarHeight || 20;
  177. this.getIndexCateInfo()
  178. },
  179. methods: {
  180. handleCategory(item) {
  181. if(!item.jumpUrl) return
  182. this.navigateTo(item.jumpUrl)
  183. },
  184. changeHotTag(index) {
  185. this.currentHotTag = index;
  186. console.log('切换标签:', index);
  187. },
  188. //跳转 URL
  189. navigateTo(url) {
  190. if(!url) return
  191. console.log(url)
  192. uni.navigateTo({
  193. url: url
  194. });
  195. },
  196. goRecommend() {
  197. uni.navigateTo({
  198. url: '/pages-sell/pages/recommend'
  199. });
  200. },
  201. goHotSell() {
  202. uni.navigateTo({
  203. url: '/pages-sell/pages/hot-sell'
  204. });
  205. },
  206. //获取首页装修信息
  207. getIndexCateInfo() {
  208. uni.$u.http.get('/token/shop/showIndex/getIndexCateInfo').then(res => {
  209. console.log(res)
  210. if (res.code == 200) {
  211. console.log(res.data)
  212. this.categoryList = res.data.find(item => item.position == 'diamond_area')?.shopIndexCateVo || []
  213. this.swiperList = res.data.find(item => item.position == 'left_banner')?.shopIndexCateVo || []
  214. this.bookList = res.data.find(item => item.position == 'right_banner')?.shopIndexCateVo || []
  215. this.leftBookList = res.data.find(item => item.position == 'left_book_list')?.shopIndexCateVo || []
  216. this.rightBookList = res.data.find(item => item.position == 'right_book_list')?.shopIndexCateVo || []
  217. //获取专题推荐
  218. this.topicList = res.data.find(item => item.position == 'topic')?.shopIndexCateVo || []
  219. }
  220. })
  221. },
  222. getDisplayBooks(item) {
  223. if (!item.bookInfoList) return []
  224. let limit = 3
  225. if (item.topicType === 2) {
  226. limit = 6
  227. }
  228. return item.bookInfoList.slice(0, limit)
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss" scoped>
  234. .sell-container {
  235. position: relative;
  236. min-height: 100vh;
  237. background-color: #F6F6F6;
  238. overflow-x: hidden;
  239. }
  240. /* 顶部大背景图 */
  241. .top-bg-image {
  242. position: absolute;
  243. top: 0;
  244. left: 0;
  245. width: 100%;
  246. z-index: 0;
  247. display: block;
  248. }
  249. /* 导航栏 */
  250. .custom-navbar {
  251. position: fixed;
  252. top: 0;
  253. left: 0;
  254. width: 100%;
  255. z-index: 100;
  256. display: flex;
  257. align-items: center;
  258. justify-content: center;
  259. .navbar-content {
  260. height: 44px;
  261. width: 100%;
  262. display: flex;
  263. align-items: center;
  264. justify-content: center;
  265. position: relative;
  266. .navbar-title {
  267. color: #fff;
  268. font-size: 36rpx;
  269. font-weight: 600;
  270. }
  271. }
  272. }
  273. .main-content {
  274. position: relative;
  275. z-index: 1;
  276. padding: 0 24rpx;
  277. }
  278. /* 搜索框 */
  279. .search-wrapper {
  280. margin-top: 10rpx;
  281. margin-bottom: 20rpx;
  282. .search-box-uview {
  283. height: 80rpx;
  284. background-color: #fff;
  285. border-radius: 40rpx;
  286. display: flex;
  287. align-items: center;
  288. padding: 0 10rpx 0 16rpx;
  289. position: relative;
  290. /* 覆盖 u-search 的 padding 以适配 */
  291. ::v-deep .u-search {
  292. flex: 1;
  293. /* 让输入框不遮挡右侧按钮 */
  294. padding-right: 140rpx !important;
  295. }
  296. .search-btn-overlay {
  297. position: absolute;
  298. right: 8rpx;
  299. top: 50%;
  300. transform: translateY(-50%);
  301. width: 140rpx;
  302. height: 64rpx;
  303. background: linear-gradient(0deg, #37C148 0%, #6ADD83 100%);
  304. border-radius: 32rpx;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. z-index: 2;
  309. text {
  310. color: #fff;
  311. font-size: 28rpx;
  312. font-weight: 500;
  313. }
  314. }
  315. }
  316. }
  317. /* 顶部横幅 */
  318. .top-banner-wrapper {
  319. width: 100%;
  320. margin-bottom: 30rpx;
  321. position: relative;
  322. .top-banner-img {
  323. width: 100%;
  324. border-radius: 40rpx;
  325. display: block;
  326. }
  327. }
  328. /* 分类图标 */
  329. .category-grid {
  330. display: flex;
  331. flex-wrap: wrap;
  332. margin-bottom: 10rpx;
  333. .grid-item {
  334. width: 20%;
  335. display: flex;
  336. flex-direction: column;
  337. align-items: center;
  338. margin-bottom: 30rpx;
  339. .icon-circle {
  340. width: 96rpx;
  341. height: 96rpx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: center;
  345. margin-bottom: 12rpx;
  346. .cat-icon {
  347. width: 100%;
  348. height: 100%;
  349. }
  350. }
  351. .cat-name {
  352. font-size: 24rpx;
  353. color: #333;
  354. font-weight: 500;
  355. }
  356. }
  357. }
  358. /* 推广双卡片 */
  359. .promo-dual-card {
  360. display: flex;
  361. justify-content: space-between;
  362. margin-bottom: 24rpx;
  363. .card-left {
  364. width: 48%;
  365. height: 252rpx;
  366. border-radius: 20rpx;
  367. position: relative;
  368. overflow: hidden;
  369. }
  370. .card-right {
  371. width: 48%;
  372. height: 252rpx;
  373. /* Updated background per request */
  374. background: linear-gradient(to bottom, #FFD7C3 0%, #FFFFFF 32%);
  375. border-radius: 20rpx;
  376. padding: 20rpx;
  377. box-sizing: border-box;
  378. .right-header {
  379. display: flex;
  380. align-items: center;
  381. justify-content: center;
  382. margin-bottom: 20rpx;
  383. .right-title {
  384. font-size: 30rpx;
  385. font-weight: bold;
  386. color: #333;
  387. margin: 0 10rpx;
  388. }
  389. .fire-icon {
  390. width: 30rpx;
  391. height: 30rpx;
  392. }
  393. .flip {
  394. transform: scaleX(-1);
  395. }
  396. }
  397. .products-container {
  398. display: flex;
  399. justify-content: space-between;
  400. gap: 20rpx;
  401. .product-cover {
  402. flex: 1;
  403. height: 160rpx;
  404. border-radius: 12rpx;
  405. background-color: #f0f0f0;
  406. }
  407. }
  408. }
  409. }
  410. /* 信息双卡片 */
  411. .info-dual-card {
  412. display: flex;
  413. justify-content: space-between;
  414. margin-bottom: 24rpx;
  415. .info-card-swiper {
  416. width: 48%;
  417. height: 140rpx;
  418. border-radius: 12px;
  419. overflow: hidden;
  420. }
  421. .info-card {
  422. width: 100%;
  423. padding: 24rpx;
  424. border-radius: 12px;
  425. /* Updated radius */
  426. display: flex;
  427. justify-content: space-between;
  428. align-items: center;
  429. height: 140rpx;
  430. box-sizing: border-box;
  431. position: relative;
  432. /* For absolute icon */
  433. overflow: hidden;
  434. &.bg-orange {
  435. background: #FFF3E0;
  436. border: 1px solid #FFB72A;
  437. }
  438. &.bg-green {
  439. background: #D4F1D8;
  440. border: 1px solid #54A94E;
  441. }
  442. .info-text-group {
  443. flex: 1;
  444. z-index: 1;
  445. /* Ensure text is above */
  446. .info-title {
  447. font-size: 28rpx;
  448. font-weight: bold;
  449. display: block;
  450. margin-bottom: 6rpx;
  451. }
  452. .info-desc {
  453. font-size: 22rpx;
  454. line-height: 1.2;
  455. }
  456. .text-orange {
  457. color: #DB832D;
  458. }
  459. .text-orange-light {
  460. color: #DB832D;
  461. }
  462. .text-green {
  463. color: #1F8049;
  464. }
  465. .text-green-light {
  466. color: #1F8049;
  467. }
  468. }
  469. .info-icon {
  470. width: 100rpx;
  471. /* Slightly larger maybe */
  472. height: 100rpx;
  473. position: absolute;
  474. right: 0;
  475. bottom: 0;
  476. z-index: 0;
  477. opacity: 0.8;
  478. }
  479. }
  480. }
  481. /* 公众号 */
  482. .gzh-section {
  483. margin-bottom: 30rpx;
  484. height: 180rpx;
  485. /* Fixed height for consistency */
  486. border-radius: 20rpx;
  487. overflow: hidden;
  488. .gzh-bg-wrapper {
  489. width: 100%;
  490. height: 100%;
  491. position: relative;
  492. .gzh-img-bg {
  493. width: 100%;
  494. height: 100%;
  495. position: absolute;
  496. top: 0;
  497. left: 0;
  498. }
  499. .gzh-content-overlay {
  500. position: absolute;
  501. top: 0;
  502. left: 0;
  503. width: 60%;
  504. /* Only cover left side */
  505. height: 100%;
  506. padding: 30rpx;
  507. display: flex;
  508. flex-direction: column;
  509. justify-content: center;
  510. .gzh-title {
  511. font-size: 32rpx;
  512. font-weight: bold;
  513. color: #134E13;
  514. /* Dark green */
  515. margin-bottom: 16rpx;
  516. }
  517. .gzh-subtitle-pill {
  518. background: #FFF;
  519. border-radius: 24rpx;
  520. padding: 0 14rpx;
  521. line-height: 1.4;
  522. align-self: flex-start;
  523. .gzh-subtitle {
  524. font-size: 22rpx;
  525. color: #134E13;
  526. font-weight: 500;
  527. }
  528. }
  529. }
  530. }
  531. }
  532. /* 书嗨推荐 */
  533. .recommend-section {
  534. background-color: #fff;
  535. border-radius: 20rpx;
  536. padding: 30rpx;
  537. margin-bottom: 24rpx;
  538. .section-header {
  539. display: flex;
  540. justify-content: space-between;
  541. align-items: center;
  542. margin-bottom: 24rpx;
  543. .section-title {
  544. font-size: 32rpx;
  545. font-weight: bold;
  546. color: #333;
  547. }
  548. .view-more {
  549. display: flex;
  550. align-items: center;
  551. font-size: 24rpx;
  552. color: #8D8D8D;
  553. .arrow-icon {
  554. width: 12rpx;
  555. margin-left: 6rpx;
  556. }
  557. }
  558. }
  559. .book-list {
  560. display: flex;
  561. flex-wrap: wrap;
  562. justify-content: space-between;
  563. }
  564. .book-item {
  565. width: 200rpx;
  566. margin-bottom: 24rpx;
  567. display: flex;
  568. flex-direction: column;
  569. .book-image {
  570. width: 200rpx;
  571. height: 255rpx;
  572. border-radius: 2rpx;
  573. margin-bottom: 16rpx;
  574. background-color: #f9f9f9;
  575. }
  576. .book-name {
  577. font-family: 'Source Han Sans SC';
  578. font-weight: bold;
  579. font-size: 28rpx;
  580. color: #303030;
  581. margin-bottom: 10rpx;
  582. overflow: hidden;
  583. text-overflow: ellipsis;
  584. white-space: nowrap;
  585. }
  586. .price-row {
  587. display: flex;
  588. align-items: baseline;
  589. margin-bottom: 12rpx;
  590. .currency {
  591. font-family: 'Source Han Sans SC';
  592. font-weight: 500;
  593. font-size: 22rpx;
  594. color: #D81A00;
  595. }
  596. .price-val {
  597. font-family: 'Source Han Sans SC';
  598. font-weight: 500;
  599. font-size: 28rpx;
  600. color: #D81A00;
  601. margin-right: 12rpx;
  602. }
  603. .price-old {
  604. font-family: 'Source Han Sans SC';
  605. font-weight: 500;
  606. font-size: 22rpx;
  607. color: #999999;
  608. text-decoration: line-through;
  609. }
  610. }
  611. .add-btn {
  612. width: fit-content;
  613. height: 36rpx;
  614. line-height: 36rpx;
  615. background: linear-gradient(0deg, #4ED964 0%, #4ED964 100%);
  616. border-radius: 18rpx;
  617. padding: 0 20rpx;
  618. display: flex;
  619. align-items: center;
  620. justify-content: center;
  621. text {
  622. font-size: 22rpx;
  623. color: #fff;
  624. }
  625. .cart-symbol {
  626. width: 24rpx;
  627. height: 24rpx;
  628. margin-left: 6rpx;
  629. }
  630. }
  631. }
  632. }
  633. .bottom-safe-area {
  634. height: 30rpx
  635. }
  636. </style>